Jump to content
  • Advertisement
Sign in to follow this  
Myke111

OpenGL Dependent Texture lookup / Texture Indirections

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys, i know it doens't fit into the OpenGL section perfectly, but it doens't fit to the other topics as well so i'll post it here. I'm having troubles to use dependent texture lookup with OpenGL and Cg. I have the following fragmentprogram:
struct fInput {
  float3 texCoord	: TEXCOORD0; // this parameter is tested and ok
  float4 direction: TEXCOORD1; // this parameter is tested and ok
};

struct fOutput {
  float4 color : COLOR;
};

fOutput fProgram (fInput IN,
                  uniform sampler3D texture,
                  uniform sampler1D lookup,
                  uniform float stepsize) {
  fOutput OUT;
  float scalar = tex3D(texture, IN.texCoord.rgb);
  OUT.color = tex1D(lookup, scalar);
  return OUT;
}

with texture being a 3D texture of format GL_ILLUMINANCE and type GL_UNSIGNED_BYTE and lookup being a 1D texture of format GL_RGBA and type GL_UNSIGNED_BYTE. The problem now is that the output is a black window only. I tested the 3D texture with
fOutput OUT;
float scalar = tex3D(texture, IN.texCoord.rgb);
OUT.color = float4(scalar, 0.0f, 0.0f, 1.0f);
return OUT;

and the 1D texture with
fOutput OUT;
float scalar = tex3D(texture, IN.texCoord.rgb);
OUT.color = tex1D(lookup, IN.texCoord.r);
return OUT;

and both works as expected. But as soon as i use the output of tex3D directly or indirectly as input to tex1D the window is black. The Profile i'm using is CG_PROFILE_VP40 and CG_PROFILE_FP40 on a Geforce 7300 Go and the same Profile on a Quadro FX 3500. Both support at least ShaderModel 3.0, so texture indirections should be unlimited, afaik. I've seen this kind of code in several books/papers, so it should be possible somehow. I posted this problem already to NVIDIA's Cg Forum, but unfortunatelly this is more or less a dead forum, with just little responce to topics, so i hope this forum is the better choice =)

Share this post


Link to post
Share on other sites
Advertisement
The values are between 0 and 1.
I know that, cause i outputted em as float4(scalar, 0, 0, 1);
Furthermore i did something like this:

if (scalar < 0 && scalar > 1)
OUT.color = float(1.0f, 0.0f, 0.0f, 1.0f);
else
OUT.color = float(0.0f, 1.0f, 0.0f, 1.0f);
and everything was greed.



i tested the 1D texture the same way and with:


tex1D(lookup, 0.5f);



which worked as expected...

So the textures values are ok!!! don't worry about that.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!