X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=shaderlib%2Fsinglepass.glsl;h=a1062fed7125bd2f69886e33c3d9a61bec25b7a3;hb=a873639a9346082f9e71145a2b318bea32bfdeb6;hp=f8940f7ddfbd02ee9582d1cf45ccbc50d8e6417f;hpb=859015dce969a0d9ba2bc603d6dbb2685159e393;p=libs%2Fgl.git diff --git a/shaderlib/singlepass.glsl b/shaderlib/singlepass.glsl index f8940f7d..a1062fed 100644 --- a/shaderlib/singlepass.glsl +++ b/shaderlib/singlepass.glsl @@ -63,7 +63,6 @@ uniform ShadowMap mat4 shd_eye_matrix; }; -const bool use_reflection = false; const bool use_environment_map = false; uniform samplerCube environment; uniform EnvMap @@ -78,12 +77,12 @@ uniform Clipping }; ////// vertex -in vec4 vertex; -in vec4 texcoord; -in vec4 color; -in vec3 normal; -in vec3 tangent; -in vec3 binormal; +layout(location=0) in vec4 vertex; +layout(location=8) in vec4 texcoord; +layout(location=3) in vec4 color; +layout(location=2) in vec3 normal; +layout(location=4) in vec3 tangent; +layout(location=5) in vec3 binormal; vec4 get_vertex_position() { @@ -129,7 +128,7 @@ void main() } ////// fragment -out vec4 frag_color; +layout(location=0) out vec4 frag_color; vec4 get_diffuse_sample() { @@ -141,6 +140,11 @@ vec3 get_normal_sample() return texture(normal_map, texcoord.xy).xyz*2.0-1.0; } +vec4 get_environment_sample(vec3 direction) +{ + return texture(environment, direction); +} + vec3 normal; vec4 diffuse_sample; @@ -195,19 +199,8 @@ vec3 singlepass_reflection() vec3 reflect_dir = reflect(incident_dir, normal); if(use_normal_map) reflect_dir = eye_tbn_matrix*reflect_dir; - vec3 result = vec3(0.0); - - if(use_environment_map) - result += texture(environment, env_eye_matrix*reflect_dir).rgb*reflectivity; - if(use_sky && use_specular) - { - float reflect_altitude = clamp(dot(reflect_dir, eye_sky_dir)-horizon_limit, -1.0, 0.0); - float sky_specular_intensity = pow((1.0-reflect_altitude*reflect_altitude), material.shininess/2.0); - result += sky_specular_intensity*sky_color.rgb; - } - - return result; + return get_environment_sample(env_eye_matrix*reflect_dir).rgb; } vec4 singlepass_color() @@ -235,7 +228,7 @@ void main() else final_color = singlepass_color(); - if(use_reflection) + if(use_environment_map) final_color += vec4(singlepass_reflection(), 0.0); if(use_fog) {