2014-05-17 21:19:18 -04:00
|
|
|
// See http://www.ozone3d.net/tutorials/glsl_texturing_p04.php for ref
|
|
|
|
|
2014-05-02 07:54:23 -04:00
|
|
|
#ifdef UBO_DISABLED
|
|
|
|
uniform mat4 ViewMatrix;
|
|
|
|
uniform mat4 ProjectionMatrix;
|
|
|
|
uniform mat4 InverseViewMatrix;
|
|
|
|
uniform mat4 InverseProjectionMatrix;
|
2014-05-19 11:57:31 -04:00
|
|
|
uniform vec2 screen;
|
2014-05-02 07:54:23 -04:00
|
|
|
#else
|
2014-04-10 11:34:57 -04:00
|
|
|
layout (std140) uniform MatrixesData
|
|
|
|
{
|
|
|
|
mat4 ViewMatrix;
|
|
|
|
mat4 ProjectionMatrix;
|
|
|
|
mat4 InverseViewMatrix;
|
|
|
|
mat4 InverseProjectionMatrix;
|
|
|
|
mat4 ShadowViewProjMatrixes[4];
|
2014-05-16 20:39:55 -04:00
|
|
|
vec2 screen;
|
2014-04-10 11:34:57 -04:00
|
|
|
};
|
2014-05-02 07:54:23 -04:00
|
|
|
#endif
|
2014-04-10 11:34:57 -04:00
|
|
|
|
2014-05-17 21:01:24 -04:00
|
|
|
uniform sampler2D tex;
|
2013-11-30 16:33:06 -05:00
|
|
|
|
2014-02-28 11:29:05 -05:00
|
|
|
#if __VERSION__ >= 130
|
|
|
|
in vec3 nor;
|
2014-01-19 13:31:00 -05:00
|
|
|
out vec4 FragColor;
|
2014-02-28 11:29:05 -05:00
|
|
|
#else
|
|
|
|
varying vec3 nor;
|
|
|
|
#define FragColor gl_FragColor
|
|
|
|
#endif
|
|
|
|
|
2014-05-17 21:19:18 -04:00
|
|
|
vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
|
2014-05-17 21:39:53 -04:00
|
|
|
vec3 getLightFactor(float specMapValue);
|
2013-11-30 16:33:06 -05:00
|
|
|
|
|
|
|
void main() {
|
2014-05-17 21:19:18 -04:00
|
|
|
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));
|
2014-05-17 21:39:53 -04:00
|
|
|
r.y = - r.y;
|
2014-05-17 21:19:18 -04:00
|
|
|
vec4 detail0 = texture(tex, r.xy / m + .5);
|
2014-05-17 21:39:53 -04:00
|
|
|
vec3 LightFactor = getLightFactor(1.);
|
2013-11-30 16:33:06 -05:00
|
|
|
|
2014-05-17 21:39:53 -04:00
|
|
|
FragColor = vec4(detail0.xyz * LightFactor, 1.);
|
2013-11-30 16:33:06 -05:00
|
|
|
}
|