Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Target GLSL 4.5.
- #version 450 core
- #define ATTRIBUTE_LOCATION(x) layout(location = x)
- #define FRAGMENT_OUTPUT_LOCATION(x) layout(location = x)
- #define FRAGMENT_OUTPUT_LOCATION_INDEXED(x, y) layout(location = x, index = y)
- #define UBO_BINDING(packing, x) layout(packing, set = 0, binding = (x - 1))
- #define SAMPLER_BINDING(x) layout(set = 1, binding = x)
- #define SSBO_BINDING(x) layout(set = 2, binding = x)
- #define TEXEL_BUFFER_BINDING(x) layout(set = 2, binding = x)
- #define VARYING_LOCATION(x) layout(location = x)
- #define FORCE_EARLY_Z layout(early_fragment_tests) in
- // hlsl to glsl function translation
- #define float2 vec2
- #define float3 vec3
- #define float4 vec4
- #define uint2 uvec2
- #define uint3 uvec3
- #define uint4 uvec4
- #define int2 ivec2
- #define int3 ivec3
- #define int4 ivec4
- #define frac fract
- #define lerp mix
- // These were changed in Vulkan
- #define gl_VertexID gl_VertexIndex
- #define gl_InstanceID gl_InstanceIndex
- UBO_BINDING(std140, 1) uniform PSBlock {
- float4 resolution;
- float4 src_rect;
- uint time;
- uint unused1;
- uint unused2;
- uint unused3;
- } options;
- SAMPLER_BINDING(0) uniform sampler2DArray samp0;
- SAMPLER_BINDING(1) uniform sampler2DArray samp1;
- layout(location = 0) in float3 uv0;
- layout(location = 1) in float4 col0;
- layout(location = 0) out float4 ocol0;
- // Interfacing functions
- // The EFB may have a zero alpha value, which we don't want to write to the frame dump, so set it to one here.
- float4 Sample()
- {
- return float4(texture(samp0, uv0).xyz, 1.0);
- }
- float4 SampleLocation(float2 location)
- {
- return float4(texture(samp0, float3(location, uv0.z)).xyz, 1.0);
- }
- float4 SampleLayer(int layer)
- {
- return float4(texture(samp0, float3(uv0.xy, float(layer))).xyz, 1.0);
- }
- #define SampleOffset(offset) float4(textureOffset(samp0, uv0, offset).xyz, 1.0)
- float4 SampleFontLocation(float2 location)
- {
- return texture(samp1, float3(location, 0.0));
- }
- float2 GetResolution()
- {
- return options.resolution.xy;
- }
- float2 GetInvResolution()
- {
- return options.resolution.zw;
- }
- float2 GetCoordinates()
- {
- return uv0.xy;
- }
- uint GetTime()
- {
- return options.time;
- }
- void SetOutput(float4 color)
- {
- ocol0 = color;
- }
- #define GetOption(x) (options.x)
- #define OptionEnabled(x) (options.x != 0)
- // Workaround because there is no getter function for src rect/layer.
- float4 src_rect = options.src_rect;
- int layer = int(uv0.z);
- void Main()
- {
- float4 color = Sample();
- float Gamma = 1.2;
- float IntensityContrast = 1.3;
- float Saturation = 1.7;
- float ToneMappingCurve = 2.0;
- float ToneMappingOversaturation = 40.0;
- float Brightness = 0.16;
- float BrightnessCurve = 1.28;
- float BrightnessMultiplier = 0.85;
- float BrightnessToneMappingCurve = 0.42;
- float HPDTonemappingExposure = 2.2;
- float HPDTonemappingClipping = 0.0004;
- float HPDTonemappingUpperTone = 6.2;
- float HPDTonemappingGreyTone = 0.5;
- float HPDTonemappingMiddleTone = 1.7;
- float HPDTonemappingLowerTone = 0.06;
- color.r = pow(color.r, Gamma);
- color.g = pow(color.g, Gamma);
- color.b = pow(color.b, Gamma);
- color.rgb *= Brightness;
- color.rgb += 0.000001;
- float3 xncol = normalize(color.rgb);
- float3 scl = color.rgb/xncol.rgb;
- scl.r = pow(scl.r, IntensityContrast);
- scl.g = pow(scl.g, IntensityContrast);
- scl.b = pow(scl.b, IntensityContrast);
- xncol.r = pow(xncol.r, Saturation);
- xncol.g = pow(xncol.g, Saturation);
- xncol.b = pow(xncol.b, Saturation);
- color.rgb = scl*xncol.rgb;
- float lumamax = ToneMappingOversaturation;
- color.rgb = (color.rgb * (1.0 + color.rgb/lumamax))/(color.rgb + ToneMappingCurve);
- float Y = dot(color.rgb, float3(0.299, 0.587, 0.114)); //0.299 * R + 0.587 * G + 0.114 * B;
- float U = dot(color.rgb, float3(-0.14713, -0.28886, 0.436)); //-0.14713 * R - 0.28886 * G + 0.436 * B;
- float V = dot(color.rgb, float3(0.615, -0.51499, -0.10001)); //0.615 * R - 0.51499 * G - 0.10001 * B;
- Y = pow(Y, BrightnessCurve);
- Y = Y*BrightnessMultiplier;
- Y = Y/(Y+BrightnessToneMappingCurve);
- float desaturatefact = clamp(Y*Y*Y*1.7, 0.0, 1.0);
- U = mix(U, 0.0, desaturatefact);
- V = mix(V, 0.0, desaturatefact);
- color.rgb = V * float3(1.13983, -0.58060, 0.0) + U * float3(0.0, -0.39465, 2.03211) + Y;
- float3 xColor = color.xyz;
- xColor = max(xColor, HPDTonemappingClipping);
- xColor = abs((xColor * (HPDTonemappingUpperTone * xColor + HPDTonemappingGreyTone )) / (xColor * (HPDTonemappingUpperTone * xColor + HPDTonemappingMiddleTone) + HPDTonemappingLowerTone ));
- color.r = pow(xColor.r, HPDTonemappingExposure);
- color.g = pow(xColor.g, HPDTonemappingExposure);
- color.b = pow(xColor.b, HPDTonemappingExposure);
- SetOutput(color);
- }
- Failed to link program
- Shader Info Log:
- Program Info Log:
- ERROR: Linking fragment stage: Missing entry point: Each stage requires one entry point
Add Comment
Please, Sign In to add comment