Hello Square: Colors
This example shows how to use parameters to the color output of a shader.
Change color:
// World View Projection matrix that will transform the input vertices // to screen space. float4x4 worldViewProjection : WorldViewProjection; // This specifies the color of the triangles. A Param with the same name will // be created on the material using the shader. float4 color; // input parameters for our vertex shader struct VertexShaderInput { float4 position : POSITION; }; // input parameters for our pixel shader struct PixelShaderInput { float4 position : POSITION; }; /** * The vertex shader simply transforms the input vertices to screen space. */ PixelShaderInput vertexShaderFunction(VertexShaderInput input) { PixelShaderInput output; // Multiply the vertex positions by the worldViewProjection matrix to // transform them to screen space. output.position = mul(input.position, worldViewProjection); return output; } /** * Our pixel shader returns the value of color parameter. */ float4 pixelShaderFunction(PixelShaderInput input): COLOR { return color; } // Here we tell our effect file *which* functions are // our vertex and pixel shaders. // #o3d VertexShaderEntryPoint vertexShaderFunction // #o3d PixelShaderEntryPoint pixelShaderFunction // #o3d MatrixLoadOrder RowMajor