Jump to content
  • Advertisement
Sign in to follow this  
rlogan

CG Shader - Textures and sampler2D

This topic is 4324 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

I have a spotlight shader that I want to stay pretty generic. In my scene I have some objects with material only, some with textures, and others with multitextures. Is there a way in the shader to determine (with the sampler2D or some other method) whether a texture exists for TEXUNIT0, TEXUNIT1, etc. I was hoping the sampler was simply an index but it doesn't seem to be the case. For instance: uniform sampler2D decal : TEXUNIT0, if(decal > 0) texColor0 = tex2D(decal,texCoord);

Share this post


Link to post
Share on other sites
Advertisement
You can always use a boolean variable(e.g. bool Tex0Present;) in the shader indicating whether a particular texture was set.

Share this post


Link to post
Share on other sites
My problem is, I don't where to get that data from. I know nothing about the scene but what I can get from OpenGL within the shader. Is there a way to get that information from within the shader(either vertex, or fragment)?

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!