-
-
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.
feat: #86 move tone mapping to post process shader
- Loading branch information
1 parent
5de3fa0
commit 3636063
Showing
24 changed files
with
193 additions
and
20 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
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
15 changes: 15 additions & 0 deletions
15
Assets/BuiltIn/Shader/PostProcessing/GLSL/PostEffectFS.d.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,15 @@ | ||
precision mediump float; | ||
|
||
uniform sampler2D uTexDiffuse; | ||
|
||
in vec2 varTexCoord0; | ||
in vec4 varColor; | ||
out vec4 FragColor; | ||
|
||
#include "LibToneMapping.glsl" | ||
|
||
void main(void) | ||
{ | ||
float4 color = texture(uTexDiffuse, varTexCoord0.xy); | ||
FragColor = float4(linearRGB(color.rgb), color.a); | ||
} |
20 changes: 20 additions & 0 deletions
20
Assets/BuiltIn/Shader/PostProcessing/GLSL/PostEffectFS.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 uTexDiffuse; | ||
in vec2 varTexCoord0; | ||
in vec4 varColor; | ||
out vec4 FragColor; | ||
const float gamma = 2.2; | ||
const float invGamma = 1.0/2.2; | ||
vec3 sRGB(vec3 color) | ||
{ | ||
return pow(color, vec3(gamma)); | ||
} | ||
vec3 linearRGB(vec3 color) | ||
{ | ||
return pow(color, vec3(invGamma)); | ||
} | ||
void main(void) | ||
{ | ||
float4 color = texture(uTexDiffuse, varTexCoord0.xy); | ||
FragColor = float4(linearRGB(color.rgb), color.a); | ||
} |
16 changes: 16 additions & 0 deletions
16
Assets/BuiltIn/Shader/PostProcessing/GLSL/PostEffectVS.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,16 @@ | ||
in vec4 inPosition; | ||
in vec4 inColor; | ||
in vec3 inNormal; | ||
in vec2 inTexCoord0; | ||
|
||
uniform mat4 uMvpMatrix; | ||
|
||
out vec2 varTexCoord0; | ||
out vec4 varColor; | ||
|
||
void main(void) | ||
{ | ||
varTexCoord0 = inTexCoord0; | ||
varColor = inColor/255.0; | ||
gl_Position = uMvpMatrix * inPosition; | ||
} |
17 changes: 17 additions & 0 deletions
17
Assets/BuiltIn/Shader/PostProcessing/HLSL/PostEffectFS.d.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,17 @@ | ||
Texture2D uTexDiffuse : register(t0); | ||
SamplerState uTexDiffuseSampler : register(s0); | ||
|
||
struct PS_INPUT | ||
{ | ||
float4 pos : SV_POSITION; | ||
float4 color : COLOR0; | ||
float2 tex0 : TEXCOORD0; | ||
}; | ||
|
||
#include "LibToneMapping.hlsl" | ||
|
||
float4 main(PS_INPUT input) : SV_TARGET | ||
{ | ||
float4 color = uTexDiffuse.Sample(uTexDiffuseSampler, input.tex0); | ||
return float4(linearRGB(color.rgb), color.a); | ||
} |
23 changes: 23 additions & 0 deletions
23
Assets/BuiltIn/Shader/PostProcessing/HLSL/PostEffectFS.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,23 @@ | ||
Texture2D uTexDiffuse : register(t0); | ||
SamplerState uTexDiffuseSampler : register(s0); | ||
struct PS_INPUT | ||
{ | ||
float4 pos : SV_POSITION; | ||
float4 color : COLOR0; | ||
float2 tex0 : TEXCOORD0; | ||
}; | ||
static const float gamma = 2.2; | ||
static const float invGamma = 1.0/2.2; | ||
float3 sRGB(float3 color) | ||
{ | ||
return pow(color, gamma); | ||
} | ||
float3 linearRGB(float3 color) | ||
{ | ||
return pow(color, invGamma); | ||
} | ||
float4 main(PS_INPUT input) : SV_TARGET | ||
{ | ||
float4 color = uTexDiffuse.Sample(uTexDiffuseSampler, input.tex0); | ||
return float4(linearRGB(color.rgb), color.a); | ||
} |
31 changes: 31 additions & 0 deletions
31
Assets/BuiltIn/Shader/PostProcessing/HLSL/PostEffectVS.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,31 @@ | ||
struct VS_INPUT | ||
{ | ||
float4 pos: POSITION; | ||
float3 norm: NORMAL; | ||
float4 color: COLOR; | ||
float2 tex0: TEXCOORD0; | ||
}; | ||
|
||
struct VS_OUTPUT | ||
{ | ||
float4 pos : SV_POSITION; | ||
float4 color : COLOR0; | ||
float2 tex0 : TEXCOORD0; | ||
}; | ||
|
||
// adding constant buffer for transform matrices | ||
cbuffer cbPerObject | ||
{ | ||
float4x4 uMvpMatrix; | ||
}; | ||
|
||
VS_OUTPUT main(VS_INPUT input) | ||
{ | ||
VS_OUTPUT output; | ||
|
||
output.pos = mul(input.pos, uMvpMatrix); | ||
output.color = input.color; | ||
output.tex0 = input.tex0; | ||
|
||
return output; | ||
} |
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,14 @@ | ||
<shaderConfig name="PostEffect" baseShader="SOLID"> | ||
<uniforms> | ||
<vs> | ||
<uniform name="uMvpMatrix" type="WORLD_VIEW_PROJECTION" value="0" float="16" matrix="true"/> | ||
</vs> | ||
<fs> | ||
<uniform name="uTexDiffuse" type="DEFAULT_VALUE" value="0" float="1" directX="false"/> | ||
</fs> | ||
</uniforms> | ||
<customUI> | ||
</customUI> | ||
<shader type="GLSL" vs="GLSL/PostEffectVS.glsl" fs="GLSL/PostEffectFS.glsl"/> | ||
<shader type="HLSL" vs="HLSL/PostEffectVS.hlsl" fs="HLSL/PostEffectFS.hlsl"/> | ||
</shaderConfig> |
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
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 |
---|---|---|
|
@@ -56,5 +56,5 @@ vec3 SG( | |
// IBL reflection | ||
// ... | ||
|
||
return linearRGB(color); | ||
return color; | ||
} |
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 |
---|---|---|
|
@@ -56,5 +56,5 @@ float3 SG( | |
// IBL reflection | ||
// ... | ||
|
||
return linearRGB(color); | ||
return color; | ||
} |
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
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