Skip to main content
GameDev.net gamedev.net
🔒 Locked

vertex and pixel shader strange problem

Started by TheItalianJob71 Mar 8, 2013 at 9:37 AM 1 replies 1.8k views
Original Post
TheItalianJob71
TheItalianJob71
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
Ashaman73
Ashaman73


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

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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.