No unlit shader?

0
Rimevel posted this 14 October 2015

Yo! I bought the system and have used it a fair bit now. It has a lot of awesome features but there is one thing I feel is missing that is quite a bummer. There does not seem to be any unlit shader?

I am not certain I can get around this since I use certain camera techniques. This makes using light and shadows on models quite tricky. I love the tools in the package but I an unlit shader would be sweet.

Any plans to add this in the near future?

Last edited 14 October 2015

4 Comments
Order By: Standard | Newest | Votes
0
GarethIW posted this 14 October 2015

You're right, there isn't a standard unlit shader - but making one would be super simple. I'm at work right now, so I can't test this but try the following:

Shader "PicaVoxel/PicaVoxel Unlit" {
    Properties{
        _Tint("Tint", Color) = (1,1,1,1)
    }
    SubShader{
        Tags{ "RenderType" = "Opaque" }
        LOD 200

        Pass{
            Tags{ "LightMode" = "Always" }

            Fog{ Mode Off }
            ZWrite On
            ZTest LEqual
            Cull Back
            Lighting Off

            CGPROGRAM
                #pragma vertex vert
                #pragma fragment frag
                #pragma fragmentoption ARB_precision_hint_fastest

                float4 _Tint;

                struct appdata {
                    float4 vertex : POSITION;
                    float4 color: COLOR;
                };

                struct v2f {
                    float4 vertex : POSITION;
                    float4 color: COLOR;
                };

                v2f vert(appdata v) {
                    v2f o;
                    o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
                    o.color = v.color;
                    return o;
                }

                fixed4 frag(v2f i) : COLOR{
                    return i.color * _Tint;
                }
            ENDCG

        }
    }
    Fallback "VertexLit"
}

Let me know if that works. If not, I'll take a proper look when I'm at a box with Unity installed.

Last edited 15 October 2015

0
Rimevel posted this 14 October 2015

Sorry for the late reply! But no, sadly it does not seem to work. It makes the model completely white.

1
GarethIW posted this 15 October 2015

Ooops! I've added the following line to the above:

o.color = v.color;

in v2f vert(). I've confirmed that this is working in Unity and will include it in the next release.

Last edited 15 October 2015

0
Rimevel posted this 15 October 2015

Thanks a lot for the help! I can confirm it works like a charm :) Will make sure to recommend PicaVoxel to my dev buddies!


Our 123 members have posted 452 times in 108 discussions