Jump to content
  • Advertisement
Sign in to follow this  
rosicky2005

Vertex Shader foundamental problem

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

For a vertex shader, there are two components to specify, color(pixel value) and position(pixel position) respectively. Then, how should I declare my texture? If, for example a simple program like this: Input an image and then output the Green value of RGB as 255.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by rosicky2005
For a vertex shader, there are two components to specify, color(pixel value) and position(pixel position) respectively.
If you're speaking for a generic vertex shader, no. Writing Position is the only requirement. If EXT_gpu_shader4 is supported then there's no need to write it.
Quote:
Original post by rosicky2005
Then, how should I declare my texture? If, for example a simple program like this: Input an image and then output the Green value of RGB as 255.
Texturing is generally a PS operation (unless you want vertex-texturing). Anyway, you must declare a sampler2D object. The object will be "sort of" a reference to a texturing unit that will be used for texturing.

Share this post


Link to post
Share on other sites
Quote:
Original post by Krohm
If you're speaking for a generic vertex shader, no. Writing Position is the only requirement. If EXT_gpu_shader4 is supported then there's no need to write it.


If position is the only requirement, then can I still specify the color value?

Quote:
Texturing is generally a PS operation (unless you want vertex-texturing). Anyway, you must declare a sampler2D object. The object will be "sort of" a reference to a texturing unit that will be used for texturing.


For a sampler2D object, is that something like below?

imageParam = glGetUniformLocationARB(programObject, "textureY");

glActiveTexture(GL_TEXTURE0);
glBindTexture(textureParameters.texTarget,imageTexID);
glUniform1iARB(imageParam, 1);

Share this post


Link to post
Share on other sites
Quote:

If position is the only requirement, then can I still specify the color value?

You can write pass on the vertex color using the varying gl_FrontColor & gl_BackColor

Quote:

glUniform1iARB(imageParam, 1);


I think, the value for the uniform must be 0, not 1 since the you have activated the 0th texture unit.

Regrads,
KumGame

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!