// World View Projection matrix that will transform the input vertices // to screen space. float4x4 worldViewProjection : WorldViewProjection; float4x4 world : WORLD; float4x4 worldInverseTranspose : WORLDINVERSETRANSPOSE; float4 ambientColor; float4 diffuseColor; float4 emissiveColor; float4 specularColor; float shininess; float3 lightWorldPosition; float4 lightColor; float4 lightIntensity; // input parameters for our vertex shader struct VertexShaderInput { float4 position : POSITION; float4 normal : NORMAL; }; // input parameters for our pixel shader struct PixelShaderInput { float4 position : POSITION; float3 worldPosition : TEXCOORD4; float3 normal : TEXCOORD1; }; /** * 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); float3 worldPosition = mul(input.position, world).xyz; output.worldPosition = worldPosition; output.normal = mul(input.normal, worldInverseTranspose).xyz; return output; } /** * This pixel shader just returns the color red. */ float4 pixelShaderFunction(PixelShaderInput input): COLOR { float3 surfaceToLight = normalize(lightWorldPosition - input.worldPosition); //L float3 worldNormal = normalize(input.normal); //N //float3 surfaceToView = normalize(viewInverse[3].xyz - input.worldPosition); //float3 halfVector = normalize(surfaceToLight + surfaceToView); //float4 litResult = lit(dot(worldNormal, surfaceToLight), // dot(worldNormal, halfVector), shininess); float4 outColor = ambientColor; outColor += diffuseColor * lightColor * max(dot(worldNormal, surfaceToLight), 0); return float4(outColor.rgb, diffuseColor.a); } // Here we tell our effect file *which* functions are // our vertex and pixel shaders. // #o3d VertexShaderEntryPoint vertexShaderFunction // #o3d PixelShaderEntryPoint pixelShaderFunction // #o3d MatrixLoadOrder RowMajor