Refl_nun.shader 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 = pow(3.*albedo_tex.rgb,vec3(2.));
  26. //ALBEDO = clamp(pow(2.*sqrt(albedo_tex.rgb),vec3(2.)),vec3(0.),vec3(1.));
  27. ALBEDO = albedo_tex.rgb;
  28. if(disable_panorama){
  29. ALBEDO = vec3(0.474,0.658,0.832);
  30. }
  31. ALBEDO*=smoothstep(0.16,0.15,abs(UV.x-0.5));
  32. ALBEDO*=smoothstep(0.23,0.22,abs(UV.y-0.75));
  33. }