Guest User

Untitled

a guest
Jul 11th, 2017
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. /*
  2. Scanlines Sine Absolute Value
  3. An ultra light scanline shader
  4. RiskyJumps
  5. */
  6. #pragma parameter amp "Amplitude" 1.2500 0.000 2.000 0.05
  7. #pragma parameter phase "Phase" 0.5000 0.000 2.000 0.05
  8. #pragma parameter lines_black "Lines Blacks" 0.0000 0.000 1.000 0.05
  9. #pragma parameter lines_white "Lines Whites" 1.0000 0.000 2.000 0.05
  10.  
  11. #ifdef PARAMETER_UNIFORM
  12. uniform float amp;
  13. uniform float phase;
  14. uniform float lines_black;
  15. uniform float lines_white;
  16. #else
  17. #define amp 1.250000
  18. #define phase 0.500000
  19. #define lines_black 0.000000
  20. #define lines_white 1.000000
  21. #endif
  22.  
  23. #define freq 0.500000
  24. #define offset 0.000000
  25. #define pi 3.141592654
  26.  
  27. struct input
  28. {
  29. float2 video_size;
  30. float2 texture_size;
  31. float2 output_size;
  32. float frame_count;
  33. float frame_direction;
  34. float frame_rotation;
  35. };
  36.  
  37. void main_vertex
  38. (
  39. uniform input IN,
  40. float4 position : POSITION,
  41. float4 color : COLOR,
  42. float2 tex : TEXCOORD0,
  43.  
  44. uniform float4x4 modelViewProj,
  45.  
  46. out float4 oPosition : POSITION,
  47. out float4 oColor : COLOR,
  48. out float2 otexCoord : TEXCOORD0,
  49. out float angle : TEXCOORD2
  50. )
  51. {
  52. oPosition = mul(modelViewProj, position);
  53. oColor = color;
  54. otexCoord = tex;
  55.  
  56. //float2 texsize = IN.texture_size;
  57. //float2 delta = 0.5 / texsize;
  58. //float dx = delta.x;
  59. //float dy = delta.y;
  60.  
  61. float omega = 2.0 * pi * freq; // Angular frequency
  62.  
  63. // NOTE: I can't calculate lines on vertex, because of sin()
  64. /*
  65. lines = tex.y * omega * IN.texture_size.y + phase;
  66. lines = sin(lines); // The use of sin() in here
  67. // yields a black screen...
  68. lines *= amp;
  69. lines += offset;
  70. lines = abs(lines);
  71. */
  72.  
  73. angle = tex.y * omega * IN.texture_size.y + phase;
  74. }
  75.  
  76.  
  77.  
  78. float4 main_fragment (
  79. uniform input IN,
  80. in float2 tex : TEXCOORD0,
  81. in float angle : TEXCOORD2,
  82. uniform sampler2D s0 : TEXUNIT0
  83. ) : COLOR
  84. {
  85. float3 color = tex2D(s0, tex).xyz;
  86. float grid;
  87.  
  88. float lines;
  89.  
  90. lines = sin(angle);
  91. lines *= amp;
  92. lines += offset;
  93. lines = abs(lines) * (lines_white - lines_black) + lines_black;
  94. color *= lines;
  95.  
  96. return color.xyzz;
  97. }
Advertisement
Add Comment
Please, Sign In to add comment