- Home /
Animating a cubemaps orientation
Hey All,
I want to add an animated "sheen" reflection to my puzzle game and I am thinking the best way to achieve this is through a cubemap. What I'd need is the ability to animate the cubemap's orientation over time. Is this possible? I am using Unity Basic/iOS Basic.
Any information is greatly appreciated!
Thanks,
A search for 'cubemap rotate' returns quite a few results. I have nearly zero experience in manipulating shaders, so I'm not going to even try to pretend this is a real answer, but it seems that either rotating the shader algorithm (my brain asplode) or rotating the cubemap source object (much easier) should rotate the sheen.
Answer by reecpj · May 14, 2014 at 12:06 PM
You'd want to rotate the view direction vector reflected by the surface normal (all normalized) with a quaternion passed in (as a shader parameter vector) representing the rotation you want.
Here's some quaternion rotation shader code:
vec3 rotate_vector( vec4 quat, vec3 vec )
{
return vec + 2.0 * cross( cross( vec, quat.xyz ) + quat.w * vec, quat.xyz );
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613070550im_/https://answers.unity.com/themes/thub/images/avi.jpg)