Simplify Spheremap shader.
This commit is contained in:
parent
0058002260
commit
42e6da443a
@ -1,8 +1,7 @@
|
||||
#version 130
|
||||
uniform sampler2D tex;
|
||||
|
||||
noperspective in vec3 eyenor;
|
||||
noperspective in vec3 viewpos;
|
||||
in vec4 color;
|
||||
noperspective in vec3 nor;
|
||||
|
||||
void main() {
|
||||
@ -10,16 +9,16 @@ void main() {
|
||||
const vec3 forward = vec3(0.0, 0.0, 1.0);
|
||||
|
||||
// get the angle between the forward vector and the horizontal portion of the normal
|
||||
vec3 normal_x = normalize(vec3(eyenor.x, 0.0, eyenor.z));
|
||||
float sin_theta_x = length(cross( forward, normal_x )) * eyenor.x/abs(eyenor.x);
|
||||
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);
|
||||
|
||||
// get the angle between the forward vector and the vertical portion of the normal
|
||||
vec3 normal_y = normalize(vec3(0.0, eyenor.y, eyenor.z));
|
||||
float sin_theta_y = length(cross( forward, normal_y )) * eyenor.y/abs(eyenor.y);
|
||||
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);
|
||||
|
||||
vec4 detail0 = texture2D(tex, vec2(0.5 + sin_theta_x*0.5, 0.5 + sin_theta_y*0.5));
|
||||
vec4 detail0 = texture2D(tex, 0.5 * vec2(sin_theta_x, sin_theta_y) + 0.5);
|
||||
|
||||
gl_FragData[0] = detail0 * gl_Color;
|
||||
gl_FragData[0] = detail0 * color;
|
||||
|
||||
gl_FragData[1] = vec4(nor, gl_FragCoord.z);
|
||||
gl_FragData[2] = vec4(0.);
|
||||
|
@ -97,7 +97,7 @@ void Shaders::loadShaders()
|
||||
m_shaders[ES_WATER_SURFACE] = glsl(dir + "water.vert", dir + "pass.frag",
|
||||
m_callbacks[ES_WATER]);
|
||||
|
||||
m_shaders[ES_SPHERE_MAP] = glslmat(dir + "objectpass_rimlit.vert", dir + "objectpass_spheremap.frag",
|
||||
m_shaders[ES_SPHERE_MAP] = glslmat(dir + "objectpass.vert", dir + "objectpass_spheremap.frag",
|
||||
m_callbacks[ES_OBJECTPASS], EMT_SOLID);
|
||||
|
||||
m_shaders[ES_GRASS] = glslmat(dir + "grass.vert", dir + "grass.frag",
|
||||
|
Loading…
Reference in New Issue
Block a user