-
-
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 Add Texture Linear RGB & SRGB shader
- Loading branch information
1 parent
0752a52
commit af0a8cb
Showing
18 changed files
with
101 additions
and
15 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
Assets/BuiltIn/Shader/Basic/GLSL/TextureLinearRGBFS.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 "../../PostProcessing/GLSL/LibToneMapping.glsl" | ||
|
||
void main(void) | ||
{ | ||
vec4 result = texture(uTexDiffuse, varTexCoord0.xy); | ||
FragColor = vec4(linearRGB(result.rgb) * varColor.rgb, result.a * varColor.a); | ||
} |
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) | ||
{ | ||
vec4 result = texture(uTexDiffuse, varTexCoord0.xy); | ||
FragColor = vec4(linearRGB(result.rgb) * varColor.rgb, result.a * varColor.a); | ||
} |
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions
17
Assets/BuiltIn/Shader/Basic/HLSL/TextureLinearRGBFS.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 "../../PostProcessing/HLSL/LibToneMapping.hlsl" | ||
|
||
float4 main(PS_INPUT input) : SV_TARGET | ||
{ | ||
float4 result = uTexDiffuse.Sample(uTexDiffuseSampler, input.tex0); | ||
return float4(input.color.rgb * linearRGB(result.rgb), result.a * input.color.a); | ||
} |
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 result = uTexDiffuse.Sample(uTexDiffuseSampler, input.tex0); | ||
return float4(input.color.rgb * linearRGB(result.rgb), result.a * input.color.a); | ||
} |
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<shaderConfig name="TextureSRGB" 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> | ||
<shader type="GLSL" vs="GLSL/TextureColorVS.glsl" fs="GLSL/TextureSRGBFS.glsl"/> | ||
<shader type="HLSL" vs="HLSL/TextureColorVS.hlsl" fs="HLSL/TextureSRGBFS.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
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