您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
37 行
1.3 KiB
37 行
1.3 KiB
#if SHADERPASS != SHADERPASS_FORWARD
|
|
#error SHADERPASS_is_not_correctly_define
|
|
#endif
|
|
|
|
void Frag( PackedVaryings packedInput,
|
|
out float4 outColor : SV_Target
|
|
#ifdef _DEPTHOFFSET_ON
|
|
, out float outputDepth : SV_Depth
|
|
#endif
|
|
)
|
|
{
|
|
FragInputs input = UnpackVaryings(packedInput);
|
|
|
|
// input.unPositionSS is SV_Position
|
|
PositionInputs posInput = GetPositionInput(input.unPositionSS.xy, _ScreenSize.zw);
|
|
UpdatePositionInput(input.unPositionSS.z, input.unPositionSS.w, input.positionWS, posInput);
|
|
float3 V = GetWorldSpaceNormalizeViewDir(input.positionWS);
|
|
|
|
SurfaceData surfaceData;
|
|
BuiltinData builtinData;
|
|
GetSurfaceAndBuiltinData(input, V, posInput, surfaceData, builtinData);
|
|
|
|
BSDFData bsdfData = ConvertSurfaceDataToBSDFData(surfaceData);
|
|
PreLightData preLightData = GetPreLightData(V, posInput, bsdfData);
|
|
|
|
float3 diffuseLighting;
|
|
float3 specularLighting;
|
|
float3 bakeDiffuseLighting = GetBakedDiffuseLigthing(surfaceData, builtinData, bsdfData, preLightData);
|
|
LightLoop(V, posInput, preLightData, bsdfData, bakeDiffuseLighting, diffuseLighting, specularLighting);
|
|
|
|
outColor = float4(diffuseLighting + specularLighting, builtinData.opacity);
|
|
|
|
#ifdef _DEPTHOFFSET_ON
|
|
outputDepth = posInput.rawDepth;
|
|
#endif
|
|
}
|
|
|