public RenderBuffer(ShaderManager.ShaderType shaderType) { this.shader = ShaderManager.GetShader(shaderType); meshesToAdd = new ConcurrentBag <Mesh>(); meshesToRemove = new ConcurrentBag <Mesh>(); }
public static RenderBuffer GetBuffer(ShaderManager.ShaderType type) { if (renderBuffers.TryGetValue(type, out RenderBuffer buffer)) { return(buffer); } return(null); }
private void SetShaderType() { if (this.rendererMaterials == null && this.rendererMaterials.Length <= 0) { return; } if (this.rendererMaterials.Length == 1 && this.rendererMaterials[0] != null && this.rendererMaterials[0].get_shader() != null) { this.m_shaderType = ShaderManager.GetShaderType(this.rendererMaterials[0].get_shader().get_name()); return; } this.m_shaderType = ShaderManager.ShaderType.None; }
public static void SwitchShader(Material[] m_materials, bool transparent, ShaderManager.ShaderType shaderType) { if (shaderType == ShaderManager.ShaderType.None) { return; } if (!transparent) { if (shaderType == ShaderManager.ShaderType.TextureMult) { ShaderEffectUtils.SetShader(m_materials, "MatCap/Vertex/Textured Multiply(NoTransparent)"); } } else if (shaderType == ShaderManager.ShaderType.TextureMult) { ShaderEffectUtils.SetShader(m_materials, "MatCap/Vertex/Textured Multiply"); } }
public VoxelRenderBuffer(ShaderManager.ShaderType shaderType) : base(shaderType) { //Calculate Space reuqirements int averageVerticesPerMesh = 500000; int meshCount = (int)Math.Pow((CommonConstants.World.DrawDistance * 2 + 1), 2); int vertexBufferSize = averageVerticesPerMesh * Vertex.SizeInBytes * meshCount; int elementBufferSize = averageVerticesPerMesh * 3 * sizeof(int) * meshCount; Log.Info(type, $"Set VoxelRB VertexBuffer to { vertexBufferSize / 996113 } MB"); Log.Info(type, $"Set VoxelRB ElementBuffer to { elementBufferSize / 996113 } MB"); //vertexBufferObject vertexBufferObject = GL.GenBuffer(); GL.BindBuffer(BufferTarget.ArrayBuffer, vertexBufferObject); GL.BufferData(BufferTarget.ArrayBuffer, vertexBufferSize, IntPtr.Zero, BufferUsageHint.StaticDraw); //elementBufferObject elementBufferObject = GL.GenBuffer(); GL.BindBuffer(BufferTarget.ElementArrayBuffer, elementBufferObject); GL.BufferData(BufferTarget.ElementArrayBuffer, elementBufferSize, IntPtr.Zero, BufferUsageHint.StaticDraw); //vertexArrayObject vertexArrayObject = GL.GenVertexArray(); GL.BindVertexArray(vertexArrayObject); GL.BindBuffer(BufferTarget.ArrayBuffer, vertexArrayObject); GL.BindBuffer(BufferTarget.ElementArrayBuffer, elementBufferObject); GL.EnableVertexAttribArray(shader.GetAttibute("vPosition")); GL.VertexAttribPointer(shader.GetAttibute("vPosition"), 3, VertexAttribPointerType.Float, false, Vertex.SizeInBytes, 0); GL.EnableVertexAttribArray(shader.GetAttibute("vColor")); GL.VertexAttribPointer(shader.GetAttibute("vColor"), 4, VertexAttribPointerType.UnsignedByte, false, Vertex.SizeInBytes, Vector3.SizeInBytes); GL.EnableVertexAttribArray(shader.GetAttibute("vNormal")); GL.VertexAttribPointer(shader.GetAttibute("vNormal"), 3, VertexAttribPointerType.Float, false, Vertex.SizeInBytes, Vector3.SizeInBytes + Vector4b.SizeInBytes); UnbindCurrentBuffer(); }