2019-01-19 04:52:40 +00:00
|
|
|
!!ver 110
|
2019-03-23 02:16:34 +00:00
|
|
|
!!samps diffuse lightmap reflectcube normalmap
|
2019-01-19 04:52:40 +00:00
|
|
|
!!cvardf gl_fake16bit=0
|
2019-02-20 13:30:16 +00:00
|
|
|
!!cvardf gl_monochrome=0
|
|
|
|
!!cvardf gl_brighten=0
|
2019-01-19 04:52:40 +00:00
|
|
|
|
|
|
|
#include "sys/defs.h"
|
|
|
|
|
|
|
|
varying vec2 tex_c;
|
|
|
|
varying vec2 lm_c;
|
|
|
|
|
2019-03-21 20:50:51 +00:00
|
|
|
#ifdef REFLECTCUBE
|
|
|
|
varying vec3 eyevector;
|
|
|
|
varying mat3 invsurface;
|
|
|
|
#endif
|
|
|
|
|
2019-01-19 04:52:40 +00:00
|
|
|
#ifdef VERTEX_SHADER
|
|
|
|
void main ()
|
|
|
|
{
|
|
|
|
tex_c = v_texcoord;
|
|
|
|
lm_c = v_lmcoord;
|
|
|
|
gl_Position = ftetransform();
|
2019-03-21 20:50:51 +00:00
|
|
|
|
|
|
|
#ifdef REFLECTCUBE
|
|
|
|
invsurface[0] = v_svector;
|
|
|
|
invsurface[1] = v_tvector;
|
|
|
|
invsurface[2] = v_normal;
|
|
|
|
vec3 eyeminusvertex = e_eyepos - v_position.xyz;
|
|
|
|
eyevector.x = dot( eyeminusvertex, v_svector.xyz );
|
|
|
|
eyevector.y = dot( eyeminusvertex, v_tvector.xyz );
|
|
|
|
eyevector.z = dot( eyeminusvertex, v_normal.xyz );
|
|
|
|
#endif
|
2019-01-19 04:52:40 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef FRAGMENT_SHADER
|
|
|
|
void main ( void )
|
|
|
|
{
|
|
|
|
vec4 diffuse_f = texture2D(s_diffuse, tex_c);
|
|
|
|
vec3 light = texture2D(s_lightmap, lm_c).rgb;
|
|
|
|
|
2019-03-13 15:48:58 +00:00
|
|
|
if (diffuse_f.rgb == vec3(0,0,1)) {
|
|
|
|
diffuse_f.rgb = vec3(0,0,0);
|
|
|
|
discard;
|
2019-01-19 04:52:40 +00:00
|
|
|
}
|
|
|
|
|
2019-03-21 20:50:51 +00:00
|
|
|
#ifdef REFLECTCUBE
|
2019-03-23 02:16:34 +00:00
|
|
|
#ifdef BUMP
|
|
|
|
vec3 normal_f = normalize(texture2D(s_normalmap, tex_c).rgb - 0.5);
|
|
|
|
#else
|
|
|
|
vec3 normal_f = vec4(0, 0, 1);
|
|
|
|
#endif
|
2019-03-21 20:50:51 +00:00
|
|
|
vec3 cube_c;
|
|
|
|
vec4 out_f = vec4( 1.0, 1.0, 1.0, 1.0 );
|
|
|
|
diffuse_f.rgb *= light.rgb * e_lmscale.rgb;
|
|
|
|
|
2019-03-23 02:16:34 +00:00
|
|
|
cube_c = reflect( normalize(-eyevector), normal_f);
|
2019-03-21 20:50:51 +00:00
|
|
|
cube_c = cube_c.x * invsurface[0] + cube_c.y * invsurface[1] + cube_c.z * invsurface[2];
|
|
|
|
cube_c = ( m_model * vec4(cube_c.xyz, 0.0)).xyz;
|
|
|
|
out_f.rgb = mix( textureCube(s_reflectcube, cube_c ).rgb, diffuse_f.rgb, diffuse_f.a);
|
|
|
|
diffuse_f = out_f;
|
|
|
|
#else
|
|
|
|
diffuse_f.rgb *= light.rgb;
|
2019-01-19 04:52:40 +00:00
|
|
|
if (diffuse_f.a < 0.5) {
|
|
|
|
discard;
|
|
|
|
}
|
2019-03-21 20:50:51 +00:00
|
|
|
#endif
|
2019-01-19 04:52:40 +00:00
|
|
|
diffuse_f *= e_colourident;
|
|
|
|
|
2019-02-20 13:30:16 +00:00
|
|
|
#if gl_brighten == 1
|
|
|
|
diffuse_f.rgb += vec3(0.1f,0.1f,0.1f) * 0.9f;
|
|
|
|
#endif
|
|
|
|
|
2019-01-19 04:52:40 +00:00
|
|
|
#if gl_fake16bit == 1
|
|
|
|
diffuse_f.rgb = floor(diffuse_f.rgb * vec3(32,64,32))/vec3(32,64,32);
|
|
|
|
#endif
|
2019-02-20 13:30:16 +00:00
|
|
|
|
|
|
|
#if gl_monochrome == 1
|
|
|
|
float m = (diffuse_f.r + diffuse_f.g + diffuse_f.b) / 3.0f;
|
|
|
|
diffuse_f.rgb = vec3(m,m,m);
|
|
|
|
#endif
|
2019-01-19 04:52:40 +00:00
|
|
|
gl_FragColor = diffuse_f;
|
2019-03-13 15:48:58 +00:00
|
|
|
|
2019-01-19 04:52:40 +00:00
|
|
|
}
|
|
|
|
#endif
|