fix wireframe.

increase xz memory limit
fix fseek/fsize to match definitions.
r_deluxemapping is more aggressive with regards to generating lux files on demand (but won't generate lit data at the same time).
fix webgl shader issues.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5071 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2017-03-06 14:06:12 +00:00
parent c385cb71b4
commit dadec86338
14 changed files with 449 additions and 403 deletions

View file

@ -7127,6 +7127,128 @@ YOU SHOULD NOT EDIT THIS FILE BY HAND
"return inp.col * t_lightmap.Sample(s_lightmap, inp.lmtc);\n"
"}\n"
"#endif\n"
},
#endif
#ifdef GLQUAKE
{QR_OPENGL, 110, "wireframe",
"!!ver 100 150\n"
"!!permu TESS\n"
"!!permu FRAMEBLEND\n"
"!!permu SKELETAL\n"
"!!permu FOG\n"
"!!cvardf r_tessellation_level=5\n"
"#include \"sys/defs.h\"\n"
//standard shader used for wireframe stuff.
//must support skeletal and 2-way vertex blending or Bad Things Will Happen.
"#ifdef VERTEX_SHADER\n"
"#include \"sys/skeletal.h\"\n"
"#ifdef TESS\n"
"varying vec3 vertex;\n"
"varying vec3 normal;\n"
"#endif\n"
"void main ()\n"
"{\n"
"vec3 n, s, t, w;\n"
"gl_Position = skeletaltransform_wnst(w,n,s,t);\n"
"#ifdef TESS\n"
"normal = n;\n"
"vertex = w;\n"
"#endif\n"
"}\n"
"#endif\n"
"#if defined(TESS_CONTROL_SHADER)\n"
"layout(vertices = 3) out;\n"
"in vec3 vertex[];\n"
"out vec3 t_vertex[];\n"
"in vec3 normal[];\n"
"out vec3 t_normal[];\n"
"void main()\n"
"{\n"
//the control shader needs to pass stuff through
"#define id gl_InvocationID\n"
"t_vertex[id] = vertex[id];\n"
"t_normal[id] = normal[id];\n"
"gl_TessLevelOuter[0] = float(r_tessellation_level);\n"
"gl_TessLevelOuter[1] = float(r_tessellation_level);\n"
"gl_TessLevelOuter[2] = float(r_tessellation_level);\n"
"gl_TessLevelInner[0] = float(r_tessellation_level);\n"
"}\n"
"#endif\n"
"#if defined(TESS_EVALUATION_SHADER)\n"
"layout(triangles) in;\n"
"in vec3 t_vertex[];\n"
"in vec3 t_normal[];\n"
"#define LERP(a) (gl_TessCoord.x*a[0] + gl_TessCoord.y*a[1] + gl_TessCoord.z*a[2])\n"
"void main()\n"
"{\n"
"#define factor 1.0\n"
"vec3 w = LERP(t_vertex);\n"
"vec3 t0 = w - dot(w-t_vertex[0],t_normal[0])*t_normal[0];\n"
"vec3 t1 = w - dot(w-t_vertex[1],t_normal[1])*t_normal[1];\n"
"vec3 t2 = w - dot(w-t_vertex[2],t_normal[2])*t_normal[2];\n"
"w = w*(1.0-factor) + factor*(gl_TessCoord.x*t0+gl_TessCoord.y*t1+gl_TessCoord.z*t2);\n"
"gl_Position = m_modelviewprojection * vec4(w,1.0);\n"
"}\n"
"#endif\n"
"#ifdef FRAGMENT_SHADER\n"
"#include \"sys/fog.h\"\n"
"void main ()\n"
"{\n"
"gl_FragColor = fog4(vec4(1.0) * e_colourident);\n"
"}\n"
"#endif\n"
},
#endif
#ifdef GLQUAKE
@ -9654,11 +9776,6 @@ YOU SHOULD NOT EDIT THIS FILE BY HAND
"#include \"sys/defs.h\"\n"
"#ifndef USE_ARB_SHADOW\n"
//fall back on regular samplers if we must
"#define sampler2DShadow sampler2D\n"
"#endif\n"
//this is the main shader responsible for realtime dlights.
//texture units:
@ -9669,14 +9786,6 @@ YOU SHOULD NOT EDIT THIS FILE BY HAND
//SPOT(projected circle
//CUBESHADOW
"#ifndef r_glsl_pcf\n"
"#error r_glsl_pcf wasnt defined\n"
"#endif\n"
"#if r_glsl_pcf < 1\n"
"#undef r_glsl_pcf\n"
"#define r_glsl_pcf 9\n"
"#endif\n"
"#if 0 && defined(GL_ARB_texture_gather) && defined(PCF) \n"
"#extension GL_ARB_texture_gather : enable\n"
"#endif\n"
@ -9850,115 +9959,25 @@ YOU SHOULD NOT EDIT THIS FILE BY HAND
"#ifdef FRAGMENT_SHADER\n"
"#include \"sys/fog.h\"\n"
"#ifdef PCF\n"
"vec3 ShadowmapCoord(void)\n"
"{\n"
"#ifdef SPOT\n"
//bias it. don't bother figuring out which side or anything, its not needed
//l_projmatrix contains the light's projection matrix so no other magic needed
"return ((vtexprojcoord.xyz-vec3(0.0,0.0,0.015))/vtexprojcoord.w + vec3(1.0, 1.0, 1.0)) * vec3(0.5, 0.5, 0.5);\n"
//#elif defined(CUBESHADOW)
// vec3 shadowcoord = vshadowcoord.xyz / vshadowcoord.w;
// #define dosamp(x,y) shadowCube(s_shadowmap, shadowcoord + vec2(x,y)*texscale.xy).r
"#else\n"
//figure out which axis to use
//texture is arranged thusly:
//forward left up
//back right down
"vec3 dir = abs(vtexprojcoord.xyz);\n"
//assume z is the major axis (ie: forward from the light)
"vec3 t = vtexprojcoord.xyz;\n"
"float ma = dir.z;\n"
"vec3 axis = vec3(0.5/3.0, 0.5/2.0, 0.5);\n"
"if (dir.x > ma)\n"
"{\n"
"ma = dir.x;\n"
"t = vtexprojcoord.zyx;\n"
"axis.x = 0.5;\n"
"}\n"
"if (dir.y > ma)\n"
"{\n"
"ma = dir.y;\n"
"t = vtexprojcoord.xzy;\n"
"axis.x = 2.5/3.0;\n"
"}\n"
//if the axis is negative, flip it.
"if (t.z > 0.0)\n"
"{\n"
"axis.y = 1.5/2.0;\n"
"t.z = -t.z;\n"
"}\n"
//we also need to pass the result through the light's projection matrix too
//the 'matrix' we need only contains 5 actual values. and one of them is a -1. So we might as well just use a vec4.
//note: the projection matrix also includes scalers to pinch the image inwards to avoid sampling over borders, as well as to cope with non-square source image
//the resulting z is prescaled to result in a value between -0.5 and 0.5.
//also make sure we're in the right quadrant type thing
"return axis + ((l_shadowmapproj.xyz*t.xyz + vec3(0.0, 0.0, l_shadowmapproj.w)) / -t.z);\n"
"#endif\n"
"}\n"
"float ShadowmapFilter(void)\n"
"{\n"
"vec3 shadowcoord = ShadowmapCoord();\n"
"#if 0//def GL_ARB_texture_gather\n"
"vec2 ipart, fpart;\n"
"#define dosamp(x,y) textureGatherOffset(s_shadowmap, ipart.xy, vec2(x,y)))\n"
"vec4 tl = step(shadowcoord.z, dosamp(-1.0, -1.0));\n"
"vec4 bl = step(shadowcoord.z, dosamp(-1.0, 1.0));\n"
"vec4 tr = step(shadowcoord.z, dosamp(1.0, -1.0));\n"
"vec4 br = step(shadowcoord.z, dosamp(1.0, 1.0));\n"
//we now have 4*4 results, woo
//we can just average them for 1/16th precision, but that's still limited graduations
//the middle four pixels are 'full strength', but we interpolate the sides to effectively give 3*3
"vec4 col = vec4(tl.ba, tr.ba) + vec4(bl.rg, br.rg) + //middle two rows are full strength\n"
"mix(vec4(tl.rg, tr.rg), vec4(bl.ba, br.ba), fpart.y); //top+bottom rows\n"
"return dot(mix(col.rgb, col.agb, fpart.x), vec3(1.0/9.0)); //blend r+a, gb are mixed because its pretty much free and gives a nicer dot instruction instead of lots of adds.\n"
"#else\n"
"#ifdef USE_ARB_SHADOW\n"
//with arb_shadow, we can benefit from hardware acclerated pcf, for smoother shadows
"#define dosamp(x,y) shadow2D(s_shadowmap, shadowcoord.xyz + (vec3(x,y,0.0)*l_shadowmapscale.xyx))\n"
"#else\n"
//this will probably be a bit blocky.
"#define dosamp(x,y) float(texture2D(s_shadowmap, shadowcoord.xy + (vec2(x,y)*l_shadowmapscale.xy)).r >= shadowcoord.z)\n"
"#endif\n"
"float s = 0.0;\n"
"#if r_glsl_pcf >= 1 && r_glsl_pcf < 5\n"
"s += dosamp(0.0, 0.0);\n"
"return s;\n"
"#elif r_glsl_pcf >= 5 && r_glsl_pcf < 9\n"
"s += dosamp(-1.0, 0.0);\n"
"s += dosamp(0.0, -1.0);\n"
"s += dosamp(0.0, 0.0);\n"
"s += dosamp(0.0, 1.0);\n"
"s += dosamp(1.0, 0.0);\n"
"return s/5.0;\n"
"#else\n"
"s += dosamp(-1.0, -1.0);\n"
"s += dosamp(-1.0, 0.0);\n"
"s += dosamp(-1.0, 1.0);\n"
"s += dosamp(0.0, -1.0);\n"
"s += dosamp(0.0, 0.0);\n"
"s += dosamp(0.0, 1.0);\n"
"s += dosamp(1.0, -1.0);\n"
"s += dosamp(1.0, 0.0);\n"
"s += dosamp(1.0, 1.0);\n"
"return s/9.0;\n"
"#endif\n"
"#endif\n"
"}\n"
"#endif\n"
"#include \"sys/pcf.h\"\n"
"#ifdef OFFSETMAPPING\n"
"#include \"sys/offsetmapping.h\"\n"
"#endif\n"
"void main ()\n"
"{\n"
"float colorscale = max(1.0 - (dot(lightvector, lightvector)/(l_lightradius*l_lightradius)), 0.0);\n"
"#ifdef PCF\n"
/*filter the light by the shadowmap. logically a boolean, but we allow fractions for softer shadows*/
"colorscale *= ShadowmapFilter(s_shadowmap);\n"
"#endif\n"
"#if defined(SPOT)\n"
/*filter the colour by the spotlight. discard anything behind the light so we don't get a mirror image*/
"if (vtexprojcoord.w < 0.0) discard;\n"
"vec2 spot = ((vtexprojcoord.st)/vtexprojcoord.w);\n"
"colorscale*=1.0-(dot(spot,spot));\n"
"#endif\n"
//read raw texture samples (offsetmapping munges the tex coords first)
"#ifdef OFFSETMAPPING\n"
"vec2 tcoffsetmap = offsetmap(s_normalmap, tcbase, eyevector);\n"
@ -9986,7 +10005,6 @@ YOU SHOULD NOT EDIT THIS FILE BY HAND
"vec4 specs = texture2D(s_specular, tcbase);\n"
"#endif\n"
"float colorscale = max(1.0 - (dot(lightvector, lightvector)/(l_lightradius*l_lightradius)), 0.0);\n"
"vec3 diff;\n"
"#ifdef NOBUMP\n"
//surface can only support ambient lighting, even for lights that try to avoid it.
@ -10020,19 +10038,6 @@ YOU SHOULD NOT EDIT THIS FILE BY HAND
"diff *= textureCube(s_projectionmap, vtexprojcoord.xyz).rgb;\n"
"#endif\n"
"#if defined(SPOT)\n"
/*filter the colour by the spotlight. discard anything behind the light so we don't get a mirror image*/
"if (vtexprojcoord.w < 0.0) discard;\n"
"vec2 spot = ((vtexprojcoord.st)/vtexprojcoord.w);colorscale*=1.0-(dot(spot,spot));\n"
"#endif\n"
"#ifdef PCF\n"
/*filter the light by the shadowmap. logically a boolean, but we allow fractions for softer shadows*/
//diff.rgb = (vtexprojcoord.xyz/vtexprojcoord.w) * 0.5 + 0.5;
"colorscale *= ShadowmapFilter();\n"
// diff = ShadowmapCoord();
"#endif\n"
"#if defined(PROJECTION)\n"
/*2d projection, not used*/
// diff *= texture2d(s_projectionmap, shadowcoord);