Skip to main content
added 319 characters in body
Source Link

I've been staring at this for too long and I'm too new to GLSL to know what is wrong. All I know is that when checking to see if the vertex shader compiles, it says that it could not do so. If someone could help me find out what I've done wrong that would be amazing.

textureShader.vert

#version 140 uniform mat4 mvpMatrix; attribute vec3 position; attribute vec2 textCoord; varying vec2 TextCoord; varying vec3 lightDir,normal; void main() { normal = normalize(gl_NormalMatrix * gl_Normal); lightDir = normalize(vec3(gl_LightSource[0].position)); gl_TexCoord[0] = gl_MultiTexCoord0; gl_Position = position; } 

textureShader.frag

#version 140 uniform sampler2D texUnit; varying vec2 TextCoord; varying vec3 lightDir,normal; void main() { vec3 ct,cf; vec4 texel; float intensity,at,af; intensity = max(dot(lightDir,normalize(normal)),0.0); cf = intensity * (gl_FrontMaterial.diffuse).rgb + gl_FrontMaterial.ambient.rgb; af = gl_FrontMaterial.diffuse.a; texel = texture2D(texUnit, TextCoord); ct = texel.rgb; at = texel.a; gl_FragColor = vec4(ct * cf, at * af); } 

What I'm doing to check the compilation. DBOUT is a function to write to the Visual Studio output box.

glCompileShader(shader_vp); validateShader(shader_vp, vsFile); GLint compiled; glGetShaderiv(shader_vp, GL_COMPILE_STATUS, &compiled); if (!compiled){ DBOUT("Couldn't Compile Vertex Shader: Aborting Mission\n"); abort(); } glCompileShader(shader_fp); validateShader(shader_fp, fsFile); glGetShaderiv(shader_fp, GL_COMPILE_STATUS, &compiled); if (!compiled){ DBOUT("Couldn't Compile Fragment Shader: Aborting Mission\n"); abort(); } 

The output I receive:

Couldn't Compile Vertex Shader: Aborting Mission Debug Error! 

SOLVED

So with everyones help I go this to compile. I had to replace these lines:

 gl_TexCoord[0] = gl_MultiTexCoord0; gl_Position = position; 

With these ones:

 TextCoord = vec2(textCoord); gl_Position = mvpMatrix * vec4(position,1.0f); 

Thank you everyone!

I've been staring at this for too long and I'm too new to GLSL to know what is wrong. All I know is that when checking to see if the vertex shader compiles, it says that it could not do so. If someone could help me find out what I've done wrong that would be amazing.

textureShader.vert

#version 140 uniform mat4 mvpMatrix; attribute vec3 position; attribute vec2 textCoord; varying vec2 TextCoord; varying vec3 lightDir,normal; void main() { normal = normalize(gl_NormalMatrix * gl_Normal); lightDir = normalize(vec3(gl_LightSource[0].position)); gl_TexCoord[0] = gl_MultiTexCoord0; gl_Position = position; } 

textureShader.frag

#version 140 uniform sampler2D texUnit; varying vec2 TextCoord; varying vec3 lightDir,normal; void main() { vec3 ct,cf; vec4 texel; float intensity,at,af; intensity = max(dot(lightDir,normalize(normal)),0.0); cf = intensity * (gl_FrontMaterial.diffuse).rgb + gl_FrontMaterial.ambient.rgb; af = gl_FrontMaterial.diffuse.a; texel = texture2D(texUnit, TextCoord); ct = texel.rgb; at = texel.a; gl_FragColor = vec4(ct * cf, at * af); } 

What I'm doing to check the compilation. DBOUT is a function to write to the Visual Studio output box.

glCompileShader(shader_vp); validateShader(shader_vp, vsFile); GLint compiled; glGetShaderiv(shader_vp, GL_COMPILE_STATUS, &compiled); if (!compiled){ DBOUT("Couldn't Compile Vertex Shader: Aborting Mission\n"); abort(); } glCompileShader(shader_fp); validateShader(shader_fp, fsFile); glGetShaderiv(shader_fp, GL_COMPILE_STATUS, &compiled); if (!compiled){ DBOUT("Couldn't Compile Fragment Shader: Aborting Mission\n"); abort(); } 

The output I receive:

Couldn't Compile Vertex Shader: Aborting Mission Debug Error! 

I've been staring at this for too long and I'm too new to GLSL to know what is wrong. All I know is that when checking to see if the vertex shader compiles, it says that it could not do so. If someone could help me find out what I've done wrong that would be amazing.

textureShader.vert

#version 140 uniform mat4 mvpMatrix; attribute vec3 position; attribute vec2 textCoord; varying vec2 TextCoord; varying vec3 lightDir,normal; void main() { normal = normalize(gl_NormalMatrix * gl_Normal); lightDir = normalize(vec3(gl_LightSource[0].position)); gl_TexCoord[0] = gl_MultiTexCoord0; gl_Position = position; } 

textureShader.frag

#version 140 uniform sampler2D texUnit; varying vec2 TextCoord; varying vec3 lightDir,normal; void main() { vec3 ct,cf; vec4 texel; float intensity,at,af; intensity = max(dot(lightDir,normalize(normal)),0.0); cf = intensity * (gl_FrontMaterial.diffuse).rgb + gl_FrontMaterial.ambient.rgb; af = gl_FrontMaterial.diffuse.a; texel = texture2D(texUnit, TextCoord); ct = texel.rgb; at = texel.a; gl_FragColor = vec4(ct * cf, at * af); } 

What I'm doing to check the compilation. DBOUT is a function to write to the Visual Studio output box.

glCompileShader(shader_vp); validateShader(shader_vp, vsFile); GLint compiled; glGetShaderiv(shader_vp, GL_COMPILE_STATUS, &compiled); if (!compiled){ DBOUT("Couldn't Compile Vertex Shader: Aborting Mission\n"); abort(); } glCompileShader(shader_fp); validateShader(shader_fp, fsFile); glGetShaderiv(shader_fp, GL_COMPILE_STATUS, &compiled); if (!compiled){ DBOUT("Couldn't Compile Fragment Shader: Aborting Mission\n"); abort(); } 

The output I receive:

Couldn't Compile Vertex Shader: Aborting Mission Debug Error! 

SOLVED

So with everyones help I go this to compile. I had to replace these lines:

 gl_TexCoord[0] = gl_MultiTexCoord0; gl_Position = position; 

With these ones:

 TextCoord = vec2(textCoord); gl_Position = mvpMatrix * vec4(position,1.0f); 

Thank you everyone!

Source Link

GLSL shader wont compile, can someone help me find out why?

I've been staring at this for too long and I'm too new to GLSL to know what is wrong. All I know is that when checking to see if the vertex shader compiles, it says that it could not do so. If someone could help me find out what I've done wrong that would be amazing.

textureShader.vert

#version 140 uniform mat4 mvpMatrix; attribute vec3 position; attribute vec2 textCoord; varying vec2 TextCoord; varying vec3 lightDir,normal; void main() { normal = normalize(gl_NormalMatrix * gl_Normal); lightDir = normalize(vec3(gl_LightSource[0].position)); gl_TexCoord[0] = gl_MultiTexCoord0; gl_Position = position; } 

textureShader.frag

#version 140 uniform sampler2D texUnit; varying vec2 TextCoord; varying vec3 lightDir,normal; void main() { vec3 ct,cf; vec4 texel; float intensity,at,af; intensity = max(dot(lightDir,normalize(normal)),0.0); cf = intensity * (gl_FrontMaterial.diffuse).rgb + gl_FrontMaterial.ambient.rgb; af = gl_FrontMaterial.diffuse.a; texel = texture2D(texUnit, TextCoord); ct = texel.rgb; at = texel.a; gl_FragColor = vec4(ct * cf, at * af); } 

What I'm doing to check the compilation. DBOUT is a function to write to the Visual Studio output box.

glCompileShader(shader_vp); validateShader(shader_vp, vsFile); GLint compiled; glGetShaderiv(shader_vp, GL_COMPILE_STATUS, &compiled); if (!compiled){ DBOUT("Couldn't Compile Vertex Shader: Aborting Mission\n"); abort(); } glCompileShader(shader_fp); validateShader(shader_fp, fsFile); glGetShaderiv(shader_fp, GL_COMPILE_STATUS, &compiled); if (!compiled){ DBOUT("Couldn't Compile Fragment Shader: Aborting Mission\n"); abort(); } 

The output I receive:

Couldn't Compile Vertex Shader: Aborting Mission Debug Error!