unity3D shader学习
网络信息汇总
unity内部阴影的使用
阴影的投射只要有shadow caster通道即可;
阴影接受的计算:
方法1
1 #pragma multi_compile_fwdbase 2 #include “AutoLight.cginc” 3 SHADOW_COORDS(1) // put shadows data into TEXCOORD1 4 TRANSFER_SHADOW(o) 5 fixed shadow = SHADOW_ATTENUATION(i);
方法2
#pragma multi_compile_fwdbase
// after CGPROGRAM;
#include "AutoLight.cginc"
// in v2f struct;
LIGHTING_COORDS(0,1) // replace 0 and 1 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. Replace i with whatever you've defined your input struct to be called (e.g. frag(v2f [b]i[/b]) : COLOR { ... ).
方法3
#pragma multi_compile_fwdbase #include "AutoLight.cginc" UNITY_LIGHTING_COORDS(6,7) UNITY_TRANSFER_LIGHTING(o, v.uv1); UNITY_LIGHT_ATTENUATION(atten, i, s.posWorld);
posted on 2020-10-27 10:17 鸟血惹人怜鱼伤无人知 阅读(122) 评论(0) 收藏 举报
浙公网安备 33010602011771号