mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-23 12:22:42 +00:00
52f0f117ab
reworked deferred rendering to support specular. mrt can be reconfigured by TCs if desired. reworked q3bsp deluxemap code (so it no longer bugs out). fixed a few warnings. updated fteqcc to try to cope with xonotic. still not working (xonotic fails from bound checks). reworked shader conditionals to support elif. added some directives from QF(aka: warsow) git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5158 fc73d0e0-1445-4013-8a0c-d673dee63da5
77 lines
1.8 KiB
GLSL
77 lines
1.8 KiB
GLSL
!!permu BUMP
|
|
!!permu SKELETAL
|
|
!!permu FRAMEBLEND
|
|
!!cvarf r_glsl_offsetmapping_scale
|
|
!!samps normalmap specular
|
|
|
|
//light pre-pass rendering (defered lighting)
|
|
//this is the initial pass, that draws the surface normals and depth to the initial colour buffer
|
|
|
|
#include "sys/defs.h"
|
|
|
|
#if defined(OFFSETMAPPING)
|
|
varying vec3 eyevector;
|
|
#endif
|
|
|
|
varying vec3 norm;
|
|
#if defined(BUMP)
|
|
varying vec3 tang, bitang;
|
|
#endif
|
|
#if defined(BUMP) || defined(SPECULAR)
|
|
varying vec2 tc;
|
|
#endif
|
|
#ifdef VERTEX_SHADER
|
|
#include "sys/skeletal.h"
|
|
|
|
void main()
|
|
{
|
|
#if defined(BUMP)
|
|
gl_Position = skeletaltransform_nst(norm, tang, bitang);
|
|
#else
|
|
gl_Position = skeletaltransform_n(norm);
|
|
#endif
|
|
#if defined(BUMP) || defined(SPECULAR)
|
|
tc = v_texcoord;
|
|
#endif
|
|
|
|
#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
|
|
}
|
|
#endif
|
|
#ifdef FRAGMENT_SHADER
|
|
#ifdef OFFSETMAPPING
|
|
#include "sys/offsetmapping.h"
|
|
#endif
|
|
void main()
|
|
{
|
|
//adjust texture coords for offsetmapping
|
|
#ifdef OFFSETMAPPING
|
|
vec2 tcoffsetmap = offsetmap(s_normalmap, tc, eyevector);
|
|
#define tc tcoffsetmap
|
|
#endif
|
|
|
|
vec3 onorm;
|
|
vec4 ospec;
|
|
|
|
//need to write surface normals so that light shines on the surfaces properly
|
|
#if defined(BUMP)
|
|
vec3 bm = 2.0*texture2D(s_normalmap, tc).xyz - 1.0;
|
|
onorm = normalize(bm.x * tang + bm.y * bitang + bm.z * norm);
|
|
#else
|
|
onorm = norm;
|
|
#endif
|
|
|
|
//we need to write specular exponents if we want per-pixel control over that
|
|
//#if defined(SPECULAR)
|
|
ospec = texture2D(s_specular, tc);
|
|
//#else
|
|
// ospec = vec4(0.0, 0.0, 0.0, 0.0);
|
|
//#endif
|
|
|
|
gl_FragColor = vec4(onorm.xyz, ospec.a * FTE_SPECULAR_EXPONENT);
|
|
}
|
|
#endif
|