Hi,
I have generated a terrain, some of whose vertices z coord is != 0. I wish to make the color dark only at those points. I use vs, ps 3.0 to do this.
So my code is something like this :
sampler MySampler
{
Texture = (tex0);
magfilter = LINEAR;
minfilter = LINEAR;
mipfilter = LINEAR;
};
struct VS_OUTPUT
{
float4 Position : POSITION;
float2 Tex : TEXCOORD0;
float4 Diffuse : COLOR0;
};
//Vertex shader
VS_OUTPUT VS (float3 Pos : POSITION,float3 norm : NORMAL,float2 Tex : TEXCOORD0)
{
VS_OUTPUT Output = (VS_OUTPUT)0;
float4 diff = tex2Dlod (MySampler, float4(Tex.x,Tex.y,0,0));
if (Pos.z != 0.0f)
{
diff = diff * 0.5f;
}
Output.Diffuse = diff;
Output.Position = mul( float4(Pos,1),worldViewProj);
Output.Tex = Tex;
return Output;
}
[/Source]
My pixel shader code is :
[Source]
void PS (VS_OUTPUT IN, out float4 oColor:COLOR0)
{
oColor = IN.Diffuse;
}
[/Source]
EACH time I use tex2Dlod, everything disappears. It does not show any error. I have not modified the vertices anywhere in the vertex shader. Please tell me what's wrong. Or can u think of a different approach which doesn't use tex2Dlod?
Thanks,
Saranya