Home› Technical Talk
# Shader - Rotate Cubemap - Any tips?

Heya peeps,

Been trying to find a way to rotate cubemaps on a shader level (EI: 180* upside down, etc).

Problem is, I'm not sure how to go about it, I tried a following a few random snippets of HLSL on the net, but they all ended up 'warping' my cubemap in one point, rather then rotating it.

So yeah, any tips would be grand and much appreciated!

Been trying to find a way to rotate cubemaps on a shader level (EI: 180* upside down, etc).

Problem is, I'm not sure how to go about it, I tried a following a few random snippets of HLSL on the net, but they all ended up 'warping' my cubemap in one point, rather then rotating it.

So yeah, any tips would be grand and much appreciated!

## Replies

Heres some C# code i wrote a while ago. Its not optimized and Im not sure if you want the "xAngle -= 90.0f;" line.

Theres probably a better way dealing with matrix multiplication, but I doubt you can do that with a locked down shader system like unreals (assuming this is for unreal).

EDIT: OK, so might as well keep in this thread to keep things organized. When I try straight up HLSL, it seems to be working, but when I try creating in a nodal based app like UDK, no dice.

Also, it seems to be breaking at 180* angles.

Here is what I got so far in UDK, I assuming for now float3x3 is a Append?

especially for those "magic" angles, the results of cos or sin will be mostly 1 or -1 or so

EDIT: Yeah, I have no idea at this point what to do in UDK, I tried doing the shader in Max and RenderMonkey, and they seem to be working (I only need to figure out the correct math for Radians to Degree's to get true values) and they do follow the 'magic' formula, but I guess I'm too stupid to figure out how to open up UDK's rotation to me since it keeps on giving me errors or refusing to rotate.