mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 09:04:38 +00:00
Empty Template for ticket #1
This commit is contained in:
parent
8337cad7ee
commit
40220512d3
1573 changed files with 141028 additions and 0 deletions
|
|
@ -0,0 +1,53 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
#include "../postFx.hlsl"
|
||||
|
||||
uniform sampler2D backBuffer : register( s0 ); // The original backbuffer.
|
||||
uniform sampler2D prepassTex : register( s1 ); // The pre-pass depth and normals.
|
||||
|
||||
uniform float brightScalar;
|
||||
|
||||
static const float3 LUMINANCE_VECTOR = float3(0.3125f, 0.6154f, 0.0721f);
|
||||
|
||||
|
||||
float4 main( PFXVertToPix IN ) : COLOR0
|
||||
{
|
||||
float4 col = float4( 0, 0, 0, 1 );
|
||||
|
||||
// Get the depth at this pixel.
|
||||
float depth = prepassUncondition( prepassTex, IN.uv0 ).w;
|
||||
|
||||
// If the depth is equal to 1.0, read from the backbuffer
|
||||
// and perform the exposure calculation on the result.
|
||||
if ( depth >= 0.999 )
|
||||
{
|
||||
col = tex2D( backBuffer, IN.uv0 );
|
||||
|
||||
//col = 1 - exp(-120000 * col);
|
||||
col += dot( col, LUMINANCE_VECTOR ) + 0.0001f;
|
||||
col *= brightScalar;
|
||||
}
|
||||
|
||||
return col;
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "../postFx.hlsl"
|
||||
|
||||
uniform sampler2D frameSampler : register( s0 );
|
||||
uniform sampler2D backBuffer : register( s1 );
|
||||
|
||||
uniform float3 camForward;
|
||||
uniform float3 lightDirection;
|
||||
uniform float2 screenSunPos;
|
||||
uniform float2 oneOverTargetSize;
|
||||
uniform int numSamples;
|
||||
uniform float density;
|
||||
uniform float weight;
|
||||
uniform float decay;
|
||||
uniform float exposure;
|
||||
|
||||
float4 main( PFXVertToPix IN ) : COLOR0
|
||||
{
|
||||
float4 texCoord = float4( IN.uv0.xy, 0, 0 );
|
||||
|
||||
// Store initial sample.
|
||||
half3 color = (half3)tex2D( frameSampler, texCoord.xy ).rgb;
|
||||
|
||||
// Store original bb color.
|
||||
float4 bbCol = tex2D( backBuffer, IN.uv1 );
|
||||
|
||||
// Set up illumination decay factor.
|
||||
half illuminationDecay = 1.0;
|
||||
|
||||
float amount = saturate( dot( -lightDirection, camForward ) );
|
||||
|
||||
int samples = numSamples * amount;
|
||||
|
||||
if ( samples <= 0 )
|
||||
return bbCol;
|
||||
|
||||
// Calculate vector from pixel to light source in screen space.
|
||||
half2 deltaTexCoord = (half2)( texCoord.xy - screenSunPos );
|
||||
|
||||
// Divide by number of samples and scale by control factor.
|
||||
deltaTexCoord *= 1.0 / (half)samples * density;
|
||||
|
||||
// Evaluate summation from Equation 3 NUM_SAMPLES iterations.
|
||||
for ( int i = 0; i < samples; i++ )
|
||||
{
|
||||
// Step sample location along ray.
|
||||
texCoord.xy -= deltaTexCoord;
|
||||
|
||||
// Retrieve sample at new location.
|
||||
half3 sample = (half3)tex2Dlod( frameSampler, texCoord );
|
||||
|
||||
// Apply sample attenuation scale/decay factors.
|
||||
sample *= illuminationDecay * weight;
|
||||
|
||||
// Accumulate combined color.
|
||||
color += sample;
|
||||
|
||||
// Update exponential decay factor.
|
||||
illuminationDecay *= decay;
|
||||
}
|
||||
|
||||
//return saturate( amount ) * color * Exposure;
|
||||
//return bbCol * decay;
|
||||
|
||||
// Output final color with a further scale control factor.
|
||||
return saturate( amount ) * float4( color * exposure, 1 ) + bbCol;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue