Jump to content
  • Advertisement
Sign in to follow this  

Glsl shader wont compile

This topic is 2073 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 created a simple shader that loads an image and displays a quad. However, I modified it to include uv manipulation, and now it wont compile. Here is my code:

#version 400

in vec3 inPosition;
in vec2 inUV;

out vec2 outUV;

uniform mat4 worldMatrix;
uniform mat4 viewMatrix;
uniform mat4 projectionMatrix;
uniform float uPosition;
uniform float vPosition;
uniform float uScale;
uniform float vScale;

void main(void)
    gl_Position = worldMatrix * vec4(inPosition, 1.0f);
    gl_Position = viewMatrix * gl_Position;
    gl_Position = projectionMatrix * gl_Position;

    inUV.x = uPosition + inUV.x;
    inUV.y = vPosition + inUV.y;
    inUV.x = uScale * inUV.x;
    inUV.y = vScale * inUV.y;
    outUV = inUV;

I did not edit the pixel shader. It could be just a syntax error, but i'm using notepad, so it's not so easy X3.

Edited by Solid_Spy

Share this post

Link to post
Share on other sites

In the future it would be helpful to provide the actual error you're getting when you try to compile the code. In this case, I think your code is failing to compile because you are assigning to your input attributes. Instead of asigning to inUV, create a temporary vec2 and assign to that instead.

Share this post

Link to post
Share on other sites

For many drivers, the same problem will occur if you try to write to a variable that is being passed down the line. 

Edited by marcClintDion

Share this post

Link to post
Share on other sites

You've declared inUV as an input variable, so it's read-only.  This is documented in the GLSL specification (section 4.3.4, I'm working off the 4.30.6 version here):



It is a compile-time error to write to a variable declared as an input.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!