811bce25f1
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds. Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system). Add mastervolume cvar (for ss). Add r_shadows 2 (aka fake shadows - for ss). Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss). Better support for some effectinfo hacks (for ss). Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss). Rework the dpcsqc versions of project+unproject builtins for better compat (for ss). Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss). Better compat with DP's loadfont console command (for ss). Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss). Detect dp's m_draw extension, to work around it (for ss). Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss). loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts. Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0. Hackily parse emoji.json to provide 💩 etc suggestions. Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic. screenshot_cubemap will now capture half-float images when saving to ktx or dds files. Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings. Fixed size of gfx/loading.lmp when replacement textures are used. Added mipmap support for rg8 and l8a8 textures. r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones. Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP). Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research. Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates. Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds. Added setmousepos builtin. Should work with glx+win32 build. VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees). Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding). Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW). sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories. edit command now displays end1.bin/end2.bin correctly, because we can. Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant. Fix threading race condition in sha1 lookups. Updated f_ruleset to include the same extra flags reported by ezquake. A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc). fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only. HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written). Fixed buf_cvarlist, should work in xonotic now, and without segfaults. Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though. Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs. sdl: support custom icons. sdl: support choosing a specific display. Added some documentation to menuqc builtins. menusys: use outlines for slightly more readable fonts. menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
211 lines
6.9 KiB
GLSL
211 lines
6.9 KiB
GLSL
!!permu FULLBRIGHT
|
|
!!permu BUMP
|
|
!!permu REFLECTCUBEMASK
|
|
!!cvarf r_glsl_offsetmapping=0.0
|
|
!!cvarf r_glsl_offsetmapping_scale=0.04
|
|
!!cvarf gl_specular=0.3
|
|
!!cvarb r_fog_exp2=true
|
|
!!samps diffuse normalmap specular fullbright lightmap
|
|
!!samps deluxemap reflectmask reflectcube
|
|
!!argb vertexlit=0
|
|
//!!samps =EIGHTBIT paletted 1
|
|
//!!argb eightbit=0
|
|
!!argf mask=1.0
|
|
!!argb masklt=false
|
|
!!permu FOG
|
|
//!!permu DELUXE
|
|
//!!permu LIGHTSTYLED //this seems to be breaking nvidia drivers if set from the engine, despite us not using it...
|
|
|
|
const bool DELUXE = false;
|
|
#define SPECULAR (cvar_gl_specular>0)
|
|
|
|
#include "sys/defs.h"
|
|
|
|
//this is what normally draws all of your walls, even with rtlights disabled
|
|
//note that the '286' preset uses drawflat_walls instead.
|
|
|
|
#include "sys/fog.h"
|
|
layout(location=1) varying vec3 eyevector;
|
|
layout(location=2) varying vec2 basetc;
|
|
layout(location=3) varying vec4 vc;
|
|
layout(location=4) varying mat3 invsurface;
|
|
#ifdef LIGHTSTYLED
|
|
//we could use an offset, but that would still need to be per-surface which would break batches
|
|
//fixme: merge attributes?
|
|
varying vec2 lm0, lm1, lm2, lm3;
|
|
#else
|
|
layout(location=0) varying vec2 lm0;
|
|
#endif
|
|
|
|
#ifdef VERTEX_SHADER
|
|
void main ()
|
|
{
|
|
if (OFFSETMAPPING || SPECULAR || REFLECTCUBEMASK)
|
|
{
|
|
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);
|
|
}
|
|
if (REFLECTCUBEMASK)
|
|
{
|
|
invsurface[0] = v_svector;
|
|
invsurface[1] = v_tvector;
|
|
invsurface[2] = v_normal;
|
|
}
|
|
basetc = v_texcoord;
|
|
lm0 = v_lmcoord;
|
|
#ifdef LIGHTSTYLED
|
|
lm1 = v_lmcoord2;
|
|
lm2 = v_lmcoord3;
|
|
lm3 = v_lmcoord4;
|
|
#endif
|
|
if (arg_vertexlit)
|
|
vc = v_colour;
|
|
gl_Position = ftetransform();
|
|
}
|
|
#endif
|
|
|
|
|
|
#ifdef FRAGMENT_SHADER
|
|
|
|
//samplers
|
|
|
|
//for 8bit
|
|
#define s_colourmap s_t0
|
|
|
|
|
|
#include "sys/offsetmapping.h"
|
|
void main ()
|
|
{
|
|
//adjust texture coords for offsetmapping
|
|
vec2 tc = basetc;
|
|
if (OFFSETMAPPING)
|
|
tc = offsetmap(s_normalmap, tc, eyevector);
|
|
|
|
//yay, regular texture!
|
|
gl_FragColor = texture2D(s_diffuse, tc);
|
|
|
|
vec3 norm;
|
|
if (BUMP && (DELUXE || SPECULAR || REFLECTCUBEMASK))
|
|
norm = normalize(texture2D(s_normalmap, tc).rgb - 0.5);
|
|
else if (SPECULAR || DELUXE || REFLECTCUBEMASK)
|
|
norm = vec3(0, 0, 1); //specular lighting expects this to exist.
|
|
|
|
vec3 lightmaps;
|
|
if (arg_vertexlit)
|
|
lightmaps = vc.rgb * e_lmscale.rgb;
|
|
else
|
|
{
|
|
//modulate that by the lightmap(s) including deluxemap(s)
|
|
#ifdef LIGHTSTYLED
|
|
if (DELUXE)
|
|
{
|
|
lightmaps = texture2D(s_lightmap0, lm0).rgb * e_lmscale[0].rgb * dot(norm, 2.0*texture2D(s_deluxemap0, lm0).rgb-0.5);
|
|
lightmaps += texture2D(s_lightmap1, lm1).rgb * e_lmscale[1].rgb * dot(norm, 2.0*texture2D(s_deluxemap1, lm1).rgb-0.5);
|
|
lightmaps += texture2D(s_lightmap2, lm2).rgb * e_lmscale[2].rgb * dot(norm, 2.0*texture2D(s_deluxemap2, lm2).rgb-0.5);
|
|
lightmaps += texture2D(s_lightmap3, lm3).rgb * e_lmscale[3].rgb * dot(norm, 2.0*texture2D(s_deluxemap3, lm3).rgb-0.5);
|
|
}
|
|
else
|
|
{
|
|
lightmaps = texture2D(s_lightmap0, lm0).rgb * e_lmscale[0].rgb;
|
|
lightmaps += texture2D(s_lightmap1, lm1).rgb * e_lmscale[1].rgb;
|
|
lightmaps += texture2D(s_lightmap2, lm2).rgb * e_lmscale[2].rgb;
|
|
lightmaps += texture2D(s_lightmap3, lm3).rgb * e_lmscale[3].rgb;
|
|
}
|
|
#else
|
|
/*if (arg_eightbit)
|
|
{
|
|
//optional: round the lightmap coords to ensure all pixels within a texel have different lighting values either. it just looks wrong otherwise.
|
|
//don't bother if its lightstyled, such cases will have unpredictable correlations anyway.
|
|
//FIXME: this rounding is likely not correct with respect to software rendering. oh well.
|
|
vec2 nearestlm0 = floor(lm0 * 256.0*8.0)/(256.0*8.0);
|
|
lightmaps = (texture2D(s_lightmap, nearestlm0) * e_lmscale).rgb;
|
|
}
|
|
else*/
|
|
lightmaps = (texture2D(s_lightmap, lm0) * e_lmscale).rgb;
|
|
//modulate by the bumpmap dot light
|
|
if (DELUXE)
|
|
{
|
|
vec3 delux = 2.0*(texture2D(s_deluxemap, lm0).rgb-0.5);
|
|
lightmaps *= 1.0 / max(0.25, delux.z); //counter the darkening from deluxmaps
|
|
lightmaps *= dot(norm, delux);
|
|
}
|
|
#endif
|
|
}
|
|
|
|
//add in specular, if applicable.
|
|
if (SPECULAR)
|
|
{
|
|
vec4 specs = texture2D(s_specular, tc);
|
|
vec3 halfdir;
|
|
if (DELUXE)
|
|
{
|
|
//not lightstyled...
|
|
halfdir = normalize(normalize(eyevector) + 2.0*(texture2D(s_deluxemap0, lm0).rgb-0.5)); //this norm should be the deluxemap info instead
|
|
}
|
|
else
|
|
{
|
|
halfdir = normalize(normalize(eyevector) + vec3(0.0, 0.0, 1.0)); //this norm should be the deluxemap info instead
|
|
}
|
|
float spec = pow(max(dot(halfdir, norm), 0.0), 32.0 * specs.a);
|
|
spec *= cvar_gl_specular;
|
|
//NOTE: rtlights tend to have a *4 scaler here to over-emphasise the effect because it looks cool.
|
|
//As not all maps will have deluxemapping, and the double-cos from the light util makes everything far too dark anyway,
|
|
//we default to something that is not garish when the light value is directly infront of every single pixel.
|
|
//we can justify this difference due to the rtlight editor etc showing the *4.
|
|
gl_FragColor.rgb += spec * specs.rgb;
|
|
}
|
|
|
|
if (REFLECTCUBEMASK)
|
|
{
|
|
vec3 rtc = reflect(-eyevector, norm);
|
|
rtc = rtc.x*invsurface[0] + rtc.y*invsurface[1] + rtc.z*invsurface[2];
|
|
rtc = (m_model * vec4(rtc.xyz,0.0)).xyz;
|
|
gl_FragColor.rgb += texture2D(s_reflectmask, tc).rgb * textureCube(s_reflectcube, rtc).rgb;
|
|
}
|
|
|
|
/*if (arg_eightbit)
|
|
{
|
|
//FIXME: with this extra flag, half the permutations are redundant.
|
|
lightmaps *= 0.5; //counter the fact that the colourmap contains overbright values and logically ranges from 0 to 2 intead of to 1.
|
|
float pal = texture2D(s_paletted, tc).r; //the palette index. hopefully not interpolated.
|
|
lightmaps -= 1.0 / 128.0; //software rendering appears to round down, so make sure we favour the lower values instead of rounding to the nearest
|
|
gl_FragColor.r = texture2D(s_colourmap, vec2(pal, 1.0-lightmaps.r)).r; //do 3 lookups. this is to cope with lit files, would be a waste to not support those.
|
|
gl_FragColor.g = texture2D(s_colourmap, vec2(pal, 1.0-lightmaps.g)).g; //its not very softwarey, but re-palettizing is ugly.
|
|
gl_FragColor.b = texture2D(s_colourmap, vec2(pal, 1.0-lightmaps.b)).b; //without lits, it should be identical.
|
|
}
|
|
else*/
|
|
{
|
|
//now we have our diffuse+specular terms, modulate by lightmap values.
|
|
gl_FragColor.rgb *= lightmaps.rgb;
|
|
|
|
//add on the fullbright
|
|
if (FULLBRIGHT)
|
|
gl_FragColor.rgb += texture2D(s_fullbright, tc).rgb;
|
|
}
|
|
|
|
//entity modifiers
|
|
gl_FragColor = gl_FragColor * e_colourident;
|
|
|
|
if (arg_mask != 1.0)
|
|
{
|
|
if (arg_masklt)
|
|
{
|
|
if (gl_FragColor.a < arg_mask)
|
|
discard;
|
|
}
|
|
else
|
|
{
|
|
if (gl_FragColor.a >= arg_mask)
|
|
discard;
|
|
}
|
|
gl_FragColor.a = 1.0;
|
|
}
|
|
|
|
//and finally hide it all if we're fogged.
|
|
#ifdef FOG
|
|
gl_FragColor = fog4(gl_FragColor);
|
|
#endif
|
|
}
|
|
#endif
|