pos.z = tex2D(heightmapTexture, texUV).r;
But this doesn't compile and I get the following error.
error C1115: unable to find compatible overloaded function "Sample(sampler2D, float2)"
pos.z = tex2D(heightmapTexture, texUV).r;
But this doesn't compile and I get the following error.
error C1115: unable to find compatible overloaded function "Sample(sampler2D, float2)"
I don't really know Cg, but if tex2D is equivalent to what it was in older HLSL then you can't use it anything except for a pixel shader. This is because it uses screen-space gradients to automatically select the mip level, and gradients can only be computed in a pixel shader. Try using tex2Dlod, or whatever the Cg equivalent is for a function that lets you manually specify the mip level.
This is because it uses screen-space gradients to automatically select the mip level, and gradients can only be computed in a pixel shader. Try using tex2Dlod
Interesting. I knew you couldn't use tex2D in all the stages but didn't know the reason why. I believe I already tried tex2Dlod, but I'll give it another shot.
Thanks for replying.
Hmm.. at first I thought that using tex2Dlod worked, but now I get this compile error instead.
error C1115: unable to find compatible overloaded function "SampleLevel(sampler2D, float2, float)"
It seems that for tex2Dlod, you'd have to use float4 for 'texUV' //=================================================================== sampler2D samp; float4 tex2Dlod(sampler2D samp, float4 s)// s.w selects the mipmap level //=================================================================== http://http.developer.nvidia.com/Cg/tex2Dlod.html //=================================================================== And it says at the bottom that your GPU must support the vp40 profile. If you have a decent video card this should not be a problem. I suspect a lot of laptops might not support this.