25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

93 lines
2.1 KiB

  1. [vert.glsl]
  2. #version 120
  3. attribute vec2 in_Position;
  4. varying vec2 pass_position;
  5. void main()
  6. {
  7. pass_position = in_Position;
  8. gl_Position = vec4(in_Position, 0.0, 1.0);
  9. }
  10. [frag.glsl]
  11. #version 120
  12. #if defined GL_ES
  13. precision highp float;
  14. #endif
  15. uniform sampler2D in_texture;
  16. varying vec2 pass_position;
  17. vec3 rand_color(float t)
  18. {
  19. return vec3(0.5 + 0.5 * sin(t * 19.0 + 17.0),
  20. 0.5 + 0.5 * sin(t * 24.0 + 23.0),
  21. 0.5 + 0.5 * sin(t * 37.0 + 12.0));
  22. }
  23. void main(void)
  24. {
  25. vec2 texcoords = pass_position * 0.5 + vec2(0.5, 0.5);
  26. vec4 src_color = texture2D(in_texture, texcoords);
  27. float newg = src_color.z;
  28. float newb = 0.0;
  29. if (newg > 0.0)
  30. newb = 1.0;
  31. gl_FragColor = vec4(rand_color(newg), 1.0);
  32. }
  33. [vert.hlsl]
  34. void main(float2 in_Position : POSITION,
  35. out float2 pass_Position : TEXCOORD0,
  36. out float4 out_Position : POSITION)
  37. {
  38. pass_Position = in_Position;
  39. out_Position = float4(in_Position, 0.0, 1.0);
  40. }
  41. [frag.hlsl]
  42. float3 rand_color(float t)
  43. {
  44. return float3(0.5 + 0.5 * sin(t * 9.0 + 3.0),
  45. 0.5 + 0.5 * sin(t * 4.0 + 1.0),
  46. 0.5 + 0.5 * sin(t * 7.0 + 2.0));
  47. }
  48. void main(in float2 pass_Position : TEXCOORD0,
  49. uniform sampler2D u_texture,
  50. uniform float in_Flag,
  51. uniform float3 in_Point,
  52. uniform float3 in_Color,
  53. out float4 out_FragColor : COLOR)
  54. {
  55. if (in_Flag == 0.0)
  56. {
  57. float tc = 0.0, ta = 0.0;
  58. {
  59. float s = 3.0 + 2.0 * in_Point.z;
  60. float2 p = pass_Position - in_Point.xy * 0.9;
  61. float t = clamp(1.2 - dot(s * p, s * p), 0.0, 1.0);
  62. float u = t * t * t * t;
  63. tc += 3.0 * t * t - 2.0 * t * t * t;
  64. ta += 3.0 * u * u - 2.0 * u * u * u;
  65. }
  66. out_FragColor = float4(tc * in_Color, ta + 0.1);
  67. }
  68. else
  69. {
  70. float2 texcoords = pass_Position * float2(0.5, -0.5) + float2(0.5, 0.5);
  71. /* FIXME: this should be passed as a uniform or something */
  72. texcoords += float2(0.5 / 800.0, 0.5 / 600.0);
  73. out_FragColor = float4(tex2D(u_texture, texcoords).xyz, 1.0);
  74. }
  75. }