Jump to content

  • Log In with Google      Sign In   
  • Create Account

Glsl shader wont compile


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
3 replies to this topic

#1 Solid_Spy   Members   -  Reputation: 452

Like
0Likes
Like

Posted 15 November 2013 - 09:42 PM

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, 15 November 2013 - 09:43 PM.


Sponsor:

#2 Samith   Members   -  Reputation: 2274

Like
1Likes
Like

Posted 15 November 2013 - 09:52 PM

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.



#3 marcClintDion   Members   -  Reputation: 431

Like
0Likes
Like

Posted 17 November 2013 - 02:26 PM

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, 17 November 2013 - 02:28 PM.

Consider it pure joy, my brothers and sisters, whenever you face trials of many kinds, because you know that the testing of your faith produces perseverance. Let perseverance finish its work so that you may be mature and complete, not lacking anything.


#4 mhagain   Crossbones+   -  Reputation: 8276

Like
1Likes
Like

Posted 17 November 2013 - 06:51 PM

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.


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.





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