

RSS Feed
Indie On the Loose Blog
Unity's Reflective/Diffuse broken -- here's the fix.
The Reflective/Diffuse shader shipping with Unity 2.6.0 (haven't checked 2.6.1 just yet) does not work properly when the object is lit exclusively with vertex lighting. Here's how you fix it -- it's just one line.
Shader "MrJoy/Reflective/Diffuse" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_ReflectColor ("Reflection Color", Color) = (1,1,1,0.5)
_MainTex ("Base (RGB) RefStrength (A)", 2D) = "white" {}
_Cube ("Reflection Cubemap", Cube) = "_Skybox" { TexGen CubeReflect }
}
SubShader {
LOD 200
Tags { "RenderType"="Opaque" }
UsePass "Reflective/VertexLit/BASE"
UsePass "Reflective/VertexLit/" // <-- This is the new line.
UsePass "Diffuse/PPL"
}
FallBack "Reflective/VertexLit", 1
}
Basically, the Reflective/VertexLit shader has TWO passes, not ONE and the Diffuse shader is only including the first one -- the one used for the reflective term. The additional line adds in the second pass, and all is well.
EDIT: This only resolves the case where the object is lit ONLY by vertex lighting. In the event of pixel + vertex lighting, it still behaves as if only the pixel light was hitting it. Bah. Will suss it out later.
Category: Indie On the Loose | Posted by: Sciandu on 2010-01-27 @ 22:24
