Jump to content
  • Advertisement
Sign in to follow this  
Butabah

My shader doesn't like moving in the z-axis

This topic is 2566 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

Hey guys,

I have an issue with my shader, where I am able to translate in the X, Y axis, but not in the Z.

Here is my shader:



#version 330

layout(location = 0) in vec3 vVerts;
layout(location = 2) in vec2 vTex;

uniform mat4 modelviewMatrix;
uniform mat4 projectionMatrix;
uniform vec3 worldCoords;

smooth out vec2 vTexCoords;

void main()
{
mat4 modelviewProjectionMatrix = projectionMatrix * modelviewMatrix;
vec4 posVector = vec4(vVerts, 1.0);
posVector += vec4(worldCoords, 1.0);
vec4 pos = modelviewProjectionMatrix * posVector;

vTexCoords = vTex;
gl_Position = pos;
}


Obviously with worldCoords it should be able to update the Z axis, but it simply doesn't move at all.

Any ideas?

Share this post


Link to post
Share on other sites
Advertisement
[color=#1C2837][size=2][color=#000000]posVector [color=#666600]+=[color=#000000] vec4[color=#666600]([color=#000000]worldCoords[color=#666600],[color=#000000] [color=#006666]1.0[color=#666600]);

I don't know about your z-coordinate, but it seems that by adding the vector above to the [font=CourierNew, monospace][size=2]posVector, you'll end up having w-component with value 2.0f. Which isn't maybe what you are after right?.[/font]
[font=CourierNew, monospace][size=2]
[/font]
[font=CourierNew, monospace][size=2]Cheers![/font]

Share this post


Link to post
Share on other sites

[color="#1C2837"][color="#000000"]posVector [color="#666600"]+=[color="#000000"] vec4[color="#666600"]([color="#000000"]worldCoords[color="#666600"], [color="#006666"]1.0[color="#666600"]);

I don't know about your z-coordinate, but it seems that by adding the vector above to the [font="CourierNew, monospace"]posVector, you'll end up having w-component with value 2.0f. Which isn't maybe what you are after right?.[/font]
[font="CourierNew, monospace"] [/font]
[font="CourierNew, monospace"]Cheers![/font]


Hmm, you're right, let me try that out.

Hey man, you were right! that fixed it!

3g1t1.png

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!