mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-04-24 10:38:53 +00:00
Synced with Steve's latest NVRHI code
This commit is contained in:
parent
67a5e99597
commit
6ae1f07e95
88 changed files with 1248 additions and 872 deletions
|
@ -9,4 +9,6 @@ astyle.exe -v --formatted --options=astyle-options.ini --recursive libs/tinyexr/
|
|||
|
||||
astyle.exe -v -Q --options=astyle-options.ini --recursive ../base/renderprogs/*.hlsl
|
||||
|
||||
astyle.exe -v -Q --options=astyle-options.ini --recursive shaders/*.hlsl
|
||||
|
||||
pause
|
2
neo/extern/nvrhi
vendored
2
neo/extern/nvrhi
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 997ee5a9f3972d586f9d2474f5c2f05391952a0b
|
||||
Subproject commit 78da052111878d8d7552205f21551d030e71213c
|
|
@ -108,6 +108,7 @@ enum textureFormat_t
|
|||
FMT_R8,
|
||||
FMT_DEPTH_STENCIL, // 32 bpp
|
||||
// RB end
|
||||
FMT_SRGB8,
|
||||
};
|
||||
|
||||
int BitsForFormat( textureFormat_t format );
|
||||
|
@ -237,7 +238,8 @@ typedef enum
|
|||
TD_R11G11B10F, // memory efficient HDR RGB format with only 32bpp
|
||||
// RB end
|
||||
TD_R8F, // Stephen: Added for ambient occlusion render target.
|
||||
TD_DEPTH_STENCIL, // depth buffer and stencil buffer
|
||||
TD_LDR, // Stephen: Added for SRGB render target when tonemapping.
|
||||
TD_DEPTH_STENCIL,
|
||||
} textureUsage_t;
|
||||
|
||||
typedef enum
|
||||
|
|
|
@ -345,14 +345,18 @@ static void R_FlatNormalImage( idImage* image, nvrhi::ICommandList* commandList
|
|||
byte data[DEFAULT_SIZE][DEFAULT_SIZE][4];
|
||||
|
||||
// flat normal map for default bump mapping
|
||||
for( int i = 0 ; i < 4 ; i++ )
|
||||
for( int i = 0; i < DEFAULT_SIZE; i++ )
|
||||
{
|
||||
data[0][i][0] = 128;
|
||||
data[0][i][1] = 128;
|
||||
data[0][i][2] = 255;
|
||||
data[0][i][3] = 255;
|
||||
for( int j = 0; j < DEFAULT_SIZE; j++ )
|
||||
{
|
||||
data[j][i][0] = 128;
|
||||
data[j][i][1] = 128;
|
||||
data[j][i][2] = 255;
|
||||
data[j][i][3] = 255;
|
||||
}
|
||||
}
|
||||
image->GenerateImage( ( byte* )data, 4, 4, TF_DEFAULT, TR_REPEAT, TD_BUMP, commandList );
|
||||
|
||||
image->GenerateImage( ( byte* )data, 16, 16, TF_DEFAULT, TR_REPEAT, TD_BUMP, commandList );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -955,8 +959,8 @@ static void R_CreateImGuiFontImage( idImage* image, nvrhi::ICommandList* command
|
|||
image->GenerateImage( ( byte* )pixels, width, height, TF_LINEAR, TR_CLAMP, TD_LOOKUP_TABLE_RGBA, commandList );
|
||||
|
||||
// Store our identifier
|
||||
io.Fonts->TexID = ( void* )( intptr_t )image->GetImGuiTextureID();
|
||||
//io.Fonts->TexID = ( void* )( intptr_t )declManager->FindMaterial( "_imguiFont" );
|
||||
//io.Fonts->TexID = ( void* )( intptr_t )image->GetImGuiTextureID();
|
||||
io.Fonts->TexID = ( void* )( intptr_t )declManager->FindMaterial( "_imguiFont" );
|
||||
|
||||
// Cleanup (don't clear the input data if you want to append new fonts later)
|
||||
//io.Fonts->ClearInputData();
|
||||
|
|
|
@ -2145,7 +2145,8 @@ void idMaterial::ParseStage( idLexer& src, const textureRepeat_t trpDefault )
|
|||
{
|
||||
if( src.ReadTokenOnLine( &token ) )
|
||||
{
|
||||
newStage.fragmentProgram = renderProgManager.FindShader( token.c_str(), SHADER_STAGE_FRAGMENT );
|
||||
idList<shaderMacro_t> macros = { { "USE_GPU_SKINNING", "0" } };
|
||||
newStage.fragmentProgram = renderProgManager.FindShader( token.c_str(), SHADER_STAGE_FRAGMENT, "", macros, false );
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -2153,7 +2154,8 @@ void idMaterial::ParseStage( idLexer& src, const textureRepeat_t trpDefault )
|
|||
{
|
||||
if( src.ReadTokenOnLine( &token ) )
|
||||
{
|
||||
newStage.vertexProgram = renderProgManager.FindShader( token.c_str(), SHADER_STAGE_VERTEX );
|
||||
idList<shaderMacro_t> macros = { { "USE_GPU_SKINNING", "0" } };
|
||||
newStage.vertexProgram = renderProgManager.FindShader( token.c_str(), SHADER_STAGE_VERTEX, "", macros, false );
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -127,8 +127,12 @@ void Framebuffer::ResizeFramebuffers()
|
|||
{
|
||||
globalImages->shadowImage[i]->Reload( false, tr.backend.commandList );
|
||||
}
|
||||
tr.backend.commandList->close();
|
||||
deviceManager->GetDevice()->executeCommandList( tr.backend.commandList );
|
||||
for( int i = 0; i < MAX_BLOOM_BUFFERS; i++ )
|
||||
{
|
||||
globalImages->bloomRenderImage[i]->Reload( false, tr.backend.commandList );
|
||||
}
|
||||
tr.backend.commandList->close( );
|
||||
deviceManager->GetDevice( )->executeCommandList( tr.backend.commandList );
|
||||
|
||||
for( uint32_t index = 0; index < backBufferCount; index++ )
|
||||
{
|
||||
|
@ -203,10 +207,17 @@ void Framebuffer::ResizeFramebuffers()
|
|||
nvrhi::FramebufferDesc()
|
||||
.addColorAttachment( globalImages->smaaBlendImage->texture ) );
|
||||
|
||||
Framebuffer::Unbind();
|
||||
for( int i = 0; i < MAX_BLOOM_BUFFERS; i++ )
|
||||
{
|
||||
globalFramebuffers.bloomRenderFBO[i] = new Framebuffer( va( "_bloomRender%i", i ),
|
||||
nvrhi::FramebufferDesc()
|
||||
.addColorAttachment( globalImages->bloomRenderImage[i]->texture ) );
|
||||
}
|
||||
|
||||
Framebuffer::Unbind( );
|
||||
}
|
||||
|
||||
void Framebuffer::Bind()
|
||||
void Framebuffer::Bind( )
|
||||
{
|
||||
RENDERLOG_PRINTF( "Framebuffer::Bind( %s )\n", fboName.c_str() );
|
||||
|
||||
|
@ -215,6 +226,7 @@ void Framebuffer::Bind()
|
|||
tr.backend.currentPipeline = nullptr;
|
||||
}
|
||||
|
||||
tr.backend.lastFrameBuffer = tr.backend.currentFrameBuffer;
|
||||
tr.backend.currentFrameBuffer = this;
|
||||
}
|
||||
|
||||
|
|
|
@ -257,19 +257,19 @@ void idImage::AllocImage()
|
|||
break;
|
||||
|
||||
case FMT_ALPHA:
|
||||
format = nvrhi::Format::R8_UINT;
|
||||
format = nvrhi::Format::R8_UNORM;
|
||||
break;
|
||||
|
||||
case FMT_L8A8:
|
||||
format = nvrhi::Format::RG8_UINT;
|
||||
format = nvrhi::Format::RG8_UNORM;
|
||||
break;
|
||||
|
||||
case FMT_LUM8:
|
||||
format = nvrhi::Format::R8_UINT;
|
||||
format = nvrhi::Format::R8_UNORM;
|
||||
break;
|
||||
|
||||
case FMT_INT8:
|
||||
format = nvrhi::Format::R8_UINT;
|
||||
format = nvrhi::Format::R8_UNORM;
|
||||
break;
|
||||
|
||||
case FMT_R8:
|
||||
|
@ -329,6 +329,10 @@ void idImage::AllocImage()
|
|||
format = nvrhi::Format::R11G11B10_FLOAT;
|
||||
break;
|
||||
|
||||
case FMT_SRGB8:
|
||||
format = nvrhi::Format::SRGBA8_UNORM;
|
||||
break;
|
||||
|
||||
default:
|
||||
idLib::Error( "Unhandled image format %d in %s\n", opts.format, GetName() );
|
||||
}
|
||||
|
@ -383,6 +387,44 @@ void idImage::AllocImage()
|
|||
.setSampleCount( opts.samples )
|
||||
.setMipLevels( opts.numLevels );
|
||||
|
||||
#if 0
|
||||
if( opts.colorFormat == CFM_GREEN_ALPHA )
|
||||
{
|
||||
textureDesc.componentMapping.bits.r = 5;
|
||||
textureDesc.componentMapping.bits.g = 5;
|
||||
textureDesc.componentMapping.bits.b = 5;
|
||||
textureDesc.componentMapping.bits.a = 1;
|
||||
}
|
||||
else if( opts.format == FMT_LUM8 )
|
||||
{
|
||||
textureDesc.componentMapping.bits.r = 0;
|
||||
textureDesc.componentMapping.bits.g = 0;
|
||||
textureDesc.componentMapping.bits.b = 0;
|
||||
textureDesc.componentMapping.bits.a = 5;
|
||||
}
|
||||
else if( opts.format == FMT_L8A8 )//|| opts.format == FMT_RG16F )
|
||||
{
|
||||
textureDesc.componentMapping.bits.r = 0;
|
||||
textureDesc.componentMapping.bits.g = 0;
|
||||
textureDesc.componentMapping.bits.b = 0;
|
||||
textureDesc.componentMapping.bits.a = 1;
|
||||
}
|
||||
else if( opts.format == FMT_ALPHA )
|
||||
{
|
||||
textureDesc.componentMapping.bits.r = 5;
|
||||
textureDesc.componentMapping.bits.g = 5;
|
||||
textureDesc.componentMapping.bits.b = 5;
|
||||
textureDesc.componentMapping.bits.a = 0;
|
||||
}
|
||||
else if( opts.format == FMT_INT8 )
|
||||
{
|
||||
textureDesc.componentMapping.bits.r = 0;
|
||||
textureDesc.componentMapping.bits.g = 0;
|
||||
textureDesc.componentMapping.bits.b = 0;
|
||||
textureDesc.componentMapping.bits.a = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if( opts.isRenderTarget )
|
||||
{
|
||||
//textureDesc.keepInitialState = true;
|
||||
|
|
|
@ -720,7 +720,8 @@ void idRenderBackend::DrawElementsWithCounters( const drawSurf_t* surf )
|
|||
.addItem( nvrhi::BindingSetItem::Texture_SRV( 5, ( nvrhi::ITexture* )GetImageAt( 5 )->GetTextureID() ) )
|
||||
.addItem( nvrhi::BindingSetItem::Texture_SRV( 6, ( nvrhi::ITexture* )GetImageAt( 6 )->GetTextureID() ) )
|
||||
.addItem( nvrhi::BindingSetItem::Sampler( 0, commonPasses.m_AnisotropicWrapSampler ) )
|
||||
.addItem( nvrhi::BindingSetItem::Sampler( 1, commonPasses.m_LinearWrapSampler ) );
|
||||
.addItem( nvrhi::BindingSetItem::Sampler( 1, commonPasses.m_LinearClampSampler ) )
|
||||
.addItem( nvrhi::BindingSetItem::Sampler( 2, commonPasses.m_LinearClampCompareSampler ) );
|
||||
}
|
||||
else if( renderProgManager.BindingLayoutType() == BINDING_LAYOUT_DRAW_FOG )
|
||||
{
|
||||
|
@ -748,7 +749,7 @@ void idRenderBackend::DrawElementsWithCounters( const drawSurf_t* surf )
|
|||
currentBindingSet = bindingCache.GetOrCreateBindingSet( bindingSetDesc, renderProgManager.BindingLayout() );
|
||||
renderProgManager.CommitConstantBuffer( commandList );
|
||||
|
||||
PipelineKey key{ glStateBits, renderProgManager.CurrentProgram(), viewDef->isMirror, currentFrameBuffer };
|
||||
PipelineKey key{ glStateBits, renderProgManager.CurrentProgram(), viewDef->isMirror, depthBias, slopeScaleBias, currentFrameBuffer };
|
||||
auto pipeline = pipelineCache.GetOrCreatePipeline( key );
|
||||
|
||||
nvrhi::GraphicsState state;
|
||||
|
@ -765,7 +766,11 @@ void idRenderBackend::DrawElementsWithCounters( const drawSurf_t* surf )
|
|||
currentViewport.zmin,
|
||||
currentViewport.zmax };
|
||||
state.viewport.addViewportAndScissorRect( viewport );
|
||||
state.viewport.addScissorRect( nvrhi::Rect( currentScissor.x1, currentScissor.y1, currentScissor.x2, currentScissor.y2 ) );
|
||||
|
||||
if( !currentScissor.IsEmpty( ) )
|
||||
{
|
||||
state.viewport.addScissorRect( nvrhi::Rect( currentScissor.x1, currentScissor.x2, currentScissor.y1, currentScissor.y2 ) );
|
||||
}
|
||||
|
||||
commandList->setGraphicsState( state );
|
||||
|
||||
|
@ -1288,9 +1293,9 @@ idRenderBackend::GL_Scissor
|
|||
void idRenderBackend::GL_Scissor( int x /* left*/, int y /* bottom */, int w, int h )
|
||||
{
|
||||
// TODO Check if this is right.
|
||||
currentScissor.Clear();
|
||||
currentScissor.AddPoint( x, y );
|
||||
currentScissor.AddPoint( x + w, y + h );
|
||||
//currentScissor.Clear( );
|
||||
//currentScissor.AddPoint( x, y );
|
||||
//currentScissor.AddPoint( x + w, y + h );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1323,20 +1328,19 @@ idRenderBackend::GL_DepthBoundsTest
|
|||
*/
|
||||
void idRenderBackend::GL_DepthBoundsTest( const float zmin, const float zmax )
|
||||
{
|
||||
if( !glConfig.depthBoundsTestAvailable || zmin > zmax )
|
||||
if( /*!glConfig.depthBoundsTestAvailable || */zmin > zmax )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//if( zmin == 0.0f && zmax == 0.0f )
|
||||
//{
|
||||
// glDisable( GL_DEPTH_BOUNDS_TEST_EXT );
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// glEnable( GL_DEPTH_BOUNDS_TEST_EXT );
|
||||
// glDepthBoundsEXT( zmin, zmax );
|
||||
//}
|
||||
if( zmin == 0.0f && zmax == 0.0f )
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
currentViewport.zmin = zmin;
|
||||
currentViewport.zmax = zmax;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1728,4 +1732,9 @@ void idRenderBackend::BindProgram( nvrhi::ShaderHandle vShader, nvrhi::ShaderHan
|
|||
|
||||
// reset the pipeline.
|
||||
currentPipeline = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void idRenderBackend::ResetPipelineCache()
|
||||
{
|
||||
pipelineCache.Clear();
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
||||
Copyright (C) 2013-2018 Robert Beckebans
|
||||
Copyright (C) 2016-2017 Dustin Land
|
||||
Copyright (C) 2022 Stephen Pridham
|
||||
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
|
||||
|
@ -129,7 +129,6 @@ void idRenderProgManager::LoadShader( shader_t& shader )
|
|||
|
||||
idStr adjustedName = shader.name;
|
||||
adjustedName.StripFileExtension();
|
||||
//adjustedName.StripPath();
|
||||
adjustedName = idStr( "renderprogs/dxil/" ) + adjustedName + "." + stage + ".bin";
|
||||
|
||||
ShaderBlob shaderBlob = GetBytecode( adjustedName );
|
||||
|
@ -150,7 +149,7 @@ void idRenderProgManager::LoadShader( shader_t& shader )
|
|||
}
|
||||
|
||||
nvrhi::ShaderDesc desc = nvrhi::ShaderDesc( shaderType );
|
||||
desc.debugName = shader.name;
|
||||
desc.debugName = ( idStr( shader.name ) + idStr( shader.nameOutSuffix ) ).c_str();
|
||||
|
||||
nvrhi::ShaderDesc descCopy = desc;
|
||||
// TODO(Stephen): Might not want to hard-code this.
|
||||
|
@ -172,7 +171,7 @@ ShaderBlob idRenderProgManager::GetBytecode( const char* fileName )
|
|||
|
||||
if( !blob.data )
|
||||
{
|
||||
//common->Error( "Couldn't read the binary file for shader %s", fileName);
|
||||
common->FatalError( "Couldn't read the binary file for shader %s", fileName );
|
||||
}
|
||||
|
||||
return blob;
|
||||
|
@ -198,6 +197,20 @@ void idRenderProgManager::LoadProgram( const int programIndex, const int vertexS
|
|||
prog.bindingLayout = bindingLayouts[prog.bindingLayoutType];
|
||||
}
|
||||
|
||||
void idRenderProgManager::LoadComputeProgram( const int programIndex, const int computeShaderIndex )
|
||||
{
|
||||
renderProg_t& prog = renderProgs[programIndex];
|
||||
prog.computeShaderIndex = computeShaderIndex;
|
||||
if( prog.vertexLayout != LAYOUT_UNKNOWN )
|
||||
{
|
||||
prog.inputLayout = device->createInputLayout(
|
||||
&vertexLayoutDescs[prog.vertexLayout][0],
|
||||
vertexLayoutDescs[prog.vertexLayout].Num( ),
|
||||
shaders[prog.vertexShaderIndex].handle );
|
||||
}
|
||||
prog.bindingLayout = bindingLayouts[prog.bindingLayoutType];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================================================================================================
|
||||
|
@ -241,7 +254,9 @@ void idRenderProgManager::KillAllShaders()
|
|||
{
|
||||
Unbind();
|
||||
|
||||
for( int i = 0; i < shaders.Num(); i++ )
|
||||
tr.backend.ResetPipelineCache();
|
||||
|
||||
for( int i = 0; i < shaders.Num( ); i++ )
|
||||
{
|
||||
if( shaders[i].handle )
|
||||
{
|
||||
|
|
|
@ -76,6 +76,9 @@ void CommonRenderPasses::Init( nvrhi::IDevice* device )
|
|||
samplerDesc.setAllFilters( true );
|
||||
m_LinearClampSampler = m_Device->createSampler( samplerDesc );
|
||||
|
||||
samplerDesc.setReductionType( nvrhi::SamplerReductionType::Comparison );
|
||||
m_LinearClampCompareSampler = m_Device->createSampler( samplerDesc );
|
||||
|
||||
samplerDesc.setAllAddressModes( nvrhi::SamplerAddressMode::Wrap );
|
||||
m_LinearWrapSampler = m_Device->createSampler( samplerDesc );
|
||||
|
||||
|
|
|
@ -124,6 +124,7 @@ public:
|
|||
|
||||
nvrhi::SamplerHandle m_PointClampSampler;
|
||||
nvrhi::SamplerHandle m_LinearClampSampler;
|
||||
nvrhi::SamplerHandle m_LinearClampCompareSampler;
|
||||
nvrhi::SamplerHandle m_LinearWrapSampler;
|
||||
nvrhi::SamplerHandle m_AnisotropicWrapSampler;
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ protected:
|
|||
BindingCache bindingCache;
|
||||
Framebuffer* previousFramebuffer;
|
||||
Framebuffer* currentFramebuffer;
|
||||
Framebuffer* lastFramebuffer;
|
||||
const viewDef_t* viewDef;
|
||||
const viewEntity_t* currentSpace;
|
||||
idScreenRect currentViewport;
|
||||
|
|
|
@ -40,8 +40,16 @@ nvrhi::GraphicsPipelineHandle PipelineCache::GetOrCreatePipeline( const Pipeline
|
|||
pipelineDesc.inputLayout = progInfo.inputLayout;
|
||||
pipelineDesc.bindingLayouts = { progInfo.bindingLayout };
|
||||
pipelineDesc.primType = nvrhi::PrimitiveType::TriangleList;
|
||||
|
||||
// Set up default state.
|
||||
pipelineDesc.renderState.rasterState.enableScissor( );
|
||||
pipelineDesc.renderState.depthStencilState.enableDepthTest( ).enableDepthWrite( );
|
||||
pipelineDesc.renderState.blendState.targets[0].enableBlend( );
|
||||
//pipelineDesc.renderState.rasterState.enableDepthClip( );
|
||||
pipelineDesc.renderState.rasterState.depthBias = 0;
|
||||
pipelineDesc.renderState.rasterState.slopeScaledDepthBias = 0;
|
||||
|
||||
// Specialize the state with the state key.
|
||||
GetRenderState( key.state, key, pipelineDesc.renderState );
|
||||
|
||||
auto pipeline = device->createGraphicsPipeline( pipelineDesc, key.framebuffer->GetApiObject( ) );
|
||||
|
@ -54,7 +62,12 @@ nvrhi::GraphicsPipelineHandle PipelineCache::GetOrCreatePipeline( const Pipeline
|
|||
|
||||
void GetRenderState( uint64 stateBits, PipelineKey key, nvrhi::RenderState& renderState )
|
||||
{
|
||||
uint64 diff = 0xFFFFFFFFFFFFFFFF;
|
||||
uint64 diff = stateBits ^ GLS_DEFAULT;
|
||||
|
||||
if( diff == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto& currentBlendState = renderState.blendState;
|
||||
auto& currentDepthStencilState = renderState.depthStencilState;
|
||||
|
@ -245,6 +258,7 @@ void GetRenderState( uint64 stateBits, PipelineKey key, nvrhi::RenderState& rend
|
|||
mask = mask & ~nvrhi::ColorMask::Alpha;
|
||||
}
|
||||
|
||||
renderTarget.enableBlend( );
|
||||
renderTarget.setColorWriteMask( mask );
|
||||
}
|
||||
|
||||
|
@ -257,13 +271,13 @@ void GetRenderState( uint64 stateBits, PipelineKey key, nvrhi::RenderState& rend
|
|||
{
|
||||
if( stateBits & GLS_POLYMODE_LINE )
|
||||
{
|
||||
currentRasterState.setFillMode( nvrhi::RasterFillMode::Line );
|
||||
currentRasterState.setCullNone( );
|
||||
currentRasterState.setFillMode( nvrhi::RasterFillMode::Wireframe );
|
||||
//currentRasterState.setCullNone( );
|
||||
}
|
||||
else
|
||||
{
|
||||
currentRasterState.setCullNone( );
|
||||
currentRasterState.setFillMode( nvrhi::RasterFillMode::Fill );
|
||||
//currentRasterState.setCullNone( );
|
||||
currentRasterState.setFillMode( nvrhi::RasterFillMode::Solid );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -274,11 +288,13 @@ void GetRenderState( uint64 stateBits, PipelineKey key, nvrhi::RenderState& rend
|
|||
{
|
||||
if( stateBits & GLS_POLYGON_OFFSET )
|
||||
{
|
||||
currentRasterState.enableQuadFill( );
|
||||
currentRasterState.depthBias = key.depthBias;
|
||||
currentRasterState.slopeScaledDepthBias = key.slopeBias;
|
||||
currentRasterState.enableQuadFill();
|
||||
}
|
||||
else
|
||||
{
|
||||
currentRasterState.disableQuadFill( );
|
||||
//currentRasterState.disableQuadFill();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ struct PipelineKey
|
|||
uint64 state;
|
||||
int program;
|
||||
bool mirrored;
|
||||
int depthBias;
|
||||
float slopeBias;
|
||||
|
||||
Framebuffer* framebuffer;
|
||||
};
|
||||
|
@ -16,7 +18,9 @@ inline bool operator==( const PipelineKey& lhs, const PipelineKey& rhs )
|
|||
return lhs.state == rhs.state &&
|
||||
lhs.program == rhs.program &&
|
||||
lhs.mirrored == rhs.mirrored &&
|
||||
lhs.framebuffer == rhs.framebuffer;
|
||||
lhs.framebuffer == rhs.framebuffer &&
|
||||
lhs.depthBias == rhs.depthBias &&
|
||||
lhs.slopeBias == rhs.slopeBias;
|
||||
}
|
||||
|
||||
template<>
|
||||
|
@ -29,6 +33,8 @@ struct std::hash<PipelineKey>
|
|||
nvrhi::hash_combine( h, key.program );
|
||||
nvrhi::hash_combine( h, key.mirrored );
|
||||
nvrhi::hash_combine( h, key.framebuffer );
|
||||
nvrhi::hash_combine( h, key.depthBias );
|
||||
nvrhi::hash_combine( h, key.slopeBias );
|
||||
return h;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -2242,6 +2242,11 @@ void idRenderBackend::AmbientPass( const drawSurf_t* const* drawSurfs, int numDr
|
|||
}
|
||||
*/
|
||||
|
||||
if( fillGbuffer )
|
||||
{
|
||||
commandList->clearTextureFloat( globalImages->currentNormalsImage->GetTextureHandle( ), nvrhi::AllSubresources, nvrhi::Color( 0.f ) );
|
||||
}
|
||||
|
||||
if( !fillGbuffer && r_useSSAO.GetBool() && r_ssaoDebug.GetBool() )
|
||||
{
|
||||
GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO | GLS_DEPTHMASK | GLS_DEPTHFUNC_ALWAYS );
|
||||
|
@ -3420,7 +3425,8 @@ void idRenderBackend::ShadowMapPass( const drawSurf_t* drawSurfs, const viewLigh
|
|||
const nvrhi::FramebufferAttachment& att = currentFrameBuffer->GetApiObject()->getDesc().depthAttachment;
|
||||
if( att.texture )
|
||||
{
|
||||
commandList->clearDepthStencilTexture( att.texture, nvrhi::TextureSubresourceSet().setArraySlices( side, 1 ), true, 1.f, false, 0x80 );
|
||||
int slice = std::max( 0, side );
|
||||
commandList->clearDepthStencilTexture( att.texture, nvrhi::TextureSubresourceSet().setArraySlices( slice, 1 ), true, 1.f, false, 0x80 );
|
||||
}
|
||||
#elif !defined( USE_VULKAN )
|
||||
globalFramebuffers.shadowFBO[vLight->shadowLOD]->Bind();
|
||||
|
@ -4742,6 +4748,7 @@ void idRenderBackend::CalculateAutomaticExposure()
|
|||
deltaTime = curTime - hdrTime;
|
||||
|
||||
//if(r_hdrMaxLuminance->value)
|
||||
if( 0 )
|
||||
{
|
||||
hdrAverageLuminance = idMath::ClampFloat( r_hdrMinLuminance.GetFloat(), r_hdrMaxLuminance.GetFloat(), hdrAverageLuminance );
|
||||
avgLuminance = idMath::ClampFloat( r_hdrMinLuminance.GetFloat(), r_hdrMaxLuminance.GetFloat(), avgLuminance );
|
||||
|
@ -4946,6 +4953,11 @@ void idRenderBackend::Bloom( const viewDef_t* _viewDef )
|
|||
|
||||
// resolve the screen
|
||||
globalImages->currentRenderImage->CopyFramebuffer( x, y, w, h );
|
||||
commonPasses.BlitTexture(
|
||||
commandList,
|
||||
globalFramebuffers.bloomRenderFBO[0]->GetApiObject( ),
|
||||
globalImages->currentRenderLDR->GetTextureHandle( ),
|
||||
&bindingCache );
|
||||
|
||||
renderProgManager.BindShader_Brightpass();
|
||||
}
|
||||
|
@ -4994,10 +5006,12 @@ void idRenderBackend::Bloom( const viewDef_t* _viewDef )
|
|||
int j;
|
||||
for( j = 0; j < r_hdrGlarePasses.GetInteger(); j++ )
|
||||
{
|
||||
globalFramebuffers.bloomRenderFBO[( j + 1 ) % 2 ]->Bind();
|
||||
int index = ( j + 1 ) % 2;
|
||||
globalFramebuffers.bloomRenderFBO[ index ]->Bind();
|
||||
|
||||
// FIXME
|
||||
#if !defined(USE_VULKAN)
|
||||
#if defined( USE_NHRI )
|
||||
commandList->clearTextureFloat( globalImages->bloomRenderImage[index]->GetTextureHandle(), nvrhi::AllSubresources, nvrhi::Color( 0.f, 0.f, 0.f, 1.f ) );
|
||||
#elif !defined( USE_VULKAN )
|
||||
glClear( GL_COLOR_BUFFER_BIT );
|
||||
#endif
|
||||
|
||||
|
@ -5007,7 +5021,7 @@ void idRenderBackend::Bloom( const viewDef_t* _viewDef )
|
|||
}
|
||||
|
||||
// add filtered glare back to main context
|
||||
Framebuffer::Unbind();
|
||||
globalFramebuffers.ldrFBO->Bind( );
|
||||
|
||||
ResetViewportAndScissorToDefaultCamera( _viewDef );
|
||||
|
||||
|
@ -5039,7 +5053,7 @@ void idRenderBackend::DrawScreenSpaceAmbientOcclusion( const viewDef_t* _viewDef
|
|||
return;
|
||||
}
|
||||
|
||||
if( r_useSSAO.GetInteger() <= 0 )
|
||||
if( r_useSSAO.GetInteger() <= 0 || r_useSSAO.GetInteger() > 1 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -5384,6 +5398,35 @@ void idRenderBackend::DrawScreenSpaceAmbientOcclusion( const viewDef_t* _viewDef
|
|||
commandList->endMarker();
|
||||
renderLog.CloseBlock();
|
||||
renderLog.CloseMainBlock();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
NVRHI SSAO using compute shaders.
|
||||
*/
|
||||
void idRenderBackend::DrawScreenSpaceAmbientOcclusion2( const viewDef_t* _viewDef, bool downModulateScreen )
|
||||
{
|
||||
if( !_viewDef->viewEntitys || _viewDef->is2Dgui )
|
||||
{
|
||||
// 3D views only
|
||||
return;
|
||||
}
|
||||
|
||||
if( r_useSSAO.GetInteger( ) <= 0 || r_useSSAO.GetInteger( ) < 2 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// skip this in subviews because it is very expensive
|
||||
if( _viewDef->isSubview )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if( _viewDef->renderView.rdflags & ( RDF_NOAMBIENT | RDF_IRRADIANCE ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//GL_CheckErrors();
|
||||
#endif
|
||||
|
@ -5730,6 +5773,12 @@ void idRenderBackend::ExecuteBackEndCommands( const emptyCommand_t* cmds )
|
|||
globalImages->currentNormalsImage->GetTextureHandle(),
|
||||
globalImages->ambientOcclusionImage[0]->GetTextureHandle() );
|
||||
}
|
||||
|
||||
if( !toneMapPass.IsLoaded() )
|
||||
{
|
||||
TonemapPass::CreateParameters tonemapParms;
|
||||
toneMapPass.Init( deviceManager->GetDevice(), &commonPasses, tonemapParms, globalFramebuffers.ldrFBO->GetApiObject() );
|
||||
}
|
||||
#endif
|
||||
|
||||
uint64 backEndStartTime = Sys_Microseconds();
|
||||
|
@ -6084,8 +6133,13 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste
|
|||
}
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
CalculateAutomaticExposure();
|
||||
Tonemap( _viewDef );
|
||||
#else
|
||||
ToneMappingParameters parms;
|
||||
toneMapPass.SimpleRender( commandList, parms, viewDef, globalImages->currentRenderHDRImage->GetTextureHandle(), globalFramebuffers.ldrFBO->GetApiObject() );
|
||||
#endif
|
||||
}
|
||||
|
||||
if( !r_skipBloom.GetBool() )
|
||||
|
|
|
@ -38,6 +38,7 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#include "Passes/MipMapGenPass.h"
|
||||
#include "Passes/FowardShadingPass.h"
|
||||
#include "Passes/SsaoPass.h"
|
||||
#include "Passes/TonemapPass.h"
|
||||
|
||||
#include "PipelineCache.h"
|
||||
|
||||
|
@ -468,6 +469,9 @@ public:
|
|||
drawSurf_t zeroOneSphereSurface; // RB
|
||||
drawSurf_t testImageSurface;
|
||||
|
||||
float slopeScaleBias;
|
||||
float depthBias;
|
||||
|
||||
private:
|
||||
uint64 glStateBits;
|
||||
|
||||
|
@ -495,20 +499,22 @@ private:
|
|||
|
||||
idScreenRect currentViewport;
|
||||
nvrhi::BufferHandle currentVertexBuffer;
|
||||
int currentVertexOffset;
|
||||
nvrhi::BufferHandle currentIndexBuffer;
|
||||
int currentIndexOffset;
|
||||
nvrhi::BindingSetHandle currentBindingSet;
|
||||
nvrhi::BindingLayoutHandle currentBindingLayout;
|
||||
nvrhi::GraphicsPipelineHandle currentPipeline;
|
||||
nvrhi::RenderState currentRenderState;
|
||||
float slopeScaleBias;
|
||||
float depthBias;
|
||||
|
||||
Framebuffer* currentFrameBuffer;
|
||||
Framebuffer* lastFrameBuffer;
|
||||
nvrhi::CommandListHandle commandList;
|
||||
idList<IRenderPass*> renderPasses;
|
||||
CommonRenderPasses commonPasses;
|
||||
SsaoPass* ssaoPass;
|
||||
MipMapGenPass* hiZGenPass;
|
||||
TonemapPass toneMapPass;
|
||||
|
||||
ForwardShadingPass fowardShadingPass;
|
||||
|
||||
|
@ -524,11 +530,15 @@ private:
|
|||
public:
|
||||
|
||||
void BindProgram( nvrhi::ShaderHandle vShader, nvrhi::ShaderHandle fShader, nvrhi::InputLayoutHandle layout, nvrhi::BindingLayoutHandle bindingLayout );
|
||||
void ResetPipelineCache();
|
||||
|
||||
void SetCurrentImage( idImage* image );
|
||||
idImage* GetCurrentImage();
|
||||
idImage* GetImageAt( int index );
|
||||
|
||||
CommonRenderPasses& GetCommonPasses()
|
||||
{
|
||||
return commonPasses;
|
||||
}
|
||||
#elif !defined( USE_VULKAN )
|
||||
int currenttmu;
|
||||
|
||||
|
|
|
@ -848,6 +848,9 @@ enum bindingLayoutType_t
|
|||
BINDING_LAYOUT_DRAW_INTERACTION_SM,
|
||||
BINDING_LAYOUT_DRAW_FOG,
|
||||
BINDING_LAYOUT_POST_PROCESS_CNM,
|
||||
BINDING_LAYOUT_TONEMAP,
|
||||
BINDING_LAYOUT_HISTOGRAM,
|
||||
BINDING_LAYOUT_EXPOSURE,
|
||||
NUM_BINDING_LAYOUTS
|
||||
};
|
||||
|
||||
|
|
|
@ -256,7 +256,8 @@ void idRenderProgManager::Init( nvrhi::IDevice* _device )
|
|||
.addItem( nvrhi::BindingLayoutItem::Texture_SRV( 5 ) ) // shadow map array
|
||||
.addItem( nvrhi::BindingLayoutItem::Texture_SRV( 6 ) ) // jitter
|
||||
.addItem( nvrhi::BindingLayoutItem::Sampler( 0 ) )
|
||||
.addItem( nvrhi::BindingLayoutItem::Sampler( 1 ) );
|
||||
.addItem( nvrhi::BindingLayoutItem::Sampler( 1 ) )
|
||||
.addItem( nvrhi::BindingLayoutItem::Sampler( 2 ) );
|
||||
|
||||
bindingLayouts[BINDING_LAYOUT_DRAW_INTERACTION_SM] = device->createBindingLayout( interactionSmBindingLayout );
|
||||
|
||||
|
@ -279,7 +280,38 @@ void idRenderProgManager::Init( nvrhi::IDevice* _device )
|
|||
.addItem( nvrhi::BindingLayoutItem::Sampler( 0 ) ); // Linear sampler
|
||||
|
||||
bindingLayouts[BINDING_LAYOUT_POST_PROCESS_CNM] = device->createBindingLayout( ppFxBindingLayout );
|
||||
#endif
|
||||
|
||||
nvrhi::BindingLayoutDesc tonemapLayout;
|
||||
tonemapLayout.visibility = nvrhi::ShaderType::Pixel;
|
||||
tonemapLayout.bindings =
|
||||
{
|
||||
nvrhi::BindingLayoutItem::VolatileConstantBuffer( 0 ),
|
||||
nvrhi::BindingLayoutItem::Texture_SRV( 0 ),
|
||||
nvrhi::BindingLayoutItem::TypedBuffer_SRV( 1 ),
|
||||
nvrhi::BindingLayoutItem::Texture_SRV( 2 ),
|
||||
nvrhi::BindingLayoutItem::Sampler( 0 )
|
||||
};
|
||||
bindingLayouts[BINDING_LAYOUT_TONEMAP] = device->createBindingLayout( tonemapLayout );
|
||||
|
||||
nvrhi::BindingLayoutDesc histogramLayout;
|
||||
histogramLayout.visibility = nvrhi::ShaderType::Compute;
|
||||
histogramLayout.bindings =
|
||||
{
|
||||
nvrhi::BindingLayoutItem::VolatileConstantBuffer( 0 ),
|
||||
nvrhi::BindingLayoutItem::Texture_SRV( 0 ),
|
||||
nvrhi::BindingLayoutItem::TypedBuffer_UAV( 0 )
|
||||
};
|
||||
bindingLayouts[BINDING_LAYOUT_HISTOGRAM] = device->createBindingLayout( histogramLayout );
|
||||
|
||||
nvrhi::BindingLayoutDesc exposureLayout;
|
||||
exposureLayout.visibility = nvrhi::ShaderType::Compute;
|
||||
exposureLayout.bindings =
|
||||
{
|
||||
nvrhi::BindingLayoutItem::VolatileConstantBuffer( 0 ),
|
||||
nvrhi::BindingLayoutItem::TypedBuffer_SRV( 0 ),
|
||||
nvrhi::BindingLayoutItem::TypedBuffer_UAV( 0 )
|
||||
};
|
||||
bindingLayouts[BINDING_LAYOUT_EXPOSURE] = device->createBindingLayout( exposureLayout );
|
||||
|
||||
// RB: added checks for GPU skinning
|
||||
struct builtinShaders_t
|
||||
|
@ -312,8 +344,8 @@ void idRenderProgManager::Init( nvrhi::IDevice* _device )
|
|||
{ BUILTIN_AMBIENT_LIGHTGRID_IBL_PBR, "builtin/lighting/ambient_lightgrid_IBL", "_PBR", { { "USE_GPU_SKINNING", "0" }, { "USE_PBR", "1" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_AMBIENT_LIGHTING_IBL },
|
||||
{ BUILTIN_AMBIENT_LIGHTGRID_IBL_PBR_SKINNED, "builtin/lighting/ambient_lightgrid_IBL", "_PBR_skinned", { { "USE_GPU_SKINNING", "1" }, { "USE_PBR", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_AMBIENT_LIGHTING_IBL },
|
||||
|
||||
{ BUILTIN_SMALL_GEOMETRY_BUFFER, "builtin/gbuffer", "", { {"USE_GPU_SKINNING", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT },
|
||||
{ BUILTIN_SMALL_GEOMETRY_BUFFER_SKINNED, "builtin/gbuffer", "_skinned", { {"USE_GPU_SKINNING", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT },
|
||||
{ BUILTIN_SMALL_GEOMETRY_BUFFER, "builtin/gbuffer", "", { {"USE_GPU_SKINNING", "0" }, { "USE_NORMAL_FMT_RGB8", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT },
|
||||
{ BUILTIN_SMALL_GEOMETRY_BUFFER_SKINNED, "builtin/gbuffer", "_skinned", { {"USE_GPU_SKINNING", "1" }, { "USE_NORMAL_FMT_RGB8", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT },
|
||||
// RB end
|
||||
{ BUILTIN_TEXTURED, "builtin/texture", "", { }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT },
|
||||
{ BUILTIN_TEXTURE_VERTEXCOLOR, "builtin/texture_color", "", { {"USE_GPU_SKINNING", "0" }, {"USE_SRGB", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT },
|
||||
|
@ -328,14 +360,14 @@ void idRenderProgManager::Init( nvrhi::IDevice* _device )
|
|||
{ BUILTIN_INTERACTION_AMBIENT, "builtin/lighting/interactionAmbient", "", { {"USE_GPU_SKINNING", "0" }, { "USE_PBR", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION },
|
||||
{ BUILTIN_INTERACTION_AMBIENT_SKINNED, "builtin/lighting/interactionAmbient", "_skinned", { {"USE_GPU_SKINNING", "1" }, { "USE_PBR", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION },
|
||||
|
||||
{ BUILTIN_INTERACTION_SHADOW_MAPPING_SPOT, "builtin/lighting/interactionSM", "_spot", { {"USE_GPU_SKINNING", "0" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM },
|
||||
{ BUILTIN_INTERACTION_SHADOW_MAPPING_SPOT_SKINNED, "builtin/lighting/interactionSM", "_spot_skinned", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", 0 }, { "USE_PBR", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM },
|
||||
{ BUILTIN_INTERACTION_SHADOW_MAPPING_SPOT, "builtin/lighting/interactionSM", "_spot", { {"USE_GPU_SKINNING", "0" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "0" }, { "USE_NORMAL_FMT_RGB8", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM },
|
||||
{ BUILTIN_INTERACTION_SHADOW_MAPPING_SPOT_SKINNED, "builtin/lighting/interactionSM", "_spot_skinned", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", 0 }, { "USE_PBR", "0" }, { "USE_NORMAL_FMT_RGB8", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM },
|
||||
|
||||
{ BUILTIN_INTERACTION_SHADOW_MAPPING_POINT, "builtin/lighting/interactionSM", "_point", { {"USE_GPU_SKINNING", "0" }, { "LIGHT_POINT", "1" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM },
|
||||
{ BUILTIN_INTERACTION_SHADOW_MAPPING_POINT_SKINNED, "builtin/lighting/interactionSM", "_point_skinned", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "1" }, { "LIGHT_PARALLEL", 0 }, { "USE_PBR", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM },
|
||||
{ BUILTIN_INTERACTION_SHADOW_MAPPING_POINT, "builtin/lighting/interactionSM", "_point", { {"USE_GPU_SKINNING", "0" }, { "LIGHT_POINT", "1" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "0" }, { "USE_NORMAL_FMT_RGB8", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM },
|
||||
{ BUILTIN_INTERACTION_SHADOW_MAPPING_POINT_SKINNED, "builtin/lighting/interactionSM", "_point_skinned", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "1" }, { "LIGHT_PARALLEL", 0 }, { "USE_PBR", "0" }, { "USE_NORMAL_FMT_RGB8", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM },
|
||||
|
||||
{ BUILTIN_INTERACTION_SHADOW_MAPPING_PARALLEL, "builtin/lighting/interactionSM", "_parallel", { {"USE_GPU_SKINNING", "0" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "1" }, { "USE_PBR", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM },
|
||||
{ BUILTIN_INTERACTION_SHADOW_MAPPING_PARALLEL_SKINNED, "builtin/lighting/interactionSM", "_parallel_skinned", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "1" }, { "USE_PBR", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM },
|
||||
{ BUILTIN_INTERACTION_SHADOW_MAPPING_PARALLEL, "builtin/lighting/interactionSM", "_parallel", { {"USE_GPU_SKINNING", "0" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "1" }, { "USE_PBR", "0" }, { "USE_NORMAL_FMT_RGB8", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM },
|
||||
{ BUILTIN_INTERACTION_SHADOW_MAPPING_PARALLEL_SKINNED, "builtin/lighting/interactionSM", "_parallel_skinned", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "1" }, { "USE_PBR", "0" }, { "USE_NORMAL_FMT_RGB8", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM },
|
||||
|
||||
// PBR variants
|
||||
{ BUILTIN_PBR_INTERACTION, "builtin/lighting/interaction", "_PBR", { {"USE_GPU_SKINNING", "0" }, { "USE_PBR", "1" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION },
|
||||
|
@ -344,14 +376,14 @@ void idRenderProgManager::Init( nvrhi::IDevice* _device )
|
|||
{ BUILTIN_PBR_INTERACTION_AMBIENT, "builtin/lighting/interactionAmbient", "_PBR", { {"USE_GPU_SKINNING", "0" }, { "USE_PBR", "1" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION },
|
||||
{ BUILTIN_PBR_INTERACTION_AMBIENT_SKINNED, "builtin/lighting/interactionAmbient_skinned", "_PBR", { {"USE_GPU_SKINNING", "1" }, { "USE_PBR", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION },
|
||||
|
||||
{ BUILTIN_PBR_INTERACTION_SHADOW_MAPPING_SPOT, "builtin/lighting/interactionSM", "_spot_PBR", { {"USE_GPU_SKINNING", "0" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "1" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM },
|
||||
{ BUILTIN_PBR_INTERACTION_SHADOW_MAPPING_SPOT_SKINNED, "builtin/lighting/interactionSM", "_spot_skinned_PBR", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM },
|
||||
{ BUILTIN_PBR_INTERACTION_SHADOW_MAPPING_SPOT, "builtin/lighting/interactionSM", "_spot_PBR", { {"USE_GPU_SKINNING", "0" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "1" }, { "USE_NORMAL_FMT_RGB8", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM },
|
||||
{ BUILTIN_PBR_INTERACTION_SHADOW_MAPPING_SPOT_SKINNED, "builtin/lighting/interactionSM", "_spot_skinned_PBR", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "1" }, { "USE_NORMAL_FMT_RGB8", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM },
|
||||
|
||||
{ BUILTIN_PBR_INTERACTION_SHADOW_MAPPING_POINT, "builtin/lighting/interactionSM", "_point_PBR", { {"USE_GPU_SKINNING", "0" }, { "LIGHT_POINT", "1" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "1" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM },
|
||||
{ BUILTIN_PBR_INTERACTION_SHADOW_MAPPING_POINT_SKINNED, "builtin/lighting/interactionSM", "_point_skinned_PBR", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "1" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM },
|
||||
{ BUILTIN_PBR_INTERACTION_SHADOW_MAPPING_POINT, "builtin/lighting/interactionSM", "_point_PBR", { {"USE_GPU_SKINNING", "0" }, { "LIGHT_POINT", "1" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "1" }, { "USE_NORMAL_FMT_RGB8", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM },
|
||||
{ BUILTIN_PBR_INTERACTION_SHADOW_MAPPING_POINT_SKINNED, "builtin/lighting/interactionSM", "_point_skinned_PBR", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "1" }, { "LIGHT_PARALLEL", "0" }, { "USE_PBR", "1" }, { "USE_NORMAL_FMT_RGB8", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM },
|
||||
|
||||
{ BUILTIN_PBR_INTERACTION_SHADOW_MAPPING_PARALLEL, "builtin/lighting/interactionSM", "_parallel_PBR", { {"USE_GPU_SKINNING", "0" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "1" }, { "USE_PBR", "1" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM },
|
||||
{ BUILTIN_PBR_INTERACTION_SHADOW_MAPPING_PARALLEL_SKINNED, "builtin/lighting/interactionSM", "_parallel_skinned_PBR", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "1" }, { "USE_PBR", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM },
|
||||
{ BUILTIN_PBR_INTERACTION_SHADOW_MAPPING_PARALLEL, "builtin/lighting/interactionSM", "_parallel_PBR", { {"USE_GPU_SKINNING", "0" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "1" }, { "USE_PBR", "1" }, { "USE_NORMAL_FMT_RGB8", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM },
|
||||
{ BUILTIN_PBR_INTERACTION_SHADOW_MAPPING_PARALLEL_SKINNED, "builtin/lighting/interactionSM", "_parallel_skinned_PBR", { {"USE_GPU_SKINNING", "1" }, { "LIGHT_POINT", "0" }, { "LIGHT_PARALLEL", "1" }, { "USE_PBR", "1" }, { "USE_NORMAL_FMT_RGB8", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_INTERACTION_SM },
|
||||
|
||||
// debug stuff
|
||||
{ BUILTIN_DEBUG_LIGHTGRID, "builtin/debug/lightgrid", "", { {"USE_GPU_SKINNING", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT },
|
||||
|
@ -375,9 +407,9 @@ void idRenderProgManager::Init( nvrhi::IDevice* _device )
|
|||
{ BUILTIN_SHADOW_DEBUG, "builtin/debug/shadowDebug", "", { {"USE_GPU_SKINNING", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT },
|
||||
{ BUILTIN_SHADOW_DEBUG_SKINNED, "builtin/debug/shadowDebug", "_skinned", { {"USE_GPU_SKINNING", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT },
|
||||
|
||||
{ BUILTIN_BLENDLIGHT, "builtin/fog/blendlight", "", {}, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT },
|
||||
{ BUILTIN_FOG, "builtin/fog/fog", "", { {"USE_GPU_SKINNING", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_FOG },
|
||||
{ BUILTIN_FOG_SKINNED, "builtin/fog/fog", "_skinned", { {"USE_GPU_SKINNING", "1" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_FOG },
|
||||
{ BUILTIN_BLENDLIGHT, "builtin/fog/blendlight", "", { { "USE_LINEAR_RGB", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT },
|
||||
{ BUILTIN_FOG, "builtin/fog/fog", "", { {"USE_GPU_SKINNING", "0" }, { "USE_LINEAR_RGB", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_FOG },
|
||||
{ BUILTIN_FOG_SKINNED, "builtin/fog/fog", "_skinned", { {"USE_GPU_SKINNING", "1" }, { "USE_LINEAR_RGB", "0" } }, true, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DRAW_FOG },
|
||||
{ BUILTIN_SKYBOX, "builtin/legacy/skybox", "", {}, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT },
|
||||
{ BUILTIN_WOBBLESKY, "builtin/legacy/wobblesky", "", {}, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT },
|
||||
{ BUILTIN_POSTPROCESS, "builtin/post/postprocess", "", {}, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT },
|
||||
|
@ -412,8 +444,16 @@ void idRenderProgManager::Init( nvrhi::IDevice* _device )
|
|||
// RB begin
|
||||
{ BUILTIN_DEBUG_SHADOWMAP, "builtin/debug/debug_shadowmap", "", {}, false, SHADER_STAGE_DEFAULT, LAYOUT_DRAW_VERT, BINDING_LAYOUT_DEFAULT },
|
||||
// RB end
|
||||
|
||||
// SP begin
|
||||
{ BUILTIN_BLIT, "builtin/blit", "", { { "TEXTURE_ARRAY", "0" } }, false, SHADER_STAGE_FRAGMENT, LAYOUT_UNKNOWN, BINDING_LAYOUT_BLIT },
|
||||
{ BUILTIN_RECT, "builtin/rect", "", { }, false, SHADER_STAGE_VERTEX, LAYOUT_DRAW_VERT, BINDING_LAYOUT_BLIT },
|
||||
{ BUILTIN_TONEMAPPING, "builtin/post/tonemapping", "", { { "HISTOGRAM_BINS", "256" }, { "SOURCE_ARRAY", "0" }, { "QUAD_Z", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_UNKNOWN, BINDING_LAYOUT_TONEMAP },
|
||||
{ BUILTIN_TONEMAPPING_TEX_ARRAY, "builtin/post/tonemapping", "", { { "HISTOGRAM_BINS", "256" }, { "SOURCE_ARRAY", "1" }, { "QUAD_Z", "0" } }, false, SHADER_STAGE_DEFAULT, LAYOUT_UNKNOWN, BINDING_LAYOUT_TONEMAP },
|
||||
{ BUILTIN_HISTOGRAM_CS, "builtin/post/histogram", "", { { "HISTOGRAM_BINS", "256" }, { "SOURCE_ARRAY", "0" } }, false, SHADER_STAGE_COMPUTE, LAYOUT_UNKNOWN, BINDING_LAYOUT_HISTOGRAM },
|
||||
{ BUILTIN_HISTOGRAM_TEX_ARRAY_CS, "builtin/post/histogram", "", { { "HISTOGRAM_BINS", "256" }, { "SOURCE_ARRAY", "1" } }, false, SHADER_STAGE_COMPUTE, LAYOUT_UNKNOWN, BINDING_LAYOUT_HISTOGRAM },
|
||||
{ BUILTIN_EXPOSURE_CS, "builtin/post/exposure", "", { { "HISTOGRAM_BINS", "256" } }, false, SHADER_STAGE_COMPUTE, LAYOUT_UNKNOWN, BINDING_LAYOUT_EXPOSURE },
|
||||
// SP end
|
||||
};
|
||||
int numBuiltins = sizeof( builtins ) / sizeof( builtins[0] );
|
||||
|
||||
|
@ -448,11 +488,25 @@ void idRenderProgManager::Init( nvrhi::IDevice* _device )
|
|||
fIndex = FindShader( builtins[ i ].name, SHADER_STAGE_FRAGMENT, builtins[i].nameOutSuffix, builtins[i].macros, true, builtins[i].layout );
|
||||
}
|
||||
|
||||
//idLib::Printf( "Loading GLSL program %i %i %i\n", i, vIndex, fIndex );
|
||||
int cIndex = -1;
|
||||
if( builtins[i].stages & SHADER_STAGE_COMPUTE )
|
||||
{
|
||||
cIndex = FindShader( builtins[ i ].name, SHADER_STAGE_COMPUTE, builtins[i].nameOutSuffix, builtins[i].macros, true, builtins[i].layout );
|
||||
}
|
||||
|
||||
idLib::Printf( "Loading shader program %s\n", prog.name.c_str() );
|
||||
|
||||
LoadProgram( i, vIndex, fIndex );
|
||||
if( vIndex > -1 && fIndex > -1 )
|
||||
{
|
||||
LoadProgram( i, vIndex, fIndex );
|
||||
}
|
||||
|
||||
if( cIndex > -1 )
|
||||
{
|
||||
LoadComputeProgram( i, cIndex );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
r_useHalfLambertLighting.ClearModified();
|
||||
r_useHDR.ClearModified();
|
||||
|
@ -560,6 +614,8 @@ void idRenderProgManager::Shutdown()
|
|||
idRenderProgManager::FindVertexShader
|
||||
================================================================================================
|
||||
*/
|
||||
|
||||
// TODO REMOVE
|
||||
int idRenderProgManager::FindShader( const char* name, rpStage_t stage )
|
||||
{
|
||||
idStr shaderName( name );
|
||||
|
@ -580,6 +636,7 @@ int idRenderProgManager::FindShader( const char* name, rpStage_t stage )
|
|||
shader.name = shaderName;
|
||||
shader.stage = stage;
|
||||
|
||||
#if 0
|
||||
for( int i = 0; i < MAX_SHADER_MACRO_NAMES; i++ )
|
||||
{
|
||||
int feature = ( bool )( 0 & BIT( i ) );
|
||||
|
@ -587,6 +644,7 @@ int idRenderProgManager::FindShader( const char* name, rpStage_t stage )
|
|||
idStr value( feature );
|
||||
shader.macros.Append( shaderMacro_t( macroName, value ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
int index = shaders.Append( shader );
|
||||
LoadShader( index, stage );
|
||||
|
@ -594,6 +652,7 @@ int idRenderProgManager::FindShader( const char* name, rpStage_t stage )
|
|||
return index;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
int idRenderProgManager::FindShader( const char* name, rpStage_t stage, const char* nameOutSuffix, uint32 features, bool builtin, vertexLayoutType_t vertexLayout )
|
||||
{
|
||||
|
@ -676,6 +735,10 @@ programInfo_t idRenderProgManager::GetProgramInfo( int index )
|
|||
{
|
||||
info.ps = GetShader( prog.fragmentShaderIndex );
|
||||
}
|
||||
if( prog.computeShaderIndex > -1 && prog.computeShaderIndex < shaders.Num() )
|
||||
{
|
||||
info.cs = GetShader( prog.computeShaderIndex );
|
||||
}
|
||||
info.inputLayout = prog.inputLayout;
|
||||
info.bindingLayout = prog.bindingLayout;
|
||||
|
||||
|
|
|
@ -266,6 +266,7 @@ struct programInfo_t
|
|||
{
|
||||
nvrhi::ShaderHandle vs;
|
||||
nvrhi::ShaderHandle ps;
|
||||
nvrhi::ShaderHandle cs;
|
||||
nvrhi::InputLayoutHandle inputLayout;
|
||||
nvrhi::BindingLayoutHandle bindingLayout;
|
||||
};
|
||||
|
@ -381,6 +382,11 @@ enum
|
|||
// SP Begin
|
||||
BUILTIN_BLIT,
|
||||
BUILTIN_RECT,
|
||||
BUILTIN_TONEMAPPING,
|
||||
BUILTIN_TONEMAPPING_TEX_ARRAY,
|
||||
BUILTIN_HISTOGRAM_CS,
|
||||
BUILTIN_HISTOGRAM_TEX_ARRAY_CS,
|
||||
BUILTIN_EXPOSURE_CS,
|
||||
// SP End
|
||||
|
||||
MAX_BUILTINS
|
||||
|
@ -977,6 +983,7 @@ private:
|
|||
|
||||
bool CompileGLSL( uint target, const char* name );
|
||||
void LoadProgram( const int programIndex, const int vertexShaderIndex, const int fragmentShaderIndex );
|
||||
void LoadComputeProgram( const int programIndex, const int computeShaderIndex );
|
||||
|
||||
static const uint INVALID_PROGID = 0xFFFFFFFF;
|
||||
|
||||
|
@ -1009,6 +1016,7 @@ private:
|
|||
name(),
|
||||
vertexShaderIndex( -1 ),
|
||||
fragmentShaderIndex( -1 ),
|
||||
computeShaderIndex( -1 ),
|
||||
builtin( true ),
|
||||
usesJoints( false ),
|
||||
vertexLayout( LAYOUT_UNKNOWN ),
|
||||
|
@ -1021,6 +1029,7 @@ private:
|
|||
idStr name;
|
||||
int vertexShaderIndex;
|
||||
int fragmentShaderIndex;
|
||||
int computeShaderIndex;
|
||||
bool builtin;
|
||||
bool usesJoints;
|
||||
vertexLayoutType_t vertexLayout;
|
||||
|
|
|
@ -286,9 +286,9 @@ idCVar r_shadowMapSunDepthBiasScale( "r_shadowMapSunDepthBiasScale", "0.999991",
|
|||
#endif
|
||||
|
||||
idCVar r_hdrAutoExposure( "r_hdrAutoExposure", "0", CVAR_RENDERER | CVAR_BOOL, "EXPENSIVE: enables adapative HDR tone mapping otherwise the exposure is derived by r_exposure" );
|
||||
idCVar r_hdrAdaptionRate( "r_hdrAdaptionRate", "3", CVAR_RENDERER | CVAR_FLOAT, "The rate of adapting the hdr exposure value`. Defaulted to a third of a second." );
|
||||
idCVar r_hdrMinLuminance( "r_hdrMinLuminance", "0.005", CVAR_RENDERER | CVAR_FLOAT, "" );
|
||||
idCVar r_hdrMaxLuminance( "r_hdrMaxLuminance", "300", CVAR_RENDERER | CVAR_FLOAT, "" );
|
||||
idCVar r_hdrAdaptionRate( "r_hdrAdaptionRate", "1", CVAR_RENDERER | CVAR_FLOAT, "The rate of adapting the hdr exposure value`. Defaulted to a second." );
|
||||
idCVar r_hdrMinLuminance( "r_hdrMinLuminance", "0.02", CVAR_RENDERER | CVAR_FLOAT, "" );
|
||||
idCVar r_hdrMaxLuminance( "r_hdrMaxLuminance", "0.5", CVAR_RENDERER | CVAR_FLOAT, "" );
|
||||
idCVar r_hdrKey( "r_hdrKey", "0.015", CVAR_RENDERER | CVAR_FLOAT, "magic exposure key that works well with Doom 3 maps" );
|
||||
idCVar r_hdrContrastDynamicThreshold( "r_hdrContrastDynamicThreshold", "2", CVAR_RENDERER | CVAR_FLOAT, "if auto exposure is on, all pixels brighter than this cause HDR bloom glares" );
|
||||
idCVar r_hdrContrastStaticThreshold( "r_hdrContrastStaticThreshold", "3", CVAR_RENDERER | CVAR_FLOAT, "if auto exposure is off, all pixels brighter than this cause HDR bloom glares" );
|
||||
|
@ -328,7 +328,7 @@ idCVar r_showLightGrid( "r_showLightGrid", "0", CVAR_RENDERER | CVAR_INTEGER, "s
|
|||
|
||||
idCVar r_useLightGrid( "r_useLightGrid", "1", CVAR_RENDERER | CVAR_BOOL, "" );
|
||||
|
||||
idCVar r_exposure( "r_exposure", "0.5", CVAR_ARCHIVE | CVAR_RENDERER | CVAR_FLOAT, "HDR exposure or LDR brightness [0.0 .. 1.0]", 0.0f, 1.0f );
|
||||
idCVar r_exposure( "r_exposure", "-0.5", CVAR_ARCHIVE | CVAR_RENDERER | CVAR_FLOAT, "HDR exposure or LDR brightness [-1.0 .. 0.0]", -1.0f, 0.0f );
|
||||
// RB end
|
||||
|
||||
const char* fileExten[4] = { "tga", "png", "jpg", "exr" };
|
||||
|
|
|
@ -26,31 +26,32 @@ If you have questions concerning this license or the applicable additional terms
|
|||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "renderprogs/global.inc.hlsl"
|
||||
#include "global_inc.hlsl"
|
||||
|
||||
|
||||
// *INDENT-OFF*
|
||||
uniform sampler2D samp0 : register(s0); //_accum
|
||||
uniform sampler2D samp1 : register(s1); //_currentRender
|
||||
uniform sampler2D samp2 : register(s2); //mask
|
||||
Texture2D t_Accum : register( t0 );
|
||||
Texture2D t_CurrentRender : register( t1 );
|
||||
Texture2D t_Mask : register( t2 );
|
||||
|
||||
SamplerState LinearSampler : register( s0 );
|
||||
|
||||
struct PS_IN {
|
||||
float4 position : VPOS;
|
||||
float4 position : SV_Position;
|
||||
float2 texcoord0 : TEXCOORD0_centroid;
|
||||
float2 texcoord1 : TEXCOORD1_centroid;
|
||||
};
|
||||
|
||||
struct PS_OUT {
|
||||
float4 color : COLOR;
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
void main( PS_IN fragment, out PS_OUT result )
|
||||
{
|
||||
|
||||
float4 accumSample = tex2D( samp0, fragment.texcoord0 );
|
||||
float4 maskSample = tex2D( samp2, fragment.texcoord1 );
|
||||
float4 currentRenderSample = tex2D( samp1, fragment.texcoord1 );
|
||||
float4 accumSample = t_Accum.Sample( LinearSampler, fragment.texcoord0 );
|
||||
float4 maskSample = t_Mask.Sample( LinearSampler, fragment.texcoord1 );
|
||||
float4 currentRenderSample = t_CurrentRender.Sample( LinearSampler, fragment.texcoord1 );
|
||||
|
||||
result.color = lerp( accumSample, currentRenderSample, maskSample.a );
|
||||
}
|
|
@ -26,11 +26,10 @@ If you have questions concerning this license or the applicable additional terms
|
|||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "renderprogs/global.inc.hlsl"
|
||||
#include "global_inc.hlsl"
|
||||
|
||||
|
||||
// *INDENT-OFF*
|
||||
uniform float4 rpUser0 : register( c128 ); //rpCenterScale
|
||||
|
||||
struct VS_IN {
|
||||
float4 position : POSITION;
|
||||
|
@ -41,9 +40,9 @@ struct VS_IN {
|
|||
};
|
||||
|
||||
struct VS_OUT {
|
||||
float4 position : POSITION;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float4 position : SV_Position;
|
||||
float2 texcoord0 : TEXCOORD0_centroid;
|
||||
float2 texcoord1 : TEXCOORD1_centroid;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
|
|
|
@ -26,16 +26,18 @@ If you have questions concerning this license or the applicable additional terms
|
|||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "renderprogs/global.inc.hlsl"
|
||||
#include "global_inc.hlsl"
|
||||
|
||||
|
||||
// *INDENT-OFF*
|
||||
uniform sampler2D samp0 : register(s0); //_accum
|
||||
uniform sampler2D samp1 : register(s1); //_currentRender
|
||||
uniform sampler2D samp2 : register(s2); //mask
|
||||
Texture2D t_Accum : register( t0 );
|
||||
Texture2D t_CurrentRender : register( t1 );
|
||||
Texture2D t_Mask : register( t2 );
|
||||
|
||||
SamplerState LinearSampler : register( s0 );
|
||||
|
||||
struct PS_IN {
|
||||
float4 position : VPOS;
|
||||
float4 position : SV_Position;
|
||||
float2 texcoord0 : TEXCOORD0_centroid;
|
||||
float2 texcoord1 : TEXCOORD1_centroid;
|
||||
float2 texcoord2 : TEXCOORD2_centroid;
|
||||
|
@ -43,7 +45,7 @@ struct PS_IN {
|
|||
};
|
||||
|
||||
struct PS_OUT {
|
||||
float4 color : COLOR;
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
|
@ -51,12 +53,12 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
{
|
||||
|
||||
float4 redTint = float4( 1, 0.98, 0.98, 1 );
|
||||
float4 accumSample = tex2D( samp0, fragment.texcoord0 ) * redTint;
|
||||
float4 accumSample = t_Accum.Sample( LinearSampler, fragment.texcoord0 ) * redTint;
|
||||
|
||||
float4 maskSample = tex2D( samp2, fragment.texcoord1 );
|
||||
float4 maskSample = t_Mask.Sample( LinearSampler, fragment.texcoord1 );
|
||||
|
||||
float4 tint = float4( 1.0, 0.8, 0.8, 1 );
|
||||
float4 currentRenderSample = tex2D( samp1, fragment.texcoord2 ) * tint;
|
||||
float4 currentRenderSample = t_CurrentRender.Sample( LinearSampler, fragment.texcoord2 ) * tint;
|
||||
|
||||
result.color = lerp( accumSample, currentRenderSample, maskSample.a );
|
||||
}
|
|
@ -26,14 +26,10 @@ If you have questions concerning this license or the applicable additional terms
|
|||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "renderprogs/global.inc.hlsl"
|
||||
#include "global_inc.hlsl"
|
||||
|
||||
|
||||
// *INDENT-OFF*
|
||||
uniform float4 rpUser0 : register( c128 ); //rpCenterScaleTex0
|
||||
uniform float4 rpUser1 : register( c129 ); //rpRotateTex0
|
||||
uniform float4 rpUser2 : register( c130 ); //rpCenterScaleTex1
|
||||
|
||||
struct VS_IN {
|
||||
float4 position : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
|
@ -43,10 +39,10 @@ struct VS_IN {
|
|||
};
|
||||
|
||||
struct VS_OUT {
|
||||
float4 position : POSITION;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float2 texcoord2 : TEXCOORD2;
|
||||
float4 position : SV_Position;
|
||||
float2 texcoord0 : TEXCOORD0_centroid;
|
||||
float2 texcoord1 : TEXCOORD1_centroid;
|
||||
float2 texcoord2 : TEXCOORD2_centroid;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
|
|
|
@ -26,16 +26,18 @@ If you have questions concerning this license or the applicable additional terms
|
|||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "renderprogs/global.inc.hlsl"
|
||||
#include "global_inc.hlsl"
|
||||
|
||||
|
||||
// *INDENT-OFF*
|
||||
uniform sampler2D samp0 : register(s0); //_accum
|
||||
uniform sampler2D samp1 : register(s1); //_currentRender
|
||||
uniform sampler2D samp2 : register(s2); //mask
|
||||
Texture2D t_Accum : register( t0 );
|
||||
Texture2D t_CurrentRender : register( t1 );
|
||||
Texture2D t_Mask : register( t2 );
|
||||
|
||||
SamplerState LinearSampler : register( s0 );
|
||||
|
||||
struct PS_IN {
|
||||
float4 position : VPOS;
|
||||
float4 position : SV_Position;
|
||||
float2 texcoord0 : TEXCOORD0_centroid;
|
||||
float2 texcoord1 : TEXCOORD1_centroid;
|
||||
float2 texcoord2 : TEXCOORD2_centroid;
|
||||
|
@ -44,7 +46,7 @@ struct PS_IN {
|
|||
};
|
||||
|
||||
struct PS_OUT {
|
||||
float4 color : COLOR;
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
|
@ -56,13 +58,13 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
float4 color1 = float4( 1.0f, 0.95f - colorFactor, 0.95f, 0.5f );
|
||||
float4 color2 = float4( 0.015f, 0.015f, 0.015f, 0.01f );
|
||||
|
||||
float4 accumSample0 = tex2D( samp0, fragment.texcoord0 ) * color0;
|
||||
float4 accumSample1 = tex2D( samp0, fragment.texcoord1 ) * color1;
|
||||
float4 accumSample2 = tex2D( samp0, fragment.texcoord2 ) * color2;
|
||||
float4 maskSample = tex2D( samp2, fragment.texcoord3 );
|
||||
float4 accumSample0 = t_Accum.Sample( LinearSampler, fragment.texcoord0 ) * color0;
|
||||
float4 accumSample1 = t_Accum.Sample( LinearSampler, fragment.texcoord1 ) * color1;
|
||||
float4 accumSample2 = t_Accum.Sample( LinearSampler, fragment.texcoord2 ) * color2;
|
||||
float4 maskSample = t_Mask.Sample( LinearSampler, fragment.texcoord3 );
|
||||
|
||||
float4 tint = float4( 0.8, 0.5, 0.5, 1 );
|
||||
float4 currentRenderSample = tex2D( samp1, fragment.texcoord3 ) * tint;
|
||||
float4 currentRenderSample = t_CurrentRender.Sample( LinearSampler, fragment.texcoord3 ) * tint;
|
||||
|
||||
// blend of the first 2 accumulation samples
|
||||
float4 accumColor = lerp( accumSample0, accumSample1, 0.5f );
|
||||
|
|
|
@ -26,14 +26,10 @@ If you have questions concerning this license or the applicable additional terms
|
|||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "renderprogs/global.inc.hlsl"
|
||||
#include "global_inc.hlsl"
|
||||
|
||||
|
||||
// *INDENT-OFF*
|
||||
uniform float4 rpUser0 : register( c128 ); //rpCenterScaleTex
|
||||
uniform float4 rpUser1 : register( c129 ); //rpRotateTex
|
||||
uniform float4 rpUser2 : register( c130 ); //rpColorFactor
|
||||
|
||||
struct VS_IN {
|
||||
float4 position : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
|
@ -43,11 +39,11 @@ struct VS_IN {
|
|||
};
|
||||
|
||||
struct VS_OUT {
|
||||
float4 position : POSITION;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float2 texcoord2 : TEXCOORD2;
|
||||
float2 texcoord3 : TEXCOORD3;
|
||||
float4 position : SV_Position;
|
||||
float2 texcoord0 : TEXCOORD0_centroid;
|
||||
float2 texcoord1 : TEXCOORD1_centroid;
|
||||
float2 texcoord2 : TEXCOORD2_centroid;
|
||||
float2 texcoord3 : TEXCOORD3_centroid;
|
||||
float2 texcoord4 : TEXCOORD4;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
|
|
@ -26,30 +26,32 @@ If you have questions concerning this license or the applicable additional terms
|
|||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "renderprogs/global.inc.hlsl"
|
||||
#include "global_inc.hlsl"
|
||||
|
||||
|
||||
// *INDENT-OFF*
|
||||
uniform sampler2D samp0 : register(s0); //_accum
|
||||
uniform sampler2D samp1 : register(s1); //_currentRender
|
||||
uniform sampler2D samp2 : register(s2); //mask
|
||||
Texture2D t_Accum : register( t0 );
|
||||
Texture2D t_CurrentRender : register( t1 );
|
||||
Texture2D t_Mask : register( t2 );
|
||||
|
||||
SamplerState LinearSampler : register( s0 );
|
||||
|
||||
struct PS_IN {
|
||||
float4 position : VPOS;
|
||||
float4 position : SV_Position;
|
||||
float2 texcoord0 : TEXCOORD0_centroid;
|
||||
};
|
||||
|
||||
struct PS_OUT {
|
||||
float4 color : COLOR;
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
void main( PS_IN fragment, out PS_OUT result )
|
||||
{
|
||||
|
||||
float4 accumSample = tex2D( samp0, fragment.texcoord0 );
|
||||
float4 currentRenderSample = tex2D( samp1, fragment.texcoord0 );
|
||||
float4 maskSample = tex2D( samp2, fragment.texcoord0 );
|
||||
float4 accumSample = t_Accum.Sample( LinearSampler, fragment.texcoord0 );
|
||||
float4 currentRenderSample = t_CurrentRender.Sample( LinearSampler, fragment.texcoord0 );
|
||||
float4 maskSample = t_Mask.Sample( LinearSampler, fragment.texcoord0 );
|
||||
|
||||
result.color = lerp( accumSample, currentRenderSample, maskSample.a );
|
||||
}
|
|
@ -26,7 +26,7 @@ If you have questions concerning this license or the applicable additional terms
|
|||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "renderprogs/global.inc.hlsl"
|
||||
#include "global_inc.hlsl"
|
||||
|
||||
|
||||
// *INDENT-OFF*
|
||||
|
@ -39,8 +39,8 @@ struct VS_IN {
|
|||
};
|
||||
|
||||
struct VS_OUT {
|
||||
float4 position : POSITION;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float4 position : SV_Position;
|
||||
float2 texcoord0 : TEXCOORD0_centroid;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
|
|
|
@ -251,7 +251,7 @@ float3 getOffsetPosition( int2 issC, float2 unitOffset, float ssR, Texture2D<VAL
|
|||
// RB: this is the key for fast ambient occlusion - use a hierarchical depth buffer
|
||||
// for more information see McGuire12SAO.pdf - Scalable Ambient Obscurance
|
||||
// http://graphics.cs.williams.edu/papers/SAOHPG12/
|
||||
P.z = cszBuffer.Load( int3(mipP, mipLevel) ).r;
|
||||
P.z = cszBuffer.Load( int3( mipP, mipLevel ) ).r;
|
||||
#else
|
||||
P.z = cszBuffer.Load( int3( mipP, 0 ) ).r;
|
||||
#endif
|
||||
|
|
|
@ -26,19 +26,20 @@
|
|||
|
||||
struct SsaoConstants
|
||||
{
|
||||
float2 clipToView;
|
||||
float2 invQuantizedGbufferSize;
|
||||
float2 clipToView;
|
||||
float2 invQuantizedGbufferSize;
|
||||
|
||||
int2 quantizedViewportOrigin;
|
||||
float amount;
|
||||
float invBackgroundViewDepth;
|
||||
float radiusWorld;
|
||||
float surfaceBias;
|
||||
int2 quantizedViewportOrigin;
|
||||
float amount;
|
||||
float invBackgroundViewDepth;
|
||||
float radiusWorld;
|
||||
float surfaceBias;
|
||||
|
||||
float radiusToScreen;
|
||||
float powerExponent;
|
||||
float radiusToScreen;
|
||||
float powerExponent;
|
||||
};
|
||||
|
||||
// *INDENT-OFF*
|
||||
SamplerState s_Point : register(s0);
|
||||
Texture2DArray<float> t_DeinterleavedDepth : register(t0);
|
||||
#if DIRECTIONAL_OCCLUSION
|
||||
|
@ -53,123 +54,124 @@ cbuffer c_Ssao : register(b1)
|
|||
{
|
||||
SsaoConstants g_Ssao;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
void divrem(float a, float b, out float div, out float rem)
|
||||
void divrem( float a, float b, out float div, out float rem )
|
||||
{
|
||||
a = (a + 0.5) / b;
|
||||
div = floor(a);
|
||||
rem = floor(frac(a) * b);
|
||||
a = ( a + 0.5 ) / b;
|
||||
div = floor( a );
|
||||
rem = floor( frac( a ) * b );
|
||||
}
|
||||
|
||||
// Warning: do not change the group size or shared array dimensions without a complete understanding of the data loading method.
|
||||
|
||||
#if DIRECTIONAL_OCCLUSION
|
||||
groupshared float s_Depth[24][24];
|
||||
groupshared float4 s_Occlusion[24][24];
|
||||
groupshared float s_Depth[24][24];
|
||||
groupshared float4 s_Occlusion[24][24];
|
||||
#else
|
||||
groupshared float2 s_DepthAndSSAO[24][24];
|
||||
groupshared float2 s_DepthAndSSAO[24][24];
|
||||
#endif
|
||||
|
||||
[numthreads(16, 16, 1)]
|
||||
void main(uint2 groupId : SV_GroupID, uint2 threadId : SV_GroupThreadID, uint2 globalId : SV_DispatchThreadID)
|
||||
[numthreads( 16, 16, 1 )]
|
||||
void main( uint2 groupId : SV_GroupID, uint2 threadId : SV_GroupThreadID, uint2 globalId : SV_DispatchThreadID )
|
||||
{
|
||||
int linearIdx = int((threadId.y << 4) + threadId.x);
|
||||
int linearIdx = int( ( threadId.y << 4 ) + threadId.x );
|
||||
|
||||
if (linearIdx < 144)
|
||||
{
|
||||
// Rename the threads to a 3x3x16 grid where X and Y are "offsetUV" and Z is "slice"
|
||||
if( linearIdx < 144 )
|
||||
{
|
||||
// Rename the threads to a 3x3x16 grid where X and Y are "offsetUV" and Z is "slice"
|
||||
|
||||
float2 offsetUVf;
|
||||
float a, slice;
|
||||
divrem(linearIdx, 3.0, a, offsetUVf.x);
|
||||
divrem(a, 3.0, slice, offsetUVf.y);
|
||||
float2 offsetUVf;
|
||||
float a, slice;
|
||||
divrem( linearIdx, 3.0, a, offsetUVf.x );
|
||||
divrem( a, 3.0, slice, offsetUVf.y );
|
||||
|
||||
offsetUVf *= 8;
|
||||
int2 offsetUV = int2(offsetUVf);
|
||||
offsetUVf *= 8;
|
||||
int2 offsetUV = int2( offsetUVf );
|
||||
|
||||
int2 pixelPos = (int2(groupId.xy) * 16) + offsetUV + g_Ssao.quantizedViewportOrigin;
|
||||
int2 pixelPos = ( int2( groupId.xy ) * 16 ) + offsetUV + g_Ssao.quantizedViewportOrigin;
|
||||
|
||||
float2 UV = (float2(pixelPos) + 1.0) * g_Ssao.invQuantizedGbufferSize.xy;
|
||||
float2 UV = ( float2( pixelPos ) + 1.0 ) * g_Ssao.invQuantizedGbufferSize.xy;
|
||||
|
||||
// Load 4 pixels from each texture, overall the thread group loads a 24x24 block of pixels.
|
||||
// For a 16x16 thread group, 20x20 pixels would be enough, but it's impossible to do that with Gather.
|
||||
|
||||
// Each Gather instruction loads 4 adjacent pixels from a deinterleaved array, and the
|
||||
// screen-space distance between those pixels is 4, not 1.
|
||||
// Load 4 pixels from each texture, overall the thread group loads a 24x24 block of pixels.
|
||||
// For a 16x16 thread group, 20x20 pixels would be enough, but it's impossible to do that with Gather.
|
||||
|
||||
offsetUV.x += int(slice) & 3;
|
||||
offsetUV.y += int(slice) >> 2;
|
||||
// Each Gather instruction loads 4 adjacent pixels from a deinterleaved array, and the
|
||||
// screen-space distance between those pixels is 4, not 1.
|
||||
|
||||
float4 depths = t_DeinterleavedDepth.GatherRed(s_Point, float3(UV, slice), int2(0, 0));
|
||||
offsetUV.x += int( slice ) & 3;
|
||||
offsetUV.y += int( slice ) >> 2;
|
||||
|
||||
float4 depths = t_DeinterleavedDepth.GatherRed( s_Point, float3( UV, slice ), int2( 0, 0 ) );
|
||||
#if DIRECTIONAL_OCCLUSION
|
||||
int3 deinterleavedPixelPos = int3((pixelPos >> 2) - 1, slice);
|
||||
float4 occlusion_00 = t_DeinterleavedSSAO[deinterleavedPixelPos + int3(0, 0, 0)];
|
||||
float4 occlusion_10 = t_DeinterleavedSSAO[deinterleavedPixelPos + int3(1, 0, 0)];
|
||||
float4 occlusion_01 = t_DeinterleavedSSAO[deinterleavedPixelPos + int3(0, 1, 0)];
|
||||
float4 occlusion_11 = t_DeinterleavedSSAO[deinterleavedPixelPos + int3(1, 1, 0)];
|
||||
int3 deinterleavedPixelPos = int3( ( pixelPos >> 2 ) - 1, slice );
|
||||
float4 occlusion_00 = t_DeinterleavedSSAO[deinterleavedPixelPos + int3( 0, 0, 0 )];
|
||||
float4 occlusion_10 = t_DeinterleavedSSAO[deinterleavedPixelPos + int3( 1, 0, 0 )];
|
||||
float4 occlusion_01 = t_DeinterleavedSSAO[deinterleavedPixelPos + int3( 0, 1, 0 )];
|
||||
float4 occlusion_11 = t_DeinterleavedSSAO[deinterleavedPixelPos + int3( 1, 1, 0 )];
|
||||
|
||||
s_Depth[offsetUV.y + 4][offsetUV.x + 0] = depths.x;
|
||||
s_Depth[offsetUV.y + 4][offsetUV.x + 4] = depths.y;
|
||||
s_Depth[offsetUV.y + 0][offsetUV.x + 4] = depths.z;
|
||||
s_Depth[offsetUV.y + 0][offsetUV.x + 0] = depths.w;
|
||||
s_Depth[offsetUV.y + 4][offsetUV.x + 0] = depths.x;
|
||||
s_Depth[offsetUV.y + 4][offsetUV.x + 4] = depths.y;
|
||||
s_Depth[offsetUV.y + 0][offsetUV.x + 4] = depths.z;
|
||||
s_Depth[offsetUV.y + 0][offsetUV.x + 0] = depths.w;
|
||||
|
||||
s_Occlusion[offsetUV.y + 4][offsetUV.x + 0] = occlusion_01;
|
||||
s_Occlusion[offsetUV.y + 4][offsetUV.x + 4] = occlusion_11;
|
||||
s_Occlusion[offsetUV.y + 0][offsetUV.x + 4] = occlusion_10;
|
||||
s_Occlusion[offsetUV.y + 0][offsetUV.x + 0] = occlusion_00;
|
||||
s_Occlusion[offsetUV.y + 4][offsetUV.x + 0] = occlusion_01;
|
||||
s_Occlusion[offsetUV.y + 4][offsetUV.x + 4] = occlusion_11;
|
||||
s_Occlusion[offsetUV.y + 0][offsetUV.x + 4] = occlusion_10;
|
||||
s_Occlusion[offsetUV.y + 0][offsetUV.x + 0] = occlusion_00;
|
||||
#else
|
||||
float4 occlusions = t_DeinterleavedSSAO.GatherRed(s_Point, float3(UV, slice), int2(0, 0));
|
||||
float4 occlusions = t_DeinterleavedSSAO.GatherRed( s_Point, float3( UV, slice ), int2( 0, 0 ) );
|
||||
|
||||
s_DepthAndSSAO[offsetUV.y + 4][offsetUV.x + 0] = float2(depths.x, occlusions.x);
|
||||
s_DepthAndSSAO[offsetUV.y + 4][offsetUV.x + 4] = float2(depths.y, occlusions.y);
|
||||
s_DepthAndSSAO[offsetUV.y + 0][offsetUV.x + 4] = float2(depths.z, occlusions.z);
|
||||
s_DepthAndSSAO[offsetUV.y + 0][offsetUV.x + 0] = float2(depths.w, occlusions.w);
|
||||
s_DepthAndSSAO[offsetUV.y + 4][offsetUV.x + 0] = float2( depths.x, occlusions.x );
|
||||
s_DepthAndSSAO[offsetUV.y + 4][offsetUV.x + 4] = float2( depths.y, occlusions.y );
|
||||
s_DepthAndSSAO[offsetUV.y + 0][offsetUV.x + 4] = float2( depths.z, occlusions.z );
|
||||
s_DepthAndSSAO[offsetUV.y + 0][offsetUV.x + 0] = float2( depths.w, occlusions.w );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
|
||||
float totalWeight = 0;
|
||||
float totalWeight = 0;
|
||||
#if DIRECTIONAL_OCCLUSION
|
||||
float4 totalOcclusion = 0;
|
||||
float pixelDepth = s_Depth[threadId.y + 4][threadId.x + 4];
|
||||
float4 totalOcclusion = 0;
|
||||
float pixelDepth = s_Depth[threadId.y + 4][threadId.x + 4];
|
||||
#else
|
||||
float totalOcclusion = 0;
|
||||
float pixelDepth = s_DepthAndSSAO[threadId.y + 4][threadId.x + 4].x;
|
||||
float totalOcclusion = 0;
|
||||
float pixelDepth = s_DepthAndSSAO[threadId.y + 4][threadId.x + 4].x;
|
||||
#endif
|
||||
float rcpPixelDepth = rcp(pixelDepth);
|
||||
float rcpPixelDepth = rcp( pixelDepth );
|
||||
|
||||
const bool enableFilter = true;
|
||||
const int filterLeft = enableFilter ? 3 : 4;
|
||||
const int filterRight = enableFilter ? 6 : 4;
|
||||
int2 filterOffset;
|
||||
for (filterOffset.y = filterLeft; filterOffset.y <= filterRight; filterOffset.y++)
|
||||
for (filterOffset.x = filterLeft; filterOffset.x <= filterRight; filterOffset.x++)
|
||||
{
|
||||
const bool enableFilter = true;
|
||||
const int filterLeft = enableFilter ? 3 : 4;
|
||||
const int filterRight = enableFilter ? 6 : 4;
|
||||
int2 filterOffset;
|
||||
for( filterOffset.y = filterLeft; filterOffset.y <= filterRight; filterOffset.y++ )
|
||||
for( filterOffset.x = filterLeft; filterOffset.x <= filterRight; filterOffset.x++ )
|
||||
{
|
||||
#if DIRECTIONAL_OCCLUSION
|
||||
float sampleDepth = s_Depth[threadId.y + filterOffset.y][threadId.x + filterOffset.x];
|
||||
float4 sampleOcclusion = s_Occlusion[threadId.y + filterOffset.y][threadId.x + filterOffset.x];
|
||||
float sampleDepth = s_Depth[threadId.y + filterOffset.y][threadId.x + filterOffset.x];
|
||||
float4 sampleOcclusion = s_Occlusion[threadId.y + filterOffset.y][threadId.x + filterOffset.x];
|
||||
#else
|
||||
float2 sampleDAO = s_DepthAndSSAO[threadId.y + filterOffset.y][threadId.x + filterOffset.x].xy;
|
||||
float sampleDepth = sampleDAO.x;
|
||||
float sampleOcclusion = sampleDAO.y;
|
||||
float2 sampleDAO = s_DepthAndSSAO[threadId.y + filterOffset.y][threadId.x + filterOffset.x].xy;
|
||||
float sampleDepth = sampleDAO.x;
|
||||
float sampleOcclusion = sampleDAO.y;
|
||||
#endif
|
||||
float weight = saturate(1.0 - abs(pixelDepth - sampleDepth) * rcpPixelDepth * g_Ssao.radiusWorld);
|
||||
totalOcclusion += sampleOcclusion * weight;
|
||||
totalWeight += weight;
|
||||
}
|
||||
float weight = saturate( 1.0 - abs( pixelDepth - sampleDepth ) * rcpPixelDepth * g_Ssao.radiusWorld );
|
||||
totalOcclusion += sampleOcclusion * weight;
|
||||
totalWeight += weight;
|
||||
}
|
||||
|
||||
totalOcclusion *= rcp(totalWeight);
|
||||
totalOcclusion *= rcp( totalWeight );
|
||||
|
||||
#if !DIRECTIONAL_OCCLUSION
|
||||
totalOcclusion = pow(saturate(1.0 - totalOcclusion), g_Ssao.powerExponent);
|
||||
totalOcclusion = pow( saturate( 1.0 - totalOcclusion ), g_Ssao.powerExponent );
|
||||
#endif
|
||||
|
||||
int2 storePos = int2(globalId.xy) + g_Ssao.quantizedViewportOrigin;
|
||||
float2 storePosF = float2(storePos);
|
||||
int2 storePos = int2( globalId.xy ) + g_Ssao.quantizedViewportOrigin;
|
||||
float2 storePosF = float2( storePos );
|
||||
|
||||
//if (all(storePosF >= g_Ssao.view.viewportOrigin.xy) && all(storePosF < g_Ssao.view.viewportOrigin.xy + g_Ssao.view.viewportSize.xy))
|
||||
//{
|
||||
// u_RenderTarget[storePos] = totalOcclusion;
|
||||
//}
|
||||
//if (all(storePosF >= g_Ssao.view.viewportOrigin.xy) && all(storePosF < g_Ssao.view.viewportOrigin.xy + g_Ssao.view.viewportSize.xy))
|
||||
//{
|
||||
// u_RenderTarget[storePos] = totalOcclusion;
|
||||
//}
|
||||
}
|
||||
|
|
|
@ -26,19 +26,20 @@
|
|||
|
||||
struct SsaoConstants
|
||||
{
|
||||
float2 clipToView;
|
||||
float2 invQuantizedGbufferSize;
|
||||
float2 clipToView;
|
||||
float2 invQuantizedGbufferSize;
|
||||
|
||||
int2 quantizedViewportOrigin;
|
||||
float amount;
|
||||
float invBackgroundViewDepth;
|
||||
float radiusWorld;
|
||||
float surfaceBias;
|
||||
int2 quantizedViewportOrigin;
|
||||
float amount;
|
||||
float invBackgroundViewDepth;
|
||||
float radiusWorld;
|
||||
float surfaceBias;
|
||||
|
||||
float radiusToScreen;
|
||||
float powerExponent;
|
||||
float radiusToScreen;
|
||||
float powerExponent;
|
||||
};
|
||||
|
||||
// *INDENT-OFF*
|
||||
Texture2DArray<float> t_DeinterleavedDepth : register(t0);
|
||||
#if OCT_ENCODED_NORMALS
|
||||
Texture2D<uint> t_Normals : register(t1);
|
||||
|
@ -55,43 +56,46 @@ cbuffer c_Ssao : register(b1)
|
|||
{
|
||||
SsaoConstants g_Ssao;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
// Set of samples with distance from center increasing linearly,
|
||||
// and angle also increasing linearly with a step of 4.5678 radians.
|
||||
// Plotted on x-y dimensions, it looks pretty much random, but is intended
|
||||
// to make more samples closer to the center because they have greater weight.
|
||||
static const float2 g_SamplePositions[] = {
|
||||
float2(-0.016009523, -0.10995169),
|
||||
float2(-0.159746436, 0.047527402),
|
||||
float2(0.09339819, 0.201641995),
|
||||
float2(0.232600698, 0.151846663),
|
||||
float2(-0.220531935, -0.24995355),
|
||||
float2(-0.251498143, 0.29661971),
|
||||
float2(0.376870668, .23558303),
|
||||
float2(0.201175979, 0.457742532),
|
||||
float2(-0.535502966, -0.147913991),
|
||||
float2(-0.076133435, 0.606350138),
|
||||
float2(0.666537538, 0.013120791),
|
||||
float2(-0.118107615, -0.712499494),
|
||||
float2(-0.740973793, 0.236423582),
|
||||
float2(0.365057451, .749117816),
|
||||
float2(0.734614792, 0.500464349),
|
||||
float2(-0.638657704, -0.695766948)
|
||||
static const float2 g_SamplePositions[] =
|
||||
{
|
||||
float2( -0.016009523, -0.10995169 ),
|
||||
float2( -0.159746436, 0.047527402 ),
|
||||
float2( 0.09339819, 0.201641995 ),
|
||||
float2( 0.232600698, 0.151846663 ),
|
||||
float2( -0.220531935, -0.24995355 ),
|
||||
float2( -0.251498143, 0.29661971 ),
|
||||
float2( 0.376870668, .23558303 ),
|
||||
float2( 0.201175979, 0.457742532 ),
|
||||
float2( -0.535502966, -0.147913991 ),
|
||||
float2( -0.076133435, 0.606350138 ),
|
||||
float2( 0.666537538, 0.013120791 ),
|
||||
float2( -0.118107615, -0.712499494 ),
|
||||
float2( -0.740973793, 0.236423582 ),
|
||||
float2( 0.365057451, .749117816 ),
|
||||
float2( 0.734614792, 0.500464349 ),
|
||||
float2( -0.638657704, -0.695766948 )
|
||||
};
|
||||
|
||||
// Blue noise
|
||||
static const float g_RandomValues[16] = {
|
||||
0.059, 0.529, 0.176, 0.647,
|
||||
0.765, 0.294, 0.882, 0.412,
|
||||
0.235, 0.706, 0.118, 0.588,
|
||||
0.941, 0.471, 0.824, 0.353
|
||||
static const float g_RandomValues[16] =
|
||||
{
|
||||
0.059, 0.529, 0.176, 0.647,
|
||||
0.765, 0.294, 0.882, 0.412,
|
||||
0.235, 0.706, 0.118, 0.588,
|
||||
0.941, 0.471, 0.824, 0.353
|
||||
};
|
||||
|
||||
// Helper function to reflect the folds of the lower hemisphere
|
||||
// over the diagonals in the octahedral map
|
||||
float2 octWrap( float2 v )
|
||||
{
|
||||
return ( 1.f - abs( v.yx ) ) * ( v.xy >= 0.f ? 1.f : -1.f );
|
||||
return ( 1.f - abs( v.yx ) ) * ( v.xy >= 0.f ? 1.f : -1.f );
|
||||
}
|
||||
|
||||
/**********************/
|
||||
|
@ -101,21 +105,21 @@ float2 octWrap( float2 v )
|
|||
// Returns a signed position in octahedral map [-1, 1] for each component
|
||||
float2 ndirToOctSigned( float3 n )
|
||||
{
|
||||
// Project the sphere onto the octahedron (|x|+|y|+|z| = 1) and then onto the xy-plane
|
||||
float2 p = n.xy * ( 1.f / ( abs( n.x ) + abs( n.y ) + abs( n.z ) ) );
|
||||
return ( n.z < 0.f ) ? octWrap( p ) : p;
|
||||
// Project the sphere onto the octahedron (|x|+|y|+|z| = 1) and then onto the xy-plane
|
||||
float2 p = n.xy * ( 1.f / ( abs( n.x ) + abs( n.y ) + abs( n.z ) ) );
|
||||
return ( n.z < 0.f ) ? octWrap( p ) : p;
|
||||
}
|
||||
|
||||
// Converts a point in the octahedral map to a normalized direction (non-equal area, signed)
|
||||
// p - signed position in octahedral map [-1, 1] for each component
|
||||
// p - signed position in octahedral map [-1, 1] for each component
|
||||
// Returns normalized direction
|
||||
float3 octToNdirSigned( float2 p )
|
||||
{
|
||||
// https://twitter.com/Stubbesaurus/status/937994790553227264
|
||||
float3 n = float3( p.x, p.y, 1.0 - abs( p.x ) - abs( p.y ) );
|
||||
float t = max( 0, -n.z );
|
||||
n.xy += n.xy >= 0.0 ? -t : t;
|
||||
return normalize( n );
|
||||
// https://twitter.com/Stubbesaurus/status/937994790553227264
|
||||
float3 n = float3( p.x, p.y, 1.0 - abs( p.x ) - abs( p.y ) );
|
||||
float t = max( 0, -n.z );
|
||||
n.xy += n.xy >= 0.0 ? -t : t;
|
||||
return normalize( n );
|
||||
}
|
||||
|
||||
/**********************/
|
||||
|
@ -126,9 +130,9 @@ float3 octToNdirSigned( float2 p )
|
|||
// The two components of the result are stored in UNORM16 format, [0..1]
|
||||
uint ndirToOctUnorm32( float3 n )
|
||||
{
|
||||
float2 p = ndirToOctSigned( n );
|
||||
p = saturate( p.xy * 0.5 + 0.5 );
|
||||
return uint( p.x * 0xfffe ) | ( uint( p.y * 0xfffe ) << 16 );
|
||||
float2 p = ndirToOctSigned( n );
|
||||
p = saturate( p.xy * 0.5 + 0.5 );
|
||||
return uint( p.x * 0xfffe ) | ( uint( p.y * 0xfffe ) << 16 );
|
||||
}
|
||||
|
||||
// Converts a point in the octahedral map (non-equal area, unsigned normalized) to normalized direction
|
||||
|
@ -136,11 +140,11 @@ uint ndirToOctUnorm32( float3 n )
|
|||
// Returns normalized direction
|
||||
float3 octToNdirUnorm32( uint pUnorm )
|
||||
{
|
||||
float2 p;
|
||||
p.x = saturate( float( pUnorm & 0xffff ) / 0xfffe );
|
||||
p.y = saturate( float( pUnorm >> 16 ) / 0xfffe );
|
||||
p = p * 2.0 - 1.0;
|
||||
return octToNdirSigned( p );
|
||||
float2 p;
|
||||
p.x = saturate( float( pUnorm & 0xffff ) / 0xfffe );
|
||||
p.y = saturate( float( pUnorm >> 16 ) / 0xfffe );
|
||||
p = p * 2.0 - 1.0;
|
||||
return octToNdirSigned( p );
|
||||
}
|
||||
|
||||
// Project the direction onto the first two spherical harmonics.
|
||||
|
@ -149,129 +153,129 @@ float3 octToNdirUnorm32( uint pUnorm )
|
|||
// Multiply the output of this function by the signal magnitude.
|
||||
float4 directionToSphericalHarmonics( float3 normalizedDirection )
|
||||
{
|
||||
return float4( normalizedDirection, 1.0 );
|
||||
return float4( normalizedDirection, 1.0 );
|
||||
}
|
||||
|
||||
// V = unnormalized vector from center pixel to current sample
|
||||
// N = normal at center pixel
|
||||
float ComputeAO(float3 V, float3 N, float InvR2)
|
||||
float ComputeAO( float3 V, float3 N, float InvR2 )
|
||||
{
|
||||
float VdotV = dot(V, V);
|
||||
float NdotV = dot(N, V) * rsqrt(VdotV);
|
||||
float lambertian = saturate(NdotV - g_Ssao.surfaceBias);
|
||||
float falloff = saturate(1 - VdotV * InvR2);
|
||||
return saturate(lambertian * falloff * g_Ssao.amount);
|
||||
float VdotV = dot( V, V );
|
||||
float NdotV = dot( N, V ) * rsqrt( VdotV );
|
||||
float lambertian = saturate( NdotV - g_Ssao.surfaceBias );
|
||||
float falloff = saturate( 1 - VdotV * InvR2 );
|
||||
return saturate( lambertian * falloff * g_Ssao.amount );
|
||||
}
|
||||
|
||||
float2 WindowToClip(float2 windowPos)
|
||||
float2 WindowToClip( float2 windowPos )
|
||||
{
|
||||
float2 clipToWindowScale = float2( 0.5f * rpWindowCoord.z, -0.5f * rpWindowCoord.w );
|
||||
float2 clipToWindowBias = rpViewOrigin.xy + rpWindowCoord.zw * 0.5f;
|
||||
float2 clipToWindowScale = float2( 0.5f * rpWindowCoord.z, -0.5f * rpWindowCoord.w );
|
||||
float2 clipToWindowBias = rpViewOrigin.xy + rpWindowCoord.zw * 0.5f;
|
||||
|
||||
float2 windowToClipScale = 1.f / clipToWindowScale;
|
||||
float2 windowToClipBias = -clipToWindowBias * windowToClipScale;
|
||||
float2 windowToClipScale = 1.f / clipToWindowScale;
|
||||
float2 windowToClipBias = -clipToWindowBias * windowToClipScale;
|
||||
|
||||
return windowPos.xy * windowToClipScale + windowToClipBias;
|
||||
return windowPos.xy * windowToClipScale + windowToClipBias;
|
||||
}
|
||||
|
||||
float3 ViewDepthToViewPos(float2 clipPosXY, float viewDepth)
|
||||
float3 ViewDepthToViewPos( float2 clipPosXY, float viewDepth )
|
||||
{
|
||||
return float3(clipPosXY * g_Ssao.clipToView.xy * viewDepth, viewDepth);
|
||||
return float3( clipPosXY * g_Ssao.clipToView.xy * viewDepth, viewDepth );
|
||||
}
|
||||
|
||||
[numthreads(8, 8, 1)]
|
||||
void main(uint3 globalId : SV_DispatchThreadID)
|
||||
[numthreads( 8, 8, 1 )]
|
||||
void main( uint3 globalId : SV_DispatchThreadID )
|
||||
{
|
||||
int sliceIndex = int(globalId.z);
|
||||
int2 sliceOffset = int2(sliceIndex & 3, sliceIndex >> 2);
|
||||
int sliceIndex = int( globalId.z );
|
||||
int2 sliceOffset = int2( sliceIndex & 3, sliceIndex >> 2 );
|
||||
|
||||
int2 pixelPos = (int2(globalId.xy) << 2) + sliceOffset + g_Ssao.quantizedViewportOrigin;
|
||||
int2 quarterResPixelPos = pixelPos >> 2;
|
||||
int2 pixelPos = ( int2( globalId.xy ) << 2 ) + sliceOffset + g_Ssao.quantizedViewportOrigin;
|
||||
int2 quarterResPixelPos = pixelPos >> 2;
|
||||
|
||||
float pixelViewDepth = t_DeinterleavedDepth[int3(quarterResPixelPos, sliceIndex)];
|
||||
float pixelViewDepth = t_DeinterleavedDepth[int3( quarterResPixelPos, sliceIndex )];
|
||||
#if OCT_ENCODED_NORMALS
|
||||
float3 pixelNormal = octToNdirUnorm32(t_Normals[pixelPos]);
|
||||
float3 pixelNormal = octToNdirUnorm32( t_Normals[pixelPos] );
|
||||
#else
|
||||
float3 pixelNormal = t_Normals[pixelPos].xyz;
|
||||
float3 pixelNormal = t_Normals[pixelPos].xyz;
|
||||
#endif
|
||||
|
||||
// View to clip space.
|
||||
float3 pN;
|
||||
pN.x = dot4( float4( pixelNormal, 0), rpModelMatrixX );
|
||||
pN.y = dot4( float4( pixelNormal, 0 ), rpModelMatrixY );
|
||||
pN.z = dot4( float4( pixelNormal, 0 ), rpModelMatrixZ );
|
||||
// View to clip space.
|
||||
float3 pN;
|
||||
pN.x = dot4( float4( pixelNormal, 0 ), rpModelMatrixX );
|
||||
pN.y = dot4( float4( pixelNormal, 0 ), rpModelMatrixY );
|
||||
pN.z = dot4( float4( pixelNormal, 0 ), rpModelMatrixZ );
|
||||
|
||||
pixelNormal = normalize( pN );
|
||||
pixelNormal = normalize( pN );
|
||||
|
||||
float2 pixelClipPos = WindowToClip(pixelPos);
|
||||
float3 pixelViewPos = ViewDepthToViewPos(pixelClipPos.xy, pixelViewDepth);
|
||||
float2 pixelClipPos = WindowToClip( pixelPos );
|
||||
float3 pixelViewPos = ViewDepthToViewPos( pixelClipPos.xy, pixelViewDepth );
|
||||
|
||||
float radiusWorld = g_Ssao.radiusWorld * max(1.0, pixelViewDepth * g_Ssao.invBackgroundViewDepth);
|
||||
float radiusPixels = radiusWorld * g_Ssao.radiusToScreen / pixelViewDepth;
|
||||
float radiusWorld = g_Ssao.radiusWorld * max( 1.0, pixelViewDepth * g_Ssao.invBackgroundViewDepth );
|
||||
float radiusPixels = radiusWorld * g_Ssao.radiusToScreen / pixelViewDepth;
|
||||
|
||||
#if DIRECTIONAL_OCCLUSION
|
||||
float4 result = 0;
|
||||
float4 result = 0;
|
||||
#else
|
||||
float result = 0;
|
||||
float result = 0;
|
||||
#endif
|
||||
|
||||
if (radiusPixels > 1)
|
||||
{
|
||||
float invRadiusWorld2 = rcp(radiusWorld * radiusWorld);
|
||||
if( radiusPixels > 1 )
|
||||
{
|
||||
float invRadiusWorld2 = rcp( radiusWorld * radiusWorld );
|
||||
|
||||
float angle = g_RandomValues[(pixelPos.x & 3) + ((pixelPos.y & 3) << 2)] * PI;
|
||||
float2 sincos = float2(sin(angle), cos(angle));
|
||||
float angle = g_RandomValues[( pixelPos.x & 3 ) + ( ( pixelPos.y & 3 ) << 2 )] * PI;
|
||||
float2 sincos = float2( sin( angle ), cos( angle ) );
|
||||
|
||||
int numSamples = 16;
|
||||
float numValidSamples = 0;
|
||||
int numSamples = 16;
|
||||
float numValidSamples = 0;
|
||||
|
||||
[unroll]
|
||||
for (int nSample = 0; nSample < numSamples; nSample++)
|
||||
{
|
||||
float2 sampleOffset = g_SamplePositions[nSample];
|
||||
sampleOffset = float2(
|
||||
sampleOffset.x * sincos.y - sampleOffset.y * sincos.x,
|
||||
sampleOffset.x * sincos.x + sampleOffset.y * sincos.y);
|
||||
[unroll]
|
||||
for( int nSample = 0; nSample < numSamples; nSample++ )
|
||||
{
|
||||
float2 sampleOffset = g_SamplePositions[nSample];
|
||||
sampleOffset = float2(
|
||||
sampleOffset.x * sincos.y - sampleOffset.y * sincos.x,
|
||||
sampleOffset.x * sincos.x + sampleOffset.y * sincos.y );
|
||||
|
||||
float2 sampleWindowPos = pixelPos + sampleOffset * radiusPixels + 0.5;
|
||||
int2 sampleWindowPosInt = int2(floor(sampleWindowPos * 0.25));
|
||||
float2 sampleWindowPos = pixelPos + sampleOffset * radiusPixels + 0.5;
|
||||
int2 sampleWindowPosInt = int2( floor( sampleWindowPos * 0.25 ) );
|
||||
|
||||
float sampleViewDepth = t_DeinterleavedDepth[int3(sampleWindowPosInt, sliceIndex)];
|
||||
float2 actualClipPos = WindowToClip(float2(sampleWindowPosInt) * 4.0 + sliceOffset + 0.5);
|
||||
float sampleViewDepth = t_DeinterleavedDepth[int3( sampleWindowPosInt, sliceIndex )];
|
||||
float2 actualClipPos = WindowToClip( float2( sampleWindowPosInt ) * 4.0 + sliceOffset + 0.5 );
|
||||
|
||||
if (sampleViewDepth > 0 && any(quarterResPixelPos != sampleWindowPosInt) && all(abs(actualClipPos.xy) < 1.0))
|
||||
{
|
||||
float3 sampleViewPos = ViewDepthToViewPos(actualClipPos, sampleViewDepth);
|
||||
float3 pixelToSample = sampleViewPos - pixelViewPos;
|
||||
float AO = ComputeAO(pixelToSample, pixelNormal, invRadiusWorld2);
|
||||
if( sampleViewDepth > 0 && any( quarterResPixelPos != sampleWindowPosInt ) && all( abs( actualClipPos.xy ) < 1.0 ) )
|
||||
{
|
||||
float3 sampleViewPos = ViewDepthToViewPos( actualClipPos, sampleViewDepth );
|
||||
float3 pixelToSample = sampleViewPos - pixelViewPos;
|
||||
float AO = ComputeAO( pixelToSample, pixelNormal, invRadiusWorld2 );
|
||||
#if DIRECTIONAL_OCCLUSION
|
||||
result += directionToSphericalHarmonics(normalize(pixelToSample)) * AO;
|
||||
result += directionToSphericalHarmonics( normalize( pixelToSample ) ) * AO;
|
||||
#else
|
||||
result += AO;
|
||||
result += AO;
|
||||
#endif
|
||||
numValidSamples += 1;
|
||||
}
|
||||
}
|
||||
numValidSamples += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (numValidSamples > 0)
|
||||
{
|
||||
result /= numValidSamples;
|
||||
}
|
||||
}
|
||||
if( numValidSamples > 0 )
|
||||
{
|
||||
result /= numValidSamples;
|
||||
}
|
||||
}
|
||||
|
||||
#if DIRECTIONAL_OCCLUSION
|
||||
// Rotate the directional part of the SH into world space
|
||||
float directionalLength = length(result.xyz);
|
||||
if (directionalLength > 0)
|
||||
{
|
||||
float3 worldSpaceResult;
|
||||
worldSpaceResult.x = dot4( float4( normalize( result.xyz ), 0 ), rpModelMatrixX );
|
||||
worldSpaceResult.y = dot4( float4( normalize( result.xyz ), 0 ), rpModelMatrixY );
|
||||
worldSpaceResult.z = dot4( float4( normalize( result.xyz ), 0 ), rpModelMatrixZ );
|
||||
// Rotate the directional part of the SH into world space
|
||||
float directionalLength = length( result.xyz );
|
||||
if( directionalLength > 0 )
|
||||
{
|
||||
float3 worldSpaceResult;
|
||||
worldSpaceResult.x = dot4( float4( normalize( result.xyz ), 0 ), rpModelMatrixX );
|
||||
worldSpaceResult.y = dot4( float4( normalize( result.xyz ), 0 ), rpModelMatrixY );
|
||||
worldSpaceResult.z = dot4( float4( normalize( result.xyz ), 0 ), rpModelMatrixZ );
|
||||
|
||||
result.xyz = worldSpaceResult.xyz * directionalLength;
|
||||
}
|
||||
result.xyz = worldSpaceResult.xyz * directionalLength;
|
||||
}
|
||||
#endif
|
||||
|
||||
u_RenderTarget[int3(quarterResPixelPos.xy, sliceIndex)] = result;
|
||||
u_RenderTarget[int3( quarterResPixelPos.xy, sliceIndex )] = result;
|
||||
}
|
||||
|
|
|
@ -26,19 +26,20 @@
|
|||
|
||||
struct SsaoConstants
|
||||
{
|
||||
float2 clipToView;
|
||||
float2 invQuantizedGbufferSize;
|
||||
float2 clipToView;
|
||||
float2 invQuantizedGbufferSize;
|
||||
|
||||
int2 quantizedViewportOrigin;
|
||||
float amount;
|
||||
float invBackgroundViewDepth;
|
||||
float radiusWorld;
|
||||
float surfaceBias;
|
||||
int2 quantizedViewportOrigin;
|
||||
float amount;
|
||||
float invBackgroundViewDepth;
|
||||
float radiusWorld;
|
||||
float surfaceBias;
|
||||
|
||||
float radiusToScreen;
|
||||
float powerExponent;
|
||||
float radiusToScreen;
|
||||
float powerExponent;
|
||||
};
|
||||
|
||||
// *INDENT-OFF*
|
||||
cbuffer c_Ssao : register( b1 )
|
||||
{
|
||||
SsaoConstants g_Ssao;
|
||||
|
@ -46,45 +47,46 @@ cbuffer c_Ssao : register( b1 )
|
|||
|
||||
Texture2D<float> t_InputDepth : register(t0);
|
||||
RWTexture2DArray<float> u_DeinterleavedDepth : register(u0);
|
||||
// *INDENT-ON*
|
||||
|
||||
[numthreads(8, 8, 1)]
|
||||
void main(uint3 globalId : SV_DispatchThreadID)
|
||||
[numthreads( 8, 8, 1 )]
|
||||
void main( uint3 globalId : SV_DispatchThreadID )
|
||||
{
|
||||
float depths[16];
|
||||
uint2 groupBase = globalId.xy * 4 + g_Ssao.quantizedViewportOrigin;
|
||||
float depths[16];
|
||||
uint2 groupBase = globalId.xy * 4 + g_Ssao.quantizedViewportOrigin;
|
||||
|
||||
[unroll]
|
||||
for (uint y = 0; y < 4; y++)
|
||||
{
|
||||
[unroll]
|
||||
for (uint x = 0; x < 4; x++)
|
||||
{
|
||||
uint2 gbufferSamplePos = groupBase + uint2(x, y);
|
||||
float depth = t_InputDepth[gbufferSamplePos];
|
||||
[unroll]
|
||||
for( uint y = 0; y < 4; y++ )
|
||||
{
|
||||
[unroll]
|
||||
for( uint x = 0; x < 4; x++ )
|
||||
{
|
||||
uint2 gbufferSamplePos = groupBase + uint2( x, y );
|
||||
float depth = t_InputDepth[gbufferSamplePos];
|
||||
|
||||
#if LINEAR_DEPTH
|
||||
float linearDepth = depth;
|
||||
float linearDepth = depth;
|
||||
#else
|
||||
float4 clipPos = float4(0, 0, depth, 1);
|
||||
float4 viewPos;
|
||||
viewPos.x = dot4( clipPos, rpModelMatrixX );
|
||||
viewPos.y = dot4( clipPos, rpModelMatrixY );
|
||||
viewPos.z = dot4( clipPos, rpModelMatrixZ );
|
||||
viewPos.w = dot4( clipPos, rpModelMatrixW );
|
||||
float4 clipPos = float4( 0, 0, depth, 1 );
|
||||
float4 viewPos;
|
||||
viewPos.x = dot4( clipPos, rpModelMatrixX );
|
||||
viewPos.y = dot4( clipPos, rpModelMatrixY );
|
||||
viewPos.z = dot4( clipPos, rpModelMatrixZ );
|
||||
viewPos.w = dot4( clipPos, rpModelMatrixW );
|
||||
|
||||
float linearDepth = viewPos.z / viewPos.w;
|
||||
float linearDepth = viewPos.z / viewPos.w;
|
||||
#endif
|
||||
|
||||
depths[y * 4 + x] = linearDepth;
|
||||
}
|
||||
}
|
||||
depths[y * 4 + x] = linearDepth;
|
||||
}
|
||||
}
|
||||
|
||||
uint2 quarterResPos = groupBase >> 2;
|
||||
uint2 quarterResPos = groupBase >> 2;
|
||||
|
||||
[unroll]
|
||||
for(uint index = 0; index < 16; index++)
|
||||
{
|
||||
float depth = depths[index];
|
||||
u_DeinterleavedDepth[uint3(quarterResPos.xy, index)] = depth;
|
||||
}
|
||||
[unroll]
|
||||
for( uint index = 0; index < 16; index++ )
|
||||
{
|
||||
float depth = depths[index];
|
||||
u_DeinterleavedDepth[uint3( quarterResPos.xy, index )] = depth;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -526,7 +526,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
|
||||
float radialJitter = frac( sin( fragment.position.x * 1e2 +
|
||||
#if TEMPORALLY_VARY_TAPS
|
||||
rpJitterTexOffset.x +
|
||||
rpJitterTexOffset.x +
|
||||
#endif
|
||||
fragment.position.y ) * 1e5 + sin( fragment.position.y * 1e3 ) * 1e3 ) * 0.8 + 0.1;
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
// *INDENT-OFF*
|
||||
#if TEXTURE_ARRAY
|
||||
Texture2DArray tex : register(t0);
|
||||
#else
|
||||
|
@ -32,14 +33,15 @@ struct PS_IN
|
|||
float4 posClip : SV_Position;
|
||||
float2 uv : UV;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
void main(
|
||||
PS_IN fragment,
|
||||
out float4 o_rgba : SV_Target)
|
||||
out float4 o_rgba : SV_Target )
|
||||
{
|
||||
#if TEXTURE_ARRAY
|
||||
o_rgba = tex.Sample(samp, float3( fragment.uv, 0));
|
||||
o_rgba = tex.Sample( samp, float3( fragment.uv, 0 ) );
|
||||
#else
|
||||
o_rgba = tex.Sample(samp, fragment.uv);
|
||||
o_rgba = tex.Sample( samp, fragment.uv );
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -31,7 +31,8 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
|
||||
#if USE_GPU_SKINNING
|
||||
cbuffer CB : register( b1 )
|
||||
cbuffer CB :
|
||||
register( b1 )
|
||||
{
|
||||
float4 matrices[408];
|
||||
};
|
||||
|
|
|
@ -32,7 +32,8 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
#if USE_GPU_SKINNING
|
||||
|
||||
cbuffer CB : register( b1 )
|
||||
cbuffer CB :
|
||||
register( b1 )
|
||||
{
|
||||
float4 matrices[408];
|
||||
};
|
||||
|
|
|
@ -32,7 +32,8 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
#if USE_GPU_SKINNING
|
||||
|
||||
cbuffer CB : register( b1 )
|
||||
cbuffer CB :
|
||||
register( b1 )
|
||||
{
|
||||
float4 matrices[408];
|
||||
};
|
||||
|
|
|
@ -30,7 +30,8 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
|
||||
#if USE_GPU_SKINNING
|
||||
cbuffer CB : register( b1 )
|
||||
cbuffer CB :
|
||||
register( b1 )
|
||||
{
|
||||
float4 matrices[408];
|
||||
};
|
||||
|
|
|
@ -51,7 +51,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
{
|
||||
float4 c = idtex2Dproj( samp0, t_Light1, fragment.texcoord0 ) * t_Light2.Sample( samp1, fragment.texcoord1 ) * rpColor;
|
||||
|
||||
#if defined( USE_LINEAR_RGB )
|
||||
#if USE_LINEAR_RGB
|
||||
c = clamp( c, 0.0, 1.0 );
|
||||
|
||||
c = float4( Linear1( c.r ), Linear1( c.g ), Linear1( c.b ), Linear1( c.a ) );
|
||||
|
|
|
@ -31,16 +31,16 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
|
||||
// *INDENT-OFF*
|
||||
Texture2D t_Fog1 : register( t0 );
|
||||
Texture2D t_Fog2 : register( t1 );
|
||||
Texture2D t_Fog1 : register( t0 );
|
||||
Texture2D t_Fog2 : register( t1 );
|
||||
|
||||
SamplerState samp0 : register(s0);
|
||||
SamplerState samp1 : register(s1);
|
||||
SamplerState samp0 : register(s0);
|
||||
SamplerState samp1 : register(s1);
|
||||
|
||||
struct PS_IN {
|
||||
float4 position : SV_Position;
|
||||
float2 texcoord0 : TEXCOORD0_centroid;
|
||||
float2 texcoord1 : TEXCOORD1_centroid;
|
||||
float4 position : SV_Position;
|
||||
float2 texcoord0 : TEXCOORD0_centroid;
|
||||
float2 texcoord1 : TEXCOORD1_centroid;
|
||||
};
|
||||
|
||||
struct PS_OUT {
|
||||
|
@ -52,7 +52,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
{
|
||||
float4 c = t_Fog1.Sample( samp0, fragment.texcoord0 ) * t_Fog2.Sample( samp1, fragment.texcoord1 ) * rpColor;
|
||||
|
||||
#if defined( USE_LINEAR_RGB )
|
||||
#if USE_LINEAR_RGB
|
||||
c = clamp( c, 0.0, 1.0 );
|
||||
|
||||
c = float4( Linear1( c.r ), Linear1( c.g ), Linear1( c.b ), Linear1( c.a ) );
|
||||
|
|
|
@ -49,7 +49,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
{
|
||||
float4 c = tex2D( samp0, fragment.texcoord0 ) * tex2D( samp1, fragment.texcoord1 ) * rpColor;
|
||||
|
||||
#if defined( USE_LINEAR_RGB )
|
||||
#if USE_LINEAR_RGB
|
||||
c = clamp( c, 0.0, 1.0 );
|
||||
|
||||
c = float4( Linear1( c.r ), Linear1( c.g ), Linear1( c.b ), Linear1( c.a ) );
|
||||
|
|
|
@ -58,7 +58,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
|
||||
// RB begin
|
||||
float3 localNormal;
|
||||
#if defined(USE_NORMAL_FMT_RGB8)
|
||||
#if USE_NORMAL_FMT_RGB8
|
||||
localNormal = float3( bump.rg, 0.0f );
|
||||
#else
|
||||
localNormal = float3( bump.wy, 0.0f );
|
||||
|
|
|
@ -31,7 +31,8 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
|
||||
#if USE_GPU_SKINNING
|
||||
cbuffer CB : register( b1 )
|
||||
cbuffer CB :
|
||||
register( b1 )
|
||||
{
|
||||
float4 matrices[408];
|
||||
};
|
||||
|
|
|
@ -28,6 +28,7 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
#include "../global_inc.hlsl"
|
||||
|
||||
// *INDENT-OFF*
|
||||
Texture2D texGui : register( t0 );
|
||||
SamplerState samp0 : register( s0 );
|
||||
|
||||
|
@ -41,6 +42,7 @@ struct PS_IN {
|
|||
struct PS_OUT {
|
||||
float4 color : SV_Target0;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
void main( PS_IN fragment, out PS_OUT result )
|
||||
{
|
||||
|
|
|
@ -29,6 +29,7 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
#include <global_inc.hlsl>
|
||||
|
||||
// *INDENT-OFF*
|
||||
struct VS_IN {
|
||||
float4 position : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
|
@ -42,6 +43,7 @@ struct VS_OUT {
|
|||
float4 texcoord1 : TEXCOORD1;
|
||||
float4 color : COLOR0;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
void main( VS_IN vertex, out VS_OUT result )
|
||||
{
|
||||
|
|
|
@ -29,7 +29,8 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#include "global_inc.hlsl"
|
||||
|
||||
#if USE_GPU_SKINNING
|
||||
cbuffer CB : register( b1 )
|
||||
cbuffer CB :
|
||||
register( b1 )
|
||||
{
|
||||
float4 matrices[408];
|
||||
};
|
||||
|
|
|
@ -34,7 +34,7 @@ TextureCube t_CubeMap : register( t0 );
|
|||
SamplerState samp0 : register( s0 ); // texture 0 is the cube map
|
||||
|
||||
struct PS_IN {
|
||||
float4 position : VPOS;
|
||||
float4 position : SV_Position;
|
||||
float3 texcoord0 : TEXCOORD0_centroid;
|
||||
float3 texcoord1 : TEXCOORD1_centroid;
|
||||
float4 color : COLOR0;
|
||||
|
|
|
@ -30,7 +30,8 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
#if USE_GPU_SKINNING
|
||||
|
||||
cbuffer CB : register( b1 )
|
||||
cbuffer CB :
|
||||
register( b1 )
|
||||
{
|
||||
float4 matrices[408];
|
||||
};
|
||||
|
@ -48,9 +49,9 @@ struct VS_IN {
|
|||
};
|
||||
|
||||
struct VS_OUT {
|
||||
float4 position : POSITION;
|
||||
float3 texcoord0 : TEXCOORD0;
|
||||
float3 texcoord1 : TEXCOORD1;
|
||||
float4 position : SV_Position;
|
||||
float3 texcoord0 : TEXCOORD0_centroid;
|
||||
float3 texcoord1 : TEXCOORD1_centroid;
|
||||
float4 color : COLOR0;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
|
|
@ -314,7 +314,8 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
|
||||
results in these offsets
|
||||
*/
|
||||
const float3 cornerOffsets[8] = {
|
||||
const float3 cornerOffsets[8] =
|
||||
{
|
||||
float3( 0.0, 0.0, 0.0 ),
|
||||
float3( 1.0, 0.0, 0.0 ),
|
||||
float3( 0.0, 2.0, 0.0 ),
|
||||
|
|
|
@ -31,7 +31,8 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
|
||||
#if USE_GPU_SKINNING
|
||||
cbuffer CB : register( b1 )
|
||||
cbuffer CB :
|
||||
register( b1 )
|
||||
{
|
||||
float4 matrices[408];
|
||||
};
|
||||
|
|
|
@ -31,7 +31,8 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
|
||||
#if USE_GPU_SKINNING
|
||||
cbuffer CB : register( b1 )
|
||||
cbuffer CB :
|
||||
register( b1 )
|
||||
{
|
||||
float4 matrices[408];
|
||||
};
|
||||
|
|
|
@ -290,8 +290,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
radiance += t_RadianceCubeMap3.SampleLevel( samp10, normalizedOctCoordZeroOne, mip ).rgb * rpLocalLightOrigin.z;
|
||||
//radiance = float3( 0.0 );
|
||||
|
||||
// TODO(Stephen): It's possible that this should not be Sample, but something else?
|
||||
float2 envBRDF = t_BrdfLut.Sample( samp3, float2( max( vDotN, 0.0 ), roughness ) ).rg;
|
||||
float2 envBRDF = t_BrdfLut.SampleLevel( samp3, float2( max( vDotN, 0.0 ), roughness ), 0 ).rg;
|
||||
|
||||
#if 0
|
||||
result.color.rgb = float3( envBRDF.x, envBRDF.y, 0.0 );
|
||||
|
@ -300,7 +299,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
#endif
|
||||
|
||||
float specAO = ComputeSpecularAO( vDotN, ao, roughness );
|
||||
float3 specularLight = radiance * ( kS * envBRDF.x + _float3( envBRDF.y ) ) * specAO * ( rpSpecularModifier.xyz * 1.0 );
|
||||
float3 specularLight = radiance * ( kS * envBRDF.x + envBRDF.y ) * specAO * ( rpSpecularModifier.xyz * 1.0 );
|
||||
|
||||
#if 1
|
||||
// Marmoset Horizon Fade trick
|
||||
|
|
|
@ -31,7 +31,8 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
|
||||
#if USE_GPU_SKINNING
|
||||
cbuffer CB : register( b1 )
|
||||
cbuffer CB :
|
||||
register( b1 )
|
||||
{
|
||||
float4 matrices[408];
|
||||
};
|
||||
|
|
|
@ -30,7 +30,8 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#include "global_inc.hlsl"
|
||||
|
||||
#if USE_GPU_SKINNING
|
||||
cbuffer CB : register( b1 )
|
||||
cbuffer CB :
|
||||
register( b1 )
|
||||
{
|
||||
float4 matrices[408];
|
||||
};
|
||||
|
|
|
@ -33,16 +33,17 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
|
||||
// *INDENT-OFF*
|
||||
Texture2D t_Normal : register( t0 );
|
||||
Texture2D t_Specular : register( t1 );
|
||||
Texture2D t_BaseColor : register( t2 );
|
||||
Texture2D t_LightFalloff : register( t3 );
|
||||
Texture2D t_LightProjection : register( t4 );
|
||||
Texture2DArray t_ShadowMapArray : register( t5 );
|
||||
Texture2D t_Jitter : register( t6 );
|
||||
Texture2D t_Normal : register( t0 );
|
||||
Texture2D t_Specular : register( t1 );
|
||||
Texture2D t_BaseColor : register( t2 );
|
||||
Texture2D t_LightFalloff : register( t3 );
|
||||
Texture2D t_LightProjection : register( t4 );
|
||||
Texture2DArray<float> t_ShadowMapArray : register( t5 );
|
||||
Texture2D t_Jitter : register( t6 );
|
||||
|
||||
SamplerState samp0 : register(s0); // for the normal/specular/color/light fall/light projection textures
|
||||
SamplerState samp1 : register(s1); // for the shadow map sampler and jitter sampler
|
||||
SamplerState samp0 : register(s0); // for the normal/specular/color/light fall/light projection textures
|
||||
SamplerState samp1 : register(s1); // for sampling the jitter
|
||||
SamplerComparisonState samp2 : register(s2); // for the depth shadow map sampler with a compare function
|
||||
|
||||
struct PS_IN
|
||||
{
|
||||
|
@ -96,8 +97,8 @@ float2 VogelDiskSample( float sampleIndex, float samplesCount, float phi )
|
|||
void main( PS_IN fragment, out PS_OUT result )
|
||||
{
|
||||
half4 bumpMap = t_Normal.Sample( samp0, fragment.texcoord1.xy );
|
||||
half4 lightFalloff = idtex2Dproj( samp0, t_LightFalloff, fragment.texcoord2 );
|
||||
half4 lightProj = idtex2Dproj( samp0, t_LightProjection, fragment.texcoord3 );
|
||||
half4 lightFalloff = idtex2Dproj( samp1, t_LightFalloff, fragment.texcoord2 );
|
||||
half4 lightProj = idtex2Dproj( samp1, t_LightProjection, fragment.texcoord3 );
|
||||
half4 YCoCG = t_BaseColor.Sample( samp0, fragment.texcoord4.xy );
|
||||
half4 specMapSRGB = t_Specular.Sample( samp0, fragment.texcoord5.xy );
|
||||
half4 specMap = sRGBAToLinearRGBA( specMapSRGB );
|
||||
|
@ -108,7 +109,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
|
||||
half3 localNormal;
|
||||
// RB begin
|
||||
#if defined(USE_NORMAL_FMT_RGB8)
|
||||
#if USE_NORMAL_FMT_RGB8
|
||||
localNormal.xy = bumpMap.rg - 0.5;
|
||||
#else
|
||||
localNormal.xy = bumpMap.wy - 0.5;
|
||||
|
@ -209,6 +210,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
float4 shadowMatrixW = rpShadowMatrices[ int ( shadowIndex * 4 + 3 ) ];
|
||||
|
||||
float4 modelPosition = float4( fragment.texcoord7.xyz, 1.0 );
|
||||
|
||||
float4 shadowTexcoord;
|
||||
shadowTexcoord.x = dot4( modelPosition, shadowMatrixX );
|
||||
shadowTexcoord.y = dot4( modelPosition, shadowMatrixY );
|
||||
|
@ -246,12 +248,12 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
float stepSize = 1.0 / numSamples;
|
||||
|
||||
float2 jitterTC = ( fragment.position.xy * rpScreenCorrectionFactor.xy ) + rpJitterTexOffset.ww;
|
||||
for( float i = 0.0; i < numSamples; i += 1.0 )
|
||||
for( float n = 0.0; n < numSamples; n += 1.0 )
|
||||
{
|
||||
float4 jitter = base + t_Jitter.Sample( samp1, jitterTC.xy ) * rpJitterTexScale;
|
||||
jitter.zw = shadowTexcoord.zw;
|
||||
|
||||
shadow += idtex2Dproj( samp1, t_Jitter, jitter.xy / jitter.z );
|
||||
shadow += t_Jitter.Sample( samp1, jitter.xy / jitter.z ).r;
|
||||
jitterTC.x += stepSize;
|
||||
}
|
||||
|
||||
|
@ -262,19 +264,21 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
|
||||
// Poisson Disk with White Noise used for years int RBDOOM-3-BFG
|
||||
|
||||
const float2 poissonDisk[12] = {
|
||||
float2( 0.6111618, 0.1050905 ),
|
||||
float2( 0.1088336, 0.1127091 ),
|
||||
float2( 0.3030421, -0.6292974 ),
|
||||
float2( 0.4090526, 0.6716492 ),
|
||||
float2( -0.1608387, -0.3867823 ),
|
||||
float2( 0.7685862, -0.6118501 ),
|
||||
float2( -0.1935026, -0.856501 ),
|
||||
float2( -0.4028573, 0.07754025 ),
|
||||
float2( -0.6411021, -0.4748057 ),
|
||||
float2( -0.1314865, 0.8404058 ),
|
||||
float2( -0.7005203, 0.4596822 ),
|
||||
float2( -0.9713828, -0.06329931 ) };
|
||||
const float2 poissonDisk[12] =
|
||||
{
|
||||
float2( 0.6111618, 0.1050905 ),
|
||||
float2( 0.1088336, 0.1127091 ),
|
||||
float2( 0.3030421, -0.6292974 ),
|
||||
float2( 0.4090526, 0.6716492 ),
|
||||
float2( -0.1608387, -0.3867823 ),
|
||||
float2( 0.7685862, -0.6118501 ),
|
||||
float2( -0.1935026, -0.856501 ),
|
||||
float2( -0.4028573, 0.07754025 ),
|
||||
float2( -0.6411021, -0.4748057 ),
|
||||
float2( -0.1314865, 0.8404058 ),
|
||||
float2( -0.7005203, 0.4596822 ),
|
||||
float2( -0.9713828, -0.06329931 )
|
||||
};
|
||||
|
||||
float shadow = 0.0;
|
||||
|
||||
|
@ -300,7 +304,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
|
||||
float4 shadowTexcoordJittered = float4( shadowTexcoord.xy + jitterRotated * shadowTexelSize, shadowTexcoord.z, shadowTexcoord.w );
|
||||
|
||||
shadow += idtex2Dproj( samp1, t_ShadowMapArray, shadowTexcoordJittered );
|
||||
shadow += idtex2Dproj( samp1, t_ShadowMapArray, shadowTexcoordJittered.xywz ).r;
|
||||
}
|
||||
|
||||
shadow *= stepSize;
|
||||
|
@ -311,19 +315,21 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
|
||||
// Poisson Disk with animated Blue Noise or Interleaved Gradient Noise
|
||||
|
||||
const float2 poissonDisk[12] = {
|
||||
float2( 0.6111618, 0.1050905 ),
|
||||
float2( 0.1088336, 0.1127091 ),
|
||||
float2( 0.3030421, -0.6292974 ),
|
||||
float2( 0.4090526, 0.6716492 ),
|
||||
float2( -0.1608387, -0.3867823 ),
|
||||
float2( 0.7685862, -0.6118501 ),
|
||||
float2( -0.1935026, -0.856501 ),
|
||||
float2( -0.4028573, 0.07754025 ),
|
||||
float2( -0.6411021, -0.4748057 ),
|
||||
float2( -0.1314865, 0.8404058 ),
|
||||
float2( -0.7005203, 0.4596822 ),
|
||||
float2( -0.9713828, -0.06329931 ) };
|
||||
const float2 poissonDisk[12] =
|
||||
{
|
||||
float2( 0.6111618, 0.1050905 ),
|
||||
float2( 0.1088336, 0.1127091 ),
|
||||
float2( 0.3030421, -0.6292974 ),
|
||||
float2( 0.4090526, 0.6716492 ),
|
||||
float2( -0.1608387, -0.3867823 ),
|
||||
float2( 0.7685862, -0.6118501 ),
|
||||
float2( -0.1935026, -0.856501 ),
|
||||
float2( -0.4028573, 0.07754025 ),
|
||||
float2( -0.6411021, -0.4748057 ),
|
||||
float2( -0.1314865, 0.8404058 ),
|
||||
float2( -0.7005203, 0.4596822 ),
|
||||
float2( -0.9713828, -0.06329931 )
|
||||
};
|
||||
|
||||
float shadow = 0.0;
|
||||
|
||||
|
@ -350,7 +356,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
|
||||
float4 shadowTexcoordJittered = float4( shadowTexcoord.xy + jitterRotated * shadowTexelSize, shadowTexcoord.z, shadowTexcoord.w );
|
||||
|
||||
shadow += idtex2Dproj( samp1, t_ShadowMapArray, shadowTexcoordJittered );
|
||||
shadow += idtex2Dproj( samp1, t_ShadowMapArray, shadowTexcoordJittered.xywz );
|
||||
}
|
||||
|
||||
shadow *= stepSize;
|
||||
|
@ -378,8 +384,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
|
||||
float4 shadowTexcoordJittered = float4( shadowTexcoord.xy + jitter * shadowTexelSize, shadowTexcoord.z, shadowTexcoord.w );
|
||||
|
||||
// TODO(Stephen): I don't know if this is correct. It could be that the index into the array is held in shadowTexcoord.w instead of the z-component.
|
||||
shadow += t_ShadowMapArray.Sample( samp1, shadowTexcoordJittered.xyz ).r;
|
||||
shadow += t_ShadowMapArray.SampleCmpLevelZero( samp2, shadowTexcoordJittered.xyw, shadowTexcoordJittered.z );
|
||||
}
|
||||
|
||||
shadow *= stepSize;
|
||||
|
@ -389,7 +394,6 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
float shadow = idtex2Dproj( samp1, t_ShadowMapArray, shadowTexcoord );
|
||||
#endif
|
||||
|
||||
|
||||
half3 halfAngleVector = normalize( lightVector + viewVector );
|
||||
half hdotN = clamp( dot3( halfAngleVector, localNormal ), 0.0, 1.0 );
|
||||
|
||||
|
|
|
@ -31,7 +31,8 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
|
||||
#if USE_GPU_SKINNING
|
||||
cbuffer CB : register( b1 )
|
||||
cbuffer CB :
|
||||
register( b1 )
|
||||
{
|
||||
float4 matrices[408];
|
||||
};
|
||||
|
@ -41,25 +42,25 @@ cbuffer CB : register( b1 )
|
|||
struct VS_IN {
|
||||
float4 position : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float4 normal : NORMAL;
|
||||
float4 tangent : TANGENT;
|
||||
float4 color : COLOR0;
|
||||
float4 color2 : COLOR1;
|
||||
float4 normal : NORMAL;
|
||||
float4 tangent : TANGENT;
|
||||
float4 color : COLOR0;
|
||||
float4 color2 : COLOR1;
|
||||
};
|
||||
|
||||
struct VS_OUT {
|
||||
float4 position : SV_Position;
|
||||
float4 texcoord0 : TEXCOORD0_centroid;
|
||||
float4 texcoord1 : TEXCOORD1_centroid;
|
||||
float4 texcoord2 : TEXCOORD2_centroid;
|
||||
float4 texcoord3 : TEXCOORD3_centroid;
|
||||
float4 texcoord4 : TEXCOORD4_centroid;
|
||||
float4 texcoord5 : TEXCOORD5_centroid;
|
||||
float4 texcoord6 : TEXCOORD6_centroid;
|
||||
float4 texcoord7 : TEXCOORD7_centroid;
|
||||
float4 texcoord8 : TEXCOORD8_centroid;
|
||||
float4 texcoord9 : TEXCOORD9_centroid;
|
||||
float4 color : COLOR0;
|
||||
half4 position : SV_Position;
|
||||
half4 texcoord0 : TEXCOORD0_centroid;
|
||||
half4 texcoord1 : TEXCOORD1_centroid;
|
||||
half4 texcoord2 : TEXCOORD2_centroid;
|
||||
half4 texcoord3 : TEXCOORD3_centroid;
|
||||
half4 texcoord4 : TEXCOORD4_centroid;
|
||||
half4 texcoord5 : TEXCOORD5_centroid;
|
||||
half4 texcoord6 : TEXCOORD6_centroid;
|
||||
half4 texcoord7 : TEXCOORD7_centroid;
|
||||
half4 texcoord8 : TEXCOORD8_centroid;
|
||||
half4 texcoord9 : TEXCOORD9_centroid;
|
||||
half4 color : COLOR0;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
#define LOD0_TILE_SIZE 8
|
||||
#define NUM_LODS 4
|
||||
|
||||
// Number of compute dispatches needed to reduce all the
|
||||
// mip-levels at a maximum resolution of 16k :
|
||||
// Number of compute dispatches needed to reduce all the
|
||||
// mip-levels at a maximum resolution of 16k :
|
||||
// (uint)(std::ceil(std::log2f(16384)/NUM_LODS)) = 4
|
||||
#define MAX_PASSES 4
|
||||
|
||||
|
@ -36,47 +36,48 @@
|
|||
|
||||
struct MipmmapGenConstants
|
||||
{
|
||||
uint dispatch;
|
||||
uint numLODs;
|
||||
uint padding[2];
|
||||
uint dispatch;
|
||||
uint numLODs;
|
||||
uint padding[2];
|
||||
};
|
||||
|
||||
#if MODE == MODE_COLOR
|
||||
#define VALUE_TYPE float3
|
||||
float3 reduce( float3 a, float3 b )
|
||||
{
|
||||
return lerp( a, b, 0.5 );
|
||||
return lerp( a, b, 0.5 );
|
||||
}
|
||||
float3 reduce( float3 a, float3 b, float3 c, float3 d )
|
||||
{
|
||||
return reduce( reduce( a, b ), reduce( c, d ) );
|
||||
return reduce( reduce( a, b ), reduce( c, d ) );
|
||||
}
|
||||
#elif MODE == MODE_MINMAX
|
||||
#define VALUE_TYPE float2
|
||||
float2 reduce( float2 a, float2 b )
|
||||
{
|
||||
return float2( min( a.x, b.x ), max( a.y, b.y ) );
|
||||
return float2( min( a.x, b.x ), max( a.y, b.y ) );
|
||||
}
|
||||
float2 reduce( float2 a, float2 b, float2 c, float2 d )
|
||||
{
|
||||
return reduce( reduce( a, b ), reduce( c, d ) );
|
||||
return reduce( reduce( a, b ), reduce( c, d ) );
|
||||
}
|
||||
#else
|
||||
#define VALUE_TYPE float
|
||||
VALUE_TYPE reduce( VALUE_TYPE a, VALUE_TYPE b )
|
||||
{
|
||||
#if MODE == MODE_MIN
|
||||
return min( a, b );
|
||||
return min( a, b );
|
||||
#elif MODE == MODE_MAX
|
||||
return max( a, b );
|
||||
return max( a, b );
|
||||
#endif
|
||||
}
|
||||
VALUE_TYPE reduce( float4 a )
|
||||
{
|
||||
return reduce( reduce( a.x, a.y ), reduce( a.z, a.w ) );
|
||||
return reduce( reduce( a.x, a.y ), reduce( a.z, a.w ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
// *INDENT-OFF*
|
||||
cbuffer c_MipMapgen : register( b0 )
|
||||
{
|
||||
MipmmapGenConstants g_MipMapGen;
|
||||
|
@ -84,52 +85,57 @@ cbuffer c_MipMapgen : register( b0 )
|
|||
|
||||
RWTexture2D<VALUE_TYPE> u_output[NUM_LODS] : register( u0 );
|
||||
Texture2D<VALUE_TYPE> t_input : register( t0 );
|
||||
// *INDENT-ON*
|
||||
|
||||
groupshared VALUE_TYPE s_ReductionData[GROUP_SIZE][GROUP_SIZE];
|
||||
|
||||
[numthreads( 16, 16, 1 )] void main(
|
||||
uint2 groupIdx : SV_GroupID,
|
||||
uint2 globalIdx : SV_DispatchThreadID,
|
||||
uint2 threadIdx : SV_GroupThreadID )
|
||||
uint2 groupIdx : SV_GroupID,
|
||||
uint2 globalIdx : SV_DispatchThreadID,
|
||||
uint2 threadIdx : SV_GroupThreadID )
|
||||
{
|
||||
VALUE_TYPE value = t_input.mips[0][globalIdx.xy];
|
||||
VALUE_TYPE value = t_input.mips[0][globalIdx.xy];
|
||||
|
||||
#if MODE == MODE_MINMAX
|
||||
if( g_MipMapGen.dispatch == 0 )
|
||||
value.y = value.x;
|
||||
if( g_MipMapGen.dispatch == 0 )
|
||||
{
|
||||
value.y = value.x;
|
||||
}
|
||||
#endif
|
||||
|
||||
[unroll]
|
||||
for( uint level = 1; level <= NUM_LODS; level++ )
|
||||
{
|
||||
if( level == g_MipMapGen.numLODs + 1 )
|
||||
break;
|
||||
[unroll]
|
||||
for( uint level = 1; level <= NUM_LODS; level++ )
|
||||
{
|
||||
if( level == g_MipMapGen.numLODs + 1 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
uint outGroupSize = uint( GROUP_SIZE ) >> level;
|
||||
uint inGroupSize = outGroupSize << 1;
|
||||
uint outGroupSize = uint( GROUP_SIZE ) >> level;
|
||||
uint inGroupSize = outGroupSize << 1;
|
||||
|
||||
if( all( threadIdx.xy < inGroupSize ) )
|
||||
{
|
||||
s_ReductionData[threadIdx.y][threadIdx.x] = value;
|
||||
}
|
||||
if( all( threadIdx.xy < inGroupSize ) )
|
||||
{
|
||||
s_ReductionData[threadIdx.y][threadIdx.x] = value;
|
||||
}
|
||||
|
||||
GroupMemoryBarrierWithGroupSync( );
|
||||
GroupMemoryBarrierWithGroupSync( );
|
||||
|
||||
if( all( threadIdx.xy < outGroupSize ) )
|
||||
{
|
||||
VALUE_TYPE a = s_ReductionData[threadIdx.y * 2 + 0][threadIdx.x * 2 + 0];
|
||||
VALUE_TYPE b = s_ReductionData[threadIdx.y * 2 + 0][threadIdx.x * 2 + 1];
|
||||
VALUE_TYPE c = s_ReductionData[threadIdx.y * 2 + 1][threadIdx.x * 2 + 0];
|
||||
VALUE_TYPE d = s_ReductionData[threadIdx.y * 2 + 1][threadIdx.x * 2 + 1];
|
||||
if( all( threadIdx.xy < outGroupSize ) )
|
||||
{
|
||||
VALUE_TYPE a = s_ReductionData[threadIdx.y * 2 + 0][threadIdx.x * 2 + 0];
|
||||
VALUE_TYPE b = s_ReductionData[threadIdx.y * 2 + 0][threadIdx.x * 2 + 1];
|
||||
VALUE_TYPE c = s_ReductionData[threadIdx.y * 2 + 1][threadIdx.x * 2 + 0];
|
||||
VALUE_TYPE d = s_ReductionData[threadIdx.y * 2 + 1][threadIdx.x * 2 + 1];
|
||||
|
||||
#if MODE == MODE_COLOR || MODE == MODE_MINMAX
|
||||
value = reduce( a, b, c, d );
|
||||
value = reduce( a, b, c, d );
|
||||
#else
|
||||
value = reduce( float4( a, b, c, d ) );
|
||||
value = reduce( float4( a, b, c, d ) );
|
||||
#endif
|
||||
u_output[level - 1][groupIdx.xy * outGroupSize + threadIdx.xy] = value;
|
||||
}
|
||||
u_output[level - 1][groupIdx.xy * outGroupSize + threadIdx.xy] = value;
|
||||
}
|
||||
|
||||
GroupMemoryBarrierWithGroupSync( );
|
||||
}
|
||||
GroupMemoryBarrierWithGroupSync( );
|
||||
}
|
||||
}
|
|
@ -542,7 +542,11 @@
|
|||
#define API_V_ABOVE(v1, v2) v1 < v2
|
||||
static SamplerState SmaaLinearSampler; // { Filter = MIN_MAG_LINEAR_MIP_POINT; AddressU = Clamp; AddressV = Clamp; };
|
||||
static SamplerState SmaaPointSampler; // { Filter = MIN_MAG_MIP_POINT; AddressU = Clamp; AddressV = Clamp; };
|
||||
static void Init( SamplerState _samp0, SamplerState _samp1 ) { SmaaLinearSampler = _samp0; SmaaPointSampler = _samp1; }
|
||||
static void Init( SamplerState _samp0, SamplerState _samp1 )
|
||||
{
|
||||
SmaaLinearSampler = _samp0;
|
||||
SmaaPointSampler = _samp1;
|
||||
}
|
||||
#define SMAATexture2D(tex) Texture2D tex
|
||||
#define SMAATexturePass2D(tex) tex
|
||||
#define SMAASampleLevelZero(tex, coord) tex.SampleLevel(SmaaLinearSampler, coord, 0)
|
||||
|
|
|
@ -66,9 +66,9 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
Init( LinearSampler, PointSampler );
|
||||
|
||||
float4 color = SMAANeighborhoodBlendingPS( texcoord,
|
||||
offset,
|
||||
t_CurrentColor,
|
||||
t_SmaaBlend
|
||||
offset,
|
||||
t_CurrentColor,
|
||||
t_SmaaBlend
|
||||
#if SMAA_REPROJECTION
|
||||
, SMAATexture2D( velocityTex )
|
||||
#endif
|
||||
|
|
|
@ -24,28 +24,29 @@
|
|||
|
||||
struct ToneMappingConstants
|
||||
{
|
||||
uint2 viewOrigin;
|
||||
uint2 viewSize;
|
||||
uint2 viewOrigin;
|
||||
uint2 viewSize;
|
||||
|
||||
float logLuminanceScale;
|
||||
float logLuminanceBias;
|
||||
float histogramLowPercentile;
|
||||
float histogramHighPercentile;
|
||||
float logLuminanceScale;
|
||||
float logLuminanceBias;
|
||||
float histogramLowPercentile;
|
||||
float histogramHighPercentile;
|
||||
|
||||
float eyeAdaptationSpeedUp;
|
||||
float eyeAdaptationSpeedDown;
|
||||
float minAdaptedLuminance;
|
||||
float maxAdaptedLuminance;
|
||||
float eyeAdaptationSpeedUp;
|
||||
float eyeAdaptationSpeedDown;
|
||||
float minAdaptedLuminance;
|
||||
float maxAdaptedLuminance;
|
||||
|
||||
float frameTime;
|
||||
float exposureScale;
|
||||
float whitePointInvSquared;
|
||||
uint sourceSlice;
|
||||
float frameTime;
|
||||
float exposureScale;
|
||||
float whitePointInvSquared;
|
||||
uint sourceSlice;
|
||||
|
||||
float2 colorLUTTextureSize;
|
||||
float2 colorLUTTextureSizeInv;
|
||||
float2 colorLUTTextureSize;
|
||||
float2 colorLUTTextureSizeInv;
|
||||
};
|
||||
|
||||
// *INDENT-OFF*
|
||||
Buffer<uint> t_Histogram : register(t0);
|
||||
RWBuffer<uint> u_Exposure : register(u0);
|
||||
|
||||
|
@ -53,64 +54,65 @@ cbuffer c_ToneMapping : register(b0)
|
|||
{
|
||||
ToneMappingConstants g_ToneMapping;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
#define FIXED_POINT_FRAC_BITS 6
|
||||
#define FIXED_POINT_FRAC_MULTIPLIER (1 << FIXED_POINT_FRAC_BITS)
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
[numthreads( 1, 1, 1 )]
|
||||
void main()
|
||||
{
|
||||
float cdf = 0;
|
||||
uint i;
|
||||
float cdf = 0;
|
||||
uint i;
|
||||
|
||||
[loop]
|
||||
for (i = 0; i < HISTOGRAM_BINS; ++i)
|
||||
{
|
||||
cdf += float(t_Histogram[i]) / FIXED_POINT_FRAC_MULTIPLIER;
|
||||
}
|
||||
[loop]
|
||||
for( i = 0; i < HISTOGRAM_BINS; ++i )
|
||||
{
|
||||
cdf += float( t_Histogram[i] ) / FIXED_POINT_FRAC_MULTIPLIER;
|
||||
}
|
||||
|
||||
float lowCdf = cdf * g_ToneMapping.histogramLowPercentile;
|
||||
float highCdf = cdf * g_ToneMapping.histogramHighPercentile;
|
||||
float lowCdf = cdf * g_ToneMapping.histogramLowPercentile;
|
||||
float highCdf = cdf * g_ToneMapping.histogramHighPercentile;
|
||||
|
||||
float weightSum = 0;
|
||||
float binSum = 0;
|
||||
cdf = 0;
|
||||
float weightSum = 0;
|
||||
float binSum = 0;
|
||||
cdf = 0;
|
||||
|
||||
[loop]
|
||||
for (i = 0; i < HISTOGRAM_BINS; ++i)
|
||||
{
|
||||
float binValue = float(t_Histogram[i]) / FIXED_POINT_FRAC_MULTIPLIER;
|
||||
[loop]
|
||||
for( i = 0; i < HISTOGRAM_BINS; ++i )
|
||||
{
|
||||
float binValue = float( t_Histogram[i] ) / FIXED_POINT_FRAC_MULTIPLIER;
|
||||
|
||||
if (lowCdf <= cdf + binValue && cdf <= highCdf)
|
||||
{
|
||||
float histogramBinLuminance = exp2((i / (float)HISTOGRAM_BINS) * g_ToneMapping.logLuminanceScale
|
||||
+ g_ToneMapping.logLuminanceBias);
|
||||
if( lowCdf <= cdf + binValue && cdf <= highCdf )
|
||||
{
|
||||
float histogramBinLuminance = exp2( ( i / ( float )HISTOGRAM_BINS ) * g_ToneMapping.logLuminanceScale
|
||||
+ g_ToneMapping.logLuminanceBias );
|
||||
|
||||
weightSum += histogramBinLuminance * binValue;
|
||||
binSum += binValue;
|
||||
}
|
||||
weightSum += histogramBinLuminance * binValue;
|
||||
binSum += binValue;
|
||||
}
|
||||
|
||||
cdf += binValue;
|
||||
}
|
||||
cdf += binValue;
|
||||
}
|
||||
|
||||
float targetExposure = (binSum > 0) ? (weightSum / binSum) : 0;
|
||||
|
||||
targetExposure = clamp(
|
||||
targetExposure,
|
||||
g_ToneMapping.minAdaptedLuminance,
|
||||
g_ToneMapping.maxAdaptedLuminance);
|
||||
|
||||
float oldExposure = asfloat(u_Exposure[0]);
|
||||
float diff = oldExposure - targetExposure;
|
||||
float targetExposure = ( binSum > 0 ) ? ( weightSum / binSum ) : 0;
|
||||
|
||||
float adaptationSpeed = (diff < 0)
|
||||
? g_ToneMapping.eyeAdaptationSpeedUp
|
||||
: g_ToneMapping.eyeAdaptationSpeedDown;
|
||||
targetExposure = clamp(
|
||||
targetExposure,
|
||||
g_ToneMapping.minAdaptedLuminance,
|
||||
g_ToneMapping.maxAdaptedLuminance );
|
||||
|
||||
if (adaptationSpeed > 0)
|
||||
{
|
||||
targetExposure += diff * exp2(-g_ToneMapping.frameTime * adaptationSpeed);
|
||||
}
|
||||
float oldExposure = asfloat( u_Exposure[0] );
|
||||
float diff = oldExposure - targetExposure;
|
||||
|
||||
u_Exposure[0] = asuint(targetExposure);
|
||||
float adaptationSpeed = ( diff < 0 )
|
||||
? g_ToneMapping.eyeAdaptationSpeedUp
|
||||
: g_ToneMapping.eyeAdaptationSpeedDown;
|
||||
|
||||
if( adaptationSpeed > 0 )
|
||||
{
|
||||
targetExposure += diff * exp2( -g_ToneMapping.frameTime * adaptationSpeed );
|
||||
}
|
||||
|
||||
u_Exposure[0] = asuint( targetExposure );
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ SamplerState samp0 : register( s0 );
|
|||
|
||||
struct PS_IN
|
||||
{
|
||||
float4 position : VPOS;
|
||||
float4 position : SV_Position;
|
||||
float2 texcoord0 : TEXCOORD0_centroid;
|
||||
};
|
||||
|
||||
|
@ -75,7 +75,8 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
|
||||
const float gaussFact[9] = { 0.13298076, 0.12579441, 0.10648267, 0.08065691, 0.05467002, 0.03315905, 0.01799699, 0.00874063, 0.00379866 };
|
||||
|
||||
const float3 chromaticOffsets[9] = {
|
||||
const float3 chromaticOffsets[9] =
|
||||
{
|
||||
float3( 0.5, 0.5, 0.5 ), // w
|
||||
float3( 0.8, 0.3, 0.3 ),
|
||||
// float3(1.0, 0.2, 0.2), // r
|
||||
|
|
|
@ -39,8 +39,8 @@ struct VS_IN {
|
|||
};
|
||||
|
||||
struct VS_OUT {
|
||||
float4 position : POSITION;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float4 position : SV_Position;
|
||||
float2 texcoord0 : TEXCOORD0_centroid;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
|
|
|
@ -24,28 +24,29 @@
|
|||
|
||||
struct ToneMappingConstants
|
||||
{
|
||||
uint2 viewOrigin;
|
||||
uint2 viewSize;
|
||||
uint2 viewOrigin;
|
||||
uint2 viewSize;
|
||||
|
||||
float logLuminanceScale;
|
||||
float logLuminanceBias;
|
||||
float histogramLowPercentile;
|
||||
float histogramHighPercentile;
|
||||
float logLuminanceScale;
|
||||
float logLuminanceBias;
|
||||
float histogramLowPercentile;
|
||||
float histogramHighPercentile;
|
||||
|
||||
float eyeAdaptationSpeedUp;
|
||||
float eyeAdaptationSpeedDown;
|
||||
float minAdaptedLuminance;
|
||||
float maxAdaptedLuminance;
|
||||
float eyeAdaptationSpeedUp;
|
||||
float eyeAdaptationSpeedDown;
|
||||
float minAdaptedLuminance;
|
||||
float maxAdaptedLuminance;
|
||||
|
||||
float frameTime;
|
||||
float exposureScale;
|
||||
float whitePointInvSquared;
|
||||
uint sourceSlice;
|
||||
float frameTime;
|
||||
float exposureScale;
|
||||
float whitePointInvSquared;
|
||||
uint sourceSlice;
|
||||
|
||||
float2 colorLUTTextureSize;
|
||||
float2 colorLUTTextureSizeInv;
|
||||
float2 colorLUTTextureSize;
|
||||
float2 colorLUTTextureSizeInv;
|
||||
};
|
||||
|
||||
// *INDENT-OFF*
|
||||
#if SOURCE_ARRAY
|
||||
Texture2DArray t_Source : register(t0);
|
||||
#else
|
||||
|
@ -57,10 +58,11 @@ cbuffer c_ToneMapping : register(b0)
|
|||
{
|
||||
ToneMappingConstants g_ToneMapping;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
float Luminance(float3 color)
|
||||
float Luminance( float3 color )
|
||||
{
|
||||
return 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
|
||||
return 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
|
||||
}
|
||||
|
||||
#define GROUP_X 16
|
||||
|
@ -70,49 +72,55 @@ float Luminance(float3 color)
|
|||
|
||||
groupshared uint s_Histogram[HISTOGRAM_BINS];
|
||||
|
||||
[numthreads(GROUP_X, GROUP_Y, 1)]
|
||||
void main(uint linearIdx : SV_GroupIndex, uint2 globalIdx : SV_DispatchThreadID)
|
||||
[numthreads( GROUP_X, GROUP_Y, 1 )]
|
||||
void main( uint linearIdx : SV_GroupIndex, uint2 globalIdx : SV_DispatchThreadID )
|
||||
{
|
||||
uint2 pixelPos = globalIdx.xy + g_ToneMapping.viewOrigin.xy;
|
||||
bool valid = all(globalIdx.xy < g_ToneMapping.viewSize.xy);
|
||||
uint2 pixelPos = globalIdx.xy + g_ToneMapping.viewOrigin.xy;
|
||||
bool valid = all( globalIdx.xy < g_ToneMapping.viewSize.xy );
|
||||
|
||||
if (linearIdx < HISTOGRAM_BINS)
|
||||
{
|
||||
s_Histogram[linearIdx] = 0;
|
||||
}
|
||||
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
if( linearIdx < HISTOGRAM_BINS )
|
||||
{
|
||||
s_Histogram[linearIdx] = 0;
|
||||
}
|
||||
|
||||
if (valid)
|
||||
{
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
|
||||
if( valid )
|
||||
{
|
||||
#if SOURCE_ARRAY
|
||||
float3 color = t_Source[uint3(pixelPos, g_ToneMapping.sourceSlice)].rgb;
|
||||
float3 color = t_Source[uint3( pixelPos, g_ToneMapping.sourceSlice )].rgb;
|
||||
#else
|
||||
float3 color = t_Source[pixelPos].rgb;
|
||||
float3 color = t_Source[pixelPos].rgb;
|
||||
#endif
|
||||
|
||||
float luminance = Luminance(color);
|
||||
float biasedLogLuminance = log2(luminance) * g_ToneMapping.logLuminanceScale + g_ToneMapping.logLuminanceBias;
|
||||
float histogramBin = saturate(biasedLogLuminance) * (HISTOGRAM_BINS - 1);
|
||||
|
||||
uint leftBin = uint(floor(histogramBin));
|
||||
uint rightBin = leftBin + 1;
|
||||
float luminance = Luminance( color );
|
||||
float biasedLogLuminance = log2( luminance ) * g_ToneMapping.logLuminanceScale + g_ToneMapping.logLuminanceBias;
|
||||
float histogramBin = saturate( biasedLogLuminance ) * ( HISTOGRAM_BINS - 1 );
|
||||
|
||||
uint rightWeight = uint(frac(histogramBin) * FIXED_POINT_FRAC_MULTIPLIER);
|
||||
uint leftWeight = FIXED_POINT_FRAC_MULTIPLIER - rightWeight;
|
||||
uint leftBin = uint( floor( histogramBin ) );
|
||||
uint rightBin = leftBin + 1;
|
||||
|
||||
if(leftWeight != 0 && leftBin < HISTOGRAM_BINS)
|
||||
InterlockedAdd(s_Histogram[leftBin], leftWeight);
|
||||
if(rightWeight != 0 && rightBin < HISTOGRAM_BINS)
|
||||
InterlockedAdd(s_Histogram[rightBin], rightWeight);
|
||||
}
|
||||
uint rightWeight = uint( frac( histogramBin ) * FIXED_POINT_FRAC_MULTIPLIER );
|
||||
uint leftWeight = FIXED_POINT_FRAC_MULTIPLIER - rightWeight;
|
||||
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
if( leftWeight != 0 && leftBin < HISTOGRAM_BINS )
|
||||
{
|
||||
InterlockedAdd( s_Histogram[leftBin], leftWeight );
|
||||
}
|
||||
if( rightWeight != 0 && rightBin < HISTOGRAM_BINS )
|
||||
{
|
||||
InterlockedAdd( s_Histogram[rightBin], rightWeight );
|
||||
}
|
||||
}
|
||||
|
||||
if (linearIdx < HISTOGRAM_BINS)
|
||||
{
|
||||
uint localBinValue = s_Histogram[linearIdx];
|
||||
if (localBinValue != 0)
|
||||
InterlockedAdd(u_Histogram[linearIdx], localBinValue);
|
||||
}
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
|
||||
if( linearIdx < HISTOGRAM_BINS )
|
||||
{
|
||||
uint localBinValue = s_Histogram[linearIdx];
|
||||
if( localBinValue != 0 )
|
||||
{
|
||||
InterlockedAdd( u_Histogram[linearIdx], localBinValue );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ SamplerState samp0 : register(s0);
|
|||
|
||||
struct PS_IN
|
||||
{
|
||||
float4 position : VPOS;
|
||||
float4 position : SV_Position;
|
||||
float2 texcoord0 : TEXCOORD0_centroid;
|
||||
};
|
||||
|
||||
|
|
|
@ -39,8 +39,8 @@ struct VS_IN {
|
|||
};
|
||||
|
||||
struct VS_OUT {
|
||||
float4 position : POSITION;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float4 position : SV_Position;
|
||||
float2 texcoord0 : TEXCOORD0_centroid;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
|
|
|
@ -234,23 +234,24 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
#if HDR_DEBUG
|
||||
// https://google.github.io/filament/Filament.md.html#figure_luminanceviz
|
||||
|
||||
const float3 debugColors[16] = {
|
||||
float3( 0.0, 0.0, 0.0 ), // black
|
||||
float3( 0.0, 0.0, 0.1647 ), // darkest blue
|
||||
float3( 0.0, 0.0, 0.3647 ), // darker blue
|
||||
float3( 0.0, 0.0, 0.6647 ), // dark blue
|
||||
float3( 0.0, 0.0, 0.9647 ), // blue
|
||||
float3( 0.0, 0.9255, 0.9255 ), // cyan
|
||||
float3( 0.0, 0.5647, 0.0 ), // dark green
|
||||
float3( 0.0, 0.7843, 0.0 ), // green
|
||||
float3( 1.0, 1.0, 0.0 ), // yellow
|
||||
float3( 0.90588, 0.75294, 0.0 ), // yellow-orange
|
||||
float3( 1.0, 0.5647, 0.0 ), // orange
|
||||
float3( 1.0, 0.0, 0.0 ), // bright red
|
||||
float3( 0.8392, 0.0, 0.0 ), // red
|
||||
float3( 1.0, 0.0, 1.0 ), // magenta
|
||||
float3( 0.6, 0.3333, 0.7882 ), // purple
|
||||
float3( 1.0, 1.0, 1.0 ) // white
|
||||
const float3 debugColors[16] =
|
||||
{
|
||||
float3( 0.0, 0.0, 0.0 ), // black
|
||||
float3( 0.0, 0.0, 0.1647 ), // darkest blue
|
||||
float3( 0.0, 0.0, 0.3647 ), // darker blue
|
||||
float3( 0.0, 0.0, 0.6647 ), // dark blue
|
||||
float3( 0.0, 0.0, 0.9647 ), // blue
|
||||
float3( 0.0, 0.9255, 0.9255 ), // cyan
|
||||
float3( 0.0, 0.5647, 0.0 ), // dark green
|
||||
float3( 0.0, 0.7843, 0.0 ), // green
|
||||
float3( 1.0, 1.0, 0.0 ), // yellow
|
||||
float3( 0.90588, 0.75294, 0.0 ), // yellow-orange
|
||||
float3( 1.0, 0.5647, 0.0 ), // orange
|
||||
float3( 1.0, 0.0, 0.0 ), // bright red
|
||||
float3( 0.8392, 0.0, 0.0 ), // red
|
||||
float3( 1.0, 0.0, 1.0 ), // magenta
|
||||
float3( 0.6, 0.3333, 0.7882 ), // purple
|
||||
float3( 1.0, 1.0, 1.0 ) // white
|
||||
};
|
||||
|
||||
// The 5th color in the array (cyan) represents middle gray (18%)
|
||||
|
|
|
@ -53,5 +53,5 @@ void main( VS_IN vertex, out VS_OUT result )
|
|||
//result.position.y = dot4( vertex.position, rpMVPmatrixY );
|
||||
//result.position.z = dot4( vertex.position, rpMVPmatrixZ );
|
||||
//result.position.w = dot4( vertex.position, rpMVPmatrixW );
|
||||
result.texcoord0 = vertex.texcoord;
|
||||
result.texcoord0 = vertex.texcoord;
|
||||
}
|
|
@ -24,28 +24,29 @@
|
|||
|
||||
struct ToneMappingConstants
|
||||
{
|
||||
uint2 viewOrigin;
|
||||
uint2 viewSize;
|
||||
uint2 viewOrigin;
|
||||
uint2 viewSize;
|
||||
|
||||
float logLuminanceScale;
|
||||
float logLuminanceBias;
|
||||
float histogramLowPercentile;
|
||||
float histogramHighPercentile;
|
||||
float logLuminanceScale;
|
||||
float logLuminanceBias;
|
||||
float histogramLowPercentile;
|
||||
float histogramHighPercentile;
|
||||
|
||||
float eyeAdaptationSpeedUp;
|
||||
float eyeAdaptationSpeedDown;
|
||||
float minAdaptedLuminance;
|
||||
float maxAdaptedLuminance;
|
||||
float eyeAdaptationSpeedUp;
|
||||
float eyeAdaptationSpeedDown;
|
||||
float minAdaptedLuminance;
|
||||
float maxAdaptedLuminance;
|
||||
|
||||
float frameTime;
|
||||
float exposureScale;
|
||||
float whitePointInvSquared;
|
||||
uint sourceSlice;
|
||||
float frameTime;
|
||||
float exposureScale;
|
||||
float whitePointInvSquared;
|
||||
uint sourceSlice;
|
||||
|
||||
float2 colorLUTTextureSize;
|
||||
float2 colorLUTTextureSizeInv;
|
||||
float2 colorLUTTextureSize;
|
||||
float2 colorLUTTextureSizeInv;
|
||||
};
|
||||
|
||||
// *INDENT-OFF*
|
||||
#if SOURCE_ARRAY
|
||||
Texture2DArray t_Source : register(t0);
|
||||
#else
|
||||
|
@ -60,65 +61,86 @@ cbuffer c_ToneMapping : register(b0)
|
|||
{
|
||||
ToneMappingConstants g_ToneMapping;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
float Luminance(float3 color)
|
||||
float3 ACESFilm( float3 x )
|
||||
{
|
||||
return 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
|
||||
float a = 2.51;
|
||||
float b = 0.03;
|
||||
float c = 2.43;
|
||||
float d = 0.59;
|
||||
float e = 0.14;
|
||||
return saturate( ( x * ( a * x + b ) ) / ( x * ( c * x + d ) + e ) );
|
||||
}
|
||||
|
||||
float3 ConvertToLDR(float3 color)
|
||||
float Luminance( float3 color )
|
||||
{
|
||||
float srcLuminance = Luminance(color);
|
||||
|
||||
if (srcLuminance <= 0)
|
||||
return 0;
|
||||
|
||||
float adaptedLuminance = asfloat(t_Exposure[0]);
|
||||
if (adaptedLuminance <= 0)
|
||||
adaptedLuminance = g_ToneMapping.minAdaptedLuminance;
|
||||
|
||||
float scaledLuminance = g_ToneMapping.exposureScale * srcLuminance / adaptedLuminance;
|
||||
float mappedLuminance = (scaledLuminance * (1 + scaledLuminance * g_ToneMapping.whitePointInvSquared)) / (1 + scaledLuminance);
|
||||
|
||||
return color * (mappedLuminance / srcLuminance);
|
||||
return 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
|
||||
}
|
||||
|
||||
float3 ApplyColorLUT(float3 color)
|
||||
float3 ConvertToLDR( float3 color )
|
||||
{
|
||||
const float size = g_ToneMapping.colorLUTTextureSize.y;
|
||||
float srcLuminance = Luminance( color );
|
||||
|
||||
color = saturate(color);
|
||||
|
||||
float r = color.r * (size - 1) + 0.5;
|
||||
float g = color.g * (size - 1) + 0.5;
|
||||
|
||||
float b = color.b * (size - 1);
|
||||
if( srcLuminance <= 0 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
float2 uv1 = float2((floor(b) + 0) * size + r, g) * g_ToneMapping.colorLUTTextureSizeInv.xy;
|
||||
float2 uv2 = float2((floor(b) + 1) * size + r, g) * g_ToneMapping.colorLUTTextureSizeInv.xy;
|
||||
float adaptedLuminance = asfloat( t_Exposure[0] );
|
||||
if( adaptedLuminance <= 0 )
|
||||
{
|
||||
adaptedLuminance = g_ToneMapping.minAdaptedLuminance;
|
||||
}
|
||||
|
||||
float3 c1 = t_ColorLUT.SampleLevel(s_ColorLUTSampler, uv1, 0).rgb;
|
||||
float3 c2 = t_ColorLUT.SampleLevel(s_ColorLUTSampler, uv2, 0).rgb;
|
||||
float scaledLuminance = g_ToneMapping.exposureScale * srcLuminance / adaptedLuminance;
|
||||
float mappedLuminance = ( scaledLuminance * ( 1 + scaledLuminance * g_ToneMapping.whitePointInvSquared ) ) / ( 1 + scaledLuminance );
|
||||
|
||||
return lerp(c1, c2, frac(b));
|
||||
return color * ( mappedLuminance / srcLuminance );
|
||||
}
|
||||
|
||||
float3 ApplyColorLUT( float3 color )
|
||||
{
|
||||
const float size = g_ToneMapping.colorLUTTextureSize.y;
|
||||
|
||||
color = saturate( color );
|
||||
|
||||
float r = color.r * ( size - 1 ) + 0.5;
|
||||
float g = color.g * ( size - 1 ) + 0.5;
|
||||
|
||||
float b = color.b * ( size - 1 );
|
||||
|
||||
float2 uv1 = float2( ( floor( b ) + 0 ) * size + r, g ) * g_ToneMapping.colorLUTTextureSizeInv.xy;
|
||||
float2 uv2 = float2( ( floor( b ) + 1 ) * size + r, g ) * g_ToneMapping.colorLUTTextureSizeInv.xy;
|
||||
|
||||
float3 c1 = t_ColorLUT.SampleLevel( s_ColorLUTSampler, uv1, 0 ).rgb;
|
||||
float3 c2 = t_ColorLUT.SampleLevel( s_ColorLUTSampler, uv2, 0 ).rgb;
|
||||
|
||||
return lerp( c1, c2, frac( b ) );
|
||||
}
|
||||
|
||||
|
||||
void main(
|
||||
in float4 pos : SV_Position,
|
||||
in float2 uv : UV,
|
||||
out float4 o_rgba : SV_Target)
|
||||
out float4 o_rgba : SV_Target )
|
||||
{
|
||||
#if SOURCE_ARRAY
|
||||
float4 HdrColor = t_Source[uint3(pos.xy, g_ToneMapping.sourceSlice)];
|
||||
float4 HdrColor = t_Source[uint3( pos.xy, g_ToneMapping.sourceSlice )];
|
||||
#else
|
||||
float4 HdrColor = t_Source[pos.xy];
|
||||
float4 HdrColor = t_Source[pos.xy];
|
||||
#endif
|
||||
o_rgba.rgb = ConvertToLDR(HdrColor.rgb);
|
||||
o_rgba.a = HdrColor.a;
|
||||
o_rgba.rgb = ConvertToLDR( HdrColor.rgb );
|
||||
o_rgba.a = HdrColor.a;
|
||||
|
||||
if (g_ToneMapping.colorLUTTextureSize.x > 0)
|
||||
{
|
||||
o_rgba.rgb = ApplyColorLUT(o_rgba.rgb);
|
||||
}
|
||||
if( g_ToneMapping.colorLUTTextureSize.x > 0 )
|
||||
{
|
||||
o_rgba.rgb = ApplyColorLUT( o_rgba.rgb );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Tonemapping curve is applied after exposure.
|
||||
// Gamma correction is done by rendering to an sRGB render target.
|
||||
o_rgba.rgb = ACESFilm( o_rgba.rgb );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,11 @@
|
|||
|
||||
#else
|
||||
|
||||
cbuffer g_Blit : register(b0) { BlitConstants g_Blit; }
|
||||
cbuffer g_Blit :
|
||||
register( b0 )
|
||||
{
|
||||
BlitConstants g_Blit;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -45,14 +49,14 @@ struct VS_OUT
|
|||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
void main( VS_IN vertex, out VS_OUT result)
|
||||
void main( VS_IN vertex, out VS_OUT result )
|
||||
{
|
||||
uint u = vertex.iVertex & 1;
|
||||
uint v = (vertex.iVertex >> 1) & 1;
|
||||
uint v = ( vertex.iVertex >> 1 ) & 1;
|
||||
|
||||
float2 src_uv = float2(u, v) * g_Blit.sourceSize + g_Blit.sourceOrigin;
|
||||
float2 dst_uv = float2(u, v) * g_Blit.targetSize + g_Blit.targetOrigin;
|
||||
float2 src_uv = float2( u, v ) * g_Blit.sourceSize + g_Blit.sourceOrigin;
|
||||
float2 dst_uv = float2( u, v ) * g_Blit.targetSize + g_Blit.targetOrigin;
|
||||
|
||||
result.posClip = float4(dst_uv.x * 2 - 1, 1 - dst_uv.y * 2, 0, 1);
|
||||
result.posClip = float4( dst_uv.x * 2 - 1, 1 - dst_uv.y * 2, 0, 1 );
|
||||
result.uv = src_uv;
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ void main( VS_IN vertex, out VS_OUT result )
|
|||
|
||||
float4 modelPosition;
|
||||
modelPosition.x = dot4( matX, vertex.position );
|
||||
modelPosition.y = dot4( matY, vertex.position);
|
||||
modelPosition.y = dot4( matY, vertex.position );
|
||||
modelPosition.z = dot4( matZ, vertex.position );
|
||||
modelPosition.w = 1.0;
|
||||
|
||||
|
|
|
@ -28,10 +28,10 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
#include "global_inc.hlsl"
|
||||
|
||||
// *INDENT-OFF*
|
||||
Texture2D t_Texture : register( t0 );
|
||||
SamplerState samp0 : register( s0 );
|
||||
|
||||
// *INDENT-OFF*
|
||||
struct PS_IN {
|
||||
float4 position : VPOS;
|
||||
float4 texcoord0 : TEXCOORD0_centroid;
|
||||
|
|
|
@ -26,26 +26,28 @@ If you have questions concerning this license or the applicable additional terms
|
|||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "renderprogs/global.inc.hlsl"
|
||||
#include "global_inc.hlsl"
|
||||
|
||||
|
||||
// *INDENT-OFF*
|
||||
uniform sampler2D samp0 : register(s0);
|
||||
Texture2D t_CurrentRender : register( t0 );
|
||||
|
||||
SamplerState LinearSampler : register( s0 );
|
||||
|
||||
struct PS_IN {
|
||||
float4 position : VPOS;
|
||||
float4 color : COLOR;
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR0;
|
||||
float3 texcoord0 : TEXCOORD0_centroid;
|
||||
};
|
||||
|
||||
struct PS_OUT {
|
||||
float4 color : COLOR;
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
void main( PS_IN fragment, out PS_OUT result )
|
||||
{
|
||||
float4 src = tex2D( samp0, fragment.texcoord0.xy );
|
||||
float4 src = t_CurrentRender.Sample( LinearSampler, fragment.texcoord0.xy );
|
||||
float4 target = fragment.color * dot3( float3( 0.333, 0.333, 0.333 ), src );
|
||||
result.color = lerp( src, target, fragment.texcoord0.z );
|
||||
}
|
||||
|
|
|
@ -26,12 +26,10 @@ If you have questions concerning this license or the applicable additional terms
|
|||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "renderprogs/global.inc.hlsl"
|
||||
#include "global_inc.hlsl"
|
||||
|
||||
|
||||
// *INDENT-OFF*
|
||||
uniform float4 rpUser0 : register(c128); //rpFraction
|
||||
uniform float4 rpUser1 : register(c129); //rpTargetHue
|
||||
|
||||
struct VS_IN {
|
||||
float4 position : POSITION;
|
||||
|
@ -43,9 +41,9 @@ struct VS_IN {
|
|||
};
|
||||
|
||||
struct VS_OUT {
|
||||
float4 position : POSITION;
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR0;
|
||||
float3 texcoord0 : TEXCOORD0;
|
||||
float3 texcoord0 : TEXCOORD0_centroid;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
|
|
|
@ -26,21 +26,23 @@ If you have questions concerning this license or the applicable additional terms
|
|||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "renderprogs/global.inc.hlsl"
|
||||
#include "global_inc.hlsl"
|
||||
|
||||
|
||||
// *INDENT-OFF*
|
||||
uniform sampler2D samp0 : register(s0); // texture 0 is _current Render
|
||||
uniform sampler2D samp1 : register(s1); // texture 1 is the per-surface bump map
|
||||
Texture2D t_CurrentRender : register( t0 );
|
||||
Texture2D t_NormalMap : register( t1 );
|
||||
|
||||
SamplerState LinearSampler : register( s0 );
|
||||
|
||||
struct PS_IN {
|
||||
float4 position : VPOS;
|
||||
float4 position : SV_Position;
|
||||
float2 texcoord : TEXCOORD0_centroid;
|
||||
float4 color : COLOR0;
|
||||
};
|
||||
|
||||
struct PS_OUT {
|
||||
float4 color : COLOR;
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
|
@ -50,12 +52,12 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
float2 screenTexCoord = fragment.texcoord;
|
||||
|
||||
// compute warp factor
|
||||
float4 warpFactor = 1.0 - ( tex2D( samp1, screenTexCoord.xy ) * fragment.color );
|
||||
float4 warpFactor = 1.0 - ( t_NormalMap.Sample( LinearSampler, screenTexCoord.xy ) * fragment.color );
|
||||
screenTexCoord -= float2( 0.5, 0.5 );
|
||||
screenTexCoord *= warpFactor.xy;
|
||||
screenTexCoord += float2( 0.5, 0.5 );
|
||||
|
||||
// load the screen render
|
||||
result.color = tex2D( samp0, screenTexCoord );
|
||||
result.color = t_CurrentRender.Sample( LinearSampler, screenTexCoord );
|
||||
|
||||
}
|
|
@ -26,14 +26,12 @@ If you have questions concerning this license or the applicable additional terms
|
|||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "renderprogs/global.inc.hlsl"
|
||||
#include "global_inc.hlsl"
|
||||
|
||||
|
||||
// User Renderparms start at 128 as per renderprogs.h
|
||||
|
||||
// *INDENT-OFF*
|
||||
uniform float4 rpUser0 : register(c128); // rpScroll
|
||||
uniform float4 rpUser1 : register(c129); // rpDeformMagnitude
|
||||
|
||||
struct VS_IN {
|
||||
float4 position : POSITION;
|
||||
|
@ -44,7 +42,7 @@ struct VS_IN {
|
|||
};
|
||||
|
||||
struct VS_OUT {
|
||||
float4 position : POSITION;
|
||||
float4 position : SV_Position;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
|
|
@ -27,21 +27,23 @@ If you have questions concerning this license or the applicable additional terms
|
|||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "renderprogs/global.inc.hlsl"
|
||||
#include "global_inc.hlsl"
|
||||
|
||||
|
||||
// *INDENT-OFF*
|
||||
uniform sampler2D samp0 : register(s0); // texture 0 is _current Render
|
||||
uniform sampler2D samp1 : register(s1); // texture 1 is the per-surface bump map
|
||||
Texture2D t_CurrentRender : register( t0 );
|
||||
Texture2D t_NormalMap : register( t1 );
|
||||
|
||||
SamplerState LinearSampler : register( s0 );
|
||||
|
||||
struct PS_IN {
|
||||
float4 position : VPOS;
|
||||
float4 position : SV_Position;
|
||||
float4 texcoord0 : TEXCOORD0_centroid;
|
||||
float4 texcoord1 : TEXCOORD0_centroid;
|
||||
float4 texcoord1 : TEXCOORD1_centroid;
|
||||
};
|
||||
|
||||
struct PS_OUT {
|
||||
float4 color : COLOR;
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
|
@ -116,7 +118,7 @@ float snoise( float3 v )
|
|||
//float4 s1 = float4(lessThan(b1,0.0))*2.0 - 1.0;
|
||||
float4 s0 = floor( b0 ) * 2.0 + 1.0;
|
||||
float4 s1 = floor( b1 ) * 2.0 + 1.0;
|
||||
float4 sh = -step( h, float4( 0.0 ) );
|
||||
float4 sh = -step( h, _float4( 0.0 ) );
|
||||
|
||||
float4 a0 = b0.xzyw + s0.xzyw * sh.xxyy ;
|
||||
float4 a1 = b1.xzyw + s1.xzyw * sh.zzww ;
|
||||
|
@ -201,6 +203,6 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
float lighIntensity3 = 1.0/(100.0*distance(uv,light3));
|
||||
*/
|
||||
|
||||
result.color = float4( float3( cloudIntensity1 * clouds( uv, time ) ) * lightColor1 + lighIntensity1 * lightColor1
|
||||
result.color = float4( _float3( cloudIntensity1 * clouds( uv, time ) ) * lightColor1 + lighIntensity1 * lightColor1
|
||||
, 1.0 );
|
||||
}
|
|
@ -26,11 +26,10 @@ If you have questions concerning this license or the applicable additional terms
|
|||
=================================================a==========================
|
||||
*/
|
||||
|
||||
#include "renderprogs/global.inc.hlsl"
|
||||
#include "global_inc.hlsl"
|
||||
|
||||
|
||||
// *INDENT-OFF*
|
||||
uniform float4 rpUser0 : register( c128 ); //rpCenterScaleTex
|
||||
|
||||
struct VS_IN {
|
||||
float4 position : POSITION;
|
||||
|
@ -41,9 +40,9 @@ struct VS_IN {
|
|||
};
|
||||
|
||||
struct VS_OUT {
|
||||
float4 position : POSITION;
|
||||
float4 texcoord0 : TEXCOORD0;
|
||||
float4 texcoord1 : TEXCOORD0;
|
||||
float4 position : SV_Position;
|
||||
float4 texcoord0 : TEXCOORD0_centroid;
|
||||
float4 texcoord1 : TEXCOORD1_centroid;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@ float PhotoLuma( float3 c )
|
|||
|
||||
float3 sRGBToLinearRGB( float3 c )
|
||||
{
|
||||
#if defined( USE_LINEAR_RGB ) && !defined( USE_SRGB )
|
||||
#if ( defined( USE_LINEAR_RGB ) && USE_LINEAR_RGB ) && ( !defined( USE_SRGB ) || !USE_SRGB )
|
||||
c = clamp( c, 0.0, 1.0 );
|
||||
|
||||
return Linear3( c );
|
||||
|
@ -188,7 +188,7 @@ float3 sRGBToLinearRGB( float3 c )
|
|||
|
||||
float4 sRGBAToLinearRGBA( float4 c )
|
||||
{
|
||||
#if defined( USE_LINEAR_RGB ) && !defined( USE_SRGB )
|
||||
#if ( defined( USE_LINEAR_RGB ) && USE_LINEAR_RGB ) && ( !defined( USE_SRGB ) || !USE_SRGB )
|
||||
c = clamp( c, 0.0, 1.0 );
|
||||
|
||||
return float4( Linear1( c.r ), Linear1( c.g ), Linear1( c.b ), Linear1( c.a ) );
|
||||
|
@ -199,7 +199,7 @@ float4 sRGBAToLinearRGBA( float4 c )
|
|||
|
||||
float3 LinearRGBToSRGB( float3 c )
|
||||
{
|
||||
#if defined( USE_LINEAR_RGB ) && !defined( USE_SRGB )
|
||||
#if ( defined( USE_LINEAR_RGB ) && USE_LINEAR_RGB ) && ( !defined( USE_SRGB ) || !USE_SRGB )
|
||||
c = clamp( c, 0.0, 1.0 );
|
||||
|
||||
return Srgb3( c );
|
||||
|
@ -210,7 +210,7 @@ float3 LinearRGBToSRGB( float3 c )
|
|||
|
||||
float4 LinearRGBToSRGB( float4 c )
|
||||
{
|
||||
#if defined( USE_LINEAR_RGB ) && !defined( USE_SRGB )
|
||||
#if ( defined( USE_LINEAR_RGB ) && USE_LINEAR_RGB ) && ( !defined( USE_SRGB ) || !USE_SRGB )
|
||||
c = clamp( c, 0.0, 1.0 );
|
||||
|
||||
return float4( Srgb1( c.r ), Srgb1( c.g ), Srgb1( c.b ), c.a );
|
||||
|
@ -280,7 +280,7 @@ float3 octDecode( float2 o )
|
|||
#define matrixCoCg1YtoRGB1X half4( 1.0, -1.0, 0.0, 1.0 )
|
||||
// -0.5 * 256.0 / 255.0
|
||||
#define matrixCoCg1YtoRGB1Y half4( 0.0, 1.0, -0.50196078, 1.0 )
|
||||
// +1.0 * 256.0 / 255.0
|
||||
// +1.0 * 256.0 / 255.0
|
||||
#define matrixCoCg1YtoRGB1Z half4( -1.0, -1.0, 1.00392156, 1.0 )
|
||||
|
||||
static half3 ConvertYCoCgToRGB( half4 YCoCg )
|
||||
|
@ -345,14 +345,23 @@ float rand( float2 co )
|
|||
#define vec3 float3
|
||||
#define vec4 float4
|
||||
|
||||
#define VPOS WPOS
|
||||
#define VPOS SV_Position
|
||||
|
||||
#define dFdx ddx
|
||||
#define dFdy ddy
|
||||
|
||||
static float4 idtex2Dproj( SamplerState samp, Texture2D t, float4 texCoords )
|
||||
{
|
||||
// TODO(Stephen): Divide by z or w?
|
||||
return t.Sample( samp, texCoords.xy / texCoords.w );
|
||||
}
|
||||
|
||||
static float idtex2Dproj( SamplerState samp, Texture2D<float> t, float4 texCoords )
|
||||
{
|
||||
return t.Sample( samp, texCoords.xy / texCoords.w );
|
||||
}
|
||||
|
||||
static float3 idtex2Dproj( SamplerState samp, Texture2D<float3> t, float4 texCoords )
|
||||
{
|
||||
return t.Sample( samp, texCoords.xy / texCoords.w );
|
||||
}
|
||||
|
||||
|
@ -473,8 +482,7 @@ static float3 ditherRGB( float3 color, float2 uvSeed, float quantSteps )
|
|||
//float3 noise = Hash33( float3( uvSeed, rpJitterTexOffset.w ) );
|
||||
|
||||
//float3 noise = float3( InterleavedGradientNoise( uvSeed ) );
|
||||
// TODO(Stephen): Determine if the remaining two values should be 0 or something like 1.
|
||||
float3 noise = float3( InterleavedGradientNoiseAnim( uvSeed, rpJitterTexOffset.w ), 0, 0 );
|
||||
float3 noise = _float3( InterleavedGradientNoiseAnim( uvSeed, rpJitterTexOffset.w ) );
|
||||
|
||||
// triangular noise [-0.5;1.5[
|
||||
|
||||
|
@ -483,7 +491,7 @@ static float3 ditherRGB( float3 color, float2 uvSeed, float quantSteps )
|
|||
noise = noise * 2.0 - 0.5;
|
||||
#endif
|
||||
|
||||
noise = float3( noise.x, 0, 0 );
|
||||
noise = _float3( noise.x );
|
||||
|
||||
// quantize/truncate color and dither the result
|
||||
//float scale = exp2( float( TARGET_BITS ) ) - 1.0;
|
||||
|
@ -500,10 +508,6 @@ static float3 ditherRGB( float3 color, float2 uvSeed, float quantSteps )
|
|||
|
||||
//float3 color = c + whiteNoise / 255.0;
|
||||
|
||||
#if defined( USE_LINEAR_RGB )
|
||||
|
||||
#endif
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,38 +26,39 @@ If you have questions concerning this license or the applicable additional terms
|
|||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "renderprogs/global.inc.hlsl"
|
||||
#include "global_inc.hlsl"
|
||||
|
||||
|
||||
// *INDENT-OFF*
|
||||
uniform sampler2D samp0 : register(s0); // texture 0 is _current Render
|
||||
uniform sampler2D samp1 : register(s1); // texture 1 is the per-surface bump map
|
||||
uniform sampler2D samp2 : register(s2); // texture 2 is the mask texture
|
||||
Texture2D t_CurrentRender : register( t0 );
|
||||
Texture2D t_NormalMap : register( t1 );
|
||||
Texture2D t_Mask : register( t2 );
|
||||
|
||||
SamplerState LinearSampler : register( s0 );
|
||||
|
||||
struct PS_IN {
|
||||
float4 position : VPOS;
|
||||
float4 position : SV_Position;
|
||||
float4 texcoord0 : TEXCOORD0_centroid;
|
||||
float4 texcoord1 : TEXCOORD1_centroid;
|
||||
float4 texcoord2 : TEXCOORD2_centroid;
|
||||
};
|
||||
|
||||
struct PS_OUT {
|
||||
float4 color : COLOR;
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
void main( PS_IN fragment, out PS_OUT result )
|
||||
{
|
||||
|
||||
// load the distortion map
|
||||
float4 mask = tex2D( samp2, fragment.texcoord0.xy );
|
||||
float4 mask = t_Mask.Sample( LinearSampler, fragment.texcoord0.xy );
|
||||
|
||||
// kill the pixel if the distortion wound up being very small
|
||||
mask.xy -= 0.01f;
|
||||
clip( mask );
|
||||
|
||||
// load the filtered normal map and convert to -1 to 1 range
|
||||
float4 bumpMap = ( tex2D( samp1, fragment.texcoord1.xy ) * 2.0f ) - 1.0f;
|
||||
float4 bumpMap = ( t_NormalMap.Sample( LinearSampler, fragment.texcoord1.xy ) * 2.0f ) - 1.0f;
|
||||
float2 localNormal = bumpMap.wy;
|
||||
localNormal *= mask.xy;
|
||||
|
||||
|
@ -66,5 +67,5 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
screenTexCoord += ( localNormal * fragment.texcoord2.xy );
|
||||
screenTexCoord = saturate( screenTexCoord );
|
||||
|
||||
result.color = ( tex2D( samp0, screenTexCoord ) );
|
||||
result.color = ( t_CurrentRender.Sample( LinearSampler, screenTexCoord ) );
|
||||
}
|
|
@ -27,18 +27,21 @@ If you have questions concerning this license or the applicable additional terms
|
|||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "renderprogs/global.inc.hlsl"
|
||||
#include "global_inc.hlsl"
|
||||
|
||||
|
||||
// RB: no GPU skinning with ES 2.0
|
||||
#if USE_GPU_SKINNING
|
||||
uniform matrices_ubo { float4 matrices[408]; };
|
||||
#endif
|
||||
// RB end
|
||||
// User Renderparms start at 128 as per renderprogs.h
|
||||
|
||||
// *INDENT-OFF*
|
||||
uniform float4 rpUser0 : register(c128); // rpScroll
|
||||
uniform float4 rpUser1 : register(c129); // rpDeformMagnitude
|
||||
//
|
||||
// RB: no GPU skinning with ES 2.0
|
||||
#if USE_GPU_SKINNING
|
||||
cbuffer CB : register( b1 )
|
||||
{
|
||||
float4 matrices[408];
|
||||
};
|
||||
#endif
|
||||
// RB end
|
||||
|
||||
struct VS_IN {
|
||||
float4 position : POSITION;
|
||||
|
@ -50,17 +53,17 @@ struct VS_IN {
|
|||
};
|
||||
|
||||
struct VS_OUT {
|
||||
float4 position : POSITION;
|
||||
float4 texcoord0 : TEXCOORD0;
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
float4 texcoord2 : TEXCOORD2;
|
||||
float4 position : SV_Position;
|
||||
float4 texcoord0 : TEXCOORD0_centroid;
|
||||
float4 texcoord1 : TEXCOORD1_centroid;
|
||||
float4 texcoord2 : TEXCOORD2_centroid;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
void main( VS_IN vertex, out VS_OUT result )
|
||||
{
|
||||
|
||||
#include "renderprogs/skinning.inc.hlsl"
|
||||
#include "skinning.inc.hlsl"
|
||||
|
||||
|
||||
// texture 0 takes the texture coordinates unmodified
|
||||
|
|
|
@ -31,7 +31,8 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
|
||||
#if USE_GPU_SKINNING
|
||||
cbuffer CB : register( b1 )
|
||||
cbuffer CB :
|
||||
register( b1 )
|
||||
{
|
||||
float4 matrices[408];
|
||||
};
|
||||
|
|
|
@ -54,8 +54,8 @@ struct VS_IN {
|
|||
|
||||
struct VS_OUT {
|
||||
float4 position : SV_Position;
|
||||
float4 texcoord0 : TEXCOORD0;
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
float4 texcoord0 : TEXCOORD0_centroid;
|
||||
float4 texcoord1 : TEXCOORD1_centroid;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
|
@ -64,11 +64,11 @@ void main( VS_IN vertex, out VS_OUT result )
|
|||
|
||||
#include "skinning.inc.hlsl"
|
||||
|
||||
//texture 0 takes the texture coordinates and adds a scroll
|
||||
// texture 0 takes the texture coordinates and adds a scroll
|
||||
const float4 textureScroll = rpUser0;
|
||||
result.texcoord0 = float4( vertex.texcoord.xy, 0, 0 ) + textureScroll;
|
||||
|
||||
//texture 1 takes the deform magnitude and scales it by the projection distance
|
||||
// texture 1 takes the deform magnitude and scales it by the projection distance
|
||||
float4 vec = float4( 0, 1, 0, 1 );
|
||||
vec.z = dot4( modelPosition, rpModelViewMatrixZ ); // this is the modelview matrix
|
||||
|
||||
|
@ -79,7 +79,7 @@ void main( VS_IN vertex, out VS_OUT result )
|
|||
float x = dot4( vec, rpProjectionMatrixY ) * magicProjectionAdjust;
|
||||
float w = dot4( vec, rpProjectionMatrixW );
|
||||
|
||||
//don't let the recip get near zero for polygons that cross the view plane
|
||||
// don't let the recip get near zero for polygons that cross the view plane
|
||||
w = max( w, 1.0 );
|
||||
x /= w;
|
||||
//x = x * ( 1.0f / w );
|
||||
|
|
|
@ -31,7 +31,10 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
|
||||
// *INDENT-OFF*
|
||||
uniform sampler2D samp0 : register(s0); // texture 0 is texture to apply crt to.
|
||||
|
||||
Texture2D t_CurrentRender : register( t0 );
|
||||
|
||||
SamplerState LinearSampler : register( s0 );
|
||||
|
||||
struct PS_IN {
|
||||
float4 position : SV_Position;
|
||||
|
@ -40,7 +43,7 @@ struct PS_IN {
|
|||
};
|
||||
|
||||
struct PS_OUT {
|
||||
float4 color : COLOR;
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
|
@ -65,21 +68,21 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
|
||||
float2 uv = q;
|
||||
uv = curve( uv );
|
||||
float3 oricol = tex2D( samp0, float2( q.x, q.y ) ).xyz;
|
||||
float3 oricol = t_CurrentRender.Sample( LinearSampler, float2( q.x, q.y ) ).xyz;
|
||||
float3 col;
|
||||
float x = sin( 0.3 * iTime + uv.y * 21.0 ) * sin( 0.7 * iTime + uv.y * 29.0 ) * sin( 0.3 + 0.33 * iTime + uv.y * 31.0 ) * 0.0017;
|
||||
|
||||
col.r = tex2D( samp0, float2( x + uv.x + 0.001, uv.y + 0.001 ) ).x + 0.05;
|
||||
col.g = tex2D( samp0, float2( x + uv.x + 0.000, uv.y - 0.002 ) ).y + 0.05;
|
||||
col.b = tex2D( samp0, float2( x + uv.x - 0.002, uv.y + 0.000 ) ).z + 0.05;
|
||||
col.r += 0.08 * tex2D( samp0, 0.75 * float2( x + 0.025, -0.027 ) + float2( uv.x + 0.001, uv.y + 0.001 ) ).x;
|
||||
col.g += 0.05 * tex2D( samp0, 0.75 * float2( x + -0.022, -0.02 ) + float2( uv.x + 0.000, uv.y - 0.002 ) ).y;
|
||||
col.b += 0.08 * tex2D( samp0, 0.75 * float2( x + -0.02, -0.018 ) + float2( uv.x - 0.002, uv.y + 0.000 ) ).z;
|
||||
col.r = t_CurrentRender.Sample( LinearSampler, float2( x + uv.x + 0.001, uv.y + 0.001 ) ).x + 0.05;
|
||||
col.g = t_CurrentRender.Sample( LinearSampler, float2( x + uv.x + 0.000, uv.y - 0.002 ) ).y + 0.05;
|
||||
col.b = t_CurrentRender.Sample( LinearSampler, float2( x + uv.x - 0.002, uv.y + 0.000 ) ).z + 0.05;
|
||||
col.r += 0.08 * t_CurrentRender.Sample( LinearSampler, 0.75 * float2( x + 0.025, -0.027 ) + float2( uv.x + 0.001, uv.y + 0.001 ) ).x;
|
||||
col.g += 0.05 * t_CurrentRender.Sample( LinearSampler, 0.75 * float2( x + -0.022, -0.02 ) + float2( uv.x + 0.000, uv.y - 0.002 ) ).y;
|
||||
col.b += 0.08 * t_CurrentRender.Sample( LinearSampler, 0.75 * float2( x + -0.02, -0.018 ) + float2( uv.x - 0.002, uv.y + 0.000 ) ).z;
|
||||
|
||||
col = clamp( col * 0.6 + 0.4 * col * col * 1.0, 0.0, 1.0 );
|
||||
|
||||
float vig = ( 0.0 + 1.0 * 16.0 * uv.x * uv.y * ( 1.0 - uv.x ) * ( 1.0 - uv.y ) );
|
||||
col *= float3( pow( vig, 0.3 ) );
|
||||
col *= _float3( pow( vig, 0.3 ) );
|
||||
|
||||
col *= float3( 0.95, 1.05, 0.95 );
|
||||
col *= 2.8;
|
||||
|
@ -87,7 +90,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
float scans = clamp( 0.35 + 0.35 * sin( 3.5 * iTime + uv.y * iResolution.y * 1.5 ), 0.0, 1.0 );
|
||||
|
||||
float s = pow( scans, 1.7 );
|
||||
col = col * float3( 0.4 + 0.7 * s ) ;
|
||||
col = col * _float3( 0.4 + 0.7 * s ) ;
|
||||
|
||||
col *= 1.0 + 0.01 * sin( 110.0 * iTime );
|
||||
if( uv.x < 0.0 || uv.x > 1.0 )
|
||||
|
@ -99,7 +102,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
col *= 0.0;
|
||||
}
|
||||
|
||||
col *= 1.0 - 0.65 * float3( clamp( ( mod( fragment.texcoord0.x, 2.0 ) - 1.0 ) * 2.0, 0.0, 1.0 ) );
|
||||
col *= 1.0 - 0.65 * _float3( clamp( ( fmod( fragment.texcoord0.x, 2.0 ) - 1.0 ) * 2.0, 0.0, 1.0 ) );
|
||||
|
||||
float comp = smoothstep( 0.1, 0.9, sin( iTime ) );
|
||||
|
||||
|
|
|
@ -26,16 +26,19 @@ If you have questions concerning this license or the applicable additional terms
|
|||
=================================================a==========================
|
||||
*/
|
||||
|
||||
#include "renderprogs/global.inc.hlsl"
|
||||
#include "global_inc.hlsl"
|
||||
|
||||
// RB: no GPU skinning with ES 2.0
|
||||
#if defined(USE_GPU_SKINNING)
|
||||
uniform matrices_ubo { float4 matrices[408]; };
|
||||
#if USE_GPU_SKINNING
|
||||
cbuffer CB :
|
||||
register( b1 )
|
||||
{
|
||||
float4 matrices[408];
|
||||
};
|
||||
#endif
|
||||
// RB end
|
||||
|
||||
// *INDENT-OFF*
|
||||
uniform float4 rpUser0 : register( c128 ); // time, width, height, 0
|
||||
|
||||
struct VS_IN {
|
||||
float4 position : POSITION;
|
||||
|
@ -47,7 +50,7 @@ struct VS_IN {
|
|||
};
|
||||
|
||||
struct VS_OUT {
|
||||
float4 position : POSITION;
|
||||
float4 position : SV_Position;
|
||||
float4 texcoord0 : TEXCOORD0;
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
};
|
||||
|
@ -55,7 +58,7 @@ struct VS_OUT {
|
|||
|
||||
void main( VS_IN vertex, out VS_OUT result )
|
||||
{
|
||||
#include "renderprogs/skinning.inc.hlsl"
|
||||
#include "skinning.inc.hlsl"
|
||||
//result.position = vertex.position;
|
||||
|
||||
result.texcoord0.xy = vertex.texcoord;
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
|
||||
## Note: A lot of the defines for a vertex shader are there just to
|
||||
## satisfy the requirement in the engine. In the future, we can
|
||||
## remove these if we load the shaders as separate units instead of as
|
||||
## packaged programs.
|
||||
|
||||
builtin/debug/lightgrid.vs.hlsl -T vs_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
builtin/debug/lightgrid.ps.hlsl -T ps_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
builtin/debug/octahedron.vs.hlsl -T vs_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
|
@ -20,8 +25,8 @@ builtin/texture_color_texgen.vs.hlsl -T vs_5_0
|
|||
builtin/texture_color_texgen.ps.hlsl -T ps_5_0
|
||||
builtin/texture.vs.hlsl -T vs_5_0
|
||||
builtin/texture.ps.hlsl -T ps_5_0
|
||||
builtin/gbuffer.vs.hlsl -T vs_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
builtin/gbuffer.ps.hlsl -T ps_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
builtin/gbuffer.vs.hlsl -T vs_5_0 -D USE_GPU_SKINNING={0,1} -D USE_NORMAL_FMT_RGB8={0,1}
|
||||
builtin/gbuffer.ps.hlsl -T ps_5_0 -D USE_GPU_SKINNING={0,1} -D USE_NORMAL_FMT_RGB8={0,1}
|
||||
builtin/depth.vs.hlsl -T vs_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
builtin/depth.ps.hlsl -T ps_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
builtin/blit.ps.hlsl -T ps_5_0 -D TEXTURE_ARRAY={0,1}
|
||||
|
@ -46,8 +51,8 @@ builtin/lighting/interaction.vs.hlsl -T vs_5_0 -D USE_GPU_SKINNING={0,1} -D USE_
|
|||
builtin/lighting/interaction.ps.hlsl -T ps_5_0 -D USE_GPU_SKINNING={0,1} -D USE_PBR={0,1}
|
||||
builtin/lighting/interactionAmbient.vs.hlsl -T vs_5_0 -D USE_GPU_SKINNING={0,1} -D USE_PBR={0,1}
|
||||
builtin/lighting/interactionAmbient.ps.hlsl -T ps_5_0 -D USE_GPU_SKINNING={0,1} -D USE_PBR={0,1}
|
||||
builtin/lighting/interactionSM.vs.hlsl -T vs_5_0 -D USE_GPU_SKINNING={0,1} -D LIGHT_POINT={0,1} -D LIGHT_PARALLEL={0,1} -D USE_PBR={0,1}
|
||||
builtin/lighting/interactionSM.ps.hlsl -T ps_5_0 -D USE_GPU_SKINNING={0,1} -D LIGHT_POINT={0,1} -D LIGHT_PARALLEL={0,1} -D USE_PBR={0,1}
|
||||
builtin/lighting/interactionSM.vs.hlsl -T vs_5_0 -D USE_GPU_SKINNING={0,1} -D LIGHT_POINT={0,1} -D LIGHT_PARALLEL={0,1} -D USE_PBR={0,1} -D USE_NORMAL_FMT_RGB8={0,1}
|
||||
builtin/lighting/interactionSM.ps.hlsl -T ps_5_0 -D USE_GPU_SKINNING={0,1} -D LIGHT_POINT={0,1} -D LIGHT_PARALLEL={0,1} -D USE_PBR={0,1} -D USE_NORMAL_FMT_RGB8={0,1}
|
||||
builtin/lighting/shadow.vs.hlsl -T vs_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
builtin/lighting/shadow.ps.hlsl -T ps_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
|
||||
|
@ -69,7 +74,8 @@ builtin/post/motionBlur.vs.hlsl -T vs_5_0
|
|||
builtin/post/motionBlur.ps.hlsl -T ps_5_0
|
||||
builtin/post/exposure.cs.hlsl -T cs_5_0 -D HISTOGRAM_BINS=256
|
||||
builtin/post/histogram.cs.hlsl -T cs_5_0 -D HISTOGRAM_BINS=256 -D SOURCE_ARRAY={0,1}
|
||||
builtin/post/tonemapping.ps.hlsl -T ps_5_0 -D HISTOGRAM_BINS=256 -D SOURCE_ARRAY={0,1}
|
||||
builtin/post/tonemapping.ps.hlsl -T ps_5_0 -D HISTOGRAM_BINS=256 -D SOURCE_ARRAY={0,1} -D QUAD_Z={0,1}
|
||||
builtin/post/tonemapping.vs.hlsl -T vs_5_0 -D HISTOGRAM_BINS=256 -D SOURCE_ARRAY={0,1} -D QUAD_Z={0,1}
|
||||
|
||||
builtin/SSAO/AmbientOcclusion_AO.vs.hlsl -T vs_5_0 -D BRIGHTPASS={0,1}
|
||||
builtin/SSAO/AmbientOcclusion_AO.ps.hlsl -T ps_5_0 -D BRIGHTPASS={0,1}
|
||||
|
@ -83,10 +89,10 @@ builtin/SSGI/DeepGBufferRadiosity_blur.ps.hlsl -T ps_5_0
|
|||
builtin/SSGI/DeepGBufferRadiosity_radiosity.vs.hlsl -T vs_5_0
|
||||
builtin/SSGI/DeepGBufferRadiosity_radiosity.ps.hlsl -T ps_5_0
|
||||
|
||||
builtin/fog/blendLight.vs.hlsl -T vs_5_0
|
||||
builtin/fog/blendLight.ps.hlsl -T ps_5_0
|
||||
builtin/fog/fog.vs.hlsl -T vs_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
builtin/fog/fog.ps.hlsl -T ps_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
builtin/fog/blendLight.vs.hlsl -T vs_5_0 -D USE_LINEAR_RGB={0,1}
|
||||
builtin/fog/blendLight.ps.hlsl -T ps_5_0 -D USE_LINEAR_RGB={0,1}
|
||||
builtin/fog/fog.vs.hlsl -T vs_5_0 -D USE_GPU_SKINNING={0,1} -D USE_LINEAR_RGB={0,1}
|
||||
builtin/fog/fog.ps.hlsl -T ps_5_0 -D USE_GPU_SKINNING={0,1} -D USE_LINEAR_RGB={0,1}
|
||||
|
||||
builtin/video/bink.vs.hlsl -T vs_5_0
|
||||
builtin/video/bink.ps.hlsl -T ps_5_0
|
||||
|
@ -107,7 +113,27 @@ builtin/SSAO/ssao_compute.cs.hlsl -T cs_5_0 -D OCT_ENCODED_NORMALS={0,1} -D DIRE
|
|||
builtin/SSAO/ssao_deinterleave.cs.hlsl -T cs_5_0 -D LINEAR_DEPTH={0,1}
|
||||
|
||||
# User shaders
|
||||
bloodorb_draw.vs.hlsl -T vs_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
bloodorb_draw.ps.hlsl -T ps_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
bloodorb1_capture.vs.hlsl -T vs_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
bloodorb1_capture.ps.hlsl -T ps_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
bloodorb2_capture.vs.hlsl -T vs_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
bloodorb2_capture.ps.hlsl -T ps_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
bloodorb3_capture.vs.hlsl -T vs_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
bloodorb3_capture.ps.hlsl -T ps_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
colorProcess.vs.hlsl -T vs_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
colorProcess.ps.hlsl -T ps_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
enviroSuit.vs.hlsl -T vs_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
enviroSuit.ps.hlsl -T ps_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
fogwithlights.vs.hlsl -T vs_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
fogwithlights.ps.hlsl -T ps_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
heathaze.vs.hlsl -T vs_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
heathaze.ps.hlsl -T ps_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
heatHazeWithMask.vs.hlsl -T vs_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
heatHazeWithMask.ps.hlsl -T ps_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
heatHazeWithMaskAndVertex.vs.hlsl -T vs_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
heatHazeWithMaskAndVertex.ps.hlsl -T ps_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
heatHazeWithMaskAndVertex.ps.hlsl -T ps_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
mattiascrt.vs.hlsl -T vs_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
mattiascrt.ps.hlsl -T ps_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
vornoipattern.vs.hlsl -T vs_5_0 -D USE_GPU_SKINNING={0,1}
|
||||
vornoipattern.ps.hlsl -T ps_5_0 -D USE_GPU_SKINNING={0,1}
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#pragma pack_matrix(row_major)
|
||||
|
||||
// *INDENT-OFF*
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 pos : POSITION;
|
||||
|
@ -37,6 +38,7 @@ struct PS_INPUT
|
|||
float4 color : COLOR0;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
PS_INPUT main_vs( VS_INPUT input )
|
||||
{
|
||||
|
@ -55,8 +57,10 @@ PS_INPUT main_vs( VS_INPUT input )
|
|||
return output;
|
||||
}
|
||||
|
||||
Texture2D t_Texture : register( t0 );
|
||||
SamplerState s_Sampler : register( s0 );
|
||||
Texture2D t_Texture :
|
||||
register( t0 );
|
||||
SamplerState s_Sampler :
|
||||
register( s0 );
|
||||
|
||||
float4 main_ps( PS_INPUT input ) : SV_Target
|
||||
{
|
||||
|
|
|
@ -55,21 +55,19 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
*/
|
||||
|
||||
#include "renderprogs/global.inc.hlsl"
|
||||
#include "global_inc.hlsl"
|
||||
|
||||
|
||||
// *INDENT-OFF*
|
||||
uniform sampler2D samp0 : register(s0); // texture 0 is _current Render
|
||||
uniform sampler2D samp1 : register(s1); // texture 1 is the per-surface bump map
|
||||
|
||||
struct PS_IN {
|
||||
float4 position : VPOS;
|
||||
float4 texcoord0 : TEXCOORD0_centroid;
|
||||
float4 texcoord1 : TEXCOORD0_centroid;
|
||||
float4 position : SV_Position;
|
||||
float4 texcoord0 : TEXCOORD0;
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
struct PS_OUT {
|
||||
float4 color : COLOR;
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
|
@ -83,7 +81,7 @@ float2 hash22( float2 p, float iTime )
|
|||
//return fract(float2(262144, 32768)*n)*.75 + .25;
|
||||
|
||||
// Animated.
|
||||
p = fract( float2( 262144, 32768 ) * n );
|
||||
p = frac( float2( 262144, 32768 ) * n );
|
||||
return sin( p * 6.2831853 + iTime ) * .35 + .65;
|
||||
|
||||
}
|
||||
|
@ -91,9 +89,8 @@ float2 hash22( float2 p, float iTime )
|
|||
// IQ's polynomial-based smooth minimum function.
|
||||
float smin( float a, float b, float k )
|
||||
{
|
||||
|
||||
float h = clamp( .5 + .5 * ( b - a ) / k, 0., 1. );
|
||||
return mix( b, a, h ) - k * h * ( 1. - h );
|
||||
return lerp( b, a, h ) - k * h * ( 1. - h );
|
||||
}
|
||||
|
||||
// 2D 3rd-order Voronoi: This is just a rehash of Fabrice Neyret's version, which is in
|
||||
|
@ -112,7 +109,7 @@ float Voronoi( in float2 p, float iTime )
|
|||
float2 g = floor( p ), o;
|
||||
p -= g;
|
||||
|
||||
float3 d = float3( 1 ); // 1.4, etc.
|
||||
float3 d = _float3( 1 ); // 1.4, etc.
|
||||
|
||||
float r = 0.;
|
||||
|
||||
|
|
|
@ -26,16 +26,19 @@ If you have questions concerning this license or the applicable additional terms
|
|||
=================================================a==========================
|
||||
*/
|
||||
|
||||
#include "renderprogs/global.inc.hlsl"
|
||||
#include "global_inc.hlsl"
|
||||
|
||||
// RB: no GPU skinning with ES 2.0
|
||||
#if defined(USE_GPU_SKINNING)
|
||||
uniform matrices_ubo { float4 matrices[408]; };
|
||||
#if USE_GPU_SKINNING
|
||||
cbuffer CB :
|
||||
register( b1 )
|
||||
{
|
||||
float4 matrices[408];
|
||||
};
|
||||
#endif
|
||||
// RB end
|
||||
|
||||
// *INDENT-OFF*
|
||||
uniform float4 rpUser0 : register( c128 ); // time in seconds
|
||||
|
||||
struct VS_IN {
|
||||
float4 position : POSITION;
|
||||
|
@ -49,13 +52,13 @@ struct VS_IN {
|
|||
struct VS_OUT {
|
||||
float4 position : POSITION;
|
||||
float4 texcoord0 : TEXCOORD0;
|
||||
float4 texcoord1 : TEXCOORD0;
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
void main( VS_IN vertex, out VS_OUT result )
|
||||
{
|
||||
#include "renderprogs/skinning.inc.hlsl"
|
||||
#include "skinning.inc.hlsl"
|
||||
//result.position.x = dot4( vertex.position, rpMVPmatrixX );
|
||||
//result.position.y = dot4( vertex.position, rpMVPmatrixY );
|
||||
//result.position.z = dot4( vertex.position, rpMVPmatrixZ );
|
||||
|
|
Loading…
Reference in a new issue