whys the fog-calculation not working in the following pixelshader part of my normal mapping shader?
i already tried playing with the vertexshaderconstant[12] but nothinh got it to work
bold out the fog-part for you, please help!
Code:
VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]=<matWorld>;
vertexShaderConstant[9]= <vecFog>;
vertexShaderConstant[10]=<vecSunDir>;
vertexShaderConstant[11]=<vecLight>;
VertexShaderConstant[12]={0.5f, 0.5f, 10.0f, 10.0f};
VertexShader =
asm
{
vs_1_1 // Declarations
dcl_position v0
dcl_normal v3
dcl_texcoord0 v7
dcl_texcoord1 v8
m4x4 oPos, v0, c0 // Transform position to clip space
m3x3 r3, v8, c4 // Tranform normal and tangent to world space
m3x3 r5, v3, c4
mul r0, r3.zxy, r5.yzx // Compute binormal
mad r4, r3.yzx, r5.zxy, -r0
dp3 r0.x, r3.xyz, -c10 // Transform (Sun)light vector to tangent space
dp3 r0.y, r4.xyz, -c10
dp3 r0.z, r5.xyz, -c10
dp3 r0.w, r0, r0 // Normalize transformed light vector
rsq r0.w, r0.w
mul r0, r0, r0.w
mad r0, r0, c12.x, c12.x // Put light vector in range from 0 to 1
mul r0, r0, c12.y // Adjust the intensity
add oD0.xyz,r0,c11 // Add environment light then send it down the diffuse pipe
// Fog calculations
mov r1.w,c9.w
dp4 r0,v0,c6 // distance to camera position
add r0,r0,-c9.x // distance-fog_start
//float3 PositionWorld = mul(inPos, matWorld);
//float ofog = 1 - (distance(PositionWorld, vecViewPos) - vecFog.x) * (vecFog.z*1.5);
//Out.Fog = ofog;
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
};
Code:
//float3 PositionWorld = mul(inPos, matWorld);
//float ofog = 1 - (distance(PositionWorld, vecViewPos) - vecFog.x) * (vecFog.z*1.5);
//Out.Fog = ofog;
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
thanks in advance