home *** CD-ROM | disk | FTP | other *** search
-
- vector lhtR; // kierunek swiatla, dla zgodnosci (tu nie uzywam)
- vector lPos; // pozycja swiatla (we wspolrzednych mesha!)
- vector vCPS; // pozycja kamery (w swiecie)
- vector lCol; // kolor swiatla odbicia (dla dot3s)
-
- matrix mWld; // World
- matrix mTot; // Total
-
- texture tDif; // Tekstura glowna
- texture tDf3; // Normal map
-
- vector lAmb; // kolor ambientu
-
- vector sDir; // sky dir
- vector sCol; // sky col
-
-
-
- technique tec0
- {
- pass p0
- {
- ZBias=0;
- CullMode=ccw;
-
- Texture[0] = <tDif>;
-
- ColorOp[0] = Modulate;
-
- ColorArg1[0] = Diffuse;
- ColorArg2[0] = Texture;
-
- AlphaOp[0]=Disable;
-
- ColorOp[1]=Disable;
- AlphaOp[1]=Disable;
-
- PixelShader = NULL;
- VertexShader = XYZ | Normal | Tex3;
- }
-
-
- pass p1
- {
- AlphaBlendEnable = true;
- SrcBlend = One;
- DestBlend = One;
- BlendOp=Add;
- ZBias=1;
-
-
- VertexShaderConstant[0] = <mWld>; // World Matrix
- VertexShaderConstant[4] = <mTot>; // World*View*Proj Matrix
- VertexShaderConstant[9] = (1.0f, 1.0f, 1.0f, 1.0f); // diffuse
- VertexShaderConstant[10] = (1.0f, 1.0f, 1.0f, 1.0f); // specular
- VertexShaderConstant[11] = (0.0f, 0.0f, 0.0f, 0.0f); // zero
- VertexShaderConstant[12] = (1.0f, 1.0f, 1.0f, 1.0f); // jeden
- VertexShaderConstant[16] = <sDir>; // Light direction
- vertexShaderConstant[15] = (740.0f, 740.0f, 740.0f, 740.0f);
- VertexShaderConstant[17] = <sCol>; // light color
- VertexShaderConstant[18] = <lAmb>;
- vertexShaderConstant[19] = (1024.0f, 1024.0f, 1024.0f, 1024.0f);
- vertexShaderConstant[20] = (.5f,.5f,.5f,.5f);
- VertexShaderConstant[21] = <lhtR>; // sky dir
- VertexShaderConstant[22] = <lCol>; // sky col
- // VertexShaderConstant[23] = <lPos>; // light position
- VertexShaderConstant[24] = <vCPS>; // camera position
-
- Texture[0] = <tDif>;
- Texture[1] = <tDf3>;
-
- VertexShader =
- decl
- {
- stream 0;
- float v0[3]; //Position
- float v3[3]; //Normal
- float v7[2]; //Texture Coord1
- float v8[2]; //Tangent
- float v9[2]; //Tangent
- }
- asm
- {
- vs.1.1
- m4x4 oPos, v0, c4
- m4x4 r0,v0,c0
-
- // chce odleglosc od kamery
- add r5, -r0, c24
- dp3 r10.x, r5.xyz, r5.xyz // kwadrat odleglosci
-
- // odwrotnosc
- rsq r10.x, r10.x
- mul r10.x, r10.x, c15.x
-
-
- // puszczam dalej
- add r0,-r0,c24
-
- dp3 r11.x,r0.xyz,r0.xyz
- rsq r11.xyz,r11.x
- mul r0.xyz,r0.xyz,r11.xyz
-
- add r2.xyz,r0.xyz,-c16
-
- // Normalize
- dp3 r11.x,r2.xyz,r2.xyz
- rsq r11.xyz,r11.x
- mul r2.xyz,r2.xyz,r11.xyz
-
- m3x3 r1,v3,c0
-
- dp3 r3.xyzw,r1,r2
-
- mul r3,r3,r3 // 2nd
- mul r3,r3,r3 // 4th
- mul r3,r3,r3 // 8th
- mul r3,r3,r3 // 16th
-
- dp3 r4,r1,-c16
-
-
- mul r4,r4,c10 // Specular
- mad r4,r3,c20,r4 // Diffuse
-
-
- mov oD0, r4
-
- mov oD1, r10.x
-
-
- //
- // wspolrzedne tekstur
- //
- mov oT0.xy,v7.xy
- mov oT1.xy,v7.xy
- };
-
- PixelShader =
- asm
- {
- ps.1.1
- tex t0 // tekstura podstawowa
- tex t1 // normal map
-
- dp3 r0,t1_bx2,v0_bx2; // bump ze specularem
-
- mul r0, r0, t0.a // i na maske! (tekstura z diffuse w 1 pasie)
- mul r0, r0, v1
-
- };
- }
- }
-
-
- technique tec1
- {
- pass p0
- {
- ZBias=0;
-
- Texture[0] = <tDif>;
-
- ColorOp[0] = Modulate;
-
- ColorArg1[0] = Diffuse;
- ColorArg2[0] = Texture;
-
- AlphaOp[0]=Disable;
-
- ColorOp[1]=Disable;
- AlphaOp[1]=Disable;
-
- PixelShader = NULL;
- VertexShader = XYZ | Normal | Tex3;
- }
-
- }
-
-