123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- /*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
- #include <Atom/Features/SrgSemantics.azsli>
- #include <Atom/Features/PostProcessing/FullscreenPixelInfo.azsli>
- #include <Atom/Features/PostProcessing/FullscreenVertex.azsli>
- #include <Atom/Features/PostProcessing/PostProcessUtil.azsli>
- ShaderResourceGroup PassSrg : SRG_PerPass
- {
- Texture2D<float4> m_framebuffer;
- Sampler LinearSampler
- {
- MinFilter = Linear;
- MagFilter = Linear;
- MipFilter = Linear;
- AddressU = Clamp;
- AddressV = Clamp;
- AddressW = Clamp;
- };
- //float4x4 m_simulationMatrix;
- //float4 m_simulationParams;
- }
- #define BLINDNESS_STRENGTH 1.0h //PassSrg.m_simulationParams.x
- PSOutput MainPS(VSOutput IN)
- {
- float3x4 simulationMatrix = float3x4(0, 1.05118294, -0.05116099, 0,
- 0, 1, 0, 0,
- 0, 0, 1, 0);
- PSOutput OUT;
- // This texture sample will be in sRGB since HDR post process should happen before this
- half3 srgbColor = half3(PassSrg::m_framebuffer.Sample(PassSrg::LinearSampler, IN.m_texCoord).rgb);
- half3 linearColor = half3(SRGBToLinear(srgbColor));
- // LMS Transformation matrix and inverse described in http://ixora.io/projects/colorblindness/color-blindness-simulation-research/
- half3x3 lmsTransformation = half3x3(0.31399022, 0.63951294, 0.04649755,
- 0.15537241, 0.75789446, 0.08670142,
- 0.01775239, 0.10944209, 0.87256922);
- half3x3 inverseLmsTransformation = half3x3(5.47221206, -4.6419601, 0.16963708,
- -1.1252419, 2.29317094, -0.1678952,
- 0.02980165, -0.19318073, 1.16364789);
-
- // Linear to LMS
- half3 lmsColor = mul(lmsTransformation, linearColor);
- // Apply given simulation matrix to adjust colors to be what a colorblind person would see
- lmsColor = half3(mul(simulationMatrix, float4(lmsColor, 1.000)).rgb);
- // LMS back into Linear
- half3 simulatedLinearColor = mul(inverseLmsTransformation, lmsColor);
- // Linear interpolation between true color and color blindness based on blindness strength
- simulatedLinearColor = lerp(linearColor, simulatedLinearColor, BLINDNESS_STRENGTH);
- // Linear to sRGB
- float3 simulatedsRGBColor = LinearToSRGB(simulatedLinearColor);
- OUT.m_color.rgb = simulatedsRGBColor;
- OUT.m_color.w = 1;
- return OUT;
- }
|