Refl_pani.shader 917 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. shader_type spatial;
  2. render_mode blend_mix,depth_draw_always,cull_back;
  3. uniform sampler2D tex_panorama : hint_albedo;
  4. uniform float ctime;
  5. uniform float iTime;
  6. uniform bool disable_panorama;
  7. void vertex() {
  8. }
  9. vec2 uv_sphere(vec3 v)
  10. {
  11. float pi = 3.1415926536;
  12. vec2 uv=vec2(0.5 + atan(v.z, v.x) / (2.0 * pi), acos(v.y) / pi);
  13. uv.y=1.-uv.y;
  14. uv.x=-0.75+uv.x;
  15. uv=fract(uv);
  16. return uv;
  17. }
  18. void fragment() {
  19. vec3 selfpos=((WORLD_MATRIX*vec4(1.0)).xyz);
  20. vec3 cam=((CAMERA_MATRIX*vec4(1.0)).xyz);
  21. vec3 rd=normalize(((CAMERA_MATRIX*vec4(normalize(-VERTEX),0.0)).xyz));
  22. vec3 nor=normalize((CAMERA_MATRIX * vec4(NORMAL, 0.0)).xyz);
  23. vec3 ref = reflect(rd,nor);
  24. vec2 tuv=uv_sphere(normalize(ref));
  25. vec4 albedo_tex = texture(tex_panorama,tuv,1.);
  26. METALLIC=0.;
  27. ALPHA=1.+smoothstep(ctime,ctime+1.,iTime);
  28. ALBEDO = pow(albedo_tex.rgb*3.,vec3(2.));
  29. if(disable_panorama){
  30. ALBEDO = vec3(0.474,0.658,0.832);
  31. }
  32. }