-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Daltonic post processing effect.
- Loading branch information
1 parent
2efd7a2
commit 3a9f68f
Showing
4 changed files
with
78 additions
and
0 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 @@ | ||
Color altering mode to help daltonic people. |
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,64 @@ | ||
float3 LMS(float3 input) { | ||
float3 lms = 0; | ||
lms[0] = (17.8824 * input.r) + (43.5161 * input.g) + (4.11935 * input.b); | ||
lms[1] = (3.45565 * input.r) + (27.1554 * input.g) + (3.86714 * input.b); | ||
lms[2] = (0.0299566 * input.r) + (0.184309 * input.g) + (1.46709 * input.b); | ||
return lms; | ||
} | ||
|
||
float3 Correction(float3 input, float3 dlms) { | ||
float3 err = 0; | ||
err.r = (0.0809444479 * dlms[0]) + (-0.130504409 * dlms[1]) + (0.116721066 * dlms[2]); | ||
err.g = (-0.0102485335 * dlms[0]) + (0.0540193266 * dlms[1]) + (-0.113614708 * dlms[2]); | ||
err.b = (-0.000365296938 * dlms[0]) + (-0.00412161469 * dlms[1]) + (0.693511405 * dlms[2]); | ||
err = (input - err); | ||
float3 correction = 0; | ||
correction.g = (err.r * 0.7) + (err.g * 1.0); | ||
correction.b = (err.r * 0.7) + (err.b * 1.0); | ||
return input + correction; | ||
} | ||
|
||
float4 FragProtanopia(float4 input) | ||
{ | ||
float3 lms = LMS(input.rgb); | ||
float3 dlms = 0; | ||
dlms[0] = 0.0 * lms[0] + 2.02344 * lms[1] + -2.52581 * lms[2]; | ||
dlms[1] = 0.0 * lms[0] + 1.0 * lms[1] + 0.0 * lms[2]; | ||
dlms[2] = 0.0 * lms[0] + 0.0 * lms[1] + 1.0 * lms[2]; | ||
return float4(Correction(input, dlms), input.a); | ||
} | ||
|
||
float4 FragDeuteranopia(float4 input) | ||
{ | ||
half3 lms = LMS(input.rgb); | ||
float3 dlms = 0; | ||
dlms[0] = 1.0 * lms[0] + 0.0 * lms[1] + 0.0 * lms[2]; | ||
dlms[1] = 0.494207 * lms[0] + 0.0 * lms[1] + 1.24827 * lms[2]; | ||
dlms[2] = 0.0 * lms[0] + 0.0 * lms[1] + 1.0 * lms[2]; | ||
return float4(Correction(input, dlms), input.a); | ||
} | ||
|
||
float4 FragTritanopia(float4 input) | ||
{ | ||
float3 lms = LMS(input.rgb); | ||
float3 dlms = 0; | ||
dlms[0] = 1.0 * lms[0] + 0.0 * lms[1] + 0.0 * lms[2]; | ||
dlms[1] = 0.0 * lms[0] + 1.0 * lms[1] + 0.0 * lms[2]; | ||
dlms[2] = -0.395913 * lms[0] + 0.801109 * lms[1] + 0.0 * lms[2]; | ||
return float4(Correction(input, dlms), input.a); | ||
} | ||
|
||
float4 main( | ||
float2 vTexcoord : TEXCOORD0, | ||
uniform sampler2D colorMap : TEXUNIT0, | ||
uniform float Protanopia, | ||
uniform float Deuteranopia, | ||
uniform float Tritanopia) : COLOR | ||
{ | ||
float4 sample = tex2D(colorMap, vTexcoord); | ||
|
||
if (Tritanopia > 1.0f) return FragTritanopia(sample); | ||
else if (Deuteranopia > 1.0f) return FragDeuteranopia(sample); | ||
|
||
return FragProtanopia(sample); | ||
} |
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,3 @@ | ||
Protanopia=1 | ||
Deuteranopia=1 | ||
Tritanopia=1 |
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,10 @@ | ||
void main( | ||
float3 position, | ||
float2 texcoord, | ||
uniform float4x4 wvp, | ||
out float4 vPosition : POSITION, | ||
out float2 vTexcoord : TEXCOORD0) | ||
{ | ||
vPosition = mul(wvp,float4(position, 1.f)); | ||
vTexcoord = texcoord; | ||
} |