home *** CD-ROM | disk | FTP | other *** search
-
- vector vLocalAmbientAndFogFactor;
- vector vAmbientLightColor;
- vector vDiffuseLightColor;
- vector vFogColor;
- vector vHelpers1;
- vector vHelpers2;
- vector vSpecularColorAndPower;
- vector vDiffuseDirection;
- vector vViewerPosition;
-
- vector vLocalSpaceLightVector;
-
- vertexshader vsDAS =
-
- decl
- {
- stream 0;
- float v0[3]; // position
- float v1[3]; // normalized normal - not used in PPLighting!!!
- D3DCOLOR v2[1]; // color 1 - not used yet
- D3DCOLOR v3[1]; // color 2 - not used yet
- float v4[2]; // uv coordinates
- float v5[3]; // S-tangent
- }
-
- asm
- {
- vs.1.1
-
- m4x4 oPos, v0, c[0] // transform vertex clip space
-
- // * - diffuse bump computations - *
-
- // cross product normal with tangent to get binormal
- mov r2, v5
- mul r0, v1.yzxw, r2.zxyw
- mad r0,-r2.yzxw, v1.zxyw, r0
-
- // transform light by basis vectors
- dp3 r1.x, v5.xyz, c[92]
- dp3 r1.y, r0.xyz, c[92]
- dp3 r1.z, v1.xyz, c[92]
-
- // normalize light vector in tangent space
- dp3 r1.w, r1, r1
- rsq r1.w, r1.w
- mul r1, r1, r1.w
- // emit light vector
- add r1, r1, c[91].y
- mul r1,r1,c[91].w
- mov oD0, r1
-
-
- // * - specular bump computations - *
-
- add r2, c[90],-v0 // wector pointing from vertex to viewer
-
- dp3 r2.w, r2, r2 // normalize pointing
- rsq r2.w, r2.w // wector.
- mul r2, r2, r2.w
-
- add r3, r2, c[92] // now, H = Light + pointingVector
-
- // transform H-vector by basis vectors
-
- dp3 r1.x, v5.xyz, r3
- dp3 r1.y, r0.xyz, r3
- dp3 r1.z, v1.xyz, r3
-
- dp3 r1.w, r1, r1 // we must
- rsq r1.w, r1.w // also normalize
- mul r1, r1, r1.w // H vector
-
- // emit H vector
- add r1, r1, c[91].y
- mul r1,r1,c[91].w
- mov oD1, r1
-
- // * - emit coordinates for textures - *
-
- mov oT0, v4 // emit uv mapping
- mov oT1, v4 // emit coordinates for bump map
- };
-
- pixelshader psDAFS64Mpass0 =
- asm
- {
- ps.1.1
-
- tex t0 // normal map
-
- // specular component
- dp3_sat t0,t0_bx2,v1_bx2; // t0=Dot(normal,interp_H)
- mul t0,t0,t0 // power2
- mul t0,t0,t0 // power4
- mul t0,t0,t0 // power8
- mul t0,t0,t0 // power16
- mul t0,t0,t0 // power32
- mul t0,t0,c3 // modulate brightness
- mul r0,c4.a,t0
- };
-
- pixelshader psDAFS64Mpass1 =
- asm
- {
- ps.1.1
-
- tex t0 // normal map
- tex t1 // base texture
-
- // diffuse component
- dp3_sat r1,t0_bx2,v0_bx2 // r1=Dot(normal,interp_light)
-
- mad r1,r1,c2,c1 // r1 = r1*diffColor+averagedAmbient
- add r1.rgb,r1,c4
- mul r0,r1,t1 // modulate with base texture
- mov r1,c4
- lrp r0,r1.a,r0,c0
-
- };
-
-
-
-
- technique tDAFS64M
- {
- pass p0
- {
- AlphaBlendEnable = False;
- FogEnable = False;
- CullMode = CW;
- PixelShaderConstant[0] = <vFogColor>;
- PixelShaderConstant[1] = <vAmbientLightColor>;
- PixelShaderConstant[2] = <vDiffuseLightColor>;
- PixelShaderConstant[3] = <vSpecularColorAndPower>;
- PixelShaderConstant[4] = <vLocalAmbientAndFogFactor>;
-
- VertexShaderConstant[92] = <vDiffuseDirection>;
- VertexShaderConstant[91] = { 0.0 , 1.0 , 0.0039 , 0.5 };
- VertexShaderConstant[90] = <vViewerPosition>;
-
-
- VertexShader = <vsDAS>;
- PixelShader = <psDAFS64Mpass0>;
- }
-
- pass p1
- {
-
- AlphaBlendEnable = TRUE;
- FogEnable = False;
- SrcBlend = One;
- DestBlend = One;
- CullMode = CW;
-
- PixelShaderConstant[0] = <vFogColor>;
- PixelShaderConstant[1] = <vAmbientLightColor>;
- PixelShaderConstant[2] = <vDiffuseLightColor>;
- PixelShaderConstant[3] = <vSpecularColorAndPower>;
- PixelShaderConstant[4] = <vLocalAmbientAndFogFactor>;
-
- VertexShaderConstant[92] = <vDiffuseDirection>;
- VertexShaderConstant[91] = { 0.0 , 1.0 , 0.0039 , 0.5 };
- VertexShaderConstant[90] = <vViewerPosition>;
-
- VertexShader = <vsDAS>;
- PixelShader = <psDAFS64Mpass1>;
- }
- }
-
- technique test
- {
- pass p0
- {
- AlphaBlendEnable = False;
- FogEnable = False;
- CullMode = CW;
- PixelShaderConstant[0] = <vFogColor>;
- PixelShaderConstant[1] = <vAmbientLightColor>;
- PixelShaderConstant[2] = <vDiffuseLightColor>;
- PixelShaderConstant[3] = <vSpecularColorAndPower>;
- PixelShaderConstant[4] = <vLocalAmbientAndFogFactor>;
-
- VertexShaderConstant[92] = <vDiffuseDirection>;
- VertexShaderConstant[91] = { 0.0 , 1.0 , 0.0039 , 0.0 };
- VertexShaderConstant[90] = <vViewerPosition>;
-
-
- VertexShader = <vsDAS>;
- PixelShader = <psDAFS64Mpass0>;
- }
- }
-
- technique tHierSpecPP_5th
- {
- pass p0
- {
- AlphaBlendEnable = False;
- FogEnable = False;
- CullMode = CW;
-
- VertexShaderConstant[92] = <vLocalSpaceLightVector>;
- VertexShaderConstant[91] = { 0.0 , 1.0 , 0.0039 , 0.0 };
-
- VertexShader = <vsDAS>;
-
- }
- }
-
-
-
-
-
-
-