public virtual void RenderPart(RenderContext renderContext, int part, double opacity, bool combine) { if (PrepDevice == null) { bool lighting = renderContext.Lighting && renderContext.SunPosition != null; foreach (RenderTriangle tri in RenderTriangleLists[part]) { tri.Opacity = opacity; if (lighting) { // tranform normal by WV Vector3d norm = tri.Normal.Copy(); renderContext.World.MultiplyVector(norm); norm.Normalize(); // Dot product from sun angle double light = Vector3d.Dot(norm, renderContext.SunPosition); if (light < 0) { light = 0; } else { light = Math.Min(1.0f, (light * 1)); } // set lighting tri.lighting = (float)light; } else { tri.lighting = 1.0f; } tri.Draw(renderContext.Device, renderContext.WVP); } } else { TileShader.Use(renderContext, VertexBuffer, GetIndexBuffer(part, accomidation), texture2d); //renderContext.gl.enableVertexAttribArray(renderContext.vertLoc); //renderContext.gl.enableVertexAttribArray(renderContext.textureLoc); //renderContext.gl.bindBuffer(GL.ARRAY_BUFFER, VertexBuffer); //renderContext.gl.vertexAttribPointer(renderContext.vertLoc, 3, GL.FLOAT, false, 20, 0); //renderContext.gl.vertexAttribPointer(renderContext.textureLoc, 2, GL.FLOAT, false, 20, 12); //renderContext.gl.activeTexture(GL.TEXTURE0); //renderContext.gl.bindTexture(GL.TEXTURE_2D, texture2d); //renderContext.gl.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, GetIndexBuffer(part, accomidation)); renderContext.gl.drawElements(GL.TRIANGLES, TriangleCount * 3, GL.UNSIGNED_SHORT, 0); } }
//internal WebGLShader frag; //internal WebGLShader vert; //public int vertLoc; //public int textureLoc; //public WebGLUniformLocation projMatLoc; //public WebGLUniformLocation mvMatLoc; //public WebGLUniformLocation sampLoc; internal void InitGL() { if (gl == null) { return; } Tile.uvMultiple = 1; Tile.DemEnabled = true; TileShader.Init(this); }
//internal WebGLShader frag; //internal WebGLShader vert; //public int vertLoc; //public int textureLoc; //public WebGLUniformLocation projMatLoc; //public WebGLUniformLocation mvMatLoc; //public WebGLUniformLocation sampLoc; internal void InitGL() { if (gl == null) { return; } int uints_for_indices = gl.getExtension("OES_element_index_uint"); Tile.uvMultiple = 1; Tile.DemEnabled = true; TileShader.Init(this); }
public virtual void RenderPart(RenderContext renderContext, int part, double opacity, bool combine) { if (PrepDevice == null) { bool lighting = renderContext.Lighting && renderContext.SunPosition != null; foreach (RenderTriangle tri in RenderTriangleLists[part]) { tri.Opacity = opacity; if (lighting) { // tranform normal by WV Vector3d norm = tri.Normal.Copy(); renderContext.World.MultiplyVector(norm); norm.Normalize(); // Dot product from sun angle double light = Vector3d.Dot(norm, renderContext.SunPosition); if (light < 0) { light = 0; } else { light = Math.Min(1.0f, (light * 1)); } // set lighting tri.lighting = (float)light; } else { tri.lighting = 1.0f; } tri.Draw(renderContext.Device, renderContext.WVP); } } else { TileShader.Use(renderContext, VertexBuffer, GetIndexBuffer(part, accomidation), texture2d, (float)opacity, false); renderContext.gl.drawElements(GL.TRIANGLES, TriangleCount * 3, GL.UNSIGNED_SHORT, 0); } }
public override void RenderPart(RenderContext renderContext, int part, double opacity, bool combine) { if (RenderContext.UseGlVersion2 && dataset.WcsImage is FitsImage) { ColorMapContainer.BindColorMapTexture(PrepDevice, dataset.FitsProperties.ColorMapName); FitsShader.Min = (float)dataset.FitsProperties.LowerCut; FitsShader.Max = (float)dataset.FitsProperties.UpperCut; FitsShader.ContainsBlanks = dataset.FitsProperties.ContainsBlanks; FitsShader.BlankValue = (float)dataset.FitsProperties.BlankValue; FitsShader.BZero = (float)dataset.FitsProperties.BZero; FitsShader.BScale = (float)dataset.FitsProperties.BScale; FitsShader.ScaleType = (int)dataset.FitsProperties.ScaleType; FitsShader.TransparentBlack = dataset.FitsProperties.TransparentBlack; FitsShader.Use(renderContext, VertexBuffer, GetIndexBuffer(part, accomidation), texture2d, (float)opacity, false); } else { TileShader.Use(renderContext, VertexBuffer, GetIndexBuffer(part, accomidation), texture2d, (float)opacity, false); } renderContext.gl.drawElements(GL.TRIANGLES, TriangleCount * 3, GL.UNSIGNED_SHORT, 0); }
public static void DrawGalaxyImage(RenderContext renderContext, float opacity) { if (galaxyImageIndexBuffer == null) { CreateGalaxyImage(renderContext); } // renderContext.setRasterizerState(TriangleCullMode.Off); // renderContext.BlendMode = BlendMode.Additive; double zoom = renderContext.ViewCamera.Zoom; double log = Math.Log(Math.Max(1, zoom)) / Math.Log(4); double distAlpha = ((log) - 14) * 128; int alpha = (int)(Math.Min(255, (int)Math.Max(0, distAlpha)) * opacity); // renderContext.Device.ImmediateContext.PixelShader.SetShaderResource(0, milkyWayImage.ResourceView); //renderContext.SetupBasicEffect(BasicEffect.TextureColorOpacity, opacity, Color.FromArgb(alpha, alpha, alpha, alpha)); //if (galaxyImageInputLayout == null) //{ // galaxyImageInputLayout = new SharpDX.Direct3D11.InputLayout(device, renderContext.Shader.InputSignature, new[] // { // new SharpDX.Direct3D11.InputElement("POSITION", 0, SharpDX.DXGI.Format.R32G32B32_Float, 0, 0), // new SharpDX.Direct3D11.InputElement("TEXCOORD", 0, SharpDX.DXGI.Format.R32G32_Float, 12, 0), // }); //} //renderContext.Device.ImmediateContext.InputAssembler.InputLayout = galaxyImageInputLayout; //renderContext.SetVertexBuffer(galaxyImageVertexBuffer); //renderContext.SetIndexBuffer(galaxyImageIndexBuffer); //device.ImmediateContext.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleList; //renderContext.PreDraw(); //device.ImmediateContext.DrawIndexed(galaxyImageTriangleCount * 3, 0, 0); TileShader.Use(renderContext, galaxyImageVertexBuffer.VertexBuffer, galaxyImageIndexBuffer, milkyWayImage.Texture2d, (float)opacity, true); renderContext.gl.drawElements(GL.TRIANGLES, galaxyImageTriangleCount * 3, GL.UNSIGNED_SHORT, 0); }
public virtual void RenderPart(RenderContext renderContext, int part, double opacity, bool combine) { if (PrepDevice == null) { bool lighting = renderContext.Lighting && renderContext.SunPosition != null; foreach (RenderTriangle tri in RenderTriangleLists[part]) { tri.Opacity = opacity; if (lighting) { // tranform normal by WV Vector3d norm = tri.Normal.Copy(); renderContext.World.MultiplyVector(norm); norm.Normalize(); // Dot product from sun angle double light = Vector3d.Dot(norm, renderContext.SunPosition); if (light < 0) { light = 0; } else { light = Math.Min(1.0f, (light * 1)); } // set lighting tri.lighting = (float)light; } else { tri.lighting = 1.0f; } tri.Draw(renderContext.Device, renderContext.WVP); } } else { if (RenderContext.UseGlVersion2 && fitsImage != null) { ColorMapContainer.BindColorMapTexture(PrepDevice, dataset.FitsProperties.ColorMapName); FitsShader.Min = (float)dataset.FitsProperties.LowerCut; FitsShader.Max = (float)dataset.FitsProperties.UpperCut; FitsShader.ContainsBlanks = dataset.FitsProperties.ContainsBlanks; FitsShader.BlankValue = (float)dataset.FitsProperties.BlankValue; FitsShader.BZero = (float)dataset.FitsProperties.BZero; FitsShader.BScale = (float)dataset.FitsProperties.BScale; FitsShader.ScaleType = (int)dataset.FitsProperties.ScaleType; FitsShader.TransparentBlack = dataset.FitsProperties.TransparentBlack; FitsShader.Use(renderContext, VertexBuffer, GetIndexBuffer(part, accomidation), texture2d, (float)opacity, false, GlobalCenter); } else { TileShader.Use(renderContext, VertexBuffer, GetIndexBuffer(part, accomidation), texture2d, (float)opacity, false, GlobalCenter); } renderContext.gl.drawElements(GL.TRIANGLES, TriangleCount * 3, GL.UNSIGNED_SHORT, 0); } }