public override void Use(Texture source, Texture target) { RenderShader.SetVector3("Color", Color); RenderShader.SetFloat("MaxDist", AlphaLength); RenderShader.SetFloat("MaxAlpha", MaxAlpha); RenderShader.SetFloat("MinAlpha", MinAlpha); RenderShader.Use(); Render(source, target, true, false); }
public override void Use(Texture source, Texture target) { Sharpscope.Blit(source, tempA); // downscale original RenderShader.Use(); RenderShader.SetVector2("texelSize", new OpenTK.Vector2(1f / tempB.Width, 1f / tempB.Height)); RenderShader.SetInt("Horizontal", 1); Render(tempA, tempB); RenderShader.SetInt("Horizontal", 0); Render(tempB, target); }
public TerrainRenderer(Camera camera) { this.camera = camera; shader = new RenderShader(); shadowShader = new ShadowShader(); quadTree = new TerrainQuadTree(); worldTransform = Matrix4.CreateScale(Map.MapData.MapSize) * Matrix4.CreateTranslation(-Map.MapData.MapSize / 2.0f, 0.0f, -Map.MapData.MapSize / 2.0f); texture = new Texture(); textureNoise = new TextureNoise(12312234); NormalMap = new NormalMap(); HeightMap = new HeightMap(NormalMap); SplatMap = new SplatMap(); picker = new TerrainPicker(camera, HeightMap); loadTextures(); build(); Update(); }
public CameraSettings(int id = 0) { this.id = id; renderMode = RenderMode.Draw; cameraType = CameraType.MainCamera; renderShader = RenderShader.Multiply; renderLayerType = RenderLayerType.Default; customMaterial = null; customMaterialInstance = null; bufferID = 0; renderLayerId = 0; customCamera = null; materials = new CameraMaterials(); }
public override void Use(Texture source, Texture target) { RenderShader.SetInt("Combine", 1); Combine.Use(TextureUnit.Texture1); Render(source, target); }
public void Unload() { if(colorTableMgr != null) colorTableMgr.Visible = false; if(texstream != null) texstream.ClearImages(); if(images != null) { foreach(TransformedImage image in images) image.Dispose(); images = null; } arguments = null; selectionAabb = null; sdr2D_default = sdr2D_cm = null; sdr3D_default = sdr3D_cm = null; if(mesh3D != null) mesh3D.Free(); mesh3D = null; #if USE_ARG_IDX argIndex.Unload(); #endif #if USE_PARAM_IDX paramIndex.Unload(); #endif #if USE_CUSTOM_CONTROLS ccContainer.Unload(); #endif }
public void Load(IEnumerable<TransformedImage> newimages, Dictionary<string, HashSet<object>> valuerange, Size imageSize, bool floatimages = false, bool depthimages = false) { //depthimages = false; int i; this.images = Viewer.images; this.arguments = Global.arguments; if(floatimages) { colorTableMgr.Visible = true; colorTableMgr.OnSizeChanged(backbuffersize); colorTableMgr.Reset(); //foreach(TransformedImage newimage in newimages) // newimage.isFloatImage = true; } else { //foreach(TransformedImage newimage in newimages) // newimage.isFloatImage = false; } if(sdr2D_default == null) { #if USE_GS_QUAD sdr2D_default = new RenderShader(new string[] {IMAGE_CLOUD_SHADER.VS_USING_GS}, new string[] {IMAGE_CLOUD_SHADER.FS, IMAGE_CLOUD_SHADER.FS_DEFAULT_DECODER}, new string[] {IMAGE_CLOUD_SHADER.GS}); sdr2D_cm = new RenderShader(new string[] {IMAGE_CLOUD_SHADER.VS_USING_GS}, new string[] {IMAGE_CLOUD_SHADER.FS, IMAGE_CLOUD_SHADER.FS_COLORTABLE_DECODER}, new string[] {IMAGE_CLOUD_SHADER.GS}); sdr2D_assemble = new RenderShader(new string[] { IMAGE_CLOUD_SHADER.VS_USING_GS }, new string[] {IMAGE_CLOUD_SHADER.FS_ASSEMBLE_IMAGE}, new string[] {IMAGE_CLOUD_SHADER.GS})); #else sdr2D_default = new RenderShader(new string[] { IMAGE_CLOUD_SHADER.VS_DEFAULT }, new string[] {IMAGE_CLOUD_SHADER.FS, IMAGE_CLOUD_SHADER.FS_DEFAULT_DECODER}); sdr2D_cm = new RenderShader(new string[] { IMAGE_CLOUD_SHADER.VS_DEFAULT }, new string[] {IMAGE_CLOUD_SHADER.FS, IMAGE_CLOUD_SHADER.FS_COLORTABLE_DECODER}); sdr2D_assemble = new RenderShader(new string[] { IMAGE_CLOUD_SHADER.VS_DEFAULT }, new string[] {IMAGE_CLOUD_SHADER.FS_DEPTH_PEELING}); #endif sdr3D_default = new RenderShader(new string[] { IMAGE_CLOUD_SHADER.VS_DEPTHIMAGE }, new string[] {IMAGE_CLOUD_SHADER.FS, IMAGE_CLOUD_SHADER.FS_DEFAULT_DECODER}); sdr3D_cm = new RenderShader(new string[] { IMAGE_CLOUD_SHADER.VS_DEPTHIMAGE }, new string[] {IMAGE_CLOUD_SHADER.FS, IMAGE_CLOUD_SHADER.FS_COLORTABLE_DECODER}); sdr3D_assemble = new RenderShader(new string[] { IMAGE_CLOUD_SHADER.VS_DEPTHIMAGE }, new string[] {IMAGE_CLOUD_SHADER.FS_DEPTH_PEELING}); foreach(GLShader sdr in new GLShader[] {sdr2D_cm, sdr3D_cm, sdr2D_assemble, sdr3D_assemble}) { sdr.Bind(); GL.ActiveTexture(TextureUnit.Texture4); colorTableMgr.Colormap.Bind(); GL.Uniform1(sdr.GetUniformLocation("Colormap"), 4); } GL.ActiveTexture(TextureUnit.Texture0); } texstream.AddImages(newimages); if(depthimages && mesh3D == null) { // Create mesh for depth rendering Size depthimagesize = new Size(imageSize.Width, imageSize.Height); Vector3[] positions = new Vector3[depthimagesize.Width * depthimagesize.Height]; Vector2[] texcoords = new Vector2[depthimagesize.Width * depthimagesize.Height]; i = 0; for(int y = 0; y < depthimagesize.Height; ++y) for(int x = 0; x < depthimagesize.Width; ++x) { positions[i] = new Vector3(2.0f * (float)x / (float)(depthimagesize.Width - 1) - 1.0f, 2.0f * (float)y / (float)(depthimagesize.Height - 1) - 1.0f, 1.0f); texcoords[i] = new Vector2((float)x / (float)(depthimagesize.Width - 1), 1.0f - (float)y / (float)(depthimagesize.Height - 1)); ++i; } /*int[] indices = new int[6 * (depthimagesize.Width - 1) * (depthimagesize.Height - 1)]; i = 0; for(int y = 1; y < depthimagesize.Height; ++y) for(int x = 1; x < depthimagesize.Width; ++x) { indices[i++] = (x - 1) + depthimagesize.Width * (y - 1); indices[i++] = (x - 0) + depthimagesize.Width * (y - 1); indices[i++] = (x - 1) + depthimagesize.Width * (y - 0); indices[i++] = (x - 1) + depthimagesize.Width * (y - 0); indices[i++] = (x - 0) + depthimagesize.Width * (y - 1); indices[i++] = (x - 0) + depthimagesize.Width * (y - 0); } mesh3D = new GLMesh(positions, null, null, null, texcoords, indices);*/ mesh3D = new GLMesh(positions, null, null, null, texcoords, null, PrimitiveType.Points); //GL.PointSize(2.0f); } int argIndexBottom = 0; #if USE_ARG_IDX argIndex.Load(valuerange); argIndexBottom = argIndex.Bounds.Bottom + arguments.Length * argIndex.Bounds.Height * 3 / 2; #endif #if USE_PARAM_IDX paramIndex.Bounds = new Rectangle(paramIndex.Bounds.X, argIndexBottom, paramIndex.Bounds.Width, paramIndex.Bounds.Height);// paramIndex.Bounds.Y = argIndexBottom; paramIndex.Load(); #endif // Enable depth rendering by default whenever a new scene is loaded depthRenderingEnabled = true; depthRenderingEnabled_fade = 1.0f; depthRenderingEnabled = false; depthRenderingEnabled_fade = 0.0f; }
public override void Use(Texture source, Texture target) { RenderShader.SetFloat("Glow", Glow); RenderShader.Use(); Render(source, target); }