# Strange behaviour of shader

This topic is 4580 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

sorry, but i can't specify my problem in the title.. it is simple: in my game world, there is a sun, it's no normal quad or something like that. i just calculate the coordinates for the sun in ProcessMovement() and then it's position is then given to the shader for the SkyDome. this is the shader code:
VS_OUTPUT VS_SkyDome(float4 Pos : POSITION, float2 Tex0 : TEXCOORD0, float3 Normal : NORMAL )
{
VS_OUTPUT Out = (VS_OUTPUT) 0;

Out.Pos = mul(Pos, matWorldViewProjection);
Out.Tex0 = Tex0;

Out.Norm = saturate(dot(normalize(tempVec), normalize(mul(Normal, matRotation))));
Out.Hemi = saturate(dot(normalize(lightDir), normalize(mul(Normal, matRotation))));

return Out;
}

float4 PS_SkyDome(float4 Norm : COLOR0, float4 Hemi : COLOR1) : COLOR
{
tempDiffuse = (Norm+0.5f)/1.5f * SkyDome_Ambient + (0.5f - Norm/2) * SkyDome_Aequator;
SunIntensity_SunShine;
tempDiffuse += pow(Hemi, 48) * SunIntensity_SunShine;
tempDiffuse.a = SkyDomeAlpha;
return tempDiffuse;
}

what the shader does is: calc the influence of the sun direction ( lightDir ) on each vertex of the dome. then the result gets raised by the power of 48, so that it won't illuminate the whole sky: just a part of it. the strange thing is, that i can only see my sun, when i first look down ( perhaps 80° from the horizon ) and then look up again. [the norm value is not the problem i think, this is just the influence of the vertex on the color of the corresponding frament. that means that the sky towards the horizon has the color 'SkyDome_Aequator' and the sky towards zenit ( dunno if this is the right word for up ^^ ) 'SkyDome_Ambient'] here are screens ( before | lookdown | after ): its really strange and i can't figure out why this happens. i hope it's an error in my code ( some wrong calced value ) than something more worse ( memory leak, writing into memory, that wasn't allocated etc... ) something else to mention is, that the calculation of the sunposition must be correct, because the terrain diffuse lighting also needs lightDir ( it uses the same value than the sky dome ) and this doesn't change when i move the camera around ( or down and up like in the screens ) the funny thing is, that the shader doesn't get and doesn't need anything of the camera, the mouse or the angle of the camera, yet it affects the shader in some way *confused* please post if you need more information on the code / problem [Edited by - SiS-Shadowman on May 28, 2006 2:30:53 PM]

##### Share on other sites
One obvious candidate seems to be that you don't set matRotation initially.

If you can't find the bug, try running with the shader debugger and seeing what values you get wrong.

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633679
• Total Posts
3013294
×