Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your help!

We need 7 developers from Canada and 18 more from Australia to help us complete a research survey.

Support our site by taking a quick sponsored survey and win a chance at a $50 Amazon gift card. Click here to get started!


Member Since 15 Mar 2012
Offline Last Active Apr 17 2012 10:38 AM

Topics I've Started

Default value for attributes

13 April 2012 - 04:02 AM


Just checking if a function like glVertexAttrib3f() is meant to set the default value for an in attribute for a shader.

For example, if I am drawing a cube which doesnt actually have texture coordinates but my shader usually supports them, would I have to have multiple shaders or could I do something like the following...

glVertexAttrib3f(inTexCoords, 1, 2, 3);

And expect the attribute in my shader to have the vec3 value of 1, 2, 3?

So far it just seems to not draw anything, so I am wondering if this is correct functionaility or if I have a bug somewhere...



[SOLVED]Perspective Correct Texture Coordinates (Frag Shader)

16 March 2012 - 11:36 AM


I have been attempting to replace all fixed functionality from an OpenGL project I wrote a while ago and have run into a snag which I havn't been able to resolve in the many hours I have spent on it.

After much research I have found it is due to the texture coordinates not being perspective correct. What I have not been able to find is a way to fix this in the shader.

(I have attached a screenshot demonstrating the issue and as you can see, the brick texture is not drawing correctly, creating a seam.)

The line of code in my frag shader which I believe to be causing the issue is as follows.
#version 120
uniform sampler2D tex;
varying vec2 pass_tex_coord;
gl_FragColor = texture2D(tex, pass_tex_coord);

So far I am under the impression that I need to obtain the w value from the pass_tex_coord s and t values.
I am unsure of how to do this because I am simply passing in the uv texture coordinates from my model (VBO). I have also noticed that the model of the cat has the correct texture coord mapping (because the triangles are smaller?)

If anyone could help shed some light on this or offer some example shader code to do this, I would be very greatful!

Best Regards,