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 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); } }