-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af0a8cb
commit 21f423a
Showing
10 changed files
with
108 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<shaderConfig name="AdaptLuminance" baseShader="SOLID"> | ||
<uniforms> | ||
<vs> | ||
<uniform name="uMvpMatrix" type="WORLD_VIEW_PROJECTION" value="0" float="16" matrix="true"/> | ||
</vs> | ||
<fs> | ||
<uniform name="uTexLuminance" type="DEFAULT_VALUE" value="0" float="1" directX="false"/> | ||
<uniform name="uTexLastLuminance" type="DEFAULT_VALUE" value="1" float="1" directX="false"/> | ||
<uniform name="uTimeStep" type="TIME_STEP" value="0,0" float="2"/> | ||
</fs> | ||
</uniforms> | ||
<customUI> | ||
</customUI> | ||
<shader type="GLSL" vs="GLSL/PostEffectVS.glsl" fs="GLSL/AdaptLuminanceFS.glsl"/> | ||
<shader type="HLSL" vs="HLSL/PostEffectVS.hlsl" fs="HLSL/AdaptLuminanceFS.hlsl"/> | ||
</shaderConfig> |
20 changes: 20 additions & 0 deletions
20
Assets/BuiltIn/Shader/PostProcessing/GLSL/AdaptLuminanceFS.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
precision mediump float; | ||
|
||
uniform sampler2D uTexLuminance; | ||
uniform sampler2D uTexLastLuminance; | ||
|
||
uniform vec2 uTimeStep; | ||
|
||
in vec2 varTexCoord0; | ||
in vec4 varColor; | ||
out vec4 FragColor; | ||
|
||
void main(void) | ||
{ | ||
float lum = texture(uTexLuminance, varTexCoord0).x; | ||
float lastLum = texture(uTexLastLuminance, varTexCoord0).x; | ||
|
||
float adaptLum = lastLum + (lum - lastLum) * uTimeStep.x * 0.001; | ||
|
||
FragColor = vec4(adaptLum, 0, 0, 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
Assets/BuiltIn/Shader/PostProcessing/HLSL/AdaptLuminanceFS.hlsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Texture2D uTexLuminance : register(t0); | ||
SamplerState uTexLuminanceSampler : register(s0); | ||
|
||
Texture2D uTexLastLuminance : register(t1); | ||
SamplerState uTexLastLuminanceSampler : register(s1); | ||
|
||
struct PS_INPUT | ||
{ | ||
float4 pos : SV_POSITION; | ||
float4 color : COLOR0; | ||
float2 tex0 : TEXCOORD0; | ||
}; | ||
|
||
cbuffer cbPerFrame | ||
{ | ||
float2 uTimeStep; | ||
} | ||
|
||
float4 main(PS_INPUT input) : SV_TARGET | ||
{ | ||
float lum = uTexLuminance.Sample(uTexLuminanceSampler, input.tex0).x; | ||
float lastLum = uTexLastLuminance.Sample(uTexLastLuminanceSampler, input.tex0).x; | ||
|
||
float adaptLum = lastLum + (lum - lastLum) * uTimeStep.x * 0.001; | ||
|
||
return float4(adaptLum, 0, 0, 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,7 @@ namespace Skylicht | |
SSAO_KERNEL, | ||
DEFERRED_VIEW, | ||
DEFERRED_PROJECTION, | ||
TIME_STEP, | ||
NUM_SHADER_TYPE, | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters