浏览代码

Avoid the warning about division by 0

/main
Evgenii Golubev 7 年前
当前提交
f1b9bce7
共有 9 个文件被更改,包括 43 次插入18 次删除
  1. 15
      ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/FragInputs.hlsl
  2. 5
      ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl
  3. 5
      ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassDistortion.hlsl
  4. 5
      ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassForward.hlsl
  5. 5
      ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassForwardUnlit.hlsl
  6. 5
      ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl
  7. 8
      ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassLightTransport.hlsl
  8. 5
      ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassVelocity.hlsl
  9. 8
      ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/VaryingMesh.hlsl

15
ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/FragInputs.hlsl


bool isFrontFace;
};
// FragInputs use dir vector that are normalized in the code even if not used
// so we initialize them to a valid != 0 to shutdown compiler warning
FragInputs InitializeFragInputs()
{
FragInputs output;
ZERO_INITIALIZE(FragInputs, output);
// Init to some default value to make the computer quiet (else it output "divide by zero" warning even if value is not used).
output.worldToTangent[0] = float3(1, 0, 0);
output.worldToTangent[1] = float3(0, 1, 0);
output.worldToTangent[2] = float3(0, 0, 1);
return output;
}
void GetVaryingsDataDebug(uint paramId, FragInputs input, inout float3 result, inout bool needLinearToSRGB)
{
switch (paramId)

5
ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl


// input.positionSS is SV_Position
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw);
UpdatePositionInput(input.positionSS.z, input.positionSS.w, input.positionWS, posInput);
#ifdef VARYINGS_NEED_POSITION_WS
#else
float3 V = 0; // Avoid the division by 0
#endif
SurfaceData surfaceData;
BuiltinData builtinData;

5
ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassDistortion.hlsl


// input.positionSS is SV_Position
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw);
UpdatePositionInput(input.positionSS.z, input.positionSS.w, input.positionWS, posInput);
#ifdef VARYINGS_NEED_POSITION_WS
#else
float3 V = 0; // Avoid the division by 0
#endif
// Perform alpha testing + get distortion
SurfaceData surfaceData;

5
ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassForward.hlsl


// input.positionSS is SV_Position
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, uint2(input.positionSS.xy) / GetTileSize());
UpdatePositionInput(input.positionSS.z, input.positionSS.w, input.positionWS, posInput);
#ifdef VARYINGS_NEED_POSITION_WS
#else
float3 V = 0; // Avoid the division by 0
#endif
SurfaceData surfaceData;
BuiltinData builtinData;

5
ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassForwardUnlit.hlsl


// input.positionSS is SV_Position
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw);
UpdatePositionInput(input.positionSS.z, input.positionSS.w, input.positionWS, posInput);
#ifdef VARYINGS_NEED_POSITION_WS
#else
float3 V = 0; // Avoid the division by 0
#endif
SurfaceData surfaceData;
BuiltinData builtinData;

5
ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl


// input.positionSS is SV_Position
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw);
UpdatePositionInput(input.positionSS.z, input.positionSS.w, input.positionWS, posInput);
#ifdef VARYINGS_NEED_POSITION_WS
#else
float3 V = 0; // Avoid the division by 0
#endif
SurfaceData surfaceData;
BuiltinData builtinData;

8
ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassLightTransport.hlsl


// input.positionSS is SV_Position
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw);
UpdatePositionInput(input.positionSS.z, input.positionSS.w, input.positionWS, posInput);
// No position and depth in case of light transport
float3 V = float3(0.0, 0.0, 1.0); // No vector view in case of light transport
#ifdef VARYINGS_NEED_POSITION_WS
float3 V = GetWorldSpaceNormalizeViewDir(input.positionWS);
#else
float3 V = 0; // Avoid the division by 0
#endif
SurfaceData surfaceData;
BuiltinData builtinData;

5
ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassVelocity.hlsl


// input.positionSS is SV_Position
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw);
UpdatePositionInput(input.positionSS.z, input.positionSS.w, input.positionWS, posInput);
#ifdef VARYINGS_NEED_POSITION_WS
#else
float3 V = 0; // Avoid the division by 0
#endif
// Perform alpha testing + get velocity
SurfaceData surfaceData;

8
ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/VaryingMesh.hlsl


FragInputs UnpackVaryingsMeshToFragInputs(PackedVaryingsMeshToPS input)
{
FragInputs output = InitializeFragInputs();
FragInputs output;
ZERO_INITIALIZE(FragInputs, output);
// Init to some default value to make the computer quiet (else it output "divide by zero" warning even if value is not used).
// TODO: this is a really poor workaround, but the variable is used in a bunch of places
// to compute normals which are then passed on elsewhere to compute other values...
output.worldToTangent = k_identity3x3;
output.positionSS = input.positionCS; // input.positionCS is SV_Position

正在加载...
取消
保存