home *** CD-ROM | disk | FTP | other *** search
-
- vector vLocalAmbientAndFogFactor;
- vector vAmbientLightColor;
- vector vDiffuseLightColor;
- vector vFogColor;
- vector vHelpers1;
- vector vHelpers2;
- vector vSpecularColorAndPower;
- vector vDiffuseDirection;
-
- 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] // form vertex format
- //dp3 r1.y, r0.xyz, c[92] // calculated
- //dp3 r1.z, v1.xyz, c[92] // SxT ~ N
- dp3 r1.x, v5, c[92] // form vertex format
- dp3 r1.y, r0, c[92] // calculated
- dp3 r1.z, v1, c[92] // SxT ~ N
-
- // normalize light vector in tangent space
- dp3 r1.w, r1, r1 // seams
- rsq r1.w, r1.w // it isn't
- mul r1, r1, r1.w // necessary
-
- // emit light vector
- add r1, r1, c[91].y
- mul r1,r1,c[91].w
- mov oD0, r1
-
- // emit coordinates for textures
- mov oT0, v4 // emit uv mapping
- mov oT1, v4 // emit coordinates for bump map
- };
-
-
- pixelshader psDAF =
- 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)
-
- mul r1,r1,c2
- add r1,r1,c1
- add r1,r1,c3
- mul r0,r1,t1 // modulate with base texture
-
- mov r1,c3
- lrp r0,r1.a,r0,c0 //fake fog
- };
-
-
-
- technique tGF3_DiffusePerPixel
- {
- pass p0
- {
- PixelShaderConstant[0] = <vFogColor>;
- PixelShaderConstant[1] = <vAmbientLightColor>;
- PixelShaderConstant[2] = <vDiffuseLightColor>;
- PixelShaderConstant[3] = <vLocalAmbientAndFogFactor>;
-
- VertexShaderConstant[92] = <vDiffuseDirection>;
- VertexShaderConstant[91] = { 0.0 , 1.0 , 0.0 , 0.5 };
-
- FogEnable = False;
- CullMode = cw;
-
- VertexShader = <vsDAS>;
- PixelShader = <psDAF>;
- }
- }
-
-
- vertexshader vsTest =
-
- 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] // form vertex format
- dp3 r1.y, r0.xyz, c[92] // calculated
- dp3 r1.z, v1.xyz, c[92] // SxT ~ N
-
- // normalize light vector in tangent space
- dp3 r1.w, r1, r1 // seams
- rsq r1.w, r1.w // it isnt
- mul r1, r1, r1.w // necessary
-
- // emit light vector
- //mad r1.xyz, r1.xyz, c[91].w,c[91].w
- add r1, r1, c[91].y
- mul r1,r1,c[91].w
- mov oD0, r1
-
- // emit coordinates for textures
- mov oT0, v4 // emit uv mapping
- mov oT1, v4 // emit coordinates for bump map
- };
-
-
- pixelshader psTest =
- 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)
- mov r0,r1
-
- //mul_x2 r1,r1,c2
- //add r1,r1,c1
- //add r1,r1,c3
- //mul r0,r1,t1 // modulate with base texture
- //
- //lrp r0,c3.a,r0,c0 //fake fog
-
- };
-
- // test
- technique tGF3_Test
- {
- pass p0
- {
- PixelShaderConstant[0] = <vFogColor>;
- PixelShaderConstant[1] = <vAmbientLightColor>;
- PixelShaderConstant[2] = <vDiffuseLightColor>;
- PixelShaderConstant[3] = <vLocalAmbientAndFogFactor>;
-
- VertexShaderConstant[92] = <vLocalSpaceLightVector>;
- VertexShaderConstant[91] = { 0.0 , 1.0 , 0.0039 , 0.5 };
-
- FogEnable = False;
-
- VertexShader = <vsTest>;
- PixelShader = <psTest>;
- }
- }
-
- technique t5th_hierdiffPP
- {
- pass p0
- {
-
-
- VertexShaderConstant[92] = <vLocalSpaceLightVector>;
- VertexShaderConstant[91] = { 0.0 , 1.0 , 0.0039 , 0.5 };
-
- FogEnable = False;
-
- VertexShader = <vsTest>;
- }
- }
-