Posted By: rayp
How to assign materials to level geometry in A6 - 09/24/08 19:45
Again a shader-noob-question:
How can i add a material to my level geometry (a6) ?
Give the material a level-texture-name ?
I want to add this dot3 shader to my level blocks:
How can i add a material to my level geometry (a6) ?
Give the material a level-texture-name ?
I want to add this dot3 shader to my level blocks:
Code:
material mat_bumpmap{ flags=tangent; effect=" matrix matWorldViewProj; matrix matWorld; texture entSkin1; //Colormap texture entSkin2; //Normalmap vector vecLight; vector vecFog; vector vecSunDir; technique dot3mapping { pass p0 { AlphaBlendEnable = False; AlphaTestEnable = False; Lighting = True; DitherEnable = True; Texture[0] = <entSkin2>; Texture[1] = <entSkin1>; ColorOp[0] = Dotproduct3; ColorArg1[0] = Texture; ColorArg2[0] = Diffuse; ColorOp[1] = Modulate; ColorArg1[1] = Texture; ColorArg2[1] = Current; VertexShaderConstant[0]=<matWorldViewProj>; VertexShaderConstant[4]=<matWorld>; vertexShaderConstant[9]= <vecFog>; vertexShaderConstant[10]=<vecSunDir>; vertexShaderConstant[11]=<vecLight>; VertexShaderConstant[12]={0.5f, 0.5f, 0.0f, 0.0f}; VertexShader = asm { vs_1_1 // Declarations dcl_position v0 dcl_normal v3 dcl_texcoord0 v7 dcl_texcoord1 v8 // Transform position to clip space m4x4 oPos, v0, c0 // Tranform normal and tangent to world space m3x3 r3, v8, c4 m3x3 r5, v3, c4 // Compute binormal mul r0, r3.zxy, r5.yzx mad r4, r3.yzx, r5.zxy, -r0 // Transform (Sun)light vector to tangent space dp3 r0.x, r3.xyz, -c10 dp3 r0.y, r4.xyz, -c10 dp3 r0.z, r5.xyz, -c10 // Normalize transformed light vector dp3 r0.w, r0, r0 rsq r0.w, r0.w mul r0, r0, r0.w // Put light vector in range from 0 to 1 mad r0, r0, c12.x, c12.x // Adjust the intensity mul r0, r0, c12.y // Add environment light then send it down the diffuse pipe add oD0.xyz,r0,c11 // Fog calculations mov r1.w,c9.w dp4 r0,v0,c6 // distance to camera position add r0,r0,-c9.x // distance-fog_start mad r0.x,-r0.x,c9.z,r1.w // 1-(distance-fog_start)*(1/(fog_end-fog_start)) max oFog,r0.x,c12.w // clamp with custom max value // Pass the texture coordinates through mov oT0, v7 mov oT1, v7 }; } } "; }