i want to keep an negative value in the texture,but can not access that negative value in the Vertex Shader. But i found the negative value i kept turn out to be 0 in Vertex Shader. Why?
And how can i keep negative value in texture?
My texture definition is:
GLfloat edge[4][4]=
{
-1.0,0,1,0,
0,1,0,0,
0,0,1,0,
1,0,1,0,
};
glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,4,4,0,GL_LUMINANCE,GL_FLOAT,edge);
Cg code:
uniform float4x4 WorldViewProj : state.matrix.mvp;
;
void main_v(float4 pos:POSITION,
out float4 opos:POSITION,
out float4 color:COLOR,
uniform sampler2D tex
)
{
opos=mul(WorldViewProj,pos);
float a;
a=tex2D(tex,float2(0.5,0.0)).r;
if(a==0)
color=float4(1,0,0,1);
else
color=float4(0,1,0,1);
}