Guest User

Untitled

a guest
Aug 15th, 2016
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. /* COMPATIBILITY
  2. - HLSL compilers
  3. - Cg compilers
  4. */
  5.  
  6. /*
  7. Scanlines - Autorotate
  8. Author: hunterk and Themaister
  9. License: Public domain
  10. */
  11.  
  12. struct sine_coord
  13. {
  14. float2 omega;
  15. };
  16.  
  17. struct input
  18. {
  19. float2 video_size;
  20. float2 texture_size;
  21. float2 output_size;
  22. float frame_count;
  23. float frame_direction;
  24. float frame_rotation;
  25. };
  26.  
  27. void main_vertex
  28. (
  29. float4 position : POSITION,
  30. out float4 oPosition : POSITION,
  31. uniform float4x4 modelViewProj,
  32.  
  33. float4 color : COLOR,
  34. out float4 oColor : COLOR,
  35.  
  36. float2 tex : TEXCOORD,
  37. out float2 oTex : TEXCOORD,
  38.  
  39. uniform input IN,
  40. out sine_coord coords : TEXCOORD2
  41. )
  42. {
  43. oPosition = mul(modelViewProj, position);
  44. oColor = color;
  45. oTex = tex;
  46.  
  47. float2 texsize = IN.texture_size;
  48. float2 delta = 0.5 / texsize;
  49. float dx = delta.x;
  50. float dy = delta.y;
  51.  
  52. coords.omega = float2(3.1415 * IN.output_size.x * IN.texture_size.x / IN.video_size.x, 2.0 * 3.1415 * IN.texture_size.y);
  53. }
  54.  
  55. #pragma parameter SCANLINE_BASE_BRIGHTNESS "Scanline Base Brightness" 0.95 0.0 1.0 0.01
  56. #pragma parameter SCANLINE_SINE_COMP_A "Scanline Sine Comp A" 0.05 0.0 0.10 0.01
  57. #pragma parameter SCANLINE_SINE_COMP_B "Scanline Sine Comp B" 0.15 0.0 1.0 0.05
  58.  
  59. #ifdef PARAMETER_UNIFORM
  60. uniform float SCANLINE_BASE_BRIGHTNESS;
  61. uniform float SCANLINE_SINE_COMP_A;
  62. uniform float SCANLINE_SINE_COMP_B;
  63. #else
  64. #define SCANLINE_BASE_BRIGHTNESS 0.95
  65. #define SCANLINE_SINE_COMP_A 0.05
  66. #define SCANLINE_SINE_COMP_B 0.15
  67. #endif
  68.  
  69.  
  70. float4 main_fragment (in sine_coord co : TEXCOORD2, float2 tex : TEXCOORD, uniform sampler2D s0 : TEXUNIT0, uniform input IN) : COLOR
  71. {
  72. float2 sine_comp = float2(0.0, 0.0);
  73. if (IN.video_size.x > IN.video_size.y)
  74. {
  75. sine_comp = float2(SCANLINE_SINE_COMP_A, SCANLINE_SINE_COMP_B);
  76. }
  77. else
  78. {
  79. sine_comp = float2(SCANLINE_SINE_COMP_B, SCANLINE_SINE_COMP_A);
  80. }
  81. float3 res = tex2D(s0, tex).xyz;
  82. float3 scanline = res * (SCANLINE_BASE_BRIGHTNESS + dot(sine_comp * sin(tex * co.omega), float2(1.0, 1.0)));
  83. return float4(scanline.x, scanline.y, scanline.z, 1.0);
  84. }
Add Comment
Please, Sign In to add comment