• 13
• 18
• 19
• 27
• 10

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

This topic is 2441 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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.

 #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 on other sites
[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 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!