0

Shader Forge shader does not work with Graphics.DrawMeshInstanced (3D Lit).

Culzean 7 years ago updated 7 years ago 1

Nothing visible on screen but Standard Unity shader works. Unity 2017.1. Attempting to draw 128 copies of same mesh. This renders as expected using Unity Standard shader, however the most basic 3D shader generated from Shader Forge displays nothing, all settings are default and instancing is enabled on both the shader and material. I wish to adapt an more complex shader but cannot understand what is breaking this from the generated shaders.


Thanks


Daniel

ok it needs a few extra lines for this batching to work,
#pragma multi_compile_instancing
            struct VertexInput {
                ...
                UNITY_VERTEX_INPUT_INSTANCE_ID
            };
            struct VertexOutput {
                ...
                UNITY_VERTEX_INPUT_INSTANCE_ID
            };
VertexOutput vert (VertexInput v) {
                VertexOutput o = (VertexOutput)0;
                ...
                UNITY_SETUP_INSTANCE_ID(v);
                UNITY_TRANSFER_INSTANCE_ID(v, o);
                float3 lightColor = _LightColor0.rgb;
                o.pos = UnityObjectToClipPos( v.vertex );
                UNITY_TRANSFER_FOG(o,o.pos);
                return o;
            }
Possibly this is working as intended, but I was under the impression enable instancing option would add these lines or something similar.