Search Unity

GLSL - compiler not showing syntax errors?

Discussion in 'General Graphics' started by TOES, Jul 17, 2020.

  1. TOES

    TOES

    Joined:
    Jun 23, 2017
    Posts:
    134
    I am making GLSL shaders and I get no errors thrown from the shader compiler after saving a shader with syntax errors in it. This is very tedious, as if the shader doesnt work, I have to manually go through the whole code to find the syntax error myself.

    Is GLSL syntax checking really not supported? Or is my Unity project damaged somehow?
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,028
    GLSL shaders get compiled by the driver when the application using the shader is loading it. Unity shader compiler doesn't do error checking for shaders written in GLSL, only HLSL.
     
  3. TOES

    TOES

    Joined:
    Jun 23, 2017
    Posts:
    134
    Ok, thanks for letting me know. I hope you will add proper GLSL support at some point, as it is a popular shader language.
     
  4. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,028
    I don't think this is planned.
    Are you trying to accomplish something that's not possible with HLSL?
    The only reason I see to use GLSL in Unity is to use something that has no support in HLSL.
     
  5. TOES

    TOES

    Joined:
    Jun 23, 2017
    Posts:
    134
    I use existing GLSL libraries and code. These are quite large and complex shader applications that has thousands of lines with code, so porting them to HLSL seems to be a big job I would like to avoid if possible.
     
  6. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,028
    The official shader language Unity supports is HLSL wrapped in Shader Lab. GLSL and Metal shaders are supported as pass-through (i.e. the compiler doesn't do anything (or close to that) there).
    Aren't there any GLSL to HLSL translators?
     
  7. TOES

    TOES

    Joined:
    Jun 23, 2017
    Posts:
    134
    I doubt that automatic converters would work as HLSL has some fundamental differences to GLSL, such as texture samplers are using a different notation for the V component (UV coordinates in GLSL have 0 at the top and increase downwards, in HLSL 0 is at the bottom and increases upwards). Differences like this would require lots of manual work and testing.

    So, since GLSL is not officially supported in Unity, could I risk that my program would fail to compile in the future, forcing me to convert the code to HLSL at some point?

    Hopefully not, as I work on many other platforms where OpenGL is the main supported standard, and I'd rather keep my libraries in GLSL if possible so that they can be shared between Unity projects and my other projects.
     
  8. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,028
    As I said, we support pass-through GLSL shader code :)
    If this changes at some point (and I'm not aware of such plans), it will be communicated way before it happens.