Jump to content

  • Log In with Google      Sign In   
  • Create Account


vertex and pixel shader strange problem


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 TheItalianJob71   Members   -  Reputation: 810

Like
0Likes
Like

Posted 08 March 2013 - 03:37 AM

Hello everybody, i am experiencing a strange problem, i atta ch my simple vertex and pixel shader hoping that some shader expert will shed some light on it , excuse me but i am pretty new to shaders.

vertex shader:

#version 330

precision highp float;

uniform mat4 ViewMatrix;
uniform mat3 NormalMatrix;
uniform mat4 ModelViewMatrix;
uniform mat4 ModelViewProjectionMatrix;

in vec4 VertexPosition;
in vec3 VertexNormal;
out vec3 Normal;

void main()
{
// All vertex shaders should write the transformed homogeneous clip space
// vertex position into the gl_Position variables.

gl_Position = ModelViewProjectionMatrix * VertexPosition;

// normal

Normal = VertexNormal;

}

pixel shader :

#version 330

precision highp float;

out vec4 FragColor;

uniform vec4 WireFrameColor;

void main()
{

FragColor = WireFrameColor ;

}


The strange fact is that if in the vertex shader, i comment out the 'normal' , i don't get rendered anything.
Where am i wrong ?
Does anybody know a place to learn modern opengl shaders ?
Thanks

Sponsor:

#2 Ashaman73   Crossbones+   -  Reputation: 7274

Like
0Likes
Like

Posted 08 March 2013 - 04:21 AM

i don't get rendered anything.

This could be a hint, that the shaders does not compile any longer.

 

Best to output the compiler infos to get more data. My first guess is, that you need to set output parameters. If you don't do it, the compiler might throw an error (just guessing here).



#3 TheItalianJob71   Members   -  Reputation: 810

Like
0Likes
Like

Posted 08 March 2013 - 05:10 AM

I don't get any error from glloginfo function, just a black screen, during the setup process i enable everything , position, color, uv , normals, then, as i have understood correctly, i can selectively using the attributes i need according to each shader.
Could it be that i pack everything in the same vertex data and the driver gets' confused' about what to render ?
I don't think so becasue i do this:

glVertexAttribPointer(VertexAttribPosition, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex3d), BUFFER_OFFSET(0));
glVertexAttribPointer(NormalAttribPosition, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex3d), BUFFER_OFFSET(sizeof(float) * 4));
glVertexAttribPointer(TexCoordAttribPosition , 2, GL_FLOAT, GL_FALSE, sizeof(Vertex3d), BUFFER_OFFSET(sizeof(float) * 7));
glVertexAttribPointer(ColorCoordAttribPosition, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex3d), BUFFER_OFFSET(sizeof(float) * 9));

glEnableVertexAttribArray(VertexAttribPosition);
glEnableVertexAttribArray(NormalAttribPosition);
glEnableVertexAttribArray(TexCoordAttribPosition);
glEnableVertexAttribArray(ColorCoordAttribPosition);

the spacing in the vertex data is correct.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS