2014-03-14 14:13:41 -04:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
// File: LPVClear.usf
|
|
|
|
|
//
|
|
|
|
|
// Summary: Shader to clear an LPV volume
|
|
|
|
|
//
|
|
|
|
|
// Created: 2013-03-01
|
|
|
|
|
//
|
|
|
|
|
// Author: mailto:benwood@microsoft.com
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) Microsoft. All rights reserved.
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------------
|
|
|
|
|
Compile time parameters:
|
|
|
|
|
------------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#include "Common.usf"
|
|
|
|
|
#include "LPVWriteCommon.usf"
|
|
|
|
|
#include "LPVGeometryVolumeCommon.usf"
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
2015-05-15 18:54:37 -04:00
|
|
|
#define CLEAR_EDGES 0
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
[numthreads(4,4,4)]
|
|
|
|
|
void CSClear(uint3 DTid : SV_DispatchThreadID)
|
|
|
|
|
{
|
|
|
|
|
uint i = GetGridAddress( DTid );
|
|
|
|
|
|
|
|
|
|
#if REFINE_OVER_TIME
|
|
|
|
|
int3 idx = DTid;
|
|
|
|
|
int3 scrollVec = int3(LpvWrite.mOldGridOffset) - int3(LpvWrite.mLpvGridOffset);
|
|
|
|
|
idx += scrollVec;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float maxExtent = MaxGridExtent( (float3)idx );
|
|
|
|
|
float mul = PREV_FRAME_MULTIPLIER;
|
|
|
|
|
|
|
|
|
|
idx = clamp( idx, int3(0,0,0), int3(31,31,31) );
|
|
|
|
|
int sourceCell = GetGridAddress( idx );
|
|
|
|
|
|
|
|
|
|
LPVCell cell = ReadLpvCell( sourceCell );
|
|
|
|
|
|
|
|
|
|
mul *= LpvWrite.ClearMultiplier;
|
|
|
|
|
|
2015-05-15 18:54:37 -04:00
|
|
|
// corruption detection (workaround for brightlodge lighting corruption)
|
|
|
|
|
{
|
|
|
|
|
if ( isnan( cell.AO ) || isinf( cell.AO ) )
|
|
|
|
|
{
|
|
|
|
|
mul = 0.0f;
|
|
|
|
|
}
|
|
|
|
|
[unroll]
|
|
|
|
|
for ( int i=0; i<9; i++ )
|
|
|
|
|
{
|
|
|
|
|
float df = dot( cell.coeffs[i], float3(1.0f,1.0f,1.0f) );
|
|
|
|
|
if ( isnan( df ) || isinf( df ) )
|
|
|
|
|
{
|
|
|
|
|
mul = 0.0f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////@TODO: add a separate shader for this
|
2014-03-14 14:13:41 -04:00
|
|
|
[branch]
|
|
|
|
|
if ( mul == 0.0f ) // This is needed in order to fix QNANs
|
|
|
|
|
{
|
|
|
|
|
ClearCell( cell );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-05-15 18:54:37 -04:00
|
|
|
MultiplyCellCoeffs( cell, mul );
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
2015-05-15 18:54:37 -04:00
|
|
|
#if CLEAR_EDGES
|
|
|
|
|
if ( maxExtent > 13.5 && false )
|
|
|
|
|
{
|
|
|
|
|
ClearCell( cell );
|
|
|
|
|
cell.AO = 0.5;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
WriteLpvCell( cell, i );
|
|
|
|
|
|
|
|
|
|
#else // !REFINE_OVER_TIME
|
|
|
|
|
LPVCell cell;
|
|
|
|
|
ClearCell( cell );
|
|
|
|
|
WriteLpvCell( cell, i );
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
[numthreads(4,4,4)]
|
|
|
|
|
void CSClearGeometryVolume(uint3 DTid : SV_DispatchThreadID)
|
|
|
|
|
{
|
|
|
|
|
uint i = GetGridAddress( DTid );
|
|
|
|
|
ClearGvCell( i );
|
|
|
|
|
}
|