2013-12-18 19:13:17 -05:00
|
|
|
#version 130
|
2013-11-30 16:33:06 -05:00
|
|
|
uniform sampler2D tex;
|
|
|
|
|
2014-01-17 21:24:55 -05:00
|
|
|
in vec4 color;
|
2013-12-18 19:13:17 -05:00
|
|
|
noperspective in vec3 nor;
|
2013-11-30 16:33:06 -05:00
|
|
|
|
|
|
|
void main() {
|
|
|
|
// Calculate the spherical UV
|
|
|
|
const vec3 forward = vec3(0.0, 0.0, 1.0);
|
|
|
|
|
|
|
|
// get the angle between the forward vector and the horizontal portion of the normal
|
2014-01-17 21:24:55 -05:00
|
|
|
vec3 normal_x = normalize(vec3(nor.x, 0.0, nor.z));
|
|
|
|
float sin_theta_x = length(cross( forward, normal_x )) * nor.x/abs(nor.x);
|
2013-11-30 16:33:06 -05:00
|
|
|
|
|
|
|
// get the angle between the forward vector and the vertical portion of the normal
|
2014-01-17 21:24:55 -05:00
|
|
|
vec3 normal_y = normalize(vec3(0.0, nor.y, nor.z));
|
|
|
|
float sin_theta_y = length(cross( forward, normal_y )) * nor.y/abs(nor.y);
|
2013-11-30 16:33:06 -05:00
|
|
|
|
2014-01-17 21:24:55 -05:00
|
|
|
vec4 detail0 = texture2D(tex, 0.5 * vec2(sin_theta_x, sin_theta_y) + 0.5);
|
2013-11-30 16:33:06 -05:00
|
|
|
|
2014-01-17 21:24:55 -05:00
|
|
|
gl_FragData[0] = detail0 * color;
|
2013-11-30 16:33:06 -05:00
|
|
|
|
2013-12-23 11:59:55 -05:00
|
|
|
gl_FragData[1] = vec4(nor, gl_FragCoord.z);
|
2013-12-26 13:28:35 -05:00
|
|
|
gl_FragData[2] = vec4(0.);
|
2013-11-30 16:33:06 -05:00
|
|
|
}
|