Search Unity

  1. Unity 2020.2 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Is This Illegal?

Discussion in 'Shaders' started by threeguysgamestudio, Feb 10, 2019.

  1. threeguysgamestudio

    threeguysgamestudio

    Joined:
    Dec 1, 2017
    Posts:
    25
    It seems as if doing the following in a shader is not acceptable:

    struct MatrixFloats
    {
    half4 a;
    half4 b;
    half4 c;
    half4 d;

    half4x4 ToMatrix()
    // Above causes a compile error, Unexpected token '('. Expected one of: ',' ';'
    {
    return half4x4(half4(a.x, b.x, c.x, d.x), half4(a.y, b.y, c.y, d.y), half4(a.z, b.z, c.z, d.z), half4(a.w, b.w, c.w, d.w));
    }
    };


    Can structs not declare return methods?
     
  2. drcrck

    drcrck

    Joined:
    May 23, 2017
    Posts:
    312
    well you see they can't
     
  3. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    9,616
    threeguysgamestudio likes this.
unityunity