public RenderTexture2dCommand(Vector2 min, Vector2 max, TextureBufferObject t, float alpha = 1.0f, bool isDepthBuffer = false) : base() { myMin = min; myMax = max; myAlpha = alpha; myVerts = new V3T2B4[4]; myVerts[0].Position = new Vector3(min.X, min.Y, 0); myVerts[0].TexCoord = new Vector2(0, 0); myVerts[0].Color = new Color4(1.0f, 1.0f, 1.0f, alpha).toUInt(); myVerts[1].Position = new Vector3(max.X, min.Y, 0); myVerts[1].TexCoord = new Vector2(1, 0); myVerts[1].Color = new Color4(1.0f, 1.0f, 1.0f, alpha).toUInt(); myVerts[2].Position = new Vector3(max.X, max.Y, 0); myVerts[2].TexCoord = new Vector2(1, 1); myVerts[2].Color = new Color4(1.0f, 1.0f, 1.0f, alpha).toUInt(); myVerts[3].Position = new Vector3(min.X, max.Y, 0); myVerts[3].TexCoord = new Vector2(0, 1); myVerts[3].Color = new Color4(1.0f, 1.0f, 1.0f, alpha).toUInt(); renderState.setTexture(t.id, 0, TextureTarget.Texture2D); renderState.setIndexBuffer(theIBO.id); renderState.setVertexBuffer(theVBO.id, 0, 0, V3T2B4.stride); renderState.setUniform(new UniformData(0, Uniform.UniformType.Bool, false)); renderState.setUniform(new UniformData(20, Uniform.UniformType.Int, 0)); renderState.setUniform(new UniformData(23, Uniform.UniformType.Int, 0)); renderState.setUniform(new UniformData(25, Uniform.UniformType.Bool, isDepthBuffer)); pipelineState = new PipelineState(); pipelineState.shaderState.shaderProgram = theShader; pipelineState.vaoState.vao = theVAO; pipelineState.depthTest.enabled = false; pipelineState.blending.enabled = alpha < 1.0f; pipelineState.generateId(); }
public RenderWireframeCubeCommand(Vector3 min, Vector3 max, Color4 c) : base() { myVerts = new V3T2B4[8]; UInt32 col = c.toUInt(); myVerts[0].Position = new Vector3(min.X, min.Y, min.Z); myVerts[0].TexCoord = Vector2.Zero; myVerts[0].Color = col; myVerts[1].Position = new Vector3(max.X, min.Y, min.Z); myVerts[1].TexCoord = Vector2.Zero; myVerts[1].Color = col; myVerts[2].Position = new Vector3(min.X, max.Y, min.Z); myVerts[2].TexCoord = Vector2.Zero; myVerts[2].Color = col; myVerts[3].Position = new Vector3(max.X, max.Y, min.Z); myVerts[3].TexCoord = Vector2.Zero; myVerts[3].Color = col; myVerts[4].Position = new Vector3(min.X, min.Y, max.Z); myVerts[4].TexCoord = Vector2.Zero; myVerts[4].Color = col; myVerts[5].Position = new Vector3(max.X, min.Y, max.Z); myVerts[5].TexCoord = Vector2.Zero; myVerts[5].Color = col; myVerts[6].Position = new Vector3(min.X, max.Y, max.Z); myVerts[6].TexCoord = Vector2.Zero; myVerts[6].Color = col; myVerts[7].Position = new Vector3(max.X, max.Y, max.Z); myVerts[7].TexCoord = Vector2.Zero; myVerts[7].Color = col; renderState.setIndexBuffer(theIBO.id); renderState.setVertexBuffer(theVBO.id, 0, 0, V3T2B4.stride); renderState.setUniform(new UniformData(0, Uniform.UniformType.Bool, true)); //is 3d renderState.setUniform(new UniformData(23, Uniform.UniformType.Int, -1)); //no texture renderState.primativeRestart.enabled = true; renderState.primativeRestart.value = PRIM_RESTART; pipelineState = new PipelineState(); pipelineState.shaderState.shaderProgram = theShader; pipelineState.vaoState.vao = theVAO; pipelineState.depthTest.enabled = false; pipelineState.blending.enabled = c.A < 1.0f; pipelineState.generateId(); }
public RenderTexturedQuadCommand(Vector3[] verts, Texture t, float alpha = 1.0f) { UInt32 col = new Color4(1.0f, 1.0f, 1.0f, alpha).toUInt(); myVerts = new V3T2B4[4]; myVerts[0].Position = verts[0]; myVerts[0].TexCoord = new Vector2(0, 0); myVerts[0].Color = col; myVerts[1].Position = verts[1]; myVerts[1].TexCoord = new Vector2(0, 1); myVerts[1].Color = col; myVerts[2].Position = verts[2]; myVerts[2].TexCoord = new Vector2(1, 1); myVerts[2].Color = col; myVerts[3].Position = verts[3]; myVerts[3].TexCoord = new Vector2(1, 0); myVerts[3].Color = col; renderState.setTexture(t.id(), 0, t.target); pipelineState = new PipelineState(); if (t.hasAlpha == true || alpha < 1.0f) { pipelineState.blending.enabled = true; } pipelineState.shaderState.shaderProgram = theShader; pipelineState.vaoState.vao = theVAO; pipelineState.depthTest.enabled = false; pipelineState.culling.enabled = false; pipelineState.generateId(); renderState.setIndexBuffer(theIBO.id); renderState.setVertexBuffer(theVBO.id, 0, 0, V3T2B4.stride); renderState.setUniform(new UniformData(0, Uniform.UniformType.Bool, true)); renderState.setUniform(new UniformData(20, Uniform.UniformType.Int, 0)); renderState.setUniform(new UniformData(23, Uniform.UniformType.Int, 0)); renderState.setUniform(new UniformData(25, Uniform.UniformType.Bool, false)); }
public RenderFrustumCommand(Matrix4 viewProj, Color4 c) : base() { Matrix4 inv = viewProj.Inverted(); myVerts = new V3T2B4[8]; UInt32 col = c.toUInt(); myVerts[0].Position = (theVerts[0] * inv).Xyz; myVerts[0].TexCoord = Vector2.Zero; myVerts[0].Color = col; myVerts[1].Position = (theVerts[1] * inv).Xyz; myVerts[1].TexCoord = Vector2.Zero; myVerts[1].Color = col; myVerts[2].Position = (theVerts[2] * inv).Xyz; myVerts[2].TexCoord = Vector2.Zero; myVerts[2].Color = col; myVerts[3].Position = (theVerts[3] * inv).Xyz; myVerts[3].TexCoord = Vector2.Zero; myVerts[3].Color = col; myVerts[4].Position = (theVerts[4] * inv).Xyz; myVerts[4].TexCoord = Vector2.Zero; myVerts[4].Color = col; myVerts[5].Position = (theVerts[5] * inv).Xyz; myVerts[5].TexCoord = Vector2.Zero; myVerts[5].Color = col; myVerts[6].Position = (theVerts[6] * inv).Xyz; myVerts[6].TexCoord = Vector2.Zero; myVerts[6].Color = col; myVerts[7].Position = (theVerts[7] * inv).Xyz; myVerts[7].TexCoord = Vector2.Zero; myVerts[7].Color = col; renderState.setIndexBuffer(theIBO.id); renderState.setVertexBuffer(theVBO.id, 0, 0, V3T2B4.stride); renderState.setUniform(new UniformData(0, Uniform.UniformType.Bool, true)); //is 3d renderState.setUniform(new UniformData(23, Uniform.UniformType.Int, -1)); //no texture renderState.primativeRestart.enabled = true; renderState.primativeRestart.value = PRIM_RESTART; pipelineState = new PipelineState(); pipelineState.shaderState.shaderProgram = theShader; pipelineState.vaoState.vao = theVAO; pipelineState.depthTest.enabled = false; pipelineState.blending.enabled = c.A < 1.0f; pipelineState.generateId(); }
public RenderTextureCubeCommand(Vector3 min, Vector3 max, Texture t, float alpha = 1.0f) : base() { myVerts = new V3T2B4[24]; V3T2[] verts = new V3T2[24]; UInt32 col = new Color4(1.0f, 1.0f, 1.0f, alpha).toUInt(); //front face myVerts[0].Position = new Vector3(max.X, min.Y, min.Z); myVerts[0].TexCoord = new Vector2(0, 0); myVerts[0].Color = col; myVerts[1].Position = new Vector3(min.X, min.Y, min.Z); myVerts[1].TexCoord = new Vector2(1, 0); myVerts[1].Color = col; myVerts[2].Position = new Vector3(min.X, max.Y, min.Z); myVerts[2].TexCoord = new Vector2(1, 1); myVerts[2].Color = col; myVerts[3].Position = new Vector3(max.X, max.Y, min.Z); myVerts[3].TexCoord = new Vector2(0, 1); myVerts[3].Color = col; //left myVerts[4].Position = new Vector3(min.X, min.Y, min.Z); myVerts[4].TexCoord = new Vector2(0, 0); myVerts[4].Color = col; myVerts[5].Position = new Vector3(min.X, min.Y, max.Z); myVerts[5].TexCoord = new Vector2(1, 0); myVerts[5].Color = col; myVerts[6].Position = new Vector3(min.X, max.Y, max.Z); myVerts[6].TexCoord = new Vector2(1, 1); myVerts[6].Color = col; myVerts[7].Position = new Vector3(min.X, max.Y, min.Z); myVerts[7].TexCoord = new Vector2(0, 1); myVerts[7].Color = col; //right myVerts[8].Position = new Vector3(max.X, min.Y, max.Z); myVerts[8].TexCoord = new Vector2(0, 0); myVerts[8].Color = col; myVerts[9].Position = new Vector3(max.X, min.Y, min.Z); myVerts[9].TexCoord = new Vector2(1, 0); myVerts[9].Color = col; myVerts[10].Position = new Vector3(max.X, max.Y, min.Z); myVerts[10].TexCoord = new Vector2(1, 1); myVerts[10].Color = col; myVerts[11].Position = new Vector3(max.X, max.Y, max.Z); myVerts[11].TexCoord = new Vector2(0, 1); myVerts[11].Color = col; //top myVerts[12].Position = new Vector3(min.X, max.Y, max.Z); myVerts[12].TexCoord = new Vector2(0, 0); myVerts[12].Color = col; myVerts[13].Position = new Vector3(max.X, max.Y, max.Z); myVerts[13].TexCoord = new Vector2(1, 0); myVerts[13].Color = col; myVerts[14].Position = new Vector3(max.X, max.Y, min.Z); myVerts[14].TexCoord = new Vector2(1, 1); myVerts[14].Color = col; myVerts[15].Position = new Vector3(min.X, max.Y, min.Z); myVerts[15].TexCoord = new Vector2(0, 1); myVerts[15].Color = col; //bottom myVerts[16].Position = new Vector3(min.X, min.Y, min.Z); myVerts[16].TexCoord = new Vector2(0, 0); myVerts[16].Color = col; myVerts[17].Position = new Vector3(max.X, min.Y, min.Z); myVerts[17].TexCoord = new Vector2(1, 0); myVerts[17].Color = col; myVerts[18].Position = new Vector3(max.X, min.Y, max.Z); myVerts[18].TexCoord = new Vector2(1, 1); myVerts[18].Color = col; myVerts[19].Position = new Vector3(min.X, min.Y, max.Z); myVerts[19].TexCoord = new Vector2(0, 1); myVerts[19].Color = col; //back myVerts[20].Position = new Vector3(min.X, min.Y, max.Z); myVerts[20].TexCoord = new Vector2(0, 0); myVerts[20].Color = col; myVerts[21].Position = new Vector3(max.X, min.Y, max.Z); myVerts[21].TexCoord = new Vector2(1, 0); myVerts[21].Color = col; myVerts[22].Position = new Vector3(max.X, max.Y, max.Z); myVerts[22].TexCoord = new Vector2(1, 1); myVerts[22].Color = col; myVerts[23].Position = new Vector3(min.X, max.Y, max.Z); myVerts[23].TexCoord = new Vector2(0, 1); myVerts[23].Color = col; renderState.setTexture(t.id(), 0, t.target); renderState.setIndexBuffer(theIBO.id); renderState.setVertexBuffer(theVBO.id, 0, 0, V3T2B4.stride); renderState.setUniform(new UniformData(0, Uniform.UniformType.Bool, true)); renderState.setUniform(new UniformData(20, Uniform.UniformType.Int, 0)); renderState.setUniform(new UniformData(23, Uniform.UniformType.Int, 0)); renderState.setUniform(new UniformData(25, Uniform.UniformType.Bool, false)); pipelineState = new PipelineState(); pipelineState.shaderState.shaderProgram = theShader; pipelineState.vaoState.vao = theVAO; pipelineState.depthTest.enabled = false; pipelineState.blending.enabled = t.hasAlpha || alpha < 1.0f; pipelineState.generateId(); }
public override PipelineState createPipeline(Material m) { PipelineState ps = new PipelineState(); ps.shaderState.shaderProgram = myShader; ps.depthTest.enabled = false; ps.depthWrite.enabled = false; ps.culling.enabled = false; ps.depthTest.depthFunc = DepthFunction.Lequal; ps.generateId(); return(ps); }
// public override void preparePerViewBegin(View v) { } // public override void preparePerView(Renderable r, View v) { } // public override void preparePerViewFinalize(View v) { } // public override void preparePerPassBegin(Pass p) { } PipelineState createPipeline() { PipelineState ps = new PipelineState(); ps.shaderState.shaderProgram = myParticleShaderProgram; ps.vaoState.vao = myVao; ps.culling.enabled = false; ps.blending.enabled = true; ps.depthTest.enabled = true; ps.depthWrite.enabled = false; ps.generateId(); return(ps); }
public DebugPass(RenderTarget rt = null) : base("Debug", "debug") { renderTarget = rt; PipelineState ps = new PipelineState(); ps.blending.enabled = true; ps.shaderState.shaderProgram = DebugRenderer.canvas.myShader; ps.vaoState.vao = DebugRenderer.canvas.myVao; ps.generateId(); myRenderQueue = Renderer.device.createRenderQueue(ps); myRenderQueue.name = "debug"; registerQueue(myRenderQueue); }
public override PipelineState createPipeline(Material m) { PipelineState state = new PipelineState(); Texture tex = m.myTextures[(int)Material.TextureId.Diffuse].value(); //disable culling if this texture has alpha values so it can be seen from both sides if (tex.hasAlpha == true || m.alpha != 1.0) { state.culling.enabled = false; state.blending.enabled = true; state.depthWrite.enabled = false; } state.shaderState.shaderProgram = myShader; state.generateId(); return(state); }
public RenderLineCommand(Vector3 start, Vector3 end, Color4 c) { UInt32 col = c.toUInt(); myVerts = new V3T2B4[2]; myVerts[0].Position = start; myVerts[0].TexCoord = new Vector2(0, 0); myVerts[0].Color = col; myVerts[1].Position = end; myVerts[1].TexCoord = new Vector2(0, 1); myVerts[1].Color = col; pipelineState = new PipelineState(); pipelineState.blending.enabled = c.A < 1.0f; pipelineState.shaderState.shaderProgram = theShader; pipelineState.vaoState.vao = theVAO; pipelineState.depthTest.enabled = false; pipelineState.generateId(); renderState.setIndexBuffer(theIBO.id); renderState.setVertexBuffer(theVBO.id, 0, 0, V3T2B4.stride); renderState.setUniform(new UniformData(0, Uniform.UniformType.Bool, true)); renderState.setUniform(new UniformData(23, Uniform.UniformType.Int, -1)); }
public RenderSphereCommand(Vector3 position, float radius, Color4 c) { UInt32 col = c.toUInt(); myVerts = new V3T2B4[theSphereVertCount]; for (int i = 0; i < theSphereVertCount; i++) { myVerts[i].Position = position + (theSphereVerts[i] * radius); myVerts[i].TexCoord = Vector2.Zero; myVerts[i].Color = col; } pipelineState = new PipelineState(); pipelineState.blending.enabled = c.A < 1.0f; pipelineState.shaderState.shaderProgram = theShader; pipelineState.vaoState.vao = theVAO; pipelineState.depthTest.enabled = false; pipelineState.generateId(); renderState.setIndexBuffer(theIBO.id); renderState.setVertexBuffer(theVBO.id, 0, 0, V3T2B4.stride); renderState.setUniform(new UniformData(0, Uniform.UniformType.Bool, true)); renderState.setUniform(new UniformData(23, Uniform.UniformType.Int, -1)); }
public PerPixelBindlessLightingEffect(ShaderProgram sp) : base(sp) { myFeatures |= Material.Feature.Lighting; myFeatures |= Material.Feature.DiffuseMap; myFeatures |= Material.Feature.SpecMap; myFeatures |= Material.Feature.NormalMap; myFeatures |= Material.Feature.ParallaxMap; //transparent drawing myTransparentPipeline.shaderState.shaderProgram = myShader; myTransparentPipeline.culling.enabled = false; myTransparentPipeline.blending.enabled = true; myTransparentPipeline.depthTest.enabled = true; myTransparentPipeline.depthWrite.enabled = true; myTransparentPipeline.generateId(); //opaque drawing myOpaquePipeline.shaderState.shaderProgram = myShader; myOpaquePipeline.culling.enabled = true; myOpaquePipeline.blending.enabled = false; myTransparentPipeline.depthTest.enabled = true; myOpaquePipeline.depthWrite.enabled = true; myOpaquePipeline.generateId(); }