Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. /***************************************************************************************/
  2. /*! DopeShader v2.0
  3. ****************************************************************************************/
  4. #include "Common.usf"
  5. #include "PostProcessCommon.usf"
  6.  
  7. // Bloom parameterse.
  8. sampler2D BlurredImage;
  9.  
  10. // Tone-mapping parameters.
  11. sampler2D AdaptedLuminance;
  12. static const float WHITE = pow(1, 2);
  13.  
  14. // The per-color weighting to be used for luminance calculations in RGB order.
  15. static const float3 LuminanceVector = float3(0.3, 0.59, 0.11);
  16.  
  17. // Perform tone mapping on a pixel.
  18. float3 ToneMap(float3 WorldColor)
  19. {
  20. float fAdaptedLuminance = tex2D(AdaptedLuminance,float2(0.5,0.5));
  21. float lum = saturate(0.1 + WorldColor) * (LuminanceVector / fAdaptedLuminance);
  22. lum = lum * (lum / WHITE) / lum;
  23. return pow(WorldColor * lum, 1.0);
  24. }
  25.  
  26. void Main(
  27. in float2 UV : TEXCOORD0,
  28. in float2 SceneUV : TEXCOORD1,
  29. out float4 OutColor : COLOR0
  30. )
  31. {
  32. float4 sceneColor = tex2D(SceneColorTexture,SceneUV);
  33. float4 rawColor = tex2D(BlurredImage,UV);
  34. float3 filteredColor = MAX_SCENE_COLOR * rawColor.rgb;
  35. float3 RTWBloom = 1-(saturate(1-(filteredColor.rgb*0.02))*saturate(1-lerp(sceneColor.rgb, 0, saturate(rawColor.a*4)*0.02)));
  36. float3 ToneMappedColor = ToneMap(RTWBloom);
  37. OutColor = float4(ToneMappedColor.rgb, sceneColor.a);
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement