Boat Attack使用了Universal RP的许多新图形功能,可以用于探索 Universal RP 的使用方式和技巧。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

63 行
2.1 KiB

void BuildInputData(Varyings input, float3 normal, out InputData inputData)
{
inputData.positionWS = input.positionWS;
#ifdef _NORMALMAP
inputData.normalWS = TransformTangentToWorld(normal,
half3x3(input.tangentWS.xyz, input.bitangentWS.xyz, input.normalWS.xyz));
#else
inputData.normalWS = input.normalWS;
#endif
inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS);
inputData.viewDirectionWS = SafeNormalize(input.viewDirectionWS);
inputData.shadowCoord = input.shadowCoord;
inputData.fogCoord = input.fogFactorAndVertexLight.x;
inputData.vertexLighting = input.fogFactorAndVertexLight.yzw;
inputData.bakedGI = SAMPLE_GI(input.lightmapUV, input.sh, inputData.normalWS);
}
PackedVaryings vert(Attributes input)
{
Varyings output = (Varyings)0;
output = BuildVaryings(input);
PackedVaryings packedOutput = (PackedVaryings)0;
packedOutput = PackVaryings(output);
return packedOutput;
}
half4 frag(PackedVaryings packedInput) : SV_TARGET
{
Varyings unpacked = UnpackVaryings(packedInput);
UNITY_SETUP_INSTANCE_ID(unpacked);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked);
SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked);
SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs);
#if _AlphaClip
clip(surfaceDescription.Alpha - surfaceDescription.AlphaClipThreshold);
#endif
InputData inputData;
BuildInputData(unpacked, surfaceDescription.Normal, inputData);
#ifdef _SPECULAR_SETUP
float3 specular = surfaceDescription.Specular;
float metallic = 1;
#else
float3 specular = 0;
float metallic = surfaceDescription.Metallic;
#endif
half4 color = UniversalFragmentPBR(
inputData,
surfaceDescription.Albedo,
metallic,
specular,
surfaceDescription.Smoothness,
surfaceDescription.Occlusion,
surfaceDescription.Emission,
surfaceDescription.Alpha);
color.rgb = MixFog(color.rgb, inputData.fogCoord);
return color;
}