2012-05-09 15:30:53 +00:00
|
|
|
!!permu BUMP
|
|
|
|
!!permu SKELETAL
|
2016-11-20 21:05:10 +00:00
|
|
|
!!cvarf r_glsl_offsetmapping_scale
|
2012-05-09 15:30:53 +00:00
|
|
|
|
|
|
|
//light pre-pass rendering (defered lighting)
|
|
|
|
//this is the initial pass, that draws the surface normals and depth to the initial colour buffer
|
|
|
|
|
2016-11-20 21:05:10 +00:00
|
|
|
#include "sys/defs.h"
|
|
|
|
|
|
|
|
#if defined(OFFSETMAPPING)
|
|
|
|
varying vec3 eyevector;
|
|
|
|
#endif
|
|
|
|
|
2012-05-09 15:30:53 +00:00
|
|
|
varying vec3 norm, tang, bitang;
|
|
|
|
#if defined(BUMP)
|
|
|
|
varying vec2 tc;
|
|
|
|
#endif
|
|
|
|
#ifdef VERTEX_SHADER
|
|
|
|
#include "sys/skeletal.h"
|
2016-11-20 21:05:10 +00:00
|
|
|
|
2012-05-09 15:30:53 +00:00
|
|
|
void main()
|
|
|
|
{
|
|
|
|
#if defined(BUMP)
|
|
|
|
gl_Position = skeletaltransform_nst(norm, tang, bitang);
|
|
|
|
tc = v_texcoord;
|
|
|
|
#else
|
|
|
|
gl_Position = skeletaltransform_n(norm);
|
|
|
|
#endif
|
2016-11-20 21:05:10 +00:00
|
|
|
|
|
|
|
#if defined(OFFSETMAPPING)
|
|
|
|
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
|
2012-05-09 15:30:53 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef FRAGMENT_SHADER
|
2016-11-20 21:05:10 +00:00
|
|
|
#ifdef OFFSETMAPPING
|
|
|
|
#include "sys/offsetmapping.h"
|
2012-05-09 15:30:53 +00:00
|
|
|
#endif
|
|
|
|
void main()
|
|
|
|
{
|
2016-11-20 21:05:10 +00:00
|
|
|
//adjust texture coords for offsetmapping
|
|
|
|
#ifdef OFFSETMAPPING
|
|
|
|
vec2 tcoffsetmap = offsetmap(s_normalmap, tc, eyevector);
|
|
|
|
#define tc tcoffsetmap
|
|
|
|
#endif
|
|
|
|
|
2012-05-09 15:30:53 +00:00
|
|
|
vec3 onorm;
|
|
|
|
#if defined(BUMP)
|
2016-11-20 21:05:10 +00:00
|
|
|
vec3 bm = 2.0*texture2D(s_normalmap, tc).xyz - 1.0;
|
2012-05-09 15:30:53 +00:00
|
|
|
onorm = normalize(bm.x * tang + bm.y * bitang + bm.z * norm);
|
|
|
|
#else
|
|
|
|
onorm = norm;
|
|
|
|
#endif
|
2016-11-20 21:05:10 +00:00
|
|
|
gl_FragColor = vec4(onorm.xyz, gl_FragCoord.z);
|
2012-05-09 15:30:53 +00:00
|
|
|
}
|
|
|
|
#endif
|