// after CGPROGRAM;#include "AutoLight.cginc" // in v2f struct;LIGHTING_COORDS(0) // replace 0 with the next available TEXCOORDs in your shader, don't put a semicolon at the end of this line. // in vert shader;TRANSFER_VERTEX_TO_FRAGMENT(o); // Calculates shadow and light attenuation and passes it to the frag shader. //in frag shader;float atten = LIGHT_ATTENUATION(i); // This is a float for your shadow/attenuation value, multiply your lighting value by this to get shadows.
自己写着色器的时候碰到一个问题,用了阴影三件套以后阴影还是会出现问题,具体表现是当画面中不存在使用原生材质的物体的时候,自定义着色器的阴影计算就会出现问题。
当sphere离开画面的时候,阴影计算就出错
经过排查,发现问题出在Screen Space Shadows上,当相机离得远了以后这张图就获取不到了。