public override void Render(SSRenderConfig renderConfig) { base.Render (renderConfig); // mode setup SSShaderProgram.DeactivateAll(); // disable GLSL GL.Disable(EnableCap.Blend); GL.Disable(EnableCap.Lighting); GL.ActiveTexture(TextureUnit.Texture0); GL.Enable(EnableCap.Texture2D); GL.BindTexture(TextureTarget.Texture2D, 0); // reset first GL.BindTexture(TextureTarget.Texture2D, GLu_textureID); // now bind the shadowmap texture id // GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (float)TextureMagFilter.Nearest); // GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (float)TextureMinFilter.Nearest); // draw quad... GL.Begin(PrimitiveType.Triangles); float w=500; float h=500; // upper-left GL.TexCoord2(0.0, 0.0); GL.Vertex3(0.0, 0.0, 0.0); GL.TexCoord2(0.0, 1.0); GL.Vertex3(0.0, h, 0.0); GL.TexCoord2(1.0, 0.0); GL.Vertex3(w, 0.0, 0.0); // lower-right GL.TexCoord2(0.0, 1.0); GL.Vertex3(0.0, h, 0.0); GL.TexCoord2(1.0, 1.0); GL.Vertex3(w, h, 0.0); GL.TexCoord2(1.0, 0.0); GL.Vertex3(w, 0.0, 0.0); GL.End(); }
public void drawInstanced(SSRenderConfig renderConfig, int instanceCount, PrimitiveType primType) { base.renderMesh (renderConfig); foreach (SSMeshOBJSubsetData subset in this.geometrySubsets) { _renderSetupGLSL(renderConfig, renderConfig.instanceShader, subset); subset.triangleMesh.drawInstanced (renderConfig, instanceCount, primType); } }
public void drawInstanced(SSRenderConfig renderConfig, int instanceCount, PrimitiveType primType) { base.renderMesh(renderConfig); foreach (SSMeshOBJSubsetData subset in this.geometrySubsets) { _renderSetupGLSL(renderConfig, renderConfig.instanceShader, subset); subset.triangleMesh.drawInstanced(renderConfig, instanceCount, primType); } }
public virtual void DisableLight(SSRenderConfig renderConfig) { int idx = _lightName - _firstName; GL.Disable (EnableCap.Light0 + idx); if (ShadowMap != null) { ShadowMap.FinishRead(); } }
public override void Render(ref SSRenderConfig renderConfig) { UpdateTexture(); base.Render(ref renderConfig); SSShaderProgram.DeactivateAll(); // disable GLSL // mode setup // GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1); // Step 2: setup our material mode and paramaters... GL.Disable(EnableCap.CullFace); GL.Disable(EnableCap.Lighting); // enable alpha blending { GL.Enable(EnableCap.AlphaTest); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); } // fixed function single-texture GL.ActiveTexture(TextureUnit.Texture0); GL.Enable(EnableCap.Texture2D); GL.BindTexture(TextureTarget.Texture2D, textureSurface.TextureID); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (float)TextureMagFilter.Nearest); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (float)TextureMinFilter.Nearest); // draw text rectangle... GL.Begin(BeginMode.Triangles); GL.Color3(Color.White); // clear the vertex color to white.. float w = gdiSize.Width; float h = gdiSize.Height; if (gdiSize != textureSize) { // adjust texture coordinates throw new Exception("not implemented"); } // upper-left GL.TexCoord2(0.0, 0.0); GL.Vertex3(0.0, 0.0, 0.0); GL.TexCoord2(1.0, 0.0); GL.Vertex3(w, 0.0, 0.0); GL.TexCoord2(0.0, 1.0); GL.Vertex3(0.0, h, 0.0); // lower-right GL.TexCoord2(0.0, 1.0); GL.Vertex3(0.0, h, 0.0); GL.TexCoord2(1.0, 0.0); GL.Vertex3(w, 0.0, 0.0); GL.TexCoord2(1.0, 1.0); GL.Vertex3(w, h, 0.0); GL.End(); }
public virtual void Render(SSRenderConfig renderConfig) { // compute and set the modelView matrix, by combining the cameraViewMat // with the object's world matrix // ... http://www.songho.ca/opengl/gl_transform.html // ... http://stackoverflow.com/questions/5798226/3d-graphics-processing-how-to-calculate-modelview-matrix renderBoundingSphereMesh(renderConfig); Matrix4 modelViewMat = this.worldMat * renderConfig.invCameraViewMatrix; GL.MatrixMode(MatrixMode.Modelview); GL.LoadMatrix(ref modelViewMat); resetTexturingState(); if (renderConfig.drawingShadowMap) { if (renderConfig.drawingPssm && renderConfig.pssmShader != null) { renderConfig.pssmShader.Activate(); renderConfig.pssmShader.UniObjectWorldTransform = this.worldMat; } else { SSShaderProgram.DeactivateAll(); } } else { if (renderConfig.mainShader != null) { setDefaultShaderState(renderConfig.mainShader); } setMaterialState(renderConfig.mainShader); if (alphaBlendingEnabled) { GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); } else { GL.Disable(EnableCap.Blend); } if (this.renderState.lighted) { GL.Enable(EnableCap.Lighting); GL.ShadeModel(ShadingModel.Flat); } else { GL.Disable(EnableCap.Lighting); } } }
public override void Render(ref SSRenderConfig renderConfig) { base.Render(ref renderConfig); // setup infinity projection by turning off depth testing and masking.. GL.Disable(EnableCap.DepthTest); GL.DepthMask(false); GL.Disable(EnableCap.DepthClamp); this.Mesh.RenderMesh(ref renderConfig); }
public override void Render(SSRenderConfig renderConfig) { if (Mesh != null) { GL.BeginQuery(QueryTarget.SamplesPassed, _gl_query_id); base.Render(renderConfig); GL.EndQuery(QueryTarget.SamplesPassed); GL.GetQueryObject(_gl_query_id, GetQueryObjectParam.QueryResult, out _result); } else { _result = 0; } }
public virtual void DisableLight(SSRenderConfig renderConfig) { int idx = _lightName - _firstName; GL.Disable(EnableCap.Light0 + idx); if (ShadowMap != null) { ShadowMap.FinishRead(); } }
protected void setDefaultShaderState(SSMainShaderProgram pgm, SSRenderConfig config) { if (pgm != null) { pgm.Activate(); pgm.UniObjectWorldTransform = this.worldMat; pgm.UniReceivesShadow = renderState.receivesShadows; pgm.UniSpriteOffsetAndSize(0f, 0f, 1f, 1f); pgm.UniShowWireframes = (config.drawWireframeMode == WireframeMode.GLSL_SinglePass); pgm.SetupTextures(textureMaterial); } }
public override void renderMesh(SSRenderConfig renderConfig) { base.renderMesh(renderConfig); if (renderConfig.renderBoundingSpheresSolid) { this._RenderSolid(renderConfig); } if (renderConfig.renderBoundingSpheresLines) { this._RenderLines_ICO(renderConfig); } // this._RenderLines_UV(ref renderConfig); }
public void DrawArrays(SSRenderConfig renderConfig, PrimitiveType primType, bool doBind = true) { if (doBind) { DrawBind(renderConfig); } drawPrivate(primType); if (doBind) { DrawUnbind(); } }
public void SetupLight_alt(ref SSRenderConfig renderConfig) { GL.MatrixMode (MatrixMode.Modelview); GL.LoadMatrix (ref this.worldMat); GL.Enable (EnableCap.Lighting); GL.ShadeModel (ShadingModel.Smooth); GL.Light (m_lightName, LightParameter.Position, new Vector4(this._pos,1.0f)); int idx = m_lightName - c_firstName; GL.Enable (EnableCap.Light0 + idx); }
public override void renderMesh(SSRenderConfig renderConfig) { SSShaderProgram.DeactivateAll(); GL.Disable(EnableCap.Lighting); GL.Disable(EnableCap.ColorMaterial); GL.Enable(EnableCap.AlphaTest); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); base.renderMesh(renderConfig); }
private void configureDrawShader(SSRenderConfig renderConfig, SSMainShaderProgram pgm) { if (pgm != null) { pgm.Activate(); pgm.UniPoissonSamplingEnabled = renderConfig.usePoissonSampling; if (renderConfig.usePoissonSampling) { pgm.UniNumPoissonSamples = renderConfig.numPoissonSamples; } } }
public override void Render(SSRenderConfig renderConfig) { UpdateTexture (); base.Render (renderConfig); SSShaderProgram.DeactivateAll(); // disable GLSL // mode setup // GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1); // Step 2: setup our material mode and paramaters... GL.Disable (EnableCap.Lighting); // enable alpha blending { GL.Enable (EnableCap.AlphaTest); GL.Enable (EnableCap.Blend); GL.BlendFunc (BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); } // fixed function single-texture GL.ActiveTexture(TextureUnit.Texture0); GL.Enable(EnableCap.Texture2D); GL.BindTexture(TextureTarget.Texture2D, textureSurface.TextureID); GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (float)TextureMagFilter.Nearest); GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (float)TextureMinFilter.Nearest); // draw text rectangle... GL.Begin(BeginMode.Triangles); float w = gdiSize.Width; float h = gdiSize.Height; if (gdiSize != textureSize) { // adjust texture coordinates throw new Exception("not implemented"); } // upper-left GL.TexCoord2(0.0, 0.0); GL.Vertex3(0.0, 0.0, 0.0); GL.TexCoord2(0.0, 1.0); GL.Vertex3(0.0, h, 0.0); GL.TexCoord2(1.0, 0.0); GL.Vertex3(w, 0.0, 0.0); // lower-right GL.TexCoord2(0.0, 1.0); GL.Vertex3(0.0, h, 0.0); GL.TexCoord2(1.0, 1.0); GL.Vertex3(w, h, 0.0); GL.TexCoord2(1.0, 0.0); GL.Vertex3(w, 0.0, 0.0); GL.End(); }
public void SetupLight_alt(ref SSRenderConfig renderConfig) { GL.MatrixMode (MatrixMode.Modelview); GL.LoadMatrix (ref this.worldMat); GL.Enable (EnableCap.Lighting); GL.ShadeModel (ShadingModel.Smooth); GL.Light (m_lightName, LightParameter.Position, new Vector4(this._pos,1.0f)); int idx = m_lightName - c_firstName; GL.Enable (EnableCap.Light0 + idx); }
public override void Render(SSRenderConfig renderConfig) { if (_mesh != null) { base.Render(renderConfig); if (enableLineStipple) { GL.Enable(EnableCap.LineStipple); GL.LineStipple(1, lineStipplePattern); } this._mesh.renderMesh(renderConfig); } }
protected void _renderWithGPUInstancing(SSRenderConfig renderConfig) { // prepare attribute arrays for draw GL.PushClientAttrib(ClientAttribMask.ClientAllAttribBits); _prepareInstanceShader(renderConfig); // do the draw mesh.drawInstanced(renderConfig, instanceData.activeBlockLength, this.primType); GL.PopClientAttrib(); //this.boundingSphere.Render(ref renderConfig); }
public override void DisableLight(SSRenderConfig renderConfig) { base.DisableLight(renderConfig); if (renderConfig.mainShader != null) { renderConfig.mainShader.Activate(); renderConfig.mainShader.UniDirectionalLightIndex = -1; } if (renderConfig.instanceShader != null) { renderConfig.instanceShader.Activate(); renderConfig.instanceShader.UniDirectionalLightIndex = -1; } }
public override void renderMesh(SSRenderConfig renderConfig) { base.renderMesh(renderConfig); if (renderConfig.renderBoundingSpheresSolid) { this._RenderSolid(renderConfig); } if (renderConfig.renderBoundingSpheresLines) { this._RenderLines_ICO(renderConfig); } // this._RenderLines_UV(ref renderConfig); }
public void drawInstanced(SSRenderConfig renderConfig, int instanceCount, PrimitiveType primType) { _vbo.DrawBind(renderConfig); Bind(); GL.DrawElementsInstanced( primType, _numIndices, DrawElementsType.UnsignedShort, IntPtr.Zero, instanceCount ); Unbind(); _vbo.DrawUnbind(); }
public override void Render(ref SSRenderConfig renderConfig) { base.Render(ref renderConfig); if (renderSolid) { this._RenderSolid(ref renderConfig); } else { // this._RenderLines_UV(ref renderConfig); this._RenderLines_ICO(ref renderConfig); } }
public void renderInstanced(SSRenderConfig renderConfig, int instanceCount, PrimitiveType primType = PrimitiveType.Triangles) { m_vbo.DrawBind(renderConfig); Bind(); GL.DrawElementsInstanced( primType, m_numIndices, DrawElementsType.UnsignedShort, IntPtr.Zero, instanceCount ); Unbind(); m_vbo.DrawUnbind(); }
public override void Render(SSRenderConfig renderConfig) { UpdateTexture(); base.Render(renderConfig); SSShaderProgram.DeactivateAll(); // disable GLSL // mode setup // GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1); // Step 2: setup our material mode and paramaters... GL.Disable(EnableCap.Lighting); // setup our texture source if (textureSurface != null) { GL.ActiveTexture(TextureUnit.Texture0); GL.Enable(EnableCap.Texture2D); GL.BindTexture(TextureTarget.Texture2D, textureSurface.TextureID); } GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (float)TextureMagFilter.Nearest); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (float)TextureMinFilter.Nearest); // draw text rectangle... GL.Begin(PrimitiveType.Triangles); float w = gdiSize.Width; float h = gdiSize.Height; if (gdiSize != textureSize) { // adjust texture coordinates throw new Exception("not implemented"); } // upper-left GL.TexCoord2(0.0, 0.0); GL.Vertex3(0.0, 0.0, 0.0); GL.TexCoord2(0.0, 1.0); GL.Vertex3(0.0, h, 0.0); GL.TexCoord2(1.0, 0.0); GL.Vertex3(w, 0.0, 0.0); // lower-right GL.TexCoord2(0.0, 1.0); GL.Vertex3(0.0, h, 0.0); GL.TexCoord2(1.0, 1.0); GL.Vertex3(w, h, 0.0); GL.TexCoord2(1.0, 0.0); GL.Vertex3(w, 0.0, 0.0); GL.End(); }
public void renderInstanced(SSRenderConfig renderConfig, int instanceCount, PrimitiveType primType = PrimitiveType.Triangles) { m_vbo.DrawBind(renderConfig); Bind(); GL.DrawElementsInstanced( primType, m_numIndices, DrawElementsType.UnsignedShort, IntPtr.Zero, instanceCount ); Unbind(); m_vbo.DrawUnbind(); }
public void drawInstanced(SSRenderConfig renderConfig, int instanceCount, PrimitiveType primType) { _vbo.DrawBind(renderConfig); Bind(); GL.DrawElementsInstanced( primType, _numIndices, DrawElementsType.UnsignedShort, IntPtr.Zero, instanceCount ); Unbind(); _vbo.DrawUnbind(); }
public override void Render(SSRenderConfig renderConfig) { if (Mesh != null) { GL.BeginQuery(QueryTarget.SamplesPassed, _gl_query_id); base.Render(renderConfig); GL.EndQuery(QueryTarget.SamplesPassed); GL.GetQueryObject(_gl_query_id, GetQueryObjectParam.QueryResult, out _result); } else { _result = 0; } }
protected void _renderWithGPUInstancing(SSRenderConfig renderConfig) { if (renderConfig.drawingShadowMap && renderConfig.drawingPssm) { renderConfig.instancePssmShader.Activate(); renderConfig.instancePssmShader.UniObjectWorldTransform = this.worldMat; } else { // texture binding and world mat setup renderConfig.instanceShader.Activate(); base.setDefaultShaderState(renderConfig.instanceShader, renderConfig); } ISSInstancableShaderProgram instanceShader = renderConfig.ActiveInstanceShader; // prepare attribute arrays for draw GL.PushClientAttrib(ClientAttribMask.ClientAllAttribBits); _prepareAttribute(_posBuffer, instanceShader.AttrInstancePos, instanceData.positions); _prepareAttribute(_orientationXYBuffer, instanceShader.AttrInstanceOrientationXY, instanceData.orientationsXY); _prepareAttribute(_orientationZBuffer, instanceShader.AttrInstanceOrientationZ, instanceData.orientationsZ); _prepareAttribute(_masterScaleBuffer, instanceShader.AttrInstanceMasterScale, instanceData.masterScales); _prepareAttribute(_componentScaleXYBuffer, instanceShader.AttrInstanceComponentScaleXY, instanceData.componentScalesXY); _prepareAttribute(_componentScaleZBuffer, instanceShader.AttrInstanceComponentScaleZ, instanceData.componentScalesZ); _prepareAttribute(_colorBuffer, instanceShader.AttrInstanceColor, instanceData.colors); //prepareAttribute(m_spriteIndexBuffer, instanceShader.AttrInstanceSpriteIndex, m_ps.SpriteIndices); _prepareAttribute(_spriteOffsetUBuffer, instanceShader.AttrInstanceSpriteOffsetU, instanceData.spriteOffsetsU); _prepareAttribute(_spriteOffsetVBuffer, instanceShader.AttrInstanceSpriteOffsetV, instanceData.spriteOffsetsV); _prepareAttribute(_spriteSizeUBuffer, instanceShader.AttrInstanceSpriteSizeU, instanceData.spriteSizesU); _prepareAttribute(_spriteSizeVBuffer, instanceShader.AttrInstanceSpriteSizeV, instanceData.spriteSizesV); // do the draw mesh.drawInstanced(renderConfig, instanceData.activeBlockLength, this.primType); GL.PopClientAttrib(); //this.boundingSphere.Render(ref renderConfig); }
public override void setupLight(SSRenderConfig renderConfig) { base.setupLight(renderConfig); GL.Light (_lightName, LightParameter.Position, new Vector4(Direction, 0f)); int dirLightIndex = _lightName - _firstName; if (renderConfig.mainShader != null) { renderConfig.mainShader.Activate(); renderConfig.mainShader.UniDirectionalLightIndex = dirLightIndex; } if (renderConfig.instanceShader != null) { renderConfig.instanceShader.Activate(); renderConfig.instanceShader.UniDirectionalLightIndex = dirLightIndex; } }
private void configureDrawShader(ref SSRenderConfig renderConfig, SSMainShaderProgram pgm, Matrix4[] vp) { if (pgm == null) { return; } pgm.Activate(); pgm.UniNumShadowMaps = 1; if (renderConfig.usePoissonSampling) { Vector2[] poissonScales = { new Vector2(1f) }; pgm.UniPoissonScaling = poissonScales; } pgm.UniShadowMapVPs = vp; }
public override void Render(SSRenderConfig renderConfig) { base.Render(renderConfig); // mode setup SSShaderProgram.DeactivateAll(); // disable GLSL GL.Disable(EnableCap.Texture2D); GL.LineWidth(5.0f); GL.Begin(PrimitiveType.Lines); GL.Color3(1.0f, 1f, 1f); GL.Vertex3(0, 0, 0); GL.Color3(1.0f, 0.5f, 0.5f); GL.Vertex3(this.ray.dir * 10.0f); GL.End(); }
public override void DisableLight(SSRenderConfig renderConfig) { base.DisableLight(renderConfig); if (renderConfig.mainShader != null) { renderConfig.mainShader.Activate(); renderConfig.mainShader.UniDirectionalLightIndex = -1; } if (renderConfig.instanceShader != null) { renderConfig.instanceShader.Activate(); renderConfig.instanceShader.UniDirectionalLightIndex = -1; } }
public override void Render(SSRenderConfig renderConfig) { base.Render (renderConfig); // mode setup SSShaderProgram.DeactivateAll(); // disable GLSL GL.Disable(EnableCap.Texture2D); GL.LineWidth(5.0f); GL.Begin(PrimitiveType.Lines); GL.Color3(1.0f,1f,1f); GL.Vertex3(0,0,0); GL.Color3(1.0f,0.5f,0.5f); GL.Vertex3(this.ray.dir * 10.0f); GL.End(); }
public void DrawElements(SSRenderConfig renderConfig, PrimitiveType primType, bool doBind = true) { if (doBind) { m_vbo.DrawBind(renderConfig); Bind(); } GL.DrawElements(primType, m_numIndices, DrawElementsType.UnsignedShort, IntPtr.Zero); if (doBind) { Unbind(); m_vbo.DrawUnbind(); } }
protected void configureDrawShader(SSRenderConfig renderConfig, SSMainShaderProgram pgm) { if (pgm == null) { return; } pgm.Activate(); pgm.UniNumShadowMaps = c_numberOfSplits; if (renderConfig.usePoissonSampling) { pgm.UniPoissonScaling = m_poissonScaling; } pgm.UniShadowMapVPs = m_shadowViewProjBiasMatrices; pgm.UniPssmSplits = m_viewSplits; }
public override void Render(ref SSRenderConfig renderConfig) { // base.Render (ref renderConfig); // setup infinity projection Matrix4 modelViewMat = this.worldMat * renderConfig.invCameraViewMat; GL.MatrixMode(MatrixMode.Modelview); GL.LoadMatrix(ref modelViewMat); GL.Disable(EnableCap.DepthTest); GL.DepthMask(false); GL.Disable(EnableCap.DepthClamp); this.Mesh.RenderMesh(ref renderConfig); }
public static void PrepareTexCoord(SSRenderConfig renderConfig, int stride, IntPtr offset) { ISSInstancableShaderProgram isp = renderConfig.ActiveInstanceShader; if (isp == null) // no instancing // this is the "transitional" GLSL 120 way of assigning buffer contents // http://www.opentk.com/node/80?page=1 { GL.EnableClientState(ArrayCap.TextureCoordArray); GL.TexCoordPointer(2, TexCoordPointerType.Float, stride, offset); } else // instancing { preparePerVertexAttribute(stride, offset, isp.AttrTexCoord, 2); } }
public override void Render(SSRenderConfig renderConfig) { UpdateTexture(); base.Render(renderConfig); SSShaderProgram.DeactivateAll (); // disable GLSL // mode setup // GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1); // Step 2: setup our material mode and paramaters... // setup our texture source if (textureSurface != null) { GL.ActiveTexture(TextureUnit.Texture0); GL.Enable(EnableCap.Texture2D); GL.BindTexture(TextureTarget.Texture2D, textureSurface.TextureID); } GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (float)TextureMagFilter.Nearest); GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (float)TextureMinFilter.Nearest); // draw text rectangle... GL.Begin(PrimitiveType.Triangles); float w = gdiSize.Width; float h = gdiSize.Height; if (gdiSize != textureSize) { // adjust texture coordinates throw new Exception("not implemented"); } // upper-left GL.TexCoord2(0.0, 0.0); GL.Vertex3(0.0, 0.0, 0.0); GL.TexCoord2(0.0, 1.0); GL.Vertex3(0.0, h, 0.0); GL.TexCoord2(1.0, 0.0); GL.Vertex3(w, 0.0, 0.0); // lower-right GL.TexCoord2(0.0, 1.0); GL.Vertex3(0.0, h, 0.0); GL.TexCoord2(1.0, 1.0); GL.Vertex3(w, h, 0.0); GL.TexCoord2(1.0, 0.0); GL.Vertex3(w, 0.0, 0.0); GL.End(); }
public override void Render(ref SSRenderConfig renderConfig) { base.Render(ref renderConfig); // mode setup GL.UseProgram(0); // disable GLSL GL.Disable(EnableCap.CullFace); GL.Disable(EnableCap.Texture2D); GL.Disable(EnableCap.Blend); GL.Disable(EnableCap.Lighting); GL.LineWidth(1.0f); GL.Color3(1.0f,1.0f,1.0f); // should generate these from screen-space size approximation float rings = 10.0f; float segments = 10.0f; // Establish constants used in sphere generation float fDeltaRingAngle = ((float)Math.PI / rings); float fDeltaSegAngle = (2.0f * (float)Math.PI / segments); float r0; float y0; float x0; float z0; GL.Begin(PrimitiveType.LineStrip); for (int ring = 0; ring < rings + 1; ring++) { r0 = (float)Math.Sin(ring * fDeltaRingAngle); y0 = (float)Math.Cos(ring * fDeltaRingAngle); for (int seg = 0; seg < segments + 1; seg++) { x0 = r0 * (float)Math.Sin(seg * fDeltaSegAngle); z0 = r0 * (float)Math.Cos(seg * fDeltaSegAngle); // add first vertex var pos = new Vector3(x0 * radius, y0 * radius, z0 * radius); GL.Normal3(pos); GL.Vertex3(pos); } } GL.End(); }
public override void Render(SSRenderConfig renderConfig) { base.Render (renderConfig); // mode setup SSShaderProgram.DeactivateAll(); // disable GLSL GL.Disable(EnableCap.Texture2D); // triangle draw... GL.Begin(PrimitiveType.Triangles); GL.Color3(1.0f, 1.0f, 0.0f); GL.Vertex3(-1.0f, -1.0f, 0.0f); GL.Color3(1.0f, 0.0f, 0.0f); GL.Vertex3(1.0f, -1.0f, 0.0f); GL.Color3(0.2f, 0.9f, 1.0f); GL.Vertex3(0.0f, 1.0f, 0.0f); GL.End(); }
public void DrawElements(SSRenderConfig renderConfig, PrimitiveType primType, bool doBind = true) { if (doBind) { m_vbo.DrawBind(renderConfig); Bind(); } GL.DrawElements(primType, m_numIndices, DrawElementsType.UnsignedShort, IntPtr.Zero); if (doBind) { Unbind(); m_vbo.DrawUnbind(); } }
public void UpdateAndDrawArrays(SSRenderConfig renderConfig, Vertex[] vertices, PrimitiveType primType, bool doBind = true) { genBufferPrivate(); if (doBind) { DrawBind(renderConfig); } updatePrivate(vertices); drawPrivate(primType); if (doBind) { DrawUnbind(); } }
public override void Render(SSRenderConfig renderConfig) { base.Render(renderConfig); // mode setup SSShaderProgram.DeactivateAll(); // disable GLSL GL.Disable(EnableCap.Texture2D); // triangle draw... GL.Begin(PrimitiveType.Triangles); GL.Color3(1.0f, 1.0f, 0.0f); GL.Vertex3(-1.0f, -1.0f, 0.0f); GL.Color3(1.0f, 0.0f, 0.0f); GL.Vertex3(1.0f, -1.0f, 0.0f); GL.Color3(0.2f, 0.9f, 1.0f); GL.Vertex3(0.0f, 1.0f, 0.0f); GL.End(); }
private void _RenderSolid(ref SSRenderConfig renderConfig) { // mode setup SSShaderProgram.DeactivateAll(); // disable GLSL GL.Disable(EnableCap.CullFace); GL.Disable(EnableCap.Texture2D); GL.Disable(EnableCap.Blend); GL.Enable(EnableCap.Lighting); // should generate these from screen-space size approximation float rings = 10.0f; float segments = 10.0f; // Establish constants used in sphere generation float fDeltaRingAngle = ((float)Math.PI / rings); float fDeltaSegAngle = (2.0f * (float)Math.PI / segments); float r0; float y0; float x0; float z0; GL.Begin(PrimitiveType.Triangles); GL.LineWidth(1.0f); GL.Color3(1.0f, 1.0f, 1.0f); for (int ring = 0; ring < rings + 1; ring++) { r0 = (float)Math.Sin(ring * fDeltaRingAngle); y0 = (float)Math.Cos(ring * fDeltaRingAngle); for (int seg = 0; seg < segments + 1; seg++) { x0 = r0 * (float)Math.Sin(seg * fDeltaSegAngle); z0 = r0 * (float)Math.Cos(seg * fDeltaSegAngle); // add first vertex var pos = new Vector3(x0 * radius, y0 * radius, z0 * radius); GL.Normal3(pos); GL.Vertex3(pos); } } GL.End(); }
protected void renderBoundingSphereMesh(SSRenderConfig renderConfig) { if (worldBoundingSphereRadius > 0f && (renderConfig.renderBoundingSpheresLines || renderConfig.renderBoundingSpheresSolid)) { GL.Color4(MainColor); Matrix4 modelViewMat = Matrix4.CreateScale(worldBoundingSphereRadius) * Matrix4.CreateTranslation(worldBoundingSphereCenter) * renderConfig.invCameraViewMatrix; GL.MatrixMode(MatrixMode.Modelview); GL.LoadMatrix(ref modelViewMat); //GL.Translate (boundingSphere.center); //GL.Scale (new Vector3 (this.scaleMax * boundingSphere.radius)); _boundingSphereMesh.renderMesh(renderConfig); } }
public override void Render(SSRenderConfig renderConfig) { GL.ColorMask(false, false, false, true); GL.ClearColor(0f, 0f, 0f, 0f); GL.Clear(ClearBufferMask.ColorBufferBit); GL.ColorMask(true, true, true, true); base.Render(renderConfig); if (_fadeAwayCounter > 0f) { _fadeAwayCounter -= renderConfig.timeElapsedS; if (_fadeAwayCounter <= 0f) { renderState.toBeDeleted = true; } } }
public override void Render(ref SSRenderConfig renderConfig) { base.Render (ref renderConfig); // mode setup GL.UseProgram(0); // disable GLSL GL.Disable(EnableCap.CullFace); GL.Disable(EnableCap.Texture2D); GL.Disable(EnableCap.Blend); GL.Disable(EnableCap.Lighting); GL.LineWidth(5.0f); GL.Begin(BeginMode.Lines); GL.Color3(1.0f,1f,1f); GL.Vertex3(0,0,0); GL.Color3(1.0f,0.5f,0.5f); GL.Vertex3(this.ray.dir * 10.0f); GL.End(); }
protected virtual void beforeRenderObjectHandler(Object obj, SSRenderConfig renderConfig) { bool showWireFrames; if (autoWireframeMode) { if (obj == selectedObject) { renderConfig.drawWireframeMode = WireframeMode.GLSL_SinglePass; showWireFrames = true; } else { renderConfig.drawWireframeMode = WireframeMode.None; showWireFrames = false; } } else { // manual showWireFrames = (scene.renderConfig.drawWireframeMode == WireframeMode.GLSL_SinglePass); } mainShader.Activate(); mainShader.UniShowWireframes = showWireFrames; instancingShader.Activate(); instancingShader.UniShowWireframes = showWireFrames; }
public virtual void setupLight(SSRenderConfig renderConfig) { // we only use the invCameraViewMatrix, because we specify the pos/dir later below... Matrix4 modelViewMatrix = renderConfig.invCameraViewMatrix; GL.MatrixMode (MatrixMode.Modelview); GL.LoadMatrix (ref modelViewMatrix); GL.Light (_lightName, LightParameter.Ambient, this.Ambient); // ambient light color (R,G,B,A) GL.Light (_lightName, LightParameter.Diffuse, this.Diffuse); // diffuse color (R,G,B,A) GL.Light (_lightName, LightParameter.Specular, this.Specular); // specular light color (R,G,B,A) int idx = _lightName - _firstName; GL.Enable (EnableCap.Light0 + idx); if (ShadowMap != null) { ShadowMap.PrepareForRead(); } }
public override void PrepareForRender( SSRenderConfig renderConfig, List<SSObject> objects, float fov, float aspect, float nearZ, float farZ) { base.PrepareForRenderBase(renderConfig, objects); ComputeProjections(objects, m_light, renderConfig.invCameraViewMatrix, renderConfig.projectionMatrix); // update info for the regular draw pass later Matrix4[] vp = { m_shadowViewMatrix * m_shadowProjMatrix * c_biasMatrix }; configureDrawShader (ref renderConfig, renderConfig.mainShader, vp); configureDrawShader (ref renderConfig, renderConfig.instanceShader, vp); // setup for render shadowmap pass renderConfig.projectionMatrix = m_shadowProjMatrix; renderConfig.invCameraViewMatrix = m_shadowViewMatrix; SSShaderProgram.DeactivateAll(); }
public override void Render(SSRenderConfig renderConfig) { if (Mesh != null) { base.Render(renderConfig); Matrix4 modelView = this.worldMat * renderConfig.invCameraViewMatrix; modelView = OpenTKHelper.BillboardMatrix(ref modelView); GL.MatrixMode(MatrixMode.Modelview); GL.LoadMatrix(ref modelView); if (isOcclusionQueueryEnabled) { GL.BeginQuery(QueryTarget.SamplesPassed, GL_query_id); } Mesh.renderMesh(renderConfig); if (isOcclusionQueueryEnabled) { GL.EndQuery(QueryTarget.SamplesPassed); } } }
private void _RenderLines_ICO(SSRenderConfig renderConfig) { // mode setup SSShaderProgram.DeactivateAll(); // disable GLSL GL.Disable(EnableCap.Texture2D); GL.Disable(EnableCap.Blend); GL.Disable(EnableCap.Lighting); GL.Begin(PrimitiveType.Lines); GL.LineWidth(1.0f); foreach (var face in icoSphereFaces) { var v1 = icoSphereVertices[face.v1] * radius; var v2 = icoSphereVertices[face.v2] * radius; var v3 = icoSphereVertices[face.v3] * radius; GL.Vertex3(v1); GL.Vertex3(v2); GL.Vertex3(v2); GL.Vertex3(v3); GL.Vertex3(v1); GL.Vertex3(v3); } GL.End(); }
public override void renderMesh(SSRenderConfig renderConfig) { SSShaderProgram.DeactivateAll (); GL.Disable(EnableCap.Texture2D); GL.Disable(EnableCap.Lighting); GL.Enable(EnableCap.PointSmooth); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha,BlendingFactorDest.OneMinusSrcAlpha); GL.PointSize(1.5f); GL.Begin(BeginMode.Points); for (int i = 0; i < this.numstars; i++) { GL.Color3(Color.FromArgb(vertices[i].DiffuseColor)); GL.Normal3(vertices[i].Normal); GL.Vertex3(vertices[i].Position); } GL.End(); GL.Disable(EnableCap.Blend); }
public override void PrepareForRender(SSRenderConfig renderConfig, List<SSObject> objects, float fov, float aspect, float cameraNearZ, float cameraFarZ) { base.PrepareForRenderBase(renderConfig, objects); ComputeProjections( objects, renderConfig.invCameraViewMatrix, renderConfig.projectionMatrix, fov, aspect, cameraNearZ, cameraFarZ); // update info for the regular draw pass later configureDrawShader (renderConfig, renderConfig.mainShader); configureDrawShader (renderConfig, renderConfig.instanceShader); // setup for render shadowmap pass configurePssmShader (renderConfig.pssmShader); configurePssmShader (renderConfig.instancePssmShader); renderConfig.drawingPssm = true; }
public override void Render(SSRenderConfig renderConfig) { base.Render (renderConfig); var p0 = new Vector3 (-1, -1, 1); var p1 = new Vector3 ( 1, -1, 1); var p2 = new Vector3 ( 1, 1, 1); var p3 = new Vector3 (-1, 1, 1); var p4 = new Vector3 (-1, -1, -1); var p5 = new Vector3 ( 1, -1, -1); var p6 = new Vector3 ( 1, 1, -1); var p7 = new Vector3 (-1, 1, -1); GL.Begin(BeginMode.Triangles); drawQuadFace(p0, p1, p2, p3); drawQuadFace(p7, p6, p5, p4); drawQuadFace(p1, p0, p4, p5); drawQuadFace(p2, p1, p5, p6); drawQuadFace(p3, p2, p6, p7); drawQuadFace(p0, p3, p7, p4); GL.End(); }
public void drawSingle(SSRenderConfig renderConfig, PrimitiveType primType) { renderMesh(renderConfig); }
public void updateWireframeDisplayText(SSRenderConfig config) { wireframeDisplay.Label = String.Format ("press 'w' to toggle wireframe mode: [{0}]", config.drawWireframeMode); }
public override void Render(SSRenderConfig renderConfig) { if (_mesh != null) { base.Render (renderConfig); this._mesh.renderMesh (renderConfig); } }
public SSScene(SSMainShaderProgram main = null, SSPssmShaderProgram pssm = null, SSInstanceShaderProgram instance = null, SSInstancePssmShaderProgram instancePssm = null) { renderConfig = new SSRenderConfig (main, pssm, instance, instancePssm); }