SHARE
    TWEET
    Guest User

    ntsc-test2.shader

    a guest
    May 15th, 2011
    5,345
    0
    Never
    Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
    XML 5.87 KB | None | 0 0
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <shader language="GLSL">
    3. <fragment filter="nearest" size_x="256"><![CDATA[#version 120
    4. uniform sampler2D rubyTexture;
    5. uniform vec2 rubyTextureSize;
    6. uniform vec2 rubyInputSize;
    7. uniform int rubyFrameCount;
    8. #define TEX2D(c) texture2D(rubyTexture,(c))
    9. #define PI 3.14159265
    10. void main()
    11. {
    12. vec2 xy = gl_TexCoord[0].st;
    13. vec2 xyp = xy * rubyTextureSize * 4.0 * PI / 3.0;
    14. xyp.y = xyp.y / 2.0 + 2.0 * PI / 3.0 * mod(rubyFrameCount,2);
    15. vec4 rgb = TEX2D(xy);
    16. mat3x3 rgb2yuv = mat3x3(0.299,-0.14713, 0.615,
    17. 0.587,-0.28886,-0.51499,
    18. 0.114, 0.436 ,-0.10001);
    19. vec3 yuv;
    20. yuv = rgb2yuv * rgb.rgb;
    21. float dx = PI/3.0;
    22. xyp.x = xyp.x * rubyInputSize.x/256.0;
    23. float c0 = yuv.x + yuv.y * sin(xyp.x+xyp.y) + yuv.z*cos(xyp.x+xyp.y);
    24. float c1 = yuv.x + yuv.y * sin(xyp.x+xyp.y+dx) + yuv.z * cos(xyp.x+xyp.y+dx);
    25. rgb = TEX2D(xy + vec2(1.0/rubyTextureSize.x * rubyInputSize.x / 512.0, 0.0));
    26. yuv = rgb2yuv * rgb.rgb;
    27. float c2 = yuv.x + yuv.y * sin(xyp.x+xyp.y+2.0*dx) + yuv.z * cos(xyp.x+xyp.y+2.0*dx);
    28. float c3 = yuv.x + yuv.y * sin(xyp.x+xyp.y+3.0*dx) + yuv.z * cos(xyp.x+xyp.y+3.0*dx);
    29. gl_FragColor = (vec4(c0,c1,c2,c3)+0.65)/2.3;
    30. }
    31. ]]></fragment>
    32. <fragment filter="nearest" size_x="1024" scale_y="4.0"><![CDATA[#version 120
    33. uniform sampler2D rubyTexture;
    34. uniform vec2 rubyTextureSize;
    35. uniform vec2 rubyOutputSize;
    36. uniform int rubyFrameCount;
    37. #define TEX2D(c) texture2D(rubyTexture,(c))
    38. #define PI 3.14159265
    39. void main()
    40. {
    41. vec2 xy = gl_TexCoord[0].st;
    42. vec2 xyf = fract(xy * rubyTextureSize);
    43. vec2 xyp = floor(xy * rubyTextureSize)+vec2(0.5);
    44. xy = xyp / rubyTextureSize;
    45. xyp.y = -xyp.y-1.0; // fix for inconsistent texture coordinates
    46. float offs = mod(rubyFrameCount,2)/2.0;
    47. vec4 phases = (vec4(0.0,0.25,0.5,0.75) + vec4(xyp.x+xyp.y/2.0+offs)) *4.0*PI/3.0;
    48. vec4 phasesl = (vec4(0.0,0.25,0.5,0.75) + vec4(-1.0+xyp.x+xyp.y/2.0+offs)) *4.0*PI/3.0;
    49. vec4 phasesr = (vec4(0.0,0.25,0.5,0.75) + vec4( 1.0+xyp.x+xyp.y/2.0+offs)) *4.0*PI/3.0;
    50. vec4 phsin = sin(phases);
    51. vec4 phcos = cos(phases);
    52. vec4 phsinl= sin(phasesl);
    53. vec4 phcosl= cos(phasesl);
    54. vec4 phsinr= sin(phasesr);
    55. vec4 phcosr= cos(phasesr);
    56. vec4 phone = vec4(1.0);
    57. vec2 one = 1.0/rubyTextureSize;
    58. vec4 c = TEX2D(xy)*2.3-0.65;
    59. vec4 cl= TEX2D(xy + vec2(-one.x,0.0))*2.3-0.65;
    60. vec4 cr= TEX2D(xy + vec2( one.x,0.0))*2.3-0.65;
    61. vec3 yuva = vec3((dot(cl.zw,phone.zw)+dot(c.xyz,phone.xyz)+0.5*(cl.y+c.w))/6.0, (dot(cl.zw,phsinl.zw)+dot(c.xyz,phsin.xyz)+0.5*(cl.y*phsinl.y+c.w*phsin.w))/3.0, (dot(cl.zw,phcosl.zw)+dot(c.xyz,phcos.xyz)+0.5*(cl.y*phcosl.y+c.w*phcos.w))/3.0);
    62. vec3 yuvb = vec3((cl.w*phone.w+dot(c.xyzw,phone.xyzw)+0.5*(cl.z+cr.x))/6.0, (cl.w*phsinl.w+dot(c.xyzw,phsin.xyzw)+0.5*(cl.z*phsinl.z+cr.x*phsinr.x))/3.0, (cl.w*phcosl.w+dot(c.xyzw,phcos.xyzw)+0.5*(cl.z*phcosl.z+cr.x*phcosr.x))/3.0);
    63. vec3 yuvc = vec3((cr.x*phone.x+dot(c.xyzw,phone.xyzw)+0.5*(cl.w+cr.y))/6.0, (cr.x*phsinr.x+dot(c.xyzw,phsin.xyzw)+0.5*(cl.w*phsinl.w+cr.y*phsinr.y))/3.0, (cr.x*phcosr.x+dot(c.xyzw,phcos.xyzw)+0.5*(cl.w*phcosl.w+cr.y*phcosr.y))/3.0);
    64. vec3 yuvd = vec3((dot(cr.xy,phone.xy)+dot(c.yzw,phone.yzw)+0.5*(c.x+cr.z))/6.0, (dot(cr.xy,phsinr.xy)+dot(c.yzw,phsin.yzw)+0.5*(c.x*phsin.x+cr.z*phsinr.z))/3.0, (dot(cr.xy,phcosr.xy)+dot(c.yzw,phcos.yzw)+0.5*(c.x*phcos.x+cr.z*phcosr.z))/3.0);
    65. mat3x3 yuv2rgb = mat3x3(1.0, 1.0, 1.0,
    66. 0.0,-0.39465,2.03211,
    67. 1.13983,-0.58060,0.0);
    68. if (xyf.x < 0.25)
    69. gl_FragColor = vec4(yuv2rgb*yuva, 0.0);
    70. else if (xyf.x < 0.5)
    71. gl_FragColor = vec4(yuv2rgb*yuvb, 0.0);
    72. else if (xyf.x < 0.75)
    73. gl_FragColor = vec4(yuv2rgb*yuvc, 0.0);
    74. else
    75. gl_FragColor = vec4(yuv2rgb*yuvd, 0.0);
    76. }
    77. ]]></fragment>
    78. <fragment filter="nearest" scale="1.0"><![CDATA[#version 120
    79. uniform sampler2D rubyTexture;
    80. uniform vec2 rubyInputSize;
    81. uniform vec2 rubyTextureSize;
    82. uniform vec2 rubyOutputSize;
    83. #define TEX2D(v) texture2D(rubyTexture, (v))
    84. void main()
    85. {
    86. mat3x3 rgb2yuv = mat3x3(0.299,-0.14713, 0.615,
    87. 0.587,-0.28886,-0.51499,
    88. 0.114, 0.436 ,-0.10001);
    89. mat3x3 yuv2rgb = mat3x3(1.0, 1.0, 1.0,
    90. 0.0,-0.39465,2.03211,
    91. 1.13983,-0.58060,0.0);
    92. vec4 sum = vec4(0.0);
    93. float wid = 3.0;
    94. vec4 c1 = vec4(exp(-1.0/wid/wid));
    95. vec4 c2 = vec4(exp(-4.0/wid/wid));
    96. vec4 c3 = vec4(exp(-9.0/wid/wid));
    97. vec4 c4 = vec4(exp(-16.0/wid/wid));
    98. vec4 norm = 1.0 / (vec4(1.0) + vec4(2.0)*(c1+c2+c3+c4));
    99. vec2 xy = gl_TexCoord[0].st;
    100. float onex = 1.0 / rubyTextureSize.x;
    101. sum += TEX2D(xy + vec2(-4.0 * onex, 0.0)) * c4;
    102. sum += TEX2D(xy + vec2(-3.0 * onex, 0.0)) * c3;
    103. sum += TEX2D(xy + vec2(-2.0 * onex, 0.0)) * c2;
    104. sum += TEX2D(xy + vec2(-1.0 * onex, 0.0)) * c1;
    105. sum += TEX2D(xy);
    106. sum += TEX2D(xy + vec2(+1.0 * onex, 0.0)) * c1;
    107. sum += TEX2D(xy + vec2(+2.0 * onex, 0.0)) * c2;
    108. sum += TEX2D(xy + vec2(+3.0 * onex, 0.0)) * c3;
    109. sum += TEX2D(xy + vec2(+4.0 * onex, 0.0)) * c4;
    110. float y = (rgb2yuv * TEX2D(xy).rgb).x;
    111. vec2 uv = (rgb2yuv * (sum.rgb*norm.rgb)).yz;
    112. gl_FragColor = vec4(yuv2rgb * vec3(y, uv), 0.0);
    113. }
    114. ]]></fragment>
    115. </shader>
    Advertisement
    Add Comment
    Please, Sign In to add comment
    Public Pastes
    We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
    Not a member of Pastebin yet?
    Sign Up, it unlocks many cool features!

    AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /