Skybox rotation Topic is solved
- TaaTT4
- OGRE Contributor
- Posts: 267
- Joined: Wed Apr 23, 2014 3:49 pm
- Location: Bologna, Italy
- x 75
- Contact:
Skybox rotation
To render the skybox, I use the same technique that OGRE uses in its sample Sample_TutorialSky_Postprocess. As the title says, I'm wondering if there's an easy way to apply a rotation (to make things simpler: just a yaw around the world y axis) to the skybox.
I know I can simply apply a counter-rotation to the objects, but doing this creates a mess with the AABB visualization.
I know I can simply apply a counter-rotation to the objects, but doing this creates a mess with the AABB visualization.
Senior programmer at 505 Games; former senior engine programmer at Sandbox Games
Worked on: Racecraft Esport — Racecraft Coin-Op, Victory: The Age of Racing
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 168
Re: Skybox rotation
should be something like this (SkyPostprocess_vs.glsl):
Code: Select all
outVs.cameraDir.xyz = normal.xyz;
float radian = 3.14; //whatever, maybe pass through uniform
float s = sin(radian);
float c = cos(radian);
mat2 m = mat2(c, -s, s, c);
outVs.cameraDir.xz = m * outVs.cameraDir.xz;
- dark_sylinc
- OGRE Team Member
- Posts: 5299
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1280
- Contact:
Re: Skybox rotation
If you want an arbitrary rotation, convert the quaternion to a Matrix3 and then send it to the shader:
I don't know if you need to swap the multiplication order though (i.e. try float3 * float3x3 if float3x3 * float3 doesn't work as intended or rotates in the opposite direction).
xrgo's answer works on rotating with 2 axes by using a float2x2, instead of 3 axis; but is basically the same concept.
Code: Select all
uniform float3x3 rotation;
....
//GLSL
outVs.cameraDir.xyz = (rotation * normal.xyz);
//HLSL
outVs.cameraDir.xyz = mul(rotation, normal.xyz);
xrgo's answer works on rotating with 2 axes by using a float2x2, instead of 3 axis; but is basically the same concept.
- TaaTT4
- OGRE Contributor
- Posts: 267
- Joined: Wed Apr 23, 2014 3:49 pm
- Location: Bologna, Italy
- x 75
- Contact:
Re: Skybox rotation
Yep, I had thought about using a rotation matrix in the vertex shader. Correct multiplication order is float3x3 * float3.dark_sylinc wrote: ↑Mon Mar 04, 2019 8:43 pm If you want an arbitrary rotation, convert the quaternion to a Matrix3 and then send it to the shader:
I don't know if you need to swap the multiplication order though (i.e. try float3 * float3x3 if float3x3 * float3 doesn't work as intended or rotates in the opposite direction).Code: Select all
uniform float3x3 rotation; .... //GLSL outVs.cameraDir.xyz = (rotation * normal.xyz); //HLSL outVs.cameraDir.xyz = mul(rotation, normal.xyz);
Thanks guys!
Senior programmer at 505 Games; former senior engine programmer at Sandbox Games
Worked on: Racecraft Esport — Racecraft Coin-Op, Victory: The Age of Racing