MCPcopy Create free account
hub / github.com/carbonengine/trinity / SetupScreenSpaceSubSurfaceScattering

Method SetupScreenSpaceSubSurfaceScattering

trinity/Tr2SSSSS.cpp:66–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66void Tr2SSSSS::SetupScreenSpaceSubSurfaceScattering( Tr2RenderContext& renderContext, ITriRenderBatchAccumulator* batches, const Tr2TextureAL& colorMap, const Tr2TextureAL& opaqueColorMap, const Tr2TextureAL& depthMap, Tr2GpuResourcePool& gpuResourcePool )
67{
68 CCP_STATS_ZONE( __FUNCTION__ );
69
70 if( !m_enabled )
71 {
72 return;
73 }
74
75 static const auto SSSSS = BlueSharedString( "SSSSS" );
76 m_hasSSSSSInScene = renderContext.TechniqueInBatch( batches->GetGdprBatches(), SSSSS ) || renderContext.TechniqueInBatch( batches->GetBatches(), SSSSS );
77 if( !m_hasSSSSSInScene )
78 {
79 return;
80 }
81
82 auto seprableSpecularColorMap = gpuResourcePool.GetTempTexture( "SeprableSpecularColorMap", colorMap.GetWidth(), colorMap.GetHeight(), ImageIO::PIXEL_FORMAT_R16G16B16A16_FLOAT, Tr2GpuUsage::RENDER_TARGET | Tr2GpuUsage::SHADER_RESOURCE );
83 // Update RT
84 {
85 // Using depth stencil as shadow map
86 renderContext.m_esm.PushViewport();
87 renderContext.m_esm.PushRenderTarget( seprableSpecularColorMap );
88
89
90 renderContext.m_esm.UpdateRenderTargetViewport( seprableSpecularColorMap->GetWidth(), seprableSpecularColorMap->GetHeight() );
91
92 renderContext.Clear( CLEARFLAGS_TARGET, 0, 0, 0 );
93 }
94
95 // JKG need to confirm m_primaryBatches is a safe batch to render from
96 {
97 CCP_STATS_ZONE( "SeprableSpecularRendering" );
98
99 renderContext.m_esm.ApplyStandardStates( Tr2EffectStateManager::RM_OPAQUE );
100 renderContext.RenderBatches( batches, SSSSS );
101 }
102
103
104 // Reset render target back to OG
105 {
106 renderContext.m_esm.PopRenderTarget();
107 renderContext.m_esm.PopViewport();
108 }
109
110
111 // Setup the blur effect as well as the buffers required for the blur
112 if( m_screenSpaceSubSurfaceScatteringEffect == nullptr )
113 {
114 m_subSurfaceFrontScatterColorBuffer.CreateInstance();
115
116 // Currently we only have once instance of the front scatter data, this can be scaled in the future if needed
117 m_subSurfaceFrontScatterColorBuffer->Create( 1, sizeof( PerSubSurfaceFrontScatterData ), Tr2GpuBuffer::CPU_WRITABLE );
118 m_subSurfaceFrontScatterColorBuffer->SetName( "SubSurface Front Scatter Color Buffer" );
119
120 // Create and configure the basic effect settings
121 m_screenSpaceSubSurfaceScatteringEffect.CreateInstance();
122 m_screenSpaceSubSurfaceScatteringEffect->SetEffectPathName( "res:/Graphics/Effect/Managed/Space/SpaceObject/V5/PBR/Global/SSSSSBlur.fx" );
123 m_screenSpaceSubSurfaceScatteringEffect->SetParameter( BlueSharedString( "SubSurfaceFrontScatterColorBuffer" ), m_subSurfaceFrontScatterColorBuffer );

Callers 1

RenderMainPassMethod · 0.80

Calls 15

TechniqueInBatchMethod · 0.80
GetTempTextureMethod · 0.80
PushViewportMethod · 0.80
ApplyStandardStatesMethod · 0.80
RenderBatchesMethod · 0.80
PopViewportMethod · 0.80
CreateInstanceMethod · 0.80
SetEffectPathNameMethod · 0.80
StartUpdateMethod · 0.80
GetBatchesMethod · 0.45
GetWidthMethod · 0.45

Tested by

no test coverage detected