Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. <jittershader name="tf_2textureIn.jxs">
  2. <description>Basic Vectorfield</description>
  3. <param name="input_position" type="vec3" state="POSITION" />
  4. <param name="input_velocity" type="vec3" state="NORMAL" />
  5.  
  6. <texture name="tex0" />
  7. <language name="glsl" version="1.5">
  8. <bind param="input_position" program="vp" />
  9. <bind param="input_velocity" program="vp" />
  10.  
  11. <bind param="bfg_tex0" program="vp" />
  12. <program name="vp" type="vertex">
  13. <![CDATA[
  14. #version 330 core
  15.  
  16. in vec3 input_velocity;
  17. out vec3 output_velocity;
  18.  
  19.  
  20. uniform sampler2D bfg_tex0;
  21.  
  22.  
  23. in vec3 input_position;
  24.  
  25.  
  26. out vec3 output_position;
  27.  
  28. void main() {
  29.  
  30. vec3 direction_texture = texture(bfg_tex0, normPos).xyz;
  31. vec3 direction = direction_texture - input_position;
  32. vec3 normalized_direction = normalize(direction);
  33. float dist = lenght(direction);
  34.  
  35. vec3 acc = normalized_direction * 0.001;
  36. acc /= (dist*50)*(dist*50) + 1.0;
  37.  
  38. output_velocity = input_velocity + acc;
  39. output_velocity *= 0.99;
  40. output_velocity = clamp(output_velocity, vec3(-0.01 -0.01 -0.01), vec3(0.01, 0.01, 0.01));
  41.  
  42. output_position = input_position + output_velocity;
  43.  
  44. output_position = mod(output_position + vec3(2.0), vec3(4.0)) - vec3(2.0);
  45.  
  46.  
  47.  
  48. // vec2 normPos = input_position.xy * 0.5 + 0.5;
  49.  
  50.  
  51. //float velX = (texture(bfg_tex0, normPos).x * 2 - 1);
  52. //float velY = (texture(bfg_tex0, normPos).y * 2 - 1);
  53.  
  54.  
  55. // float posX = input_position.x + velX * input_velocity.z;
  56. // float posY = input_position.y + velY * input_velocity.z;
  57.  
  58.  
  59.  
  60. // if (posX > 1. || posX < -1. || posY > 1. || posY < -1.){
  61.  
  62. // output_position = vec3(input_velocity.x, input_velocity.y, input_position.z);
  63. // }
  64.  
  65. //else {
  66. // output_position = vec3(posX, posY, input_position.z);
  67. //}
  68.  
  69.  
  70.  
  71. output_position = input_position;
  72. output_velocity = input_velocity;
  73.  
  74.  
  75.  
  76.  
  77.  
  78. }
  79. ]]>
  80. </program>
  81.  
  82. <program name="fp" type="fragment" >
  83. <![CDATA[
  84. #version 330 core
  85. void main()
  86. {
  87. }
  88. ]]>
  89. </program>
  90. </language>
  91. </jittershader>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement