0

This works fine on a PC but I'm using a Mac and it brings up the warning

No subshaders can run on this graphics card

Which for shaders then brings up the pink error shader.

Shader "Custom/wireframeShaderWithLambert" {
Properties {
    _Glossiness ("Smoothness", Range(0,1)) = 0.5
    _Metallic ("Metallic", Range(0,1)) = 0.0
    _Color ("Line Color", Color) = (1,1,1,1)
    _MainTex ("Main Texture", 2D) = "white" {}
    _Thickness ("Thickness", Float) = 1
}     
SubShader {

  Tags { "RenderType" = "Opaque" }
  CGPROGRAM
  #pragma surface surf Lambert

  struct Input {
      float2 uv_MainTex;
  };

  sampler2D _MainTex;

  void surf (Input IN, inout SurfaceOutput o) {
      o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb;
  }
  ENDCG
    Pass
    {
        Tags { "RenderType"="Opaque" "Queue"="Geometry" } 

        Blend SrcAlpha OneMinusSrcAlpha

        Cull Off
        LOD 200

        CGPROGRAM
        #pragma target 5.0
        #include "UnityCG.cginc"
        #pragma vertex vert
        #pragma fragment frag
        #pragma geometry geom

            struct vertToGeom
            {
                float4  pos     : POSITION;     // vertex position
                float2  uv      : TEXCOORD0;    // vertex uv coordinate
            };

            // Geometry to  UCLAGL_fragment
            struct geomToFrag
            {
                float4  pos     : POSITION;     // fragment position
                float2  uv      : TEXCOORD0;    // fragment uv coordinate
                float3  dist    : TEXCOORD1;    // distance to each edge of the triangle
            };

            // PARAMETERS //

            //float4 _Texture_ST;           // For the Main Tex UV transform
            float _Thickness = 1;       // Thickness of the wireframe line rendering
            float4 _Color = {1,1,1,1};  // Color of the line
            float4 _MainTex_ST;         // For the Main Tex UV transform
            sampler2D _MainTex;         // Texture used for the line


            // Vertex Shader
            vertToGeom vertShader(appdata_base v)
            {
                //Random shader code

                return output;
            }

            // Geometry Shader
            [maxvertexcount(3)]
            void geomShader(triangle UCLAGL_v2g p[3], inout TriangleStream<UCLAGL_g2f> triStream)
            {
                   //Random shader code
            }

        ENDCG
    }
} 
}

I'm not sure why this is, the only thing I can think of is perhaps Cg doesn't work on Macs?

Plus, I can't seem to find a way to make it GLSL.

ForceMagic
  • 6,230
  • 12
  • 66
  • 88
normyp
  • 184
  • 1
  • 11

1 Answers1

1

It's not that Cg doesn't work on Macs, but more than the shader version you are targetting (5.0) is too high for your Mac's Graphic Card.

Usually, you should always write one subshader targetting 2.0, which is the default shader. The effects won't be as good as higher version of course and some function might not be available, so you'd have to adapt it.

Then, add more subshader targetting higher version, as you need it, for a better quality version.

See this Unity3D doc for more info about Shader Targets and Rendering Platform.


Shader targets overview:

By default, Unity compiles shaders into roughly shader model 2.0 equivalent. Using #pragma target allows shaders to be compiled into other capability levels. Currently these targets are supported:

#pragma target 2.0 (default) - roughly shader model 2.0

  • Shader Model 2.0 on Direct3D 9.
  • Limited amount of arithmetic & texture instructions; no vertex texture sampling; no derivatives in fragment shaders.

#pragma target 3.0 - compile to shader model 3.0:

  • Shader Model 3.0 on Direct3D 9.

#pragma target 4.0 - compile to DX10 shader model 4.0.

  • This target is currently only supported by DirectX 11 and XboxOne/PS4 platforms.`

#pragma target 5.0 - compile to DX11 shader model 5.0.

  • This target is currently only supported by DirectX 11 and XboxOne/PS4 platforms.`
ForceMagic
  • 6,230
  • 12
  • 66
  • 88