2016-08-03 07:59:29 +00:00
|
|
|
#version 120
|
2012-03-25 17:03:52 +00:00
|
|
|
#extension GL_EXT_gpu_shader4 : enable
|
2012-05-01 06:47:38 +00:00
|
|
|
// -*- mode: C; -*-
|
|
|
|
// Licence: GPL v2
|
|
|
|
// Author: Frederic Bouvier.
|
2012-03-25 17:03:52 +00:00
|
|
|
//
|
2012-05-01 06:47:38 +00:00
|
|
|
|
2012-03-25 17:03:52 +00:00
|
|
|
varying vec3 ecNormal;
|
2012-04-03 21:29:30 +00:00
|
|
|
varying float alpha;
|
2012-03-25 17:03:52 +00:00
|
|
|
uniform int materialID;
|
|
|
|
uniform sampler2D texture;
|
2012-04-12 21:58:03 +00:00
|
|
|
|
2012-05-01 06:47:38 +00:00
|
|
|
void encode_gbuffer(vec3 normal, vec3 color, int mId, float specular, float shininess, float emission, float depth);
|
2012-04-12 21:58:03 +00:00
|
|
|
|
2012-03-25 17:03:52 +00:00
|
|
|
void main() {
|
|
|
|
vec4 texel = texture2D(texture, gl_TexCoord[0].st);
|
2012-04-03 21:29:30 +00:00
|
|
|
if (texel.a * alpha < 0.1)
|
|
|
|
discard;
|
|
|
|
float specular = dot( gl_FrontMaterial.specular.rgb, vec3( 0.3, 0.59, 0.11 ) );
|
|
|
|
float shininess = gl_FrontMaterial.shininess;
|
|
|
|
float emission = dot( gl_FrontLightModelProduct.sceneColor.rgb, vec3( 0.3, 0.59, 0.11 ) );
|
2012-04-04 16:11:58 +00:00
|
|
|
|
2012-05-01 06:47:38 +00:00
|
|
|
vec3 normal2 = normalize( (2.0 * gl_Color.a - 1.0) * ecNormal );
|
|
|
|
encode_gbuffer(normal2, gl_Color.rgb * texel.rgb, materialID, specular, shininess, emission, gl_FragCoord.z);
|
2012-03-25 17:03:52 +00:00
|
|
|
}
|