您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

12_voronoi.lolfx 2.0 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //-----------------------------------------------------------------------------
  2. //GLSL
  3. //-----------------------------------------------------------------------------
  4. [vert.glsl]
  5. #version 120
  6. attribute vec2 in_Position;
  7. uniform vec2 in_screen_res;
  8. uniform float in_step;
  9. varying vec2 pass_pos;
  10. varying vec2 pass_p[8];
  11. void main()
  12. {
  13. //JFA ALGO
  14. pass_pos = ((vec2(1.0) + in_Position) * 0.5);
  15. float k = in_step;
  16. vec2 p2 = pass_pos;
  17. pass_p[0] = p2 + vec2(-k, -k);
  18. pass_p[1] = p2 + vec2( 0, -k);
  19. pass_p[2] = p2 + vec2( k, -k);
  20. pass_p[3] = p2 + vec2(-k, 0);
  21. pass_p[4] = p2 + vec2( k, 0);
  22. pass_p[5] = p2 + vec2(-k, k);
  23. pass_p[6] = p2 + vec2( 0, k);
  24. pass_p[7] = p2 + vec2( k, k);
  25. gl_Position = vec4(in_Position, 0.0, 1.0);
  26. }
  27. [frag.glsl]
  28. #version 120
  29. #if defined GL_ES
  30. precision highp float;
  31. #endif
  32. uniform sampler2D in_texture;
  33. varying vec2 pass_pos;
  34. varying vec2 pass_p[8];
  35. void main(void)
  36. {
  37. vec4 src_color = texture2D(in_texture, pass_pos);
  38. vec4 neigh_color;
  39. for (int i = 0; i < 8; ++i)
  40. {
  41. neigh_color = texture2D(in_texture, pass_p[i]);
  42. if (neigh_color.z > 0.0 && src_color.z == 0.0)
  43. src_color = neigh_color;
  44. else if (neigh_color.z > 0.0 && src_color.z > 0.0 &&
  45. length(neigh_color.xy - pass_pos) < length(src_color.xy - pass_pos))
  46. src_color = neigh_color;
  47. }
  48. gl_FragColor = src_color;
  49. }
  50. //-----------------------------------------------------------------------------
  51. //HLSL
  52. //-----------------------------------------------------------------------------
  53. [vert.hlsl]
  54. void main(float2 in_Position : POSITION,
  55. out float2 pass_Position : TEXCOORD0,
  56. out float4 out_Position : POSITION)
  57. {
  58. pass_Position = in_Position;
  59. out_Position = float4(in_Position, 0.0, 1.0);
  60. }
  61. [frag.hlsl]
  62. void main(in float2 pass_Position : TEXCOORD0,
  63. uniform float in_Flag,
  64. uniform float3 in_Point,
  65. uniform float3 in_Color,
  66. out float4 out_FragColor : COLOR)
  67. {
  68. out_FragColor = float4(0.0);
  69. }