Advertisement
Guest User

Untitled

a guest
Jan 19th, 2015
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. #pragma parameter BLOOM_STRENGTH "Bloom Strength" 0.45 0.0 1.0 0.01
  2. #pragma parameter SOURCE_BOOST "Bloom Color Boost" 1.15 1.0 1.3 0.01
  3. #ifdef PARAMETER_UNIFORM
  4. uniform float BLOOM_STRENGTH;
  5. uniform float SOURCE_BOOST;
  6. #else
  7. #define BLOOM_STRENGTH 0.03
  8. #define SOURCE_BOOST 2.0
  9. #endif
  10.  
  11.  
  12.  
  13. // END PARAMETERS //
  14.  
  15.  
  16. struct prev
  17. {
  18. uniform float2 video_size;
  19. uniform float2 texture_size;
  20. uniform sampler2D texture;
  21. float2 tex_coord;
  22. };
  23.  
  24. struct input
  25. {
  26. float2 video_size;
  27. float2 texture_size;
  28. };
  29.  
  30. struct VertexData
  31. {
  32. float2 tex;
  33. float2 prev;
  34. };
  35.  
  36. #define CRT_PASS PASS3
  37.  
  38. void main_vertex
  39. (
  40. float4 position : POSITION,
  41. float2 texCoord : TEXCOORD0,
  42. prev CRT_PASS,
  43.  
  44. uniform float4x4 modelViewProj,
  45.  
  46. out float4 oPosition : POSITION,
  47. out VertexData vert
  48. )
  49. {
  50. oPosition = mul(modelViewProj, position);
  51.  
  52. vert.tex = texCoord;
  53. vert.prev = CRT_PASS.tex_coord;
  54. }
  55.  
  56. // For debugging
  57. #define BLOOM_ONLY 0
  58.  
  59. #define INV_OUTPUT_GAMMA (1.0 / 2.2)
  60.  
  61. float4 main_fragment(in VertexData vert, uniform sampler2D s0 : TEXUNIT0, uniform input IN, prev CRT_PASS) : COLOR
  62. {
  63. #if BLOOM_ONLY
  64. float3 source = BLOOM_STRENGTH * tex2D(s0, vert.tex).rgb;
  65. #else
  66. float3 source = SOURCE_BOOST * tex2D(CRT_PASS.texture, vert.prev).rgb;
  67. float3 bloom = tex2D(s0, vert.tex).rgb;
  68. source += BLOOM_STRENGTH * bloom;
  69. #endif
  70. return float4(pow(saturate(source), INV_OUTPUT_GAMMA), 1.0);
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement