Culling and ZSort Test
Objects off screen should get culled and nothing in the front should zbuffer out stuff in the back.
Total Transforms:
-
Transforms Processed:
-
Transforms Culled:
-
Total DrawElements:
-
DrawElements Processed:
-
DrawElements Culled:
-
DrawElements Rendered:
-
Primitives Rendered:
-
// The 4x4 world view projection matrix. float4x4 worldViewProjection : WorldViewProjection; float4x4 worldInverseTranspose : WorldInverseTranspose; float4x4 world : World; // positions of the light and camera float3 light_pos; float3 camera_pos; // lighting components of the light source float4 light_ambient; float4 light_diffuse; float4 light_specular; // shininess of the material. (for specular lighting) float shininess; float4 colorMult; // input parameters for our vertex shader struct a2v { float4 pos : POSITION; float3 normal : NORMAL; float4 col : COLOR; }; // input parameters for our pixel shader // also the output parameters for our vertex shader struct v2f { float4 pos : POSITION; float4 pos2 : TEXCOORD0; float3 norm : TEXCOORD1; float3 light : TEXCOORD2; float4 col : COLOR; }; /** * vsMain - our vertex shader * * @param IN.pos Position vector of vertex * @param IN.normal Normal of vertex * @param IN.col Color of vertex */ v2f vsMain(a2v IN) { /** * We use the standard phong illumination equation here. * We restrict (clamp) the dot products so that we * don't get any negative values. * All vectors are normalized for proper calculations. * * The output color is the summation of the * ambient, diffuse, and specular contributions. * * Note that we have to transform each vertex and normal * by the view projection matrix first. */ v2f OUT; OUT.pos = mul(IN.pos, worldViewProjection); OUT.pos2 = OUT.pos; OUT.norm = mul(float4(IN.normal, 0), worldInverseTranspose).xyz; OUT.light = light_pos - mul(IN.pos, world).xyz; OUT.col = IN.col; return OUT; } /** * psMain - pixel shader * * @param IN.pos Position vector of vertex * @param IN.col Color of vertex */ float4 psMain(v2f IN): COLOR { float3 light = normalize(IN.light); float3 normal = normalize(IN.norm); float3 litR = normalize(2 * dot(light, normal) * normal - light); float3 v = normalize(mul(float4(camera_pos, 1), worldViewProjection).xyz - IN.pos2.xyz); // use lit function to calculate phong shading float4 phong_coeff = lit(dot(normal, light), dot(litR, v), shininess); float4 ambient = light_ambient * phong_coeff.x * IN.col; float4 diffuse = light_diffuse * phong_coeff.y * IN.col; float4 specular = light_specular * phong_coeff.z * IN.col; return float4(((ambient + diffuse) * colorMult + specular).xyz, 0.5); } // Here we tell our effect file *which* functions are // our vertex and pixel shaders. // #o3d VertexShaderEntryPoint vsMain // #o3d PixelShaderEntryPoint psMain // #o3d MatrixLoadOrder RowMajor