Jump to content
  • Advertisement
Sign in to follow this  
faculaganymede

OpenGL OpenGL Shader Question

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

OpenGL Shader Experts, I am new to shaders. I want to implement a fragment shader to change the RGB color on the textures (assuming all objects in the scene are textured) using a lookup table. I do not want to include the light and fog colors in that process. Thus, my question is can I apply lighting and fog after the fragment shader operation? I appreciate any suggestions.

Share this post


Link to post
Share on other sites
Advertisement
Yes :)

Standard glfog and -lighting is very simple to do...
The lighting-part would be done in a vertexshader.

Is that what you mean?

Not sure how to help...

Share this post


Link to post
Share on other sites
Thanks for your reply, Stein.

Quote:
Original post by stein
The lighting-part would be done in a vertexshader.

Is that what you mean?

Sorry for not being very clear, it's because I don't know the shader stuff very well.

I don't think I want lighting to be done in the vertex shader. If lighting is done in the vertex shader, then the light color will be mixed with texture color, so the final color that goes into the fragment shader will be light+texture. That's not what I want. I only want the texture color to go into the fragment shader.

Perhaps some more detail on my task will make things a little more clear:

RGB -> fragment shader (use look-up table) -> intensity

I basically want to take the RGB values of the texture, use the fragment shader to look up the intensity value in a reference look-up table. The reference look-up table contains intensity values that correspond to a set of RGB texture values.

If lighting and fog are applied before the fragment shader, then the "mixed" RGB values used to lookup the intensity values would not be correct because the reference look-up table did not take lighting and fog into account. Does that make sense? Perhaps there's a better way?

Share this post


Link to post
Share on other sites
ah, you appear to be slightly confused about something [smile]

Per Vertex Lighting and Fog can be worked out before the fragment shader is run but they WONT effect the colors read from the texture unless you do it yourself in the fragment program.

So, you can work out the per vertex lighting and fog stuff, pass it down to a fragment shader as a set of varying varibles and then in the fragment shader read in the texture, perform the lookup and then, if you want, apply the interpolated per fragment vertex lighting and fog to it for output.

When you do shaders nuffin automatic happens for you, you control practically everything from what goes in to what ends up in the final output.

Share this post


Link to post
Share on other sites
Phantom,

Thanks so much for your explanation. People like you and Stein are making this site THE best.

Quote:
Original post by _the_phantom_
So, you can work out the per vertex lighting and fog stuff, pass it down to a fragment shader as a set of varying variables and then in the fragment shader read in the texture, perform the lookup and then, if you want, apply the interpolated per fragment vertex lighting and fog to it for output.

So, if I don't want to do anything with lighting and fog in the shaders (just let some fixed API functions handle those), then I don't need to have a vertex shader, a fragment shader would be sufficient for my task, right?

Meanwhile, I have to go learn how to implement this... If anyone has some sample codes to share, I would appreciate it ;)

[Edited by - faculaganymede on March 9, 2005 3:34:56 PM]

Share this post


Link to post
Share on other sites
hmmm I dont think you can have a fragment shader without a vertex shader, so you'll probably want to make a basic one which just does the transform and passes the texture coords down to the fragment shader at least

Share this post


Link to post
Share on other sites
yeah you can't use a pixel shader without a vertex program. But you can use a vertex program without a pixel shader. I tried it, and it won't work without a vertex program to drive it. Maybe there is a way to do it but I don't think so.

no I am no shader expert yet :-)

g'luck

Share this post


Link to post
Share on other sites
Correct... You need to implement your own version of the lighting (in a vertexshader) and fog (in the fragmentshader).

Take a look at http://www.clockworkcoders.com/oglsl/tutorials.html, and specifically the 5th for lighting.

best regards

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!