Skip to content

Commit

Permalink
Define GetDiffuseOrDefaultColor() for the Unlit BSDF to fix compilati… (
Browse files Browse the repository at this point in the history
#39)

* Define GetDiffuseOrDefaultColor() for the Unlit BSDF to fix compilation errors in Unlit shaders in the DynamicGIDataSample pass.

* Define DynamicGIDataSample pass for AxF and Unlit shaders. Remove now unnecessary #if UNLIT define in ShaderPassDynamicGIDataSample.

Co-authored-by: pastasfuture <nickb@bonfirestudios.com>
  • Loading branch information
pastasfuture and pastasfuture committed Oct 6, 2021
1 parent ff9abbb commit 84a6aa6
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,32 @@ Shader "HDRP/AxF"
ENDHLSL
}

Pass
{
Name "DynamicGIDataSample"
Tags{ "LightMode" = "DynamicGIDataSample" }

Cull Off

HLSLPROGRAM

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch

#pragma multi_compile _ HIGH_DEFINITION_EXTENSIONS_ENABLED

#define SHADERPASS SHADERPASS_DYNAMIC_GIDATA_SAMPLE
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/ShaderPass/AxFSharePass.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxFData.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDynamicGIDataSample.hlsl"

#pragma vertex Vert
#pragma fragment Frag

ENDHLSL
}

Pass
{
Name "ShadowCaster"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,8 @@ LightTransportData GetLightTransportData(SurfaceData surfaceData, BuiltinData bu

return lightTransportData;
}

float4 GetDiffuseOrDefaultColor(BSDFData bsdfData, float replace)
{
return float4(bsdfData.color, 0.0);
}
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,32 @@ Shader "HDRP/Unlit"
ENDHLSL
}

Pass
{
Name "DynamicGIDataSample"
Tags{ "LightMode" = "DynamicGIDataSample" }

Cull Off

HLSLPROGRAM

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch

#pragma multi_compile _ HIGH_DEFINITION_EXTENSIONS_ENABLED

#define SHADERPASS SHADERPASS_DYNAMIC_GIDATA_SAMPLE
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/Unlit.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/ShaderPass/UnlitSharePass.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/UnlitData.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDynamicGIDataSample.hlsl"

#pragma vertex Vert
#pragma fragment Frag

ENDHLSL
}

Pass
{
Name "ShadowCaster"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,8 @@ void Frag( Varyings varInput,
GetSurfaceAndBuiltinData(input, V, posInput, surfaceData, builtinData);

float3 outAlbedo = float3(0,1,0);
#ifdef UNLIT
outAlbedo.xyz = surfaceData.color;
#else
BSDFData bsdfData = ConvertSurfaceDataToBSDFData(input.positionSS.xy, surfaceData);
outAlbedo.xyz = GetDiffuseOrDefaultColor(bsdfData, 1.0).xyz;
#endif

// Output
ExtraDataRequestOutput output;
Expand Down

0 comments on commit 84a6aa6

Please sign in to comment.