2014-08-26 11:31:05 -04:00
|
|
|
// See http://www.ozone3d.net/tutorials/glsl_texturing_p04.php for ref
|
|
|
|
|
2014-12-18 16:09:14 -05:00
|
|
|
#ifndef Use_Bindless_Texture
|
2014-08-26 11:31:05 -04:00
|
|
|
uniform sampler2D tex;
|
|
|
|
#endif
|
|
|
|
|
2014-12-18 16:09:14 -05:00
|
|
|
#ifdef Use_Bindless_Texture
|
2014-08-26 11:31:05 -04:00
|
|
|
flat in sampler2D handle;
|
|
|
|
#endif
|
|
|
|
in vec3 nor;
|
|
|
|
out vec4 FragColor;
|
|
|
|
|
2016-06-27 07:11:27 -04:00
|
|
|
#stk_include "utils/getPosFromUVDepth.frag"
|
|
|
|
#stk_include "utils/getLightFactor.frag"
|
2014-08-26 11:31:05 -04:00
|
|
|
|
|
|
|
void main() {
|
|
|
|
vec3 texc = gl_FragCoord.xyz / vec3(screen, 1.);
|
|
|
|
vec3 u = getPosFromUVDepth(texc, InverseProjectionMatrix).xyz;
|
|
|
|
vec3 r = reflect(u, nor);
|
|
|
|
|
|
|
|
float m = 2.0 * sqrt(r.x * r.x + r.y * r.y + (r.z + 1.0) * (r.z + 1.0));
|
|
|
|
r.y = - r.y;
|
2014-12-18 16:09:14 -05:00
|
|
|
#ifdef Use_Bindless_Texture
|
2014-08-26 11:31:05 -04:00
|
|
|
vec4 detail0 = texture(handle, r.xy / m + .5);
|
2014-08-28 15:59:55 -04:00
|
|
|
#ifdef SRGBBindlessFix
|
2014-08-26 11:31:05 -04:00
|
|
|
detail0.xyz = pow(detail0.xyz, vec3(2.2));
|
2014-08-28 15:59:55 -04:00
|
|
|
#endif
|
2014-08-26 11:31:05 -04:00
|
|
|
#else
|
|
|
|
vec4 detail0 = texture(tex, r.xy / m + .5);
|
|
|
|
#endif
|
|
|
|
|
2014-11-22 09:59:22 -05:00
|
|
|
FragColor = vec4(getLightFactor(detail0.xyz, vec3(1.), 0., 0.), 1.);
|
2014-08-26 11:31:05 -04:00
|
|
|
}
|