lundi 30 septembre 2019

How can I rotate Cubemap?

I am currently working on some reflection shaders in Unity. And I am totally newbie about shaders. I found an article about cubemap rotation. I' ve done some implementation but it seems doesn't work properly. I rotated cubemap in vertex shader with only rotate normal.
How can I achive this effect?

 float3 RotateAroundYInDegrees (float3 vertex, float degrees)
      {
         float alpha = degrees * UNITY_PI / 180.0;
         float sina, cosa;
         sincos(alpha / 2, sina, cosa);
         float3x3 m = float3x3(cosa, 0, sina, 0, 1, 0, -sina, 0, cosa);
        float3 r = float3(mul(m, vertex.xyz) ).rgb;
        return r;
    }
    void vert (inout appdata_full v, out Input o) {
        UNITY_INITIALIZE_OUTPUT(Input,o);
        v.normal = RotateAroundYInDegrees(v.normal, _Rotate);
      }




Aucun commentaire:

Enregistrer un commentaire