Skip to content

Commit af2751e

Browse files
GLTF Viewer: use specular IBL with SSR
1 parent 05bbb5e commit af2751e

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

Samples/GLTFViewer/assets/shaders/ApplyPostEffects.psh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ cbuffer cbFrameAttribs
1515
Texture2D<float4> g_tex2DRadiance;
1616
Texture2D<float4> g_tex2DNormal;
1717
Texture2D<float4> g_tex2DSSR;
18-
Texture2D<float4> g_tex2DIBL;
18+
Texture2D<float4> g_tex2DSpecularIBL;
1919
Texture2D<float4> g_tex2DMaterialData;
2020
Texture2D<float4> g_tex2DBaseColor;
2121

@@ -27,7 +27,7 @@ float4 main(in FullScreenTriangleVSOutput VSOut) : SV_Target
2727
float4 OutColor = g_tex2DRadiance.Load(int3(VSOut.f4PixelPos.xy, 0));
2828
float3 Normal = g_tex2DNormal.Load(int3(VSOut.f4PixelPos.xy, 0)).xyz;
2929
float4 SSRRadiance = g_tex2DSSR.Load(int3(VSOut.f4PixelPos.xy, 0));
30-
float4 IBL = g_tex2DIBL.Load(int3(VSOut.f4PixelPos.xy, 0));
30+
float4 SpecularIBL = g_tex2DSpecularIBL.Load(int3(VSOut.f4PixelPos.xy, 0));
3131
float4 BaseColor = g_tex2DBaseColor.Load(int3(VSOut.f4PixelPos.xy, 0));
3232
float4 Material = g_tex2DMaterialData.Load(int3(VSOut.f4PixelPos.xy, 0));
3333

@@ -51,7 +51,7 @@ float4 main(in FullScreenTriangleVSOutput VSOut) : SV_Target
5151

5252
if (DebugMode == 0.0)
5353
{
54-
OutColor.rgb += (SSR.rgb - IBL.rgb) * SSRRadiance.w * OutColor.a * SSRScale;
54+
OutColor.rgb += (SSR.rgb - SpecularIBL.rgb) * SSRRadiance.w * OutColor.a * SSRScale;
5555
}
5656
else if (DebugMode == 1.0)
5757
{

Samples/GLTFViewer/src/GLTFViewer.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ struct PSOutput
355355
float4 BaseColor : SV_Target2;
356356
float4 MaterialData : SV_Target3;
357357
float4 MotionVec : SV_Target4;
358-
float4 IBL : SV_Target5;
358+
float4 SpecularIBL : SV_Target5;
359359
};
360360
)";
361361

@@ -367,15 +367,15 @@ struct PSOutput
367367
PSOut.Normal = float4(0.0, 0.0, 0.0, 0.0);
368368
PSOut.MaterialData = float4(0.0, 0.0, 0.0, 0.0);
369369
PSOut.BaseColor = float4(0.0, 0.0, 0.0, 0.0);
370-
PSOut.IBL = float4(0.0, 0.0, 0.0, 0.0);
370+
PSOut.SpecularIBL = float4(0.0, 0.0, 0.0, 0.0);
371371
}
372372
# else
373373
{
374374
PSOut.Color = OutColor;
375375
PSOut.Normal.xyz = Shading.BaseLayer.Normal.xyz;
376376
PSOut.MaterialData.xyz = float3(Shading.BaseLayer.Srf.PerceptualRoughness, Shading.BaseLayer.Metallic, 0.0);
377377
PSOut.BaseColor.xyz = BaseColor.xyz;
378-
PSOut.IBL.xyz = GetBaseLayerIBL(Shading, SrfLighting);
378+
PSOut.SpecularIBL.xyz = GetBaseLayerSpecularIBL(Shading, SrfLighting);
379379
380380
# if ENABLE_CLEAR_COAT
381381
{
@@ -391,8 +391,8 @@ struct PSOutput
391391
// Note that the base layer IBL is weighted by (1.0 - Shading.Clearcoat.Factor * ClearcoatFresnel).
392392
// Here we are weighting it by (1.0 - Shading.Clearcoat.Factor), which is always smaller,
393393
// so when we subtract the IBL, it can never be negative.
394-
PSOut.IBL.xyz = lerp(
395-
PSOut.IBL.xyz,
394+
PSOut.SpecularIBL.xyz = lerp(
395+
PSOut.SpecularIBL.xyz,
396396
GetClearcoatIBL(Shading, SrfLighting),
397397
Shading.Clearcoat.Factor);
398398
}
@@ -401,7 +401,7 @@ struct PSOutput
401401
// Blend material data and IBL with background
402402
PSOut.BaseColor = float4(PSOut.BaseColor.xyz * BaseColor.a, BaseColor.a);
403403
PSOut.MaterialData = float4(PSOut.MaterialData.xyz * BaseColor.a, BaseColor.a);
404-
PSOut.IBL = float4(PSOut.IBL.xyz * BaseColor.a, BaseColor.a);
404+
PSOut.SpecularIBL = float4(PSOut.SpecularIBL.xyz * BaseColor.a, BaseColor.a);
405405
406406
// Do not blend motion vectors as it does not make sense
407407
PSOut.MotionVec = float4(MotionVector, 0.0, 1.0);
@@ -425,15 +425,15 @@ void main(in float4 Pos : SV_Position,
425425
out float4 BaseColor : SV_Target2,
426426
out float4 MaterialData : SV_Target3,
427427
out float4 MotionVec : SV_Target4,
428-
out float4 IBL : SV_Target5)
428+
out float4 SpecularIBL : SV_Target5)
429429
{
430430
Color = SampleEnvMap(ClipPos);
431431
432432
Normal = float4(0.0, 0.0, 0.0, 0.0);
433433
BaseColor = float4(0.0, 0.0, 0.0, 0.0);
434434
MaterialData = float4(0.0, 0.0, 0.0, 0.0);
435435
MotionVec = float4(0.0, 0.0, 0.0, 0.0);
436-
IBL = float4(0.0, 0.0, 0.0, 0.0);
436+
SpecularIBL = float4(0.0, 0.0, 0.0, 0.0);
437437
}
438438
)";
439439

@@ -699,7 +699,7 @@ void GLTFViewer::ApplyPosteffects::Initialize(IRenderDevice* pDevice, TEXTURE_FO
699699
ptex2DRadianceVar = GetVariable("g_tex2DRadiance");
700700
ptex2DNormalVar = GetVariable("g_tex2DNormal");
701701
ptex2DSSR = GetVariable("g_tex2DSSR");
702-
ptex2DPecularIBL = GetVariable("g_tex2DIBL");
702+
ptex2DPecularIBL = GetVariable("g_tex2DSpecularIBL");
703703
ptex2DBaseColorVar = GetVariable("g_tex2DBaseColor");
704704
ptex2DMaterialDataVar = GetVariable("g_tex2DMaterialData");
705705
ptex2DPreintegratedGGXVar = GetVariable("g_tex2DPreintegratedGGX");

0 commit comments

Comments
 (0)