public void Render(Context context, SceneState sceneState) { _pointSize.Value = (float)(8.0 * sceneState.HighResolutionSnapScale); context.Draw(PrimitiveType.Triangles, 0, 6, _drawState, sceneState); context.Draw(PrimitiveType.Points, 6, 1, _drawState, sceneState); }
public void Render(Context context, SceneState sceneState) { Verify.ThrowIfNull(context); Verify.ThrowIfNull(sceneState); _lineWidth.Value = (float)(0.5 * Width * sceneState.HighResolutionSnapScale); context.Draw(_primitiveType, _drawState, sceneState); }
public void Render(Context context, SceneState sceneState) { Verify.ThrowIfNull(context); Verify.ThrowInvalidOperationIfNull(Texture, "Texture"); _geometry.Update(context, _drawState.ShaderProgram); context.TextureUnits[0].Texture = Texture; context.TextureUnits[0].TextureSampler = Device.TextureSamplers.LinearClamp; _drawState.VertexArray = _geometry.VertexArray; context.Draw(PrimitiveType.TriangleStrip, _drawState, sceneState); }
public void Render(Context context, SceneState sceneState) { Verify.ThrowIfNull(context); Verify.ThrowInvalidOperationIfNull(Texture, "Texture"); Update(context); if (_drawState.VertexArray != null) { context.TextureUnits[0].Texture = Texture; context.TextureUnits[0].TextureSampler = Device.TextureSamplers.LinearClamp; context.Draw(PrimitiveType.Points, _drawState, sceneState); } }
public void Render(Context context, SceneState sceneState) { Verify.ThrowIfNull(context); Verify.ThrowIfNull(sceneState); if (_drawState.ShaderProgram != null) { double fillDistance = Width * 0.5 * sceneState.HighResolutionSnapScale; _fillDistance.Value = (float)(fillDistance); _outlineDistance.Value = (float)(fillDistance + (OutlineWidth * sceneState.HighResolutionSnapScale)); context.Draw(_primitiveType, _drawState, sceneState); } }
public void Render(Context context, SceneState sceneState) { Verify.ThrowIfNull(context); Verify.ThrowIfNull(sceneState); if (Show) { if (_drawState.ShaderProgram != null) { _fillDistance.Value = (float)(Width * 0.5 * sceneState.HighResolutionSnapScale); context.Draw(_primitiveType, _drawState, sceneState); } } }
public void Render(Context context, SceneState sceneState) { Verify.ThrowIfNull(context); Clean(context); if (_textured.Value) { Verify.ThrowInvalidOperationIfNull(Texture, "Texture"); context.TextureUnits[0].Texture = Texture; context.TextureUnits[0].TextureSampler = Device.TextureSamplers.LinearClamp; } _drawState.RenderState.RasterizationMode = Wireframe ? RasterizationMode.Line : RasterizationMode.Fill; context.Draw(_primitiveType, _drawState, sceneState); }
public void Render(Context context, SceneState sceneState, Texture2D silhouetteTexture, Texture2D depthTexture) { // // Render the line on terrain using the wall method // context.TextureUnits[0].Texture = silhouetteTexture; context.TextureUnits[0].TextureSampler = Device.TextureSamplers.LinearClamp; context.TextureUnits[1].Texture = depthTexture; context.TextureUnits[1].TextureSampler = Device.TextureSamplers.LinearClamp; context.Draw(PrimitiveType.LinesAdjacency, _wallDrawState, sceneState); // // Render the line on terrain using the depth-fail shadow volume method // context.TextureUnits[0].Texture = silhouetteTexture; context.TextureUnits[0].TextureSampler = Device.TextureSamplers.LinearClamp; context.Draw(PrimitiveType.LinesAdjacency, _shadowVolumePassOne, sceneState); // // Render where the stencil is set; note that the stencil is also cleared // where it is set. // context.Draw(PrimitiveType.LinesAdjacency, _shadowVolumePassTwo, sceneState); }
public void Render(Context context, SceneState sceneState) { Verify.ThrowIfNull(context); Update(context); if (ShowTerrain) { context.TextureUnits[0].Texture = _texture; context.TextureUnits[0].TextureSampler = Device.TextureSamplers.NearestClamp; context.Draw(_primitiveType, _drawState, sceneState); } if (ShowWireframe) { _wireframe.Render(context, sceneState); } }
public void Render(Context context, SceneState sceneState) { // // Select LOD // DrawState ds = null; if ((sceneState.Camera.Eye - _center).Magnitude < 100.0) { ds = _drawStateHigh; UpdateHigh(sceneState); } else { ds = _drawStateLow; UpdateLow(sceneState); } context.Draw(PrimitiveType.Triangles, 0, 6, ds, sceneState); context.Draw(PrimitiveType.Points, 6, 1, ds, sceneState); }
public void Render(Context context, SceneState sceneState) { Verify.ThrowIfNull(context); Verify.ThrowIfNull(sceneState); Verify.ThrowInvalidOperationIfNull(Texture, "Texture"); Clean(context); if (ShowGlobe) { Vector3D eye = sceneState.Camera.Eye; Vector3F cameraEyeSquared = eye.MultiplyComponents(eye).ToVector3F(); if (Shade) { context.TextureUnits[0].Texture = Texture; context.TextureUnits[0].TextureSampler = Device.TextureSamplers.LinearClamp; _cameraEyeSquared.Value = cameraEyeSquared; context.Draw(_primitiveType, _drawState, sceneState); } else { _cameraEyeSquaredSolid.Value = cameraEyeSquared; context.Draw(_primitiveType, _drawStateSolid, sceneState); } } if (ShowWireframeBoundingBox) { _wireframe.Render(context, sceneState); } }
private void UpdateNormals(Context context, ClipmapUpdate update) { ClipmapLevel level = update.Level; context.TextureUnits[0].Texture = update.Level.HeightTexture; context.TextureUnits[0].TextureSampler = Device.TextureSamplers.NearestRepeat; _framebuffer.ColorAttachments[_normalOutput] = level.NormalTexture; int clipmapSize = level.NextExtent.East - level.NextExtent.West + 1; int west = (level.OriginInTextures.X + (update.West - level.NextExtent.West)) % clipmapSize; int south = (level.OriginInTextures.Y + (update.South - level.NextExtent.South)) % clipmapSize; _computeNormalsUpdateSize.Value = new Vector2F(update.Width, update.Height); _computeNormalsOrigin.Value = new Vector2F(west, south); _computeNormalsOneOverHeightMapSize.Value = new Vector2F(1.0f / update.Level.HeightTexture.Description.Width, 1.0f / update.Level.HeightTexture.Description.Height); _postDelta.Value = (float)update.Level.Terrain.PostDeltaLongitude; // Save the current state of the context Rectangle oldViewport = context.Viewport; Framebuffer oldFramebuffer = context.Framebuffer; // Update the context and draw context.Viewport = new Rectangle(0, 0, level.NormalTexture.Description.Width, level.NormalTexture.Description.Height); context.Framebuffer = _framebuffer; context.Draw(_unitQuadPrimitiveType, _computeNormalsDrawState, _sceneState); // Restore the context to its original state context.Framebuffer = oldFramebuffer; context.Viewport = oldViewport; }
public void Render(Context context, SceneState sceneState) { Verify.ThrowIfNull(context); Verify.ThrowIfNull(sceneState); Update(context); context.Draw(_primitiveType, _drawState, sceneState); }
private void DrawBlock(VertexArray block, ClipmapLevel level, ClipmapLevel coarserLevel, int overallWest, int overallSouth, int blockWest, int blockSouth, Context context, SceneState sceneState) { int textureWest = blockWest - overallWest; int textureSouth = blockSouth - overallSouth; _patchOriginInClippedLevel.Value = new Vector2F(textureWest, textureSouth); DrawState drawState = new DrawState(_renderState, _shaderProgram, block); context.Draw(_primitiveType, drawState, sceneState); }
public void Render(Context context, SceneState sceneState) { Verify.ThrowIfNull(context); Verify.ThrowIfNull(sceneState); if (_drawState.ShaderProgram != null) { Update(context, sceneState); _distance.Value = (float)(((Width * 0.5) + OutlineWidth + 1) * sceneState.HighResolutionSnapScale); context.TextureUnits[0].Texture = _texture; context.TextureUnits[0].TextureSampler = Device.TextureSamplers.LinearClamp; context.Draw(_primitiveType, _drawState, sceneState); } }
public void Render(Context context, SceneState sceneState) { Verify.ThrowIfNull(context); Verify.ThrowIfNull(sceneState); if (Show) { Update(); if (ShowOutline) { // // Pass 1: Outline // _lineFillDistance.Value = (float)(OutlineWidth * 0.5 * sceneState.HighResolutionSnapScale); context.Draw(PrimitiveType.LineLoop, 0, 4, _drawStateLine, sceneState); } if (ShowFill) { // // Pass 2: Fill // context.Draw(PrimitiveType.Triangles, 4, 6, _drawStateFill, sceneState); } } }
public void Render(Context context, SceneState sceneState) { Verify.ThrowIfNull(context); Verify.ThrowIfNull(sceneState); Verify.ThrowInvalidOperationIfNull(ColorMapTexture, "ColorMap"); Verify.ThrowInvalidOperationIfNull(ColorRampHeightTexture, "ColorRampTexture"); Verify.ThrowInvalidOperationIfNull(ColorRampSlopeTexture, "ColorRampSlopeTexture"); Verify.ThrowInvalidOperationIfNull(BlendRampTexture, "BlendRampTexture"); Verify.ThrowInvalidOperationIfNull(GrassTexture, "GrassTexture"); Verify.ThrowInvalidOperationIfNull(StoneTexture, "StoneTexture"); Verify.ThrowInvalidOperationIfNull(BlendMaskTexture, "BlendMaskTexture"); if (ShowTerrain || ShowSilhouette || ShowWireframe || ShowNormals) { Update(sceneState); context.TextureUnits[0].Texture = _texture; context.TextureUnits[0].TextureSampler = Device.TextureSamplers.NearestClamp; context.TextureUnits[6].Texture = ColorMapTexture; context.TextureUnits[6].TextureSampler = Device.TextureSamplers.LinearClamp; context.TextureUnits[1].Texture = ColorRampHeightTexture; context.TextureUnits[1].TextureSampler = Device.TextureSamplers.LinearClamp; context.TextureUnits[7].Texture = ColorRampSlopeTexture; context.TextureUnits[7].TextureSampler = Device.TextureSamplers.LinearClamp; context.TextureUnits[2].Texture = BlendRampTexture; context.TextureUnits[2].TextureSampler = Device.TextureSamplers.LinearClamp; context.TextureUnits[3].Texture = GrassTexture; context.TextureUnits[3].TextureSampler = Device.TextureSamplers.LinearRepeat; context.TextureUnits[4].Texture = StoneTexture; context.TextureUnits[4].TextureSampler = Device.TextureSamplers.LinearRepeat; context.TextureUnits[5].Texture = BlendMaskTexture; context.TextureUnits[5].TextureSampler = Device.TextureSamplers.LinearClamp; if (ShowTerrain || ShowSilhouette) { context.Draw(_primitiveType, _drawStateTerrain, sceneState); } if (ShowWireframe) { context.Draw(_primitiveType, _drawStateWireframe, sceneState); } if (ShowNormals && (_normalsAlgorithm != TerrainNormalsAlgorithm.None)) { context.Draw(PrimitiveType.Points, _drawStateNormals, sceneState); } } }
private void RenderTileToLevelTexture(Context context, ClipmapLevel level, RasterDataDetails details, RasterTileRegion region, Texture2D tileTexture) { Texture2D levelTexture; Vector2I originInTextures; ClipmapLevel.Extent nextExtent; if (details.Type == RasterType.Terrain) { levelTexture = level.HeightTexture; originInTextures = level.OriginInTextures; nextExtent = level.NextExtent; } else { levelTexture = level.ImageryTexture; originInTextures = level.OriginInImagery; nextExtent = level.NextImageryExtent; } context.TextureUnits[0].Texture = tileTexture; context.TextureUnits[0].TextureSampler = Device.TextureSamplers.NearestClamp; _framebuffer.ColorAttachments[_updateTexelOutput] = levelTexture; int clipmapSize = nextExtent.East - nextExtent.West + 1; int destWest = (originInTextures.X + (region.Tile.West + region.West - nextExtent.West)) % clipmapSize; int destSouth = (originInTextures.Y + (region.Tile.South + region.South - nextExtent.South)) % clipmapSize; int width = region.East - region.West + 1; int height = region.North - region.South + 1; _updateSourceOrigin.Value = new Vector2F(region.West, region.South); _updateUpdateSize.Value = new Vector2F(width, height); _updateDestinationOffset.Value = new Vector2F(destWest, destSouth); // Save the current state of the context Rectangle oldViewport = context.Viewport; Framebuffer oldFramebuffer = context.Framebuffer; // Update the context and draw context.Viewport = new Rectangle(0, 0, levelTexture.Description.Width, levelTexture.Description.Height); context.Framebuffer = _framebuffer; context.Draw(_unitQuadPrimitiveType, _updateDrawState, _sceneState); // Restore the context to its original state context.Framebuffer = oldFramebuffer; context.Viewport = oldViewport; }
private void UpsampleTileData(Context context, ClipmapLevel level, RasterDataDetails details, RasterTileRegion region) { ClipmapLevel coarserLevel = level.CoarserLevel; if (coarserLevel == null) return; Texture2D levelTexture; Texture2D coarserLevelTexture; Vector2I originInTextures; Vector2I coarserOriginInTextures; ClipmapLevel.Extent nextExtent; ClipmapLevel.Extent coarserNextExtent; if (details.Type == RasterType.Terrain) { levelTexture = level.HeightTexture; coarserLevelTexture = coarserLevel.HeightTexture; originInTextures = level.OriginInTextures; coarserOriginInTextures = coarserLevel.OriginInTextures; nextExtent = level.NextExtent; coarserNextExtent = coarserLevel.NextExtent; } else { levelTexture = level.ImageryTexture; coarserLevelTexture = coarserLevel.ImageryTexture; originInTextures = level.OriginInImagery; coarserOriginInTextures = coarserLevel.OriginInImagery; nextExtent = level.NextImageryExtent; coarserNextExtent = coarserLevel.NextImageryExtent; } context.TextureUnits[0].Texture = coarserLevelTexture; context.TextureUnits[0].TextureSampler = Device.TextureSamplers.LinearRepeat; _framebuffer.ColorAttachments[_upsampleTexelOutput] = levelTexture; int fineClipmapSize = nextExtent.East - nextExtent.West + 1; int destWest = (originInTextures.X + (region.Tile.West + region.West - nextExtent.West)) % fineClipmapSize; int destSouth = (originInTextures.Y + (region.Tile.South + region.South - nextExtent.South)) % fineClipmapSize; int coarseClipmapSize = coarserNextExtent.East - coarserNextExtent.West + 1; double sourceWest = (coarserOriginInTextures.X + ((region.Tile.West + region.West) / 2.0 - coarserNextExtent.West)) % coarseClipmapSize; double sourceSouth = (coarserOriginInTextures.Y + ((region.Tile.South + region.South) / 2.0 - coarserNextExtent.South)) % coarseClipmapSize; int width = region.East - region.West + 1; int height = region.North - region.South + 1; _upsampleSourceOrigin.Value = new Vector2F((float)sourceWest, (float)sourceSouth); _upsampleUpdateSize.Value = new Vector2F(width, height); _upsampleDestinationOffset.Value = new Vector2F(destWest, destSouth); _upsampleOneOverTextureSize.Value = new Vector2F(1.0f / coarserLevelTexture.Description.Width, 1.0f / coarserLevelTexture.Description.Height); // Save the current state of the context Rectangle oldViewport = context.Viewport; Framebuffer oldFramebuffer = context.Framebuffer; // Update the context and draw context.Viewport = new Rectangle(0, 0, levelTexture.Description.Width, levelTexture.Description.Height); context.Framebuffer = _framebuffer; context.Draw(_unitQuadPrimitiveType, _upsampleDrawState, _sceneState); // Restore the context to its original state context.Framebuffer = oldFramebuffer; context.Viewport = oldViewport; }
public void Render(Context context, SceneState sceneState) { Update(sceneState); context.Draw(PrimitiveType.Triangles, 0, 6, _drawState, sceneState); context.Draw(PrimitiveType.Points, 6, 1, _drawState, sceneState); }
public void RenderDepthAndSilhouetteTextures(Context context, SceneState sceneState, bool silhouette) { Verify.ThrowIfNull(context); Verify.ThrowIfNull(sceneState); CreateDepthAndSilhouetteData(context); // // Depth texture // context.Framebuffer = _terrainFramebuffer; context.Clear(_clearDepthStencil); Render(context, sceneState); // // Silhouette texture // context.Framebuffer = _silhouetteFramebuffer; context.Clear(_clearColor); if (silhouette) { context.Draw(_primitiveType, _silhouetteDrawState, sceneState); } }