public void RasterizationMode() { RenderState renderState = new RenderState(); renderState.RasterizationMode = OpenGlobe.Renderer.RasterizationMode.Line; Assert.AreEqual(OpenGlobe.Renderer.RasterizationMode.Line, renderState.RasterizationMode); }
public void ProgramPointSize() { RenderState renderState = new RenderState(); renderState.ProgramPointSize = OpenGlobe.Renderer.ProgramPointSize.Disabled; Assert.AreEqual(OpenGlobe.Renderer.ProgramPointSize.Disabled, renderState.ProgramPointSize); }
public HeadsUpDisplay() { RenderState renderState = new RenderState(); renderState.FacetCulling.Enabled = false; renderState.DepthTest.Enabled = false; renderState.Blending.Enabled = true; renderState.Blending.SourceRGBFactor = SourceBlendingFactor.SourceAlpha; renderState.Blending.SourceAlphaFactor = SourceBlendingFactor.SourceAlpha; renderState.Blending.DestinationRGBFactor = DestinationBlendingFactor.OneMinusSourceAlpha; renderState.Blending.DestinationAlphaFactor = DestinationBlendingFactor.OneMinusSourceAlpha; ShaderProgram sp = Device.CreateShaderProgram( EmbeddedResources.GetText("OpenGlobe.Scene.Renderables.HeadsUpDisplay.Shaders.HeadsUpDisplayVS.glsl"), EmbeddedResources.GetText("OpenGlobe.Scene.Renderables.HeadsUpDisplay.Shaders.HeadsUpDisplayGS.glsl"), EmbeddedResources.GetText("OpenGlobe.Scene.Renderables.HeadsUpDisplay.Shaders.HeadsUpDisplayFS.glsl")); _colorUniform = (Uniform<Vector3F>)sp.Uniforms["u_color"]; _originScaleUniform = (Uniform<Vector2F>)sp.Uniforms["u_originScale"]; _drawState = new DrawState(renderState, sp, null); Color = Color.White; HorizontalOrigin = HorizontalOrigin.Left; VerticalOrigin = VerticalOrigin.Bottom; _positionDirty = true; }
public OutlinedPolylineTexture() { RenderState renderState = new RenderState(); renderState.FacetCulling.Enabled = false; renderState.Blending.Enabled = true; renderState.Blending.SourceRGBFactor = SourceBlendingFactor.SourceAlpha; renderState.Blending.SourceAlphaFactor = SourceBlendingFactor.SourceAlpha; renderState.Blending.DestinationRGBFactor = DestinationBlendingFactor.OneMinusSourceAlpha; renderState.Blending.DestinationAlphaFactor = DestinationBlendingFactor.OneMinusSourceAlpha; _drawState = new DrawState(); _drawState.RenderState = renderState; Width = 3; OutlineWidth = 2; }
public ViewportQuad(Context context, string fs) { Verify.ThrowIfNull(context); RenderState renderState = new RenderState(); renderState.FacetCulling.Enabled = false; renderState.DepthTest.Enabled = false; _drawState = new DrawState(); _drawState.RenderState = renderState; _drawState.ShaderProgram = Device.CreateShaderProgram( EmbeddedResources.GetText("OpenGlobe.Scene.Renderables.ViewportQuad.Shaders.ViewportQuadVS.glsl"), fs == null ? EmbeddedResources.GetText("OpenGlobe.Scene.Renderables.ViewportQuad.Shaders.ViewportQuadFS.glsl") : fs); _geometry = new ViewportQuadGeometry(); }
public GPURelativeToEye(Context context, Vector3D[] positions, byte[] colors) { _sp = Device.CreateShaderProgram( EmbeddedResources.GetText("OpenGlobe.Examples.GPURelativeToEye.Shaders.VS.glsl"), EmbeddedResources.GetText("OpenGlobe.Examples.Shaders.FS.glsl")); _cameraEyeHigh = (Uniform<Vector3F>)_sp.Uniforms["u_cameraEyeHigh"]; _cameraEyeLow = (Uniform<Vector3F>)_sp.Uniforms["u_cameraEyeLow"]; _modelViewPerspectiveMatrixRelativeToEye = (Uniform<Matrix4F>)(_sp.Uniforms["u_modelViewPerspectiveMatrixRelativeToEye"]); _pointSize = (Uniform<float>)_sp.Uniforms["u_pointSize"]; /////////////////////////////////////////////////////////////////// Mesh mesh = new Mesh(); VertexAttributeFloatVector3 positionsHighAttribute = new VertexAttributeFloatVector3("positionHigh", positions.Length); VertexAttributeFloatVector3 positionsLowAttribute = new VertexAttributeFloatVector3("positionLow", positions.Length); VertexAttributeRGB colorAttribute = new VertexAttributeRGB("color", positions.Length); mesh.Attributes.Add(positionsHighAttribute); mesh.Attributes.Add(positionsLowAttribute); mesh.Attributes.Add(colorAttribute); for (int i = 0; i < positions.Length; ++i) { Vector3F positionHigh; Vector3F positionLow; Vector3DToTwoVector3F(positions[i], out positionHigh, out positionLow); positionsHighAttribute.Values.Add(positionHigh); positionsLowAttribute.Values.Add(positionLow); } for (int i = 0; i < colors.Length; ++i) { colorAttribute.Values.Add(colors[i]); } _va = context.CreateVertexArray(mesh, _sp.VertexAttributes, BufferHint.StaticDraw); /////////////////////////////////////////////////////////////////// RenderState renderState = new RenderState(); renderState.FacetCulling.Enabled = false; renderState.DepthTest.Enabled = false; renderState.ProgramPointSize = ProgramPointSize.Enabled; _drawState = new DrawState(renderState, _sp, _va); }
public DayNightViewportQuad(Context context) { Verify.ThrowIfNull(context); RenderState renderState = new RenderState(); renderState.FacetCulling.Enabled = false; renderState.DepthTest.Enabled = false; ShaderProgram sp = Device.CreateShaderProgram( EmbeddedResources.GetText("OpenGlobe.Scene.Globes.DayNight.Shaders.ViewportQuadVS.glsl"), EmbeddedResources.GetText("OpenGlobe.Scene.Globes.DayNight.Shaders.ViewportQuadFS.glsl")); _dayNightOutput = (Uniform<int>)sp.Uniforms["u_DayNightOutput"]; _drawState = new DrawState(); _drawState.RenderState = renderState; _drawState.ShaderProgram = sp; _geometry = new ViewportQuadGeometry(); }
public Wireframe(Context context, Mesh mesh) { RenderState renderState = new RenderState(); renderState.Blending.Enabled = true; renderState.Blending.SourceRGBFactor = SourceBlendingFactor.SourceAlpha; renderState.Blending.SourceAlphaFactor = SourceBlendingFactor.SourceAlpha; renderState.Blending.DestinationRGBFactor = DestinationBlendingFactor.OneMinusSourceAlpha; renderState.Blending.DestinationAlphaFactor = DestinationBlendingFactor.OneMinusSourceAlpha; renderState.FacetCulling.FrontFaceWindingOrder = mesh.FrontFaceWindingOrder; renderState.DepthTest.Function = DepthTestFunction.LessThanOrEqual; // // This implementation is based on the 2006 SIGGRAPH Sketch: // // Single-pass Wireframe Rendering // http://www2.imm.dtu.dk/pubdb/views/edoc_download.php/4884/pdf/imm4884.pdf // // NVIDIA published a white paper with some enhancements we can consider: // // Solid Wireframe // http://developer.download.nvidia.com/SDK/10.5/direct3d/Source/SolidWireframe/Doc/SolidWireframe.pdf // // More recent work, which I was not aware of at the time, is: // // Two Methods for Antialiased Wireframe Drawing with Hidden Line Removal // http://orbit.dtu.dk/getResource?recordId=219956&objectId=1&versionId=1 // ShaderProgram sp = Device.CreateShaderProgram( EmbeddedResources.GetText("OpenGlobe.Scene.Renderables.Wireframe.Shaders.WireframeVS.glsl"), EmbeddedResources.GetText("OpenGlobe.Scene.Renderables.Wireframe.Shaders.WireframeGS.glsl"), EmbeddedResources.GetText("OpenGlobe.Scene.Renderables.Wireframe.Shaders.WireframeFS.glsl")); _lineWidth = (Uniform<float>)sp.Uniforms["u_halfLineWidth"]; Width = 1; _colorUniform = (Uniform<Vector3F>)sp.Uniforms["u_color"]; Color = Color.Black; _drawState = new DrawState(renderState, sp, context.CreateVertexArray(mesh, sp.VertexAttributes, BufferHint.StaticDraw)); _primitiveType = mesh.PrimitiveType; }
public RelativeToCenter(Context context, Vector3D[] positions, byte[] colors) { _sp = Device.CreateShaderProgram( EmbeddedResources.GetText("OpenGlobe.Examples.RelativeToCenter.Shaders.VS.glsl"), EmbeddedResources.GetText("OpenGlobe.Examples.Shaders.FS.glsl")); _modelViewPerspectiveMatrixRelativeToCenter = (Uniform<Matrix4F>)(_sp.Uniforms["u_modelViewPerspectiveMatrixRelativeToCenter"]); _pointSize = (Uniform<float>)_sp.Uniforms["u_pointSize"]; /////////////////////////////////////////////////////////////////// Mesh mesh = new Mesh(); VertexAttributeFloatVector3 positionsAttribute = new VertexAttributeFloatVector3("position", positions.Length); VertexAttributeRGB colorAttribute = new VertexAttributeRGB("color", positions.Length); mesh.Attributes.Add(positionsAttribute); mesh.Attributes.Add(colorAttribute); _center = new AxisAlignedBoundingBox(positions).Center; for (int i = 0; i < positions.Length; ++i) { positionsAttribute.Values.Add((positions[i] - _center).ToVector3F()); } for (int i = 0; i < colors.Length; ++i) { colorAttribute.Values.Add(colors[i]); } _va = context.CreateVertexArray(mesh, _sp.VertexAttributes, BufferHint.StaticDraw); /////////////////////////////////////////////////////////////////// RenderState renderState = new RenderState(); renderState.FacetCulling.Enabled = false; renderState.DepthTest.Enabled = false; renderState.ProgramPointSize = ProgramPointSize.Enabled; _drawState = new DrawState(renderState, _sp, _va); }
public CPURelativeToEye(Context context, Vector3D[] positions, byte[] colors) { _sp = Device.CreateShaderProgram( EmbeddedResources.GetText("OpenGlobe.Examples.CPURelativeToEye.Shaders.VS.glsl"), EmbeddedResources.GetText("OpenGlobe.Examples.Shaders.FS.glsl")); _modelViewPerspectiveMatrixRelativeToEye = (Uniform<Matrix4F>)(_sp.Uniforms["u_modelViewPerspectiveMatrixRelativeToEye"]); _pointSize = (Uniform<float>)_sp.Uniforms["u_pointSize"]; /////////////////////////////////////////////////////////////////// _positions = new Vector3D[positions.Length]; positions.CopyTo(_positions, 0); _positionsRelativeToEye = new Vector3F[_positions.Length]; _eye = Vector3D.Zero; // // _positionBuffer is dynamic, and is written to when the camera moves. // _positionBuffer = Device.CreateVertexBuffer(BufferHint.DynamicDraw, ArraySizeInBytes.Size(_positionsRelativeToEye)); _colorBuffer = Device.CreateVertexBuffer(BufferHint.StaticDraw, colors.Length); _colorBuffer.CopyFromSystemMemory(colors); _va = context.CreateVertexArray(); _va.Attributes[_sp.VertexAttributes["position"].Location] = new VertexBufferAttribute(_positionBuffer, ComponentDatatype.Float, 3); _va.Attributes[_sp.VertexAttributes["color"].Location] = new VertexBufferAttribute(_colorBuffer, ComponentDatatype.UnsignedByte, 3, true, 0, 0); /////////////////////////////////////////////////////////////////// RenderState renderState = new RenderState(); renderState.FacetCulling.Enabled = false; renderState.DepthTest.Enabled = false; renderState.ProgramPointSize = ProgramPointSize.Enabled; _drawState = new DrawState(renderState, _sp, _va); }
public RayCastedGlobe(Context context) { Verify.ThrowIfNull(context); _renderState = new RenderState(); _renderState.FacetCulling.Face = CullFace.Front; string vs = EmbeddedResources.GetText("OpenGlobe.Scene.Globes.RayCasted.Shaders.GlobeVS.glsl"); ShaderProgram sp = Device.CreateShaderProgram(vs, EmbeddedResources.GetText("OpenGlobe.Scene.Globes.RayCasted.Shaders.GlobeFS.glsl")); _cameraEyeSquared = (Uniform<Vector3F>)sp.Uniforms["u_cameraEyeSquared"]; _useAverageDepth = (Uniform<bool>)sp.Uniforms["u_useAverageDepth"]; ShaderProgram solidSP = Device.CreateShaderProgram(vs, EmbeddedResources.GetText("OpenGlobe.Scene.Globes.RayCasted.Shaders.SolidShadedGlobeFS.glsl")); _cameraEyeSquaredSolid = (Uniform<Vector3F>)solidSP.Uniforms["u_cameraEyeSquared"]; _useAverageDepthSolid = (Uniform<bool>)solidSP.Uniforms["u_useAverageDepth"]; _drawState = new DrawState(_renderState, sp, null); _drawStateSolid = new DrawState(_renderState, solidSP, null); Shape = Ellipsoid.ScaledWgs84; Shade = true; ShowGlobe = true; }
public void RenderPointWithStencil() { using (GraphicsWindow window = Device.CreateWindow(1, 1)) using (Framebuffer framebuffer = TestUtility.CreateFramebuffer(window.Context)) using (Texture2D depthStencilTexture = Device.CreateTexture2D(new Texture2DDescription(1, 1, TextureFormat.Depth24Stencil8, false))) using (ShaderProgram sp = Device.CreateShaderProgram(ShaderSources.PassThroughVertexShader(), ShaderSources.PassThroughFragmentShader())) using (VertexArray va = TestUtility.CreateVertexArray(window.Context, sp.VertexAttributes["position"].Location)) { framebuffer.DepthStencilAttachment = depthStencilTexture; StencilTest stencilTest = new StencilTest(); stencilTest.Enabled = true; stencilTest.FrontFace.DepthFailStencilPassOperation = StencilOperation.Replace; stencilTest.FrontFace.DepthPassStencilPassOperation = StencilOperation.Replace; stencilTest.FrontFace.StencilFailOperation = StencilOperation.Replace; stencilTest.FrontFace.ReferenceValue = 2; RenderState renderState = new RenderState(); renderState.StencilTest = stencilTest; window.Context.Framebuffer = framebuffer; window.Context.Clear(new ClearState()); window.Context.Draw(PrimitiveType.Points, 0, 1, new DrawState(renderState, sp, va), new SceneState()); TestUtility.ValidateColor(framebuffer.ColorAttachments[0], 255, 0, 0); using (ReadPixelBuffer readPixelBuffer = depthStencilTexture.CopyToBuffer(ImageFormat.DepthStencil, ImageDatatype.UnsignedInt248, 1)) { byte[] depthStencil = readPixelBuffer.CopyToSystemMemory<byte>(); Assert.AreEqual(stencilTest.FrontFace.ReferenceValue, depthStencil[0]); } } }
public static RenderState CreateRenderStateWithoutDepthTest() { RenderState rs = new RenderState(); rs.DepthTest.Enabled = false; return rs; }
public void DepthMask() { RenderState renderState = new RenderState(); renderState.DepthMask = false; Assert.IsFalse(renderState.DepthMask); }
public GlobeClipmapTerrain(Context context, RasterSource terrainSource, EsriRestImagery imagery, Ellipsoid ellipsoid, int clipmapPosts) { _terrainSource = terrainSource; _ellipsoid = ellipsoid; _clipmapPosts = clipmapPosts; _clipmapSegments = _clipmapPosts - 1; int clipmapLevels = _terrainSource.Levels.Count; _clipmapLevels = new ClipmapLevel[clipmapLevels]; for (int i = 0; i < _clipmapLevels.Length; ++i) { _clipmapLevels[i] = new ClipmapLevel(); } for (int i = 0; i < _clipmapLevels.Length; ++i) { RasterLevel terrainLevel = _terrainSource.Levels[i]; _clipmapLevels[i].Terrain = terrainLevel; _clipmapLevels[i].HeightTexture = Device.CreateTexture2D(new Texture2DDescription(_clipmapPosts, _clipmapPosts, TextureFormat.Red32f)); _clipmapLevels[i].NormalTexture = Device.CreateTexture2D(new Texture2DDescription(_clipmapPosts, _clipmapPosts, TextureFormat.RedGreenBlue32f)); _clipmapLevels[i].CoarserLevel = i == 0 ? null : _clipmapLevels[i - 1]; _clipmapLevels[i].FinerLevel = i == _clipmapLevels.Length - 1 ? null : _clipmapLevels[i + 1]; // Aim for roughly one imagery texel per geometry texel. // Find the first imagery level that meets our resolution needs. double longitudeResRequired = terrainLevel.PostDeltaLongitude; double latitudeResRequired = terrainLevel.PostDeltaLatitude; RasterLevel imageryLevel = null; for (int j = 0; j < imagery.Levels.Count; ++j) { imageryLevel = imagery.Levels[j]; if (imageryLevel.PostDeltaLongitude <= longitudeResRequired && imageryLevel.PostDeltaLatitude <= latitudeResRequired) { break; } } _clipmapLevels[i].Imagery = imageryLevel; _clipmapLevels[i].ImageryWidth = (int)Math.Ceiling(_clipmapPosts * terrainLevel.PostDeltaLongitude / imageryLevel.PostDeltaLongitude); _clipmapLevels[i].ImageryHeight = (int)Math.Ceiling(_clipmapPosts * terrainLevel.PostDeltaLatitude / imageryLevel.PostDeltaLatitude); _clipmapLevels[i].ImageryTexture = Device.CreateTexture2D(new Texture2DDescription(_clipmapLevels[i].ImageryWidth, _clipmapLevels[i].ImageryHeight, TextureFormat.RedGreenBlue8, false)); } _shaderProgram = Device.CreateShaderProgram( EmbeddedResources.GetText("OpenGlobe.Scene.Terrain.ClipmapTerrain.GlobeClipmapVS.glsl"), EmbeddedResources.GetText("OpenGlobe.Scene.Terrain.ClipmapTerrain.GlobeClipmapFS.glsl")); _fillPatchPosts = (clipmapPosts + 1) / 4; // M _fillPatchSegments = _fillPatchPosts - 1; // Create the MxM block used to fill the ring and the field. Mesh fieldBlockMesh = RectangleTessellator.Compute( new RectangleD(new Vector2D(0.0, 0.0), new Vector2D(_fillPatchSegments, _fillPatchSegments)), _fillPatchSegments, _fillPatchSegments); _fillPatch = context.CreateVertexArray(fieldBlockMesh, _shaderProgram.VertexAttributes, BufferHint.StaticDraw); // Create the Mx3 block used to fill the space between the MxM blocks in the ring Mesh ringFixupHorizontalMesh = RectangleTessellator.Compute( new RectangleD(new Vector2D(0.0, 0.0), new Vector2D(_fillPatchSegments, 2.0)), _fillPatchSegments, 2); _horizontalFixupPatch = context.CreateVertexArray(ringFixupHorizontalMesh, _shaderProgram.VertexAttributes, BufferHint.StaticDraw); // Create the 3xM block used to fill the space between the MxM blocks in the ring Mesh ringFixupVerticalMesh = RectangleTessellator.Compute( new RectangleD(new Vector2D(0.0, 0.0), new Vector2D(2.0, _fillPatchSegments)), 2, _fillPatchSegments); _verticalFixupPatch = context.CreateVertexArray(ringFixupVerticalMesh, _shaderProgram.VertexAttributes, BufferHint.StaticDraw); Mesh offsetStripHorizontalMesh = RectangleTessellator.Compute( new RectangleD(new Vector2D(0.0, 0.0), new Vector2D(2 * _fillPatchPosts, 1.0)), 2 * _fillPatchPosts, 1); _horizontalOffsetPatch = context.CreateVertexArray(offsetStripHorizontalMesh, _shaderProgram.VertexAttributes, BufferHint.StaticDraw); Mesh offsetStripVerticalMesh = RectangleTessellator.Compute( new RectangleD(new Vector2D(0.0, 0.0), new Vector2D(1.0, 2 * _fillPatchPosts - 1)), 1, 2 * _fillPatchPosts - 1); _verticalOffsetPatch = context.CreateVertexArray(offsetStripVerticalMesh, _shaderProgram.VertexAttributes, BufferHint.StaticDraw); Mesh centerMesh = RectangleTessellator.Compute(new RectangleD(new Vector2D(0.0, 0.0), new Vector2D(2.0, 2.0)), 2, 2); _centerPatch = context.CreateVertexArray(centerMesh, _shaderProgram.VertexAttributes, BufferHint.StaticDraw); Mesh degenerateTriangleMesh = CreateDegenerateTriangleMesh(); _degenerateTrianglePatch = context.CreateVertexArray(degenerateTriangleMesh, _shaderProgram.VertexAttributes, BufferHint.StaticDraw); _patchOriginInClippedLevel = (Uniform<Vector2F>)_shaderProgram.Uniforms["u_patchOriginInClippedLevel"]; _levelScaleFactor = (Uniform<Vector2F>)_shaderProgram.Uniforms["u_levelScaleFactor"]; _levelZeroWorldScaleFactor = (Uniform<Vector2F>)_shaderProgram.Uniforms["u_levelZeroWorldScaleFactor"]; _levelOffsetFromWorldOrigin = (Uniform<Vector2F>)_shaderProgram.Uniforms["u_levelOffsetFromWorldOrigin"]; _heightExaggeration = (Uniform<float>)_shaderProgram.Uniforms["u_heightExaggeration"]; _viewPosInClippedLevel = (Uniform<Vector2F>)_shaderProgram.Uniforms["u_viewPosInClippedLevel"]; _fineLevelOriginInCoarse = (Uniform<Vector2F>)_shaderProgram.Uniforms["u_fineLevelOriginInCoarse"]; _unblendedRegionSize = (Uniform<Vector2F>)_shaderProgram.Uniforms["u_unblendedRegionSize"]; _oneOverBlendedRegionSize = (Uniform<Vector2F>)_shaderProgram.Uniforms["u_oneOverBlendedRegionSize"]; _fineTextureOrigin = (Uniform<Vector2F>)_shaderProgram.Uniforms["u_fineTextureOrigin"]; _showBlendRegions = (Uniform<bool>)_shaderProgram.Uniforms["u_showBlendRegions"]; _useBlendRegions = (Uniform<bool>)_shaderProgram.Uniforms["u_useBlendRegions"]; _oneOverClipmapSize = (Uniform<float>)_shaderProgram.Uniforms["u_oneOverClipmapSize"]; _color = (Uniform<Vector3F>)_shaderProgram.Uniforms["u_color"]; _blendRegionColor = (Uniform<Vector3F>)_shaderProgram.Uniforms["u_blendRegionColor"]; _terrainToImageryResolutionRatio = (Uniform<Vector2F>)_shaderProgram.Uniforms["u_terrainToImageryResolutionRatio"]; _terrainOffsetInImagery = (Uniform<Vector2F>)_shaderProgram.Uniforms["u_terrainOffsetInImagery"]; _oneOverImagerySize = (Uniform<Vector2F>)_shaderProgram.Uniforms["u_oneOverImagerySize"]; _showImagery = (Uniform<bool>)_shaderProgram.Uniforms["u_showImagery"]; _lighting = (Uniform<bool>)_shaderProgram.Uniforms["u_shade"]; ((Uniform<Vector3F>)_shaderProgram.Uniforms["u_globeRadiiSquared"]).Value = ellipsoid.RadiiSquared.ToVector3F(); _renderState = new RenderState(); _renderState.FacetCulling.FrontFaceWindingOrder = fieldBlockMesh.FrontFaceWindingOrder; _primitiveType = fieldBlockMesh.PrimitiveType; float oneOverBlendedRegionSize = (float)(10.0 / _clipmapPosts); _oneOverBlendedRegionSize.Value = new Vector2F(oneOverBlendedRegionSize, oneOverBlendedRegionSize); float unblendedRegionSize = (float)(_clipmapSegments / 2 - _clipmapPosts / 10.0 - 1); _unblendedRegionSize.Value = new Vector2F(unblendedRegionSize, unblendedRegionSize); _useBlendRegions.Value = true; _showImagery.Value = true; _oneOverClipmapSize.Value = 1.0f / clipmapPosts; _updater = new ClipmapUpdater(context, _clipmapLevels); HeightExaggeration = 0.00001f; }
public Plane(Context context) { Verify.ThrowIfNull(context); RenderState lineRS = new RenderState(); lineRS.FacetCulling.Enabled = false; ShaderProgram lineSP = Device.CreateShaderProgram( EmbeddedResources.GetText("OpenGlobe.Scene.Renderables.Plane.Shaders.LineVS.glsl"), EmbeddedResources.GetText("OpenGlobe.Scene.Renderables.Plane.Shaders.LineGS.glsl"), EmbeddedResources.GetText("OpenGlobe.Scene.Renderables.Plane.Shaders.LineFS.glsl")); _lineLogarithmicDepth = (Uniform<bool>)lineSP.Uniforms["u_logarithmicDepth"]; _lineLogarithmicDepthConstant = (Uniform<float>)lineSP.Uniforms["u_logarithmicDepthConstant"]; _lineFillDistance = (Uniform<float>)lineSP.Uniforms["u_fillDistance"]; _lineColorUniform = (Uniform<Vector3F>)lineSP.Uniforms["u_color"]; OutlineWidth = 1; OutlineColor = Color.Gray; /////////////////////////////////////////////////////////////////// RenderState fillRS = new RenderState(); fillRS.FacetCulling.Enabled = false; fillRS.Blending.Enabled = true; fillRS.Blending.SourceRGBFactor = SourceBlendingFactor.SourceAlpha; fillRS.Blending.SourceAlphaFactor = SourceBlendingFactor.SourceAlpha; fillRS.Blending.DestinationRGBFactor = DestinationBlendingFactor.OneMinusSourceAlpha; fillRS.Blending.DestinationAlphaFactor = DestinationBlendingFactor.OneMinusSourceAlpha; ShaderProgram fillSP = Device.CreateShaderProgram( EmbeddedResources.GetText("OpenGlobe.Scene.Renderables.Plane.Shaders.FillVS.glsl"), EmbeddedResources.GetText("OpenGlobe.Scene.Renderables.Plane.Shaders.FillFS.glsl")); _fillLogarithmicDepth = (Uniform<bool>)fillSP.Uniforms["u_logarithmicDepth"]; _fillLogarithmicDepthConstant = (Uniform<float>)fillSP.Uniforms["u_logarithmicDepthConstant"]; _fillColorUniform = (Uniform<Vector3F>)fillSP.Uniforms["u_color"]; _fillAlphaUniform = (Uniform<float>)fillSP.Uniforms["u_alpha"]; LogarithmicDepthConstant = 1; FillColor = Color.Gray; FillTranslucency = 0.5f; /////////////////////////////////////////////////////////////////// _positionBuffer = Device.CreateVertexBuffer(BufferHint.StaticDraw, 2 * 4 * SizeInBytes<Vector3F>.Value); ushort[] indices = new ushort[] { 0, 1, 2, 3, // Line loop 0, 1, 2, 0, 2, 3 // Triangles }; IndexBuffer indexBuffer = Device.CreateIndexBuffer(BufferHint.StaticDraw, indices.Length * sizeof(ushort)); indexBuffer.CopyFromSystemMemory(indices); int stride = 2 * SizeInBytes<Vector3F>.Value; _va = context.CreateVertexArray(); _va.Attributes[VertexLocations.PositionHigh] = new VertexBufferAttribute(_positionBuffer, ComponentDatatype.Float, 3, false, 0, stride); _va.Attributes[VertexLocations.PositionLow] = new VertexBufferAttribute(_positionBuffer, ComponentDatatype.Float, 3, false, SizeInBytes<Vector3F>.Value, stride); _va.IndexBuffer = indexBuffer; Show = true; ShowOutline = true; ShowFill = true; /////////////////////////////////////////////////////////////////// _drawStateLine = new DrawState(lineRS, lineSP, _va); _drawStateFill = new DrawState(fillRS, fillSP, _va); Origin = Vector3D.Zero; XAxis = Vector3D.UnitX; YAxis = Vector3D.UnitY; }
public VertexDisplacementMapTerrainTile(Context context, TerrainTile tile) { // // Upload height map as a one channel floating point texture // WritePixelBuffer pixelBuffer = Device.CreateWritePixelBuffer(PixelBufferHint.Stream, sizeof(float) * tile.Heights.Length); pixelBuffer.CopyFromSystemMemory(tile.Heights); _texture = Device.CreateTexture2DRectangle(new Texture2DDescription( tile.Resolution.X, tile.Resolution.Y, TextureFormat.Red32f)); _texture.CopyFromBuffer(pixelBuffer, ImageFormat.Red, ImageDatatype.Float); /////////////////////////////////////////////////////////////////// ShaderProgram spTerrain = Device.CreateShaderProgram( EmbeddedResources.GetText("OpenGlobe.Scene.Terrain.VertexDisplacementMapTerrainTile.TerrainVS.glsl"), EmbeddedResources.GetText("OpenGlobe.Scene.Terrain.VertexDisplacementMapTerrainTile.TerrainFS.glsl")); _heightExaggerationUniform = (Uniform<float>)spTerrain.Uniforms["u_heightExaggeration"]; ((Uniform<Vector2F>)spTerrain.Uniforms["u_positionToTextureCoordinate"]).Value = new Vector2F( (float)(1.0 / (double)(tile.Resolution.X)), (float)( 1.0 / (double)(tile.Resolution.Y))); ((Uniform<Vector2F>)spTerrain.Uniforms["u_positionToRepeatTextureCoordinate"]).Value = new Vector2F( (float)(4.0 / (double)tile.Resolution.X), (float)(4.0 / (double)tile.Resolution.Y)); /////////////////////////////////////////////////////////////////// ShaderProgram spNormals = Device.CreateShaderProgram( EmbeddedResources.GetText("OpenGlobe.Scene.Terrain.VertexDisplacementMapTerrainTile.NormalsVS.glsl"), EmbeddedResources.GetText("OpenGlobe.Scene.Terrain.VertexDisplacementMapTerrainTile.NormalsGS.glsl"), EmbeddedResources.GetText("OpenGlobe.Scene.Terrain.VertexDisplacementMapTerrainTile.NormalsFS.glsl")); _heightExaggerationNormals = (Uniform<float>)spNormals.Uniforms["u_heightExaggeration"]; _fillDistanceNormals = (Uniform<float>)spNormals.Uniforms["u_fillDistance"]; ((Uniform<Vector3F>)spNormals.Uniforms["u_color"]).Value = Vector3F.Zero; /////////////////////////////////////////////////////////////////// ShaderProgram spWireframe = Device.CreateShaderProgram( EmbeddedResources.GetText("OpenGlobe.Scene.Terrain.VertexDisplacementMapTerrainTile.WireframeVS.glsl"), EmbeddedResources.GetText("OpenGlobe.Scene.Terrain.VertexDisplacementMapTerrainTile.WireframeGS.glsl"), EmbeddedResources.GetText("OpenGlobe.Scene.Terrain.VertexDisplacementMapTerrainTile.WireframeFS.glsl")); _lineWidthWireframe = (Uniform<float>)spWireframe.Uniforms["u_halfLineWidth"]; _heightExaggerationWireframe = (Uniform<float>)spWireframe.Uniforms["u_heightExaggeration"]; ((Uniform<Vector3F>)spWireframe.Uniforms["u_color"]).Value = Vector3F.Zero; /////////////////////////////////////////////////////////////////// Mesh mesh = RectangleTessellator.Compute(new RectangleD(new Vector2D(0.5, 0.5), new Vector2D((double)tile.Resolution.X - 0.5, (double)tile.Resolution.Y - 0.5)), tile.Resolution.X - 1, tile.Resolution.Y - 1); _va = context.CreateVertexArray(mesh, spWireframe.VertexAttributes, BufferHint.StaticDraw); _primitiveType = mesh.PrimitiveType; /////////////////////////////////////////////////////////////////// RenderState rsTerrain = new RenderState(); rsTerrain.FacetCulling.FrontFaceWindingOrder = mesh.FrontFaceWindingOrder; RenderState rsWireframe = new RenderState(); rsWireframe.Blending.Enabled = true; rsWireframe.Blending.SourceRGBFactor = SourceBlendingFactor.SourceAlpha; rsWireframe.Blending.SourceAlphaFactor = SourceBlendingFactor.SourceAlpha; rsWireframe.Blending.DestinationRGBFactor = DestinationBlendingFactor.OneMinusSourceAlpha; rsWireframe.Blending.DestinationAlphaFactor = DestinationBlendingFactor.OneMinusSourceAlpha; rsWireframe.FacetCulling.FrontFaceWindingOrder = mesh.FrontFaceWindingOrder; rsWireframe.DepthTest.Function = DepthTestFunction.LessThanOrEqual; RenderState rsNormals = new RenderState(); rsNormals.FacetCulling.Enabled = false; rsNormals.Blending.Enabled = true; rsNormals.Blending.SourceRGBFactor = SourceBlendingFactor.SourceAlpha; rsNormals.Blending.SourceAlphaFactor = SourceBlendingFactor.SourceAlpha; rsNormals.Blending.DestinationRGBFactor = DestinationBlendingFactor.OneMinusSourceAlpha; rsNormals.Blending.DestinationAlphaFactor = DestinationBlendingFactor.OneMinusSourceAlpha; /////////////////////////////////////////////////////////////////// _drawStateTerrain = new DrawState(rsTerrain, spTerrain, _va); _drawStateWireframe = new DrawState(rsWireframe, spWireframe, _va); _drawStateNormals = new DrawState(rsNormals, spNormals, _va); _tileMinimumHeight = tile.MinimumHeight; _tileMaximumHeight = tile.MaximumHeight; _heightExaggeration = 1; _normalsAlgorithm = TerrainNormalsAlgorithm.ForwardDifference; _showTerrain = true; _dirty = true; }
public SceneGPURelativeToEyeLOD(Context context, Vector3D[] positions, byte[] colors) { _spHigh = Device.CreateShaderProgram( EmbeddedResources.GetText("OpenGlobe.Examples.GPURelativeToEyeLOD.Shaders.HighPrecisionVS.glsl"), EmbeddedResources.GetText("OpenGlobe.Examples.Shaders.FS.glsl")); _cameraEyeHigh = (Uniform<Vector3F>)_spHigh.Uniforms["u_cameraEyeHigh"]; _cameraEyeLow = (Uniform<Vector3F>)_spHigh.Uniforms["u_cameraEyeLow"]; _modelViewPerspectiveMatrixRelativeToEye = (Uniform<Matrix4F>)(_spHigh.Uniforms["u_modelViewPerspectiveMatrixRelativeToEye"]); _pointSizeHigh = (Uniform<float>)_spHigh.Uniforms["u_pointSize"]; /////////////////////////////////////////////////////////////////// Vector3F[] positionsHigh = new Vector3F[positions.Length]; Vector3F[] positionsLow = new Vector3F[positions.Length]; for (int i = 0; i < positions.Length; ++i) { Vector3DToTwoVector3F(positions[i], out positionsHigh[i], out positionsLow[i]); } _center = positions[6]; _positionBufferHigh = Device.CreateVertexBuffer(BufferHint.StaticDraw, ArraySizeInBytes.Size(positions)); _positionBufferLow = Device.CreateVertexBuffer(BufferHint.StaticDraw, ArraySizeInBytes.Size(positions)); _colorBuffer = Device.CreateVertexBuffer(BufferHint.StaticDraw, colors.Length); _positionBufferHigh.CopyFromSystemMemory(positionsHigh); _positionBufferLow.CopyFromSystemMemory(positionsLow); _colorBuffer.CopyFromSystemMemory(colors); _vaHigh = context.CreateVertexArray(); _vaHigh.Attributes[_spHigh.VertexAttributes["positionHigh"].Location] = new VertexBufferAttribute(_positionBufferHigh, ComponentDatatype.Float, 3); _vaHigh.Attributes[_spHigh.VertexAttributes["positionLow"].Location] = new VertexBufferAttribute(_positionBufferLow, ComponentDatatype.Float, 3); _vaHigh.Attributes[_spHigh.VertexAttributes["color"].Location] = new VertexBufferAttribute(_colorBuffer, ComponentDatatype.UnsignedByte, 3, true, 0, 0); /////////////////////////////////////////////////////////////////// RenderState renderState = new RenderState(); renderState.FacetCulling.Enabled = false; renderState.DepthTest.Enabled = false; renderState.ProgramPointSize = ProgramPointSize.Enabled; _drawStateHigh = new DrawState(renderState, _spHigh, _vaHigh); /////////////////////////////////////////////////////////////////// // Low Precision _spLow = Device.CreateShaderProgram( EmbeddedResources.GetText("OpenGlobe.Examples.GPURelativeToEyeLOD.Shaders.LowPrecisionVS.glsl"), EmbeddedResources.GetText("OpenGlobe.Examples.Shaders.FS.glsl")); _pointSizeLow = (Uniform<float>)_spLow.Uniforms["u_pointSize"]; _vaLow = context.CreateVertexArray(); _vaLow.Attributes[_spLow.VertexAttributes["position"].Location] = new VertexBufferAttribute(_positionBufferHigh, ComponentDatatype.Float, 3); _vaLow.Attributes[_spLow.VertexAttributes["color"].Location] = new VertexBufferAttribute(_colorBuffer, ComponentDatatype.UnsignedByte, 3, true, 0, 0); _drawStateLow = new DrawState(renderState, _spLow, _vaLow); }
public SubdivisionSphere2() { _window = Device.CreateWindow(800, 600, "Chapter 4: Subdivision Sphere 2"); _window.Resize += OnResize; _window.RenderFrame += OnRenderFrame; _sceneState = new SceneState(); _camera = new CameraLookAtPoint(_sceneState.Camera, _window, Ellipsoid.UnitSphere); _clearState = new ClearState(); string vs = @"#version 330 layout(location = og_positionVertexLocation) in vec4 position; layout(location = og_normalVertexLocation) in vec3 normal; layout(location = og_textureCoordinateVertexLocation) in vec2 textureCoordinate; out vec3 positionToLight; out vec3 positionToEye; out vec3 surfaceNormal; out vec2 surfaceTextureCoordinate; uniform mat4 og_modelViewPerspectiveMatrix; uniform vec3 og_cameraEye; uniform vec3 og_cameraLightPosition; void main() { gl_Position = og_modelViewPerspectiveMatrix * position; positionToLight = og_cameraLightPosition - position.xyz; positionToEye = og_cameraEye - position.xyz; surfaceNormal = normal; surfaceTextureCoordinate = textureCoordinate; }"; string fs = @"#version 330 in vec3 positionToLight; in vec3 positionToEye; in vec3 surfaceNormal; in vec2 surfaceTextureCoordinate; out vec3 fragmentColor; uniform vec4 og_diffuseSpecularAmbientShininess; uniform sampler2D og_texture0; float LightIntensity(vec3 normal, vec3 toLight, vec3 toEye, vec4 diffuseSpecularAmbientShininess) { vec3 toReflectedLight = reflect(-toLight, normal); float diffuse = max(dot(toLight, normal), 0.0); float specular = max(dot(toReflectedLight, toEye), 0.0); specular = pow(specular, diffuseSpecularAmbientShininess.w); return (diffuseSpecularAmbientShininess.x * diffuse) + (diffuseSpecularAmbientShininess.y * specular) + diffuseSpecularAmbientShininess.z; } void main() { vec3 normal = normalize(surfaceNormal); float intensity = LightIntensity(normal, normalize(positionToLight), normalize(positionToEye), og_diffuseSpecularAmbientShininess); fragmentColor = intensity * texture(og_texture0, surfaceTextureCoordinate).rgb; }"; ShaderProgram sp = Device.CreateShaderProgram(vs, fs); Mesh mesh = SubdivisionSphereTessellator.Compute(5, SubdivisionSphereVertexAttributes.All); VertexArray va = _window.Context.CreateVertexArray(mesh, sp.VertexAttributes, BufferHint.StaticDraw); _primitiveType = mesh.PrimitiveType; RenderState renderState = new RenderState(); renderState.FacetCulling.FrontFaceWindingOrder = mesh.FrontFaceWindingOrder; _drawState = new DrawState(renderState, sp, va); Bitmap bitmap = new Bitmap("NE2_50M_SR_W_4096.jpg"); _texture = Device.CreateTexture2D(bitmap, TextureFormat.RedGreenBlue8, false); }
public NightLights() { _window = Device.CreateWindow(800, 600, "Chapter 4: Night Lights"); _window.Resize += OnResize; _window.RenderFrame += OnRenderFrame; _sceneState = new SceneState(); _camera = new CameraLookAtPoint(_sceneState.Camera, _window, Ellipsoid.ScaledWgs84); _clearState = new ClearState(); string vs = @"#version 330 layout(location = og_positionVertexLocation) in vec4 position; out vec3 worldPosition; out vec3 positionToLight; out vec3 positionToEye; uniform mat4 og_modelViewPerspectiveMatrix; uniform vec3 og_cameraEye; uniform vec3 og_sunPosition; void main() { gl_Position = og_modelViewPerspectiveMatrix * position; worldPosition = position.xyz; positionToLight = og_sunPosition - worldPosition; positionToEye = og_cameraEye - worldPosition; }"; string fs = @"#version 330 in vec3 worldPosition; in vec3 positionToLight; in vec3 positionToEye; out vec3 fragmentColor; uniform vec4 og_diffuseSpecularAmbientShininess; uniform sampler2D og_texture0; // Day uniform sampler2D og_texture1; // Night uniform float u_blendDuration; uniform float u_blendDurationScale; float LightIntensity(vec3 normal, vec3 toLight, vec3 toEye, float diffuseDot, vec4 diffuseSpecularAmbientShininess) { vec3 toReflectedLight = reflect(-toLight, normal); float diffuse = max(diffuseDot, 0.0); float specular = max(dot(toReflectedLight, toEye), 0.0); specular = pow(specular, diffuseSpecularAmbientShininess.w); return (diffuseSpecularAmbientShininess.x * diffuse) + (diffuseSpecularAmbientShininess.y * specular) + diffuseSpecularAmbientShininess.z; } vec2 ComputeTextureCoordinates(vec3 normal) { return vec2(atan(normal.y, normal.x) * og_oneOverTwoPi + 0.5, asin(normal.z) * og_oneOverPi + 0.5); } vec3 NightColor(vec3 normal) { return texture(og_texture1, ComputeTextureCoordinates(normal)).rgb; } vec3 DayColor(vec3 normal, vec3 toLight, vec3 toEye, float diffuseDot, vec4 diffuseSpecularAmbientShininess) { float intensity = LightIntensity(normal, toLight, toEye, diffuseDot, diffuseSpecularAmbientShininess); return intensity * texture(og_texture0, ComputeTextureCoordinates(normal)).rgb; } void main() { vec3 normal = normalize(worldPosition); vec3 toLight = normalize(positionToLight); float diffuse = dot(toLight, normal); if (diffuse > u_blendDuration) { fragmentColor = DayColor(normal, toLight, normalize(positionToEye), diffuse, og_diffuseSpecularAmbientShininess); } else if (diffuse < -u_blendDuration) { fragmentColor = NightColor(normal); } else { vec3 night = NightColor(normal); vec3 day = DayColor(normal, toLight, normalize(positionToEye), diffuse, og_diffuseSpecularAmbientShininess); fragmentColor = mix(night, day, (diffuse + u_blendDuration) * u_blendDurationScale); } }"; ShaderProgram sp = Device.CreateShaderProgram(vs, fs); float blendDurationScale = 0.1f; ((Uniform<float>)sp.Uniforms["u_blendDuration"]).Value = blendDurationScale; ((Uniform<float>)sp.Uniforms["u_blendDurationScale"]).Value = 1 / (2 * blendDurationScale); Mesh mesh = SubdivisionEllipsoidTessellator.Compute(Ellipsoid.ScaledWgs84, 5, SubdivisionEllipsoidVertexAttributes.Position); VertexArray va = _window.Context.CreateVertexArray(mesh, sp.VertexAttributes, BufferHint.StaticDraw); _primitiveType = mesh.PrimitiveType; RenderState renderState = new RenderState(); renderState.FacetCulling.FrontFaceWindingOrder = mesh.FrontFaceWindingOrder; _drawState = new DrawState(renderState, sp, va); Bitmap dayBitmap = new Bitmap("world.topo.200412.3x5400x2700.jpg"); _dayTexture = Device.CreateTexture2D(dayBitmap, TextureFormat.RedGreenBlue8, false); Bitmap nightBitmap = new Bitmap("land_ocean_ice_lights_2048.jpg"); _nightTexture = Device.CreateTexture2D(nightBitmap, TextureFormat.RedGreenBlue8, false); _sceneState.DiffuseIntensity = 0.5f; _sceneState.SpecularIntensity = 0.15f; _sceneState.AmbientIntensity = 0.35f; _sceneState.Camera.ZoomToTarget(1); }
public Triangle() { _window = Device.CreateWindow(800, 600, "Chapter 3: Triangle"); _window.Resize += OnResize; _window.RenderFrame += OnRenderFrame; _sceneState = new SceneState(); _clearState = new ClearState(); string vs = @"#version 330 layout(location = og_positionVertexLocation) in vec4 position; uniform mat4 og_modelViewPerspectiveMatrix; void main() { gl_Position = og_modelViewPerspectiveMatrix * position; }"; string fs = @"#version 330 out vec3 fragmentColor; uniform vec3 u_color; void main() { fragmentColor = u_color; }"; ShaderProgram sp = Device.CreateShaderProgram(vs, fs); ((Uniform<Vector3F>)sp.Uniforms["u_color"]).Value = new Vector3F(1, 0, 0); /////////////////////////////////////////////////////////////////// Mesh mesh = new Mesh(); VertexAttributeFloatVector3 positionsAttribute = new VertexAttributeFloatVector3("position", 3); mesh.Attributes.Add(positionsAttribute); IndicesUnsignedShort indices = new IndicesUnsignedShort(3); mesh.Indices = indices; IList<Vector3F> positions = positionsAttribute.Values; positions.Add(new Vector3F(0, 0, 0)); positions.Add(new Vector3F(1, 0, 0)); positions.Add(new Vector3F(0, 0, 1)); indices.AddTriangle(new TriangleIndicesUnsignedShort(0, 1, 2)); VertexArray va = _window.Context.CreateVertexArray(mesh, sp.VertexAttributes, BufferHint.StaticDraw); /////////////////////////////////////////////////////////////////// RenderState renderState = new RenderState(); renderState.FacetCulling.Enabled = false; renderState.DepthTest.Enabled = false; _drawState = new DrawState(renderState, sp, va); /////////////////////////////////////////////////////////////////// _sceneState.Camera.ZoomToTarget(1); }
public SubdivisionSphere1() { _window = Device.CreateWindow(800, 600, "Chapter 4: Subdivision Sphere 1"); _window.Resize += OnResize; _window.RenderFrame += OnRenderFrame; _sceneState = new SceneState(); _camera = new CameraLookAtPoint(_sceneState.Camera, _window, Ellipsoid.UnitSphere); _clearState = new ClearState(); string vs = @"#version 330 layout(location = og_positionVertexLocation) in vec4 position; out vec3 worldPosition; out vec3 positionToLight; out vec3 positionToEye; uniform mat4 og_modelViewPerspectiveMatrix; uniform vec3 og_cameraEye; uniform vec3 og_cameraLightPosition; void main() { gl_Position = og_modelViewPerspectiveMatrix * position; worldPosition = position.xyz; positionToLight = og_cameraLightPosition - worldPosition; positionToEye = og_cameraEye - worldPosition; }"; string fs = @"#version 330 in vec3 worldPosition; in vec3 positionToLight; in vec3 positionToEye; out vec3 fragmentColor; uniform vec4 og_diffuseSpecularAmbientShininess; uniform sampler2D og_texture0; float LightIntensity(vec3 normal, vec3 toLight, vec3 toEye, vec4 diffuseSpecularAmbientShininess) { vec3 toReflectedLight = reflect(-toLight, normal); float diffuse = max(dot(toLight, normal), 0.0); float specular = max(dot(toReflectedLight, toEye), 0.0); specular = pow(specular, diffuseSpecularAmbientShininess.w); return (diffuseSpecularAmbientShininess.x * diffuse) + (diffuseSpecularAmbientShininess.y * specular) + diffuseSpecularAmbientShininess.z; } vec2 ComputeTextureCoordinates(vec3 normal) { return vec2(atan(normal.y, normal.x) * og_oneOverTwoPi + 0.5, asin(normal.z) * og_oneOverPi + 0.5); } void main() { vec3 normal = normalize(worldPosition); float intensity = LightIntensity(normal, normalize(positionToLight), normalize(positionToEye), og_diffuseSpecularAmbientShininess); fragmentColor = intensity * texture(og_texture0, ComputeTextureCoordinates(normal)).rgb; }"; ShaderProgram sp = Device.CreateShaderProgram(vs, fs); /////////////////////////////////////////////////////////////////// Mesh mesh = SubdivisionSphereTessellatorSimple.Compute(5); VertexArray va = _window.Context.CreateVertexArray(mesh, sp.VertexAttributes, BufferHint.StaticDraw); _primitiveType = mesh.PrimitiveType; /////////////////////////////////////////////////////////////////// RenderState renderState = new RenderState(); //_renderState.RasterizationMode = RasterizationMode.Line; renderState.FacetCulling.FrontFaceWindingOrder = mesh.FrontFaceWindingOrder; _drawState = new DrawState(renderState, sp, va); /////////////////////////////////////////////////////////////////// Bitmap bitmap = new Bitmap("NE2_50M_SR_W_4096.jpg"); //Bitmap bitmap = new Bitmap("world_topo_bathy_200411_3x5400x2700.jpg"); //Bitmap bitmap = new Bitmap("world.topo.200412.3x5400x2700.jpg"); _texture = Device.CreateTexture2D(bitmap, TextureFormat.RedGreenBlue8, false); _sceneState.Camera.ZoomToTarget(1); }
public void ColorMaskTest() { ColorMask mask = new ColorMask(true, false, true, false); Assert.IsTrue(mask.Red); Assert.IsFalse(mask.Green); Assert.IsTrue(mask.Blue); Assert.IsFalse(mask.Alpha); ColorMask mask2 = new ColorMask(true, false, true, false); Assert.IsTrue(mask == mask2); ColorMask mask3 = new ColorMask(false, true, false, true); Assert.IsTrue(mask != mask3); RenderState renderState = new RenderState(); renderState.ColorMask = mask; Assert.AreEqual(mask, renderState.ColorMask); }