Advertisement
Guest User

ApelGammaShader

a guest
Jul 11th, 2017
456
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. // Apel's gamma correction shader
  2.  
  3. //tweakables
  4. static float gamma = 0.859;
  5. static float saturation = 1.0;
  6. static float luminance = 1.0;
  7. //tweakables
  8.  
  9. texture lastshader;
  10. sampler s0 = sampler_state { texture = <lastshader>; minfilter = none; magfilter = none; };
  11.  
  12. float3 grayscale(float3 col)
  13. {
  14. return dot(col.rgb, float3(0.3, 0.59, 0.11));
  15. }
  16.  
  17. float4 gammatoo(float2 tex : TEXCOORD) : COLOR0
  18. {
  19. float3 c = tex2D(s0, tex).rgb;
  20. c = lerp(grayscale(c), c, saturation); // Apply saturation
  21. c = pow(c, gamma); // Apply gamma
  22.  
  23. return float4(saturate(c * luminance ), 1.0);
  24. }
  25.  
  26. technique T0 < string MGEinterface = "MGE XE 0"; >
  27. {
  28. pass { PixelShader = compile ps_3_0 gammatoo(); }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement