Custom Skybox ignoring matrices

Greeting everyone, allow me to explain my simple problem.

I’m trying to set up a skybox class, but I’m doing it slightly differently.

I just want to have 6 quads on which I’m displaying textures (bear with me, I’m just experimenting).

Coming from OpenGL, I thought I could do this through some matrix manipulation, creating my quads (using vertex buffers) and then do something like this in the effect.

Matrix noTranslation = MainCamera.Instance.ViewMatrix;
noTranslation.M14 = 0;
noTranslation.M24 = 0;
noTranslation.M34 = 0;
basicEffect.World = Matrix.Identity;
basicEffect.View = noTranslation;
basicEffect.Projection = MainCamera.Instance.projectionMatrix ;

This should remove any translation from the quads.

To my surprise, the quads translate normally in world space.

It appears that the basic effect doesn’t like being cheated on the matrices…

Any idea why this is happening?

UPDATE:

Ok, I’m an idiot.

I was defining my vertices with the Z at 0, which means they were always “inside” the camera if you know what I mean.
By changing the Z value to -1 or 1, I can rotate and see my quad in place and it does not translate.

All sorted, it was me all along (of course).

Personally, I just set the worldmatrix of the skybox to the cameraposition and everything is fine.

Not sure about Matrix row/col ordering, maybe you need a transpose?

Hi, I tried transposing, the result is nothing being rendered. I guess by transposing I’m resetting some scaling/rotation values and ultimately “breaking” the matrix.

Still, removing the translation from the matrix should work, it seems like the shader applies a default one.

I’ll try writing my own shader

Maybe you could check, if you are setting the right matrix elements by creating a translation matrix then manipulating the translation and checking with the debugger if you changed the right values…

Just an idea :slight_smile:

You got the rows and columns mixed up. You need to use M41, M42 and M43. You can see that by looking at the code for Matrix.Translation: https://github.com/MonoGame/MonoGame/blob/develop/MonoGame.Framework/Matrix.cs