Jump to content
  • Advertisement
Sign in to follow this  
VansFannel

OpenGL OpenGL ES 2.0: attribute not bound on vertex shader.

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

Hello.

I'm developing an Android application.

I have the following vertex shader.

"attribute vec4 vertexPosition;
attribute vec4 vertexNormal;
attribute vec2 vertexTexCoord;

varying vec2 texCoord;
varying vec4 normal;

uniform mat4 modelViewProjectionMatrix;

void main()
{
gl_Position = modelViewProjectionMatrix * vertexPosition;
normal = vertexNormal;
texCoord = vertexTexCoord;
}
";

And this is the fragment shader:

precision mediump float;

varying vec2 texCoord;
varying vec4 normal;

uniform sampler2D texSampler2D;

void main()
{
gl_FragColor = texture2D(texSampler2D, texCoord);
}
";

Is there any problem if I left vertexTexCoord unbound? I think I must use a different vertex and fragment shader if my model doesn't have a texture, isn't?

Thanks.

Share this post


Link to post
Share on other sites
Advertisement
In general I don't think there is a problem with leaving a vertex attribute unbound if you don't need it for whatever reason, but what are you expecting to happen in your particular shader?

Your output color is directly dependent on the texcoord and a texture being bound, so you're going to get garbage output from this.

You should probably have a separate shader (or some kind of compile time IFDEF) for rendering with/without textures.

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!