1

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);
      }
Ruzihm
  • 19,749
  • 5
  • 36
  • 48
  • Are you sure you want to get into shader coding ? If not, there is the Shader Graph (in unity packages) that is much (much) simpler to use and can achieve almost everything (as it now support custom nodes) – Jichael Sep 30 '19 at 13:42
  • Yes I really want to get into shader coding. And you are right about shader graph. But I'd like to coding for now. – Bora İLGAR Sep 30 '19 at 14:00
  • Your code does what you expect from the method name : the normal is rotated around the vertical axis. The question is : what do you want to do? You haven't implemented any of the specific details of the article you link, which itself has a pretty convoluted way of achieving its effect. They use a reflection vector, multiple samples of the cubemap and blending between them based on normal. – Brice V. Oct 19 '19 at 14:06

0 Answers0