struct MVP { float4x4 projection; float4x4 view; float4x4 model; } struct Uniforms { MVP mvp; float4 u_Color; bool u_HasTexture; Sampler2D u_Texture; }; struct AssembledVertex { float3 position : POSITION; float2 texcoord : TEXCOORD; }; struct Fragment { float4 color; }; struct VertexStageOutput { float2 uv : UV; float4 sv_position : SV_Position; }; float4 someFunction(float4 color) { return color * float4(0.5, 0.5, 0.5, 1.0); } [shader("vertex")] VertexStageOutput vertexMain( uniform ParameterBlock uniforms, AssembledVertex assembledVertex ) { VertexStageOutput output; float3 position = assembledVertex.position; output.uv = assembledVertex.texcoord; output.sv_position = mul( float4(position, 1.0), mul(uniforms.mvp.model, mul(uniforms.mvp.view, uniforms.mvp.projection)) ); return output; } [shader("fragment")] Fragment fragmentMain( uniform ParameterBlock uniforms, float2 uv: UV ) : SV_Target { Fragment output; if(uniforms.u_HasTexture) { output.color = uniforms.u_Texture.Sample(uv) * uniforms.u_Color; } else { output.color = someFunction(uniforms.u_Color); } return output; }