color as xyz in tex3D call (cg shader)

Hi All,

was wondering if anyone here could help me figure out why my tex3D call in my CG shader won’t work.

I am trying to do a 3D lut shader as in,
http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter24.html

but for some reason I cant seem to be able to pass my colour as xyz coordinates.

I am trying to do it like this,
(this returns black)

float3 colorXYZ = tex2D( testTexture, sUV).rgb;
output.pixel = tex3D( lut, colorXYZ ).rgb;

But strangely both the below examples work and look as I would expect:

float3 colorXYZ = tex2D( testTexture, sUV).rgb;
output.pixel = colorXYZ;

and

float3 testUV = float3(UV[0], 0.0, UV[1]);
output.pixel = tex3D( lut, testUV ).rgb;

Can anyone tell what I am doing wrong?

cheers
fred

Maybe you forget to generate 3D mipmaps ? Try to set the magnification and minification sampling to GL_LINEAR.

better check for the color interval :
float3 colorXYZ = tex2D( testTexture, sUV).rgb;
if (colorXYZ.r <0.0) {
output.pixel = ‘blue’;
} else if (colorXYZ.r <=1.0) {
output.pixel = ‘red’;
} else {
output.pixel = ‘green’;
}
the output should be green. do it for all the color components.

Hi and thanks for the reply! :slight_smile:

I don’t think I want mip-maps as I am happy with only GL_LINEAR interpolation. I have tried with both GL_LINEAR and GL_NEAREST and still get black so I think my problem lies elsewhere.

I just tried with your colour interval test.
I get the Red output, which should mean that the value lies between 0.0 and 1.0, correct? Which should be good in this case?

I find it strange that my both other above tests work but not in the combination I need it to. :slight_smile:

cheers
fred

Sorry about this bump but,

I think I can clarify my question.

What makes this float3,

float3 colorXYZ = tex2D( testTexture, sUV).rgb;

different from this float3,

float3 testUV = float3(UV[0], 0.0, UV[1]);

that I cant use ‘colorXYZ’ as coordinates in a tex3D() call, even when the rgb values of ‘colorXYZ’ are proven to be in the 0.0-1.0 range?

The shader compiles but renders black.

cheers
fred