Sign in to follow this  
rosicky2005

Vertex Shader foundamental problem

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this