Guest User

Untitled

a guest
Jan 1st, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.10 KB | None | 0 0
  1.  
  2. // Target GLSL 4.5.
  3. #version 450 core
  4. #define ATTRIBUTE_LOCATION(x) layout(location = x)
  5. #define FRAGMENT_OUTPUT_LOCATION(x) layout(location = x)
  6. #define FRAGMENT_OUTPUT_LOCATION_INDEXED(x, y) layout(location = x, index = y)
  7. #define UBO_BINDING(packing, x) layout(packing, set = 0, binding = (x - 1))
  8. #define SAMPLER_BINDING(x) layout(set = 1, binding = x)
  9. #define SSBO_BINDING(x) layout(set = 2, binding = x)
  10. #define TEXEL_BUFFER_BINDING(x) layout(set = 2, binding = x)
  11. #define VARYING_LOCATION(x) layout(location = x)
  12. #define FORCE_EARLY_Z layout(early_fragment_tests) in
  13.  
  14. // hlsl to glsl function translation
  15. #define float2 vec2
  16. #define float3 vec3
  17. #define float4 vec4
  18. #define uint2 uvec2
  19. #define uint3 uvec3
  20. #define uint4 uvec4
  21. #define int2 ivec2
  22. #define int3 ivec3
  23. #define int4 ivec4
  24. #define frac fract
  25. #define lerp mix
  26.  
  27. // These were changed in Vulkan
  28. #define gl_VertexID gl_VertexIndex
  29. #define gl_InstanceID gl_InstanceIndex
  30. UBO_BINDING(std140, 1) uniform PSBlock {
  31. float4 resolution;
  32. float4 src_rect;
  33. uint time;
  34. uint unused1;
  35.  
  36. uint unused2;
  37.  
  38. uint unused3;
  39.  
  40. } options;
  41.  
  42.  
  43. SAMPLER_BINDING(0) uniform sampler2DArray samp0;
  44. SAMPLER_BINDING(1) uniform sampler2DArray samp1;
  45.  
  46. layout(location = 0) in float3 uv0;
  47. layout(location = 1) in float4 col0;
  48. layout(location = 0) out float4 ocol0;
  49.  
  50. // Interfacing functions
  51. // 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.
  52. float4 Sample()
  53. {
  54. return float4(texture(samp0, uv0).xyz, 1.0);
  55. }
  56.  
  57. float4 SampleLocation(float2 location)
  58. {
  59. return float4(texture(samp0, float3(location, uv0.z)).xyz, 1.0);
  60. }
  61.  
  62. float4 SampleLayer(int layer)
  63. {
  64. return float4(texture(samp0, float3(uv0.xy, float(layer))).xyz, 1.0);
  65. }
  66.  
  67. #define SampleOffset(offset) float4(textureOffset(samp0, uv0, offset).xyz, 1.0)
  68.  
  69. float4 SampleFontLocation(float2 location)
  70. {
  71. return texture(samp1, float3(location, 0.0));
  72. }
  73.  
  74. float2 GetResolution()
  75. {
  76. return options.resolution.xy;
  77. }
  78.  
  79. float2 GetInvResolution()
  80. {
  81. return options.resolution.zw;
  82. }
  83.  
  84. float2 GetCoordinates()
  85. {
  86. return uv0.xy;
  87. }
  88.  
  89. uint GetTime()
  90. {
  91. return options.time;
  92. }
  93.  
  94. void SetOutput(float4 color)
  95. {
  96. ocol0 = color;
  97. }
  98.  
  99. #define GetOption(x) (options.x)
  100. #define OptionEnabled(x) (options.x != 0)
  101.  
  102. // Workaround because there is no getter function for src rect/layer.
  103. float4 src_rect = options.src_rect;
  104. int layer = int(uv0.z);
  105. void Main()
  106.  
  107. {
  108.  
  109.  
  110.  
  111. float4 color = Sample();
  112.  
  113.  
  114.  
  115. float Gamma = 1.2;
  116.  
  117. float IntensityContrast = 1.3;
  118.  
  119. float Saturation = 1.7;
  120.  
  121. float ToneMappingCurve = 2.0;
  122.  
  123. float ToneMappingOversaturation = 40.0;
  124.  
  125.  
  126.  
  127. float Brightness = 0.16;
  128.  
  129. float BrightnessCurve = 1.28;
  130.  
  131. float BrightnessMultiplier = 0.85;
  132.  
  133. float BrightnessToneMappingCurve = 0.42;
  134.  
  135.  
  136.  
  137. float HPDTonemappingExposure = 2.2;
  138.  
  139. float HPDTonemappingClipping = 0.0004;
  140.  
  141. float HPDTonemappingUpperTone = 6.2;
  142.  
  143. float HPDTonemappingGreyTone = 0.5;
  144.  
  145. float HPDTonemappingMiddleTone = 1.7;
  146.  
  147. float HPDTonemappingLowerTone = 0.06;
  148.  
  149.  
  150.  
  151. color.r = pow(color.r, Gamma);
  152.  
  153. color.g = pow(color.g, Gamma);
  154.  
  155. color.b = pow(color.b, Gamma);
  156.  
  157.  
  158.  
  159. color.rgb *= Brightness;
  160.  
  161. color.rgb += 0.000001;
  162.  
  163. float3 xncol = normalize(color.rgb);
  164.  
  165. float3 scl = color.rgb/xncol.rgb;
  166.  
  167.  
  168.  
  169. scl.r = pow(scl.r, IntensityContrast);
  170.  
  171. scl.g = pow(scl.g, IntensityContrast);
  172.  
  173. scl.b = pow(scl.b, IntensityContrast);
  174.  
  175.  
  176.  
  177. xncol.r = pow(xncol.r, Saturation);
  178.  
  179. xncol.g = pow(xncol.g, Saturation);
  180.  
  181. xncol.b = pow(xncol.b, Saturation);
  182.  
  183.  
  184.  
  185. color.rgb = scl*xncol.rgb;
  186.  
  187.  
  188.  
  189. float lumamax = ToneMappingOversaturation;
  190.  
  191. color.rgb = (color.rgb * (1.0 + color.rgb/lumamax))/(color.rgb + ToneMappingCurve);
  192.  
  193.  
  194.  
  195. float Y = dot(color.rgb, float3(0.299, 0.587, 0.114)); //0.299 * R + 0.587 * G + 0.114 * B;
  196.  
  197. float U = dot(color.rgb, float3(-0.14713, -0.28886, 0.436)); //-0.14713 * R - 0.28886 * G + 0.436 * B;
  198.  
  199. float V = dot(color.rgb, float3(0.615, -0.51499, -0.10001)); //0.615 * R - 0.51499 * G - 0.10001 * B;
  200.  
  201.  
  202.  
  203. Y = pow(Y, BrightnessCurve);
  204.  
  205. Y = Y*BrightnessMultiplier;
  206.  
  207. Y = Y/(Y+BrightnessToneMappingCurve);
  208.  
  209. float desaturatefact = clamp(Y*Y*Y*1.7, 0.0, 1.0);
  210.  
  211. U = mix(U, 0.0, desaturatefact);
  212.  
  213. V = mix(V, 0.0, desaturatefact);
  214.  
  215. color.rgb = V * float3(1.13983, -0.58060, 0.0) + U * float3(0.0, -0.39465, 2.03211) + Y;
  216.  
  217.  
  218.  
  219. float3 xColor = color.xyz;
  220.  
  221. xColor = max(xColor, HPDTonemappingClipping);
  222.  
  223. xColor = abs((xColor * (HPDTonemappingUpperTone * xColor + HPDTonemappingGreyTone )) / (xColor * (HPDTonemappingUpperTone * xColor + HPDTonemappingMiddleTone) + HPDTonemappingLowerTone ));
  224.  
  225.  
  226.  
  227. color.r = pow(xColor.r, HPDTonemappingExposure);
  228.  
  229. color.g = pow(xColor.g, HPDTonemappingExposure);
  230.  
  231. color.b = pow(xColor.b, HPDTonemappingExposure);
  232.  
  233.  
  234.  
  235. SetOutput(color);
  236.  
  237.  
  238.  
  239. }
  240. Failed to link program
  241. Shader Info Log:
  242.  
  243.  
  244. Program Info Log:
  245. ERROR: Linking fragment stage: Missing entry point: Each stage requires one entry point
Add Comment
Please, Sign In to add comment