Sign in to follow this  
Butabah

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

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:

[code]

#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;
}
[/code]

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
[color=#1C2837][size=2][color=#000000]posVector [/color][color=#666600]+=[/color][color=#000000] vec4[/color][color=#666600]([/color][color=#000000]worldCoords[/color][color=#666600],[/color][color=#000000] [/color][color=#006666]1.0[/color][color=#666600]);[/color][/size][/color]

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?.[/size][/font]
[font=CourierNew, monospace][size=2]
[/size][/font]
[font=CourierNew, monospace][size=2]Cheers![/size][/font]

Share this post


Link to post
Share on other sites
[quote name='kauna' timestamp='1310579817' post='4834928']
[color="#1C2837"][size="2"][color="#000000"]posVector [/color][color="#666600"]+=[/color][color="#000000"] vec4[/color][color="#666600"]([/color][color="#000000"]worldCoords[/color][color="#666600"],[/color] [color="#006666"]1.0[/color][color="#666600"]);[/color][/size][/color]

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?.[/size][/font]
[font="CourierNew, monospace"] [/font]
[font="CourierNew, monospace"][size="2"]Cheers![/size][/font]
[/quote]

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

Hey man, you were right! that fixed it!

[img]http://i.imgur.com/3g1t1.png[/img]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this