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

Started by
1 comment, last by Butabah 12 years, 9 months ago
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?
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]

[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

This topic is closed to new replies.

Advertisement