RacorX13The improvement of RacorX13 over RacorX12 is the use of a ps.1.4 pixel shader. With this pixel shader version you can reduce the number of passes to one. This example uses a vertex shader that combines all the functionality used in the two vertex shaders in RacorX12 and a pixel shader that combines all the functionality used in the two pixel shaders in RacorX12. ; t0 - coordinates color map ; t1 - light vector ; t2 - half vector ; t3 - unused ; t4 - coordinates 2D attenuation map ; t5 - coordinates 1D attenuation map ps.1.4 texld r1, t1 ; cube map texld r0, t0 ; normal map texcrd r3.rgb, t2 ; half angle vector dp3 r1.rgb, r1_bx2, r0_bx2 ; diffuse dp3 r4.rgb, r3, r0_bx2 ; specular phase texld r2, t0 ; color map texld r3, r4 ; samples specular value from specular map texld r4, t4 ; attenuation 2D map texld r5, t5 ; attenuation 1D map add r5, 1-r4, -r5.a ; (1.0 - 2Dvalue) - dest mul r1.a, r2.a, r3.a ; (N dot H)^16 * gloss value +mul r1.rgb, r1, r2 ; diffuse * color add r0, r1.a, r1 ; ((N dot H)^16 * gloss value) + (diffuse * color) mul r0, r0, r5 ; attenuation This shader eats up all six texture stages provided by the ps.1.4 shader specification:
Because of the independance of the texture coordinate data from the texture data in ps.1.4, this pixel shader only uses five texture coordinate registers in the vertex shader. So the texture coordinate register oT3 and the color registers v0 and v1 are still available. |