Refl.shader 820 B

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