Merge branch 'master' into sdl2

Conflicts:
	Makefile
	code/renderergl2/tr_image.c
This commit is contained in:
Tim Angus 2014-08-25 15:00:48 +01:00
commit 2a3368481d
24 changed files with 431 additions and 227 deletions

154
Makefile
View file

@ -187,32 +187,36 @@ ifndef USE_FREETYPE
USE_FREETYPE=0
endif
ifndef USE_INTERNAL_LIBS
USE_INTERNAL_LIBS=1
endif
ifndef USE_INTERNAL_SPEEX
USE_INTERNAL_SPEEX=1
USE_INTERNAL_SPEEX=$(USE_INTERNAL_LIBS)
endif
ifndef USE_INTERNAL_OGG
USE_INTERNAL_OGG=1
USE_INTERNAL_OGG=$(USE_INTERNAL_LIBS)
endif
ifndef USE_INTERNAL_VORBIS
USE_INTERNAL_VORBIS=1
USE_INTERNAL_VORBIS=$(USE_INTERNAL_LIBS)
endif
ifndef USE_INTERNAL_OPUS
USE_INTERNAL_OPUS=1
USE_INTERNAL_OPUS=$(USE_INTERNAL_LIBS)
endif
ifndef USE_INTERNAL_ZLIB
USE_INTERNAL_ZLIB=1
USE_INTERNAL_ZLIB=$(USE_INTERNAL_LIBS)
endif
ifndef USE_INTERNAL_JPEG
USE_INTERNAL_JPEG=1
USE_INTERNAL_JPEG=$(USE_INTERNAL_LIBS)
endif
ifndef USE_LOCAL_HEADERS
USE_LOCAL_HEADERS=1
USE_LOCAL_HEADERS=$(USE_INTERNAL_LIBS)
endif
ifndef USE_RENDERER_DLOPEN
@ -266,19 +270,23 @@ ifneq ($(BUILD_CLIENT),0)
# set PKG_CONFIG_PATH to influence this, e.g.
# PKG_CONFIG_PATH=/opt/cross/i386-mingw32msvc/lib/pkgconfig
ifneq ($(call bin_path, pkg-config),)
CURL_CFLAGS=$(shell pkg-config --silence-errors --cflags libcurl)
CURL_LIBS=$(shell pkg-config --silence-errors --libs libcurl)
OPENAL_CFLAGS=$(shell pkg-config --silence-errors --cflags openal)
OPENAL_LIBS=$(shell pkg-config --silence-errors --libs openal)
SDL_CFLAGS=$(shell pkg-config --silence-errors --cflags sdl2|sed 's/-Dmain=SDL_main//')
SDL_LIBS=$(shell pkg-config --silence-errors --libs sdl2)
FREETYPE_CFLAGS=$(shell pkg-config --silence-errors --cflags freetype2)
CURL_CFLAGS ?= $(shell pkg-config --silence-errors --cflags libcurl)
CURL_LIBS ?= $(shell pkg-config --silence-errors --libs libcurl)
OPENAL_CFLAGS ?= $(shell pkg-config --silence-errors --cflags openal)
OPENAL_LIBS ?= $(shell pkg-config --silence-errors --libs openal)
SDL_CFLAGS ?= $(shell pkg-config --silence-errors --cflags sdl2|sed 's/-Dmain=SDL_main//')
SDL_LIBS ?= $(shell pkg-config --silence-errors --libs sdl2)
FREETYPE_CFLAGS ?= $(shell pkg-config --silence-errors --cflags freetype2)
else
# assume they're in the system default paths (no -I or -L needed)
CURL_LIBS ?= -lcurl
OPENAL_LIBS ?= -lopenal
endif
# Use sdl-config if all else fails
# Use sdl2-config if all else fails
ifeq ($(SDL_CFLAGS),)
ifneq ($(call bin_path, sdl2-config),)
SDL_CFLAGS=$(shell sdl2-config --cflags)
SDL_LIBS=$(shell sdl2-config --libs)
SDL_CFLAGS ?= $(shell sdl2-config --cflags)
SDL_LIBS ?= $(shell sdl2-config --libs)
endif
endif
endif
@ -370,13 +378,14 @@ ifneq (,$(findstring "$(PLATFORM)", "linux" "gnu_kfreebsd" "kfreebsd-gnu"))
ifeq ($(USE_OPENAL),1)
ifneq ($(USE_OPENAL_DLOPEN),1)
CLIENT_LIBS += -lopenal
CLIENT_LIBS += $(THREAD_LIBS) $(OPENAL_LIBS)
endif
endif
ifeq ($(USE_CURL),1)
CLIENT_CFLAGS += $(CURL_CFLAGS)
ifneq ($(USE_CURL_DLOPEN),1)
CLIENT_LIBS += -lcurl
CLIENT_LIBS += $(CURL_LIBS)
endif
endif
@ -384,10 +393,6 @@ ifneq (,$(findstring "$(PLATFORM)", "linux" "gnu_kfreebsd" "kfreebsd-gnu"))
CLIENT_LIBS += -lrt
endif
ifeq ($(USE_FREETYPE),1)
BASE_CFLAGS += $(FREETYPE_CFLAGS)
endif
ifeq ($(ARCH),x86)
# linux32 make ...
BASE_CFLAGS += -m32
@ -460,15 +465,12 @@ ifeq ($(PLATFORM),darwin)
endif
ifeq ($(USE_CURL),1)
CLIENT_CFLAGS += $(CURL_CFLAGS)
ifneq ($(USE_CURL_DLOPEN),1)
CLIENT_LIBS += -lcurl
CLIENT_LIBS += $(CURL_LIBS)
endif
endif
ifeq ($(USE_FREETYPE),1)
BASE_CFLAGS += $(FREETYPE_CFLAGS)
endif
BASE_CFLAGS += -D_THREAD_SAFE=1
ifeq ($(USE_LOCAL_HEADERS),1)
@ -558,7 +560,7 @@ ifeq ($(PLATFORM),mingw32)
ifeq ($(ARCH),x86_64)
OPTIMIZEVM = -O3 -fno-omit-frame-pointer \
-funroll-loops -falign-functions=2 -fstrength-reduce
OPTIMIZE = $(OPTIMIZEVM) --fast-math
OPTIMIZE = $(OPTIMIZEVM) -ffast-math
HAVE_VM_COMPILED = true
endif
ifeq ($(ARCH),x86)
@ -579,12 +581,15 @@ ifeq ($(PLATFORM),mingw32)
endif
LIBS= -lws2_32 -lwinmm -lpsapi
CLIENT_LDFLAGS += -mwindows
# clang 3.4 doesn't support this
ifneq ("$(CC)", $(findstring "$(CC)", "clang" "clang++"))
CLIENT_LDFLAGS += -mwindows
endif
CLIENT_LIBS = -lgdi32 -lole32
RENDERER_LIBS = -lgdi32 -lole32 -lopengl32
ifeq ($(USE_FREETYPE),1)
BASE_CFLAGS += -Ifreetype2
FREETYPE_CFLAGS = -Ifreetype2
endif
ifeq ($(USE_CURL),1)
@ -670,13 +675,14 @@ ifeq ($(PLATFORM),freebsd)
# optional features/libraries
ifeq ($(USE_OPENAL),1)
ifeq ($(USE_OPENAL_DLOPEN),1)
CLIENT_LIBS += $(THREAD_LIBS) -lopenal
CLIENT_LIBS += $(THREAD_LIBS) $(OPENAL_LIBS)
endif
endif
ifeq ($(USE_CURL),1)
CLIENT_CFLAGS += $(CURL_CFLAGS)
ifeq ($(USE_CURL_DLOPEN),1)
CLIENT_LIBS += -lcurl
CLIENT_LIBS += $(CURL_LIBS)
endif
endif
@ -761,13 +767,13 @@ ifeq ($(PLATFORM),openbsd)
ifeq ($(USE_OPENAL),1)
ifneq ($(USE_OPENAL_DLOPEN),1)
CLIENT_LIBS += $(THREAD_LIBS) -lopenal
CLIENT_LIBS += $(THREAD_LIBS) $(OPENAL_LIBS)
endif
endif
ifeq ($(USE_CURL),1)
ifneq ($(USE_CURL_DLOPEN),1)
CLIENT_LIBS += -lcurl
CLIENT_LIBS += $(CURL_LIBS)
endif
endif
else # ifeq openbsd
@ -910,10 +916,6 @@ endif
TARGETS =
ifeq ($(USE_FREETYPE),1)
BASE_CFLAGS += -DBUILD_FREETYPE
endif
ifndef FULLBINEXT
FULLBINEXT=.$(ARCH)$(BINEXT)
endif
@ -984,40 +986,43 @@ ifeq ($(USE_CURL),1)
endif
endif
ifeq ($(USE_CODEC_VORBIS),1)
CLIENT_CFLAGS += -DUSE_CODEC_VORBIS
NEED_OGG=1
endif
ifeq ($(USE_CODEC_OPUS),1)
CLIENT_CFLAGS += -DUSE_CODEC_OPUS
ifeq ($(USE_INTERNAL_OPUS),1)
CLIENT_CFLAGS += -DOPUS_BUILD -DHAVE_LRINTF -DFLOATING_POINT -DUSE_ALLOCA \
OPUS_CFLAGS = -DOPUS_BUILD -DHAVE_LRINTF -DFLOATING_POINT -DUSE_ALLOCA \
-I$(OPUSDIR)/include -I$(OPUSDIR)/celt -I$(OPUSDIR)/silk \
-I$(OPUSDIR)/silk/float
CLIENT_CFLAGS += -I$(OPUSFILEDIR)/include
-I$(OPUSDIR)/silk/float -I$(OPUSFILEDIR)/include
else
CLIENT_LIBS += -lopusfile -lopus
OPUS_CFLAGS ?= $(shell pkg-config --silence-errors --cflags opusfile opus || true)
OPUS_LIBS ?= $(shell pkg-config --silence-errors --libs opusfile opus || echo -lopusfile -lopus)
endif
CLIENT_CFLAGS += $(OPUS_CFLAGS)
CLIENT_LIBS += $(OPUS_LIBS)
NEED_OGG=1
endif
ifeq ($(USE_CODEC_VORBIS),1)
CLIENT_CFLAGS += -DUSE_CODEC_VORBIS
ifeq ($(USE_INTERNAL_VORBIS),1)
CLIENT_CFLAGS += -I$(VORBISDIR)/include -I$(VORBISDIR)/lib
else
VORBIS_CFLAGS ?= $(shell pkg-config --silence-errors --cflags vorbisfile vorbis || true)
VORBIS_LIBS ?= $(shell pkg-config --silence-errors --libs vorbisfile vorbis || echo -lvorbisfile -lvorbis)
endif
CLIENT_CFLAGS += $(VORBIS_CFLAGS)
CLIENT_LIBS += $(VORBIS_LIBS)
NEED_OGG=1
endif
ifeq ($(NEED_OGG),1)
ifeq ($(USE_INTERNAL_OGG),1)
CLIENT_CFLAGS += -I$(OGGDIR)/include
OGG_CFLAGS = -I$(OGGDIR)/include
else
CLIENT_LIBS += -logg
endif
endif
ifeq ($(USE_CODEC_VORBIS),1)
ifeq ($(USE_INTERNAL_VORBIS),1)
CLIENT_CFLAGS += -I$(VORBISDIR)/include -I$(VORBISDIR)/lib
else
CLIENT_LIBS += -lvorbisfile -lvorbis
OGG_CFLAGS ?= $(shell pkg-config --silence-errors --cflags ogg || true)
OGG_LIBS ?= $(shell pkg-config --silence-errors --libs ogg || echo -logg)
endif
CLIENT_CFLAGS += $(OGG_CFLAGS)
CLIENT_LIBS += $(OGG_LIBS)
endif
ifeq ($(USE_RENDERER_DLOPEN),1)
@ -1032,28 +1037,43 @@ ifeq ($(USE_VOIP),1)
CLIENT_CFLAGS += -DUSE_VOIP
SERVER_CFLAGS += -DUSE_VOIP
ifeq ($(USE_INTERNAL_SPEEX),1)
CLIENT_CFLAGS += -DFLOATING_POINT -DUSE_ALLOCA -I$(SPEEXDIR)/include
SPEEX_CFLAGS += -DFLOATING_POINT -DUSE_ALLOCA -I$(SPEEXDIR)/include
else
CLIENT_LIBS += -lspeex -lspeexdsp
SPEEX_CFLAGS ?= $(shell pkg-config --silence-errors --cflags speex speexdsp || true)
SPEEX_LIBS ?= $(shell pkg-config --silence-errors --libs speex speexdsp || echo -lspeex -lspeexdsp)
endif
CLIENT_CFLAGS += $(SPEEX_CFLAGS)
CLIENT_LIBS += $(SPEEX_LIBS)
endif
ifeq ($(USE_INTERNAL_ZLIB),1)
BASE_CFLAGS += -DNO_GZIP
BASE_CFLAGS += -I$(ZDIR)
ZLIB_CFLAGS = -DNO_GZIP -I$(ZDIR)
else
LIBS += -lz
ZLIB_CFLAGS ?= $(shell pkg-config --silence-errors --cflags zlib || true)
ZLIB_LIBS ?= $(shell pkg-config --silence-errors --libs zlib || echo -lz)
endif
BASE_CFLAGS += $(ZLIB_CFLAGS)
LIBS += $(ZLIB_LIBS)
ifeq ($(USE_INTERNAL_JPEG),1)
BASE_CFLAGS += -DUSE_INTERNAL_JPEG
BASE_CFLAGS += -I$(JPDIR)
else
RENDERER_LIBS += -ljpeg
# libjpeg doesn't have pkg-config yet, but let users override with
# "make JPEG_CFLAGS=-I/opt/jpeg/include JPEG_LIBS='-L/opt/jpeg/lib -ljpeg'"
# if they need to
JPEG_CFLAGS ?=
JPEG_LIBS ?= -ljpeg
BASE_CFLAGS += $(JPEG_CFLAGS)
RENDERER_LIBS += $(JPEG_LIBS)
endif
ifeq ($(USE_FREETYPE),1)
RENDERER_LIBS += -lfreetype
FREETYPE_CFLAGS ?= $(shell pkg-config --silence-errors --cflags freetype2 || true)
FREETYPE_LIBS ?= $(shell pkg-config --silence-errors --libs freetype2 || echo -lfreetype)
BASE_CFLAGS += -DBUILD_FREETYPE $(FREETYPE_CFLAGS)
RENDERER_LIBS += $(FREETYPE_LIBS)
endif
ifeq ("$(CC)", $(findstring "$(CC)", "clang" "clang++"))

View file

@ -98,6 +98,10 @@ Makefile.local:
USE_CODEC_OPUS - enable Ogg Opus support
USE_MUMBLE - enable Mumble support
USE_VOIP - enable built-in VoIP support
USE_INTERNAL_LIBS - build internal libraries instead of dynamically
linking against system libraries; this just sets
the default for USE_INTERNAL_SPEEX etc.
and USE_LOCAL_HEADERS
USE_INTERNAL_SPEEX - build internal speex library instead of dynamically
linking against system libspeex
USE_FREETYPE - enable FreeType support for rendering fonts

View file

@ -677,7 +677,7 @@ void Con_DrawSolidConsole( float frac ) {
// draw the text
con.vislines = lines;
rows = (lines-SMALLCHAR_WIDTH)/SMALLCHAR_WIDTH; // rows of text to draw
rows = (lines-SMALLCHAR_HEIGHT)/SMALLCHAR_HEIGHT; // rows of text to draw
y = lines - (SMALLCHAR_HEIGHT*3);

View file

@ -253,7 +253,7 @@ void MField_CharEvent( mfield_t *edit, int ch ) {
return;
}
if ( !trap_Key_GetOverstrikeMode() ) {
if ( trap_Key_GetOverstrikeMode() ) {
if ((edit->cursor == MAX_EDIT_LINE - 1) || (edit->maxchars && edit->cursor >= edit->maxchars))
return;
} else {

View file

@ -600,6 +600,10 @@ void SkipRestOfLine ( char **data ) {
int c;
p = *data;
if ( !*p )
return;
while ( (c = *p++) != 0 ) {
if ( c == '\n' ) {
com_lines++;

View file

@ -1087,8 +1087,9 @@ void VM_Compile(vm_t *vm, vmHeader_t *header)
// ensure that the optimisation pass knows about all the jump
// table targets
pc = -1; // a bogus value to be printed in out-of-bounds error messages
for( i = 0; i < vm->numJumpTableTargets; i++ ) {
jused[ *(int *)(vm->jumpTableTargets + ( i * sizeof( int ) ) ) ] = 1;
JUSED( *(int *)(vm->jumpTableTargets + ( i * sizeof( int ) ) ) );
}
// Start buffer with x86-VM specific procedures

View file

@ -1,15 +1,17 @@
uniform sampler2D u_ScreenDepthMap;
uniform sampler2D u_ShadowMap;
uniform sampler2DShadow u_ShadowMap;
#if defined(USE_SHADOW_CASCADE)
uniform sampler2D u_ShadowMap2;
uniform sampler2D u_ShadowMap3;
uniform sampler2DShadow u_ShadowMap2;
uniform sampler2DShadow u_ShadowMap3;
uniform sampler2DShadow u_ShadowMap4;
#endif
uniform mat4 u_ShadowMvp;
#if defined(USE_SHADOW_CASCADE)
uniform mat4 u_ShadowMvp2;
uniform mat4 u_ShadowMvp3;
uniform mat4 u_ShadowMvp4;
#endif
uniform vec3 u_ViewOrigin;
@ -39,94 +41,103 @@ float random( const vec2 p )
return mod( 123456789., 1e-7 + 256. * dot(p,r) );
}
float PCF(const sampler2D shadowmap, const vec2 st, const float dist)
float PCF(const sampler2DShadow shadowmap, const vec2 st, const float dist)
{
float mult;
float scale = 2.0 / r_shadowMapSize;
#if 0
// from http://http.developer.nvidia.com/GPUGems/gpugems_ch11.html
vec2 offset = vec2(greaterThan(fract(var_DepthTex.xy * r_FBufScale * 0.5), vec2(0.25)));
offset.y += offset.x;
if (offset.y > 1.1) offset.y = 0.0;
mult = shadow2D(shadowmap, vec3(st + (offset + vec2(-1.5, 0.5)) * scale, dist)).r
+ shadow2D(shadowmap, vec3(st + (offset + vec2( 0.5, 0.5)) * scale, dist)).r
+ shadow2D(shadowmap, vec3(st + (offset + vec2(-1.5, -1.5)) * scale, dist)).r
+ shadow2D(shadowmap, vec3(st + (offset + vec2( 0.5, -1.5)) * scale, dist)).r;
mult *= 0.25;
#endif
#if defined(USE_SHADOW_FILTER)
float r = random(var_DepthTex.xy);
float sinr = sin(r) * scale;
float cosr = cos(r) * scale;
mat2 rmat = mat2(cosr, sinr, -sinr, cosr);
mult = step(dist, texture2D(shadowmap, st + rmat * vec2(-0.7055767, 0.196515)).r);
mult += step(dist, texture2D(shadowmap, st + rmat * vec2(0.3524343, -0.7791386)).r);
mult += step(dist, texture2D(shadowmap, st + rmat * vec2(0.2391056, 0.9189604)).r);
mult = shadow2D(shadowmap, vec3(st + rmat * vec2(-0.7055767, 0.196515), dist)).r;
mult += shadow2D(shadowmap, vec3(st + rmat * vec2(0.3524343, -0.7791386), dist)).r;
mult += shadow2D(shadowmap, vec3(st + rmat * vec2(0.2391056, 0.9189604), dist)).r;
#if defined(USE_SHADOW_FILTER2)
mult += step(dist, texture2D(shadowmap, st + rmat * vec2(-0.07580382, -0.09224417)).r);
mult += step(dist, texture2D(shadowmap, st + rmat * vec2(0.5784913, -0.002528916)).r);
mult += step(dist, texture2D(shadowmap, st + rmat * vec2(0.192888, 0.4064181)).r);
mult += step(dist, texture2D(shadowmap, st + rmat * vec2(-0.6335801, -0.5247476)).r);
mult += step(dist, texture2D(shadowmap, st + rmat * vec2(-0.5579782, 0.7491854)).r);
mult += step(dist, texture2D(shadowmap, st + rmat * vec2(0.7320465, 0.6317794)).r);
mult += shadow2D(shadowmap, vec3(st + rmat * vec2(-0.07580382, -0.09224417), dist)).r;
mult += shadow2D(shadowmap, vec3(st + rmat * vec2(0.5784913, -0.002528916), dist)).r;
mult += shadow2D(shadowmap, vec3(st + rmat * vec2(0.192888, 0.4064181), dist)).r;
mult += shadow2D(shadowmap, vec3(st + rmat * vec2(-0.6335801, -0.5247476), dist)).r;
mult += shadow2D(shadowmap, vec3(st + rmat * vec2(-0.5579782, 0.7491854), dist)).r;
mult += shadow2D(shadowmap, vec3(st + rmat * vec2(0.7320465, 0.6317794), dist)).r;
mult *= 0.11111;
#else
mult *= 0.33333;
#endif
#else
mult = step(dist, texture2D(shadowmap, st).r);
mult = shadow2D(shadowmap, vec3(st, dist)).r;
#endif
return mult;
}
float getLinearDepth(sampler2D depthMap, vec2 tex, float zFarDivZNear)
{
float sampleZDivW = texture2D(depthMap, tex).r;
sampleZDivW -= DEPTH_MAX_ERROR;
return 1.0 / mix(zFarDivZNear, 1.0, sampleZDivW);
float sampleZDivW = texture2D(depthMap, tex).r - DEPTH_MAX_ERROR;
return 1.0 / mix(zFarDivZNear, 1.0, sampleZDivW);
}
void main()
{
float result;
float depth = getLinearDepth(u_ScreenDepthMap, var_DepthTex, u_ViewInfo.x);
float sampleZ = u_ViewInfo.y * depth;
vec4 biasPos = vec4(u_ViewOrigin + var_ViewDir * (depth - 0.5 / u_ViewInfo.x), 1.0);
vec4 shadowpos = u_ShadowMvp * biasPos;
#if defined(USE_SHADOW_CASCADE)
const float fadeTo = 1.0;
result = fadeTo;
#else
result = 0.0;
#endif
if (all(lessThanEqual(abs(shadowpos.xyz), vec3(abs(shadowpos.w)))))
{
shadowpos.xyz = shadowpos.xyz / shadowpos.w * 0.5 + 0.5;
result = PCF(u_ShadowMap, shadowpos.xy, shadowpos.z);
}
vec4 shadowpos = u_ShadowMvp * biasPos;
#if defined(USE_SHADOW_CASCADE)
if (all(lessThan(abs(shadowpos.xyz), vec3(abs(shadowpos.w)))))
{
#endif
shadowpos.xyz = shadowpos.xyz * (0.5 / shadowpos.w) + vec3(0.5);
result = PCF(u_ShadowMap, shadowpos.xy, shadowpos.z);
#if defined(USE_SHADOW_CASCADE)
}
else
{
shadowpos = u_ShadowMvp2 * biasPos;
if (all(lessThanEqual(abs(shadowpos.xyz), vec3(abs(shadowpos.w)))))
if (all(lessThan(abs(shadowpos.xyz), vec3(abs(shadowpos.w)))))
{
shadowpos.xyz = shadowpos.xyz / shadowpos.w * 0.5 + 0.5;
shadowpos.xyz = shadowpos.xyz * (0.5 / shadowpos.w) + vec3(0.5);
result = PCF(u_ShadowMap2, shadowpos.xy, shadowpos.z);
}
else
{
shadowpos = u_ShadowMvp3 * biasPos;
if (all(lessThanEqual(abs(shadowpos.xyz), vec3(abs(shadowpos.w)))))
if (all(lessThan(abs(shadowpos.xyz), vec3(abs(shadowpos.w)))))
{
shadowpos.xyz = shadowpos.xyz / shadowpos.w * 0.5 + 0.5;
shadowpos.xyz = shadowpos.xyz * (0.5 / shadowpos.w) + vec3(0.5);
result = PCF(u_ShadowMap3, shadowpos.xy, shadowpos.z);
float fade = clamp(sampleZ / r_shadowCascadeZFar * 10.0 - 9.0, 0.0, 1.0);
result = mix(result, fadeTo, fade);
}
else
{
shadowpos = u_ShadowMvp4 * biasPos;
shadowpos.xyz = shadowpos.xyz * (0.5 / shadowpos.w) + vec3(0.5);
result = PCF(u_ShadowMap4, shadowpos.xy, shadowpos.z);
}
}
}
#endif
gl_FragColor = vec4(vec3(result), 1.0);
}

View file

@ -1122,13 +1122,24 @@ const void *RB_DrawSurfs( const void *data ) {
GLSL_BindProgram(&tr.shadowmaskShader);
GL_BindToTMU(tr.renderDepthImage, TB_COLORMAP);
GL_BindToTMU(tr.sunShadowDepthImage[0], TB_SHADOWMAP);
GL_BindToTMU(tr.sunShadowDepthImage[1], TB_SHADOWMAP2);
GL_BindToTMU(tr.sunShadowDepthImage[2], TB_SHADOWMAP3);
if (r_shadowCascadeZFar->integer != 0)
{
GL_BindToTMU(tr.sunShadowDepthImage[0], TB_SHADOWMAP);
GL_BindToTMU(tr.sunShadowDepthImage[1], TB_SHADOWMAP2);
GL_BindToTMU(tr.sunShadowDepthImage[2], TB_SHADOWMAP3);
GL_BindToTMU(tr.sunShadowDepthImage[3], TB_SHADOWMAP4);
GLSL_SetUniformMat4(&tr.shadowmaskShader, UNIFORM_SHADOWMVP, backEnd.refdef.sunShadowMvp[0]);
GLSL_SetUniformMat4(&tr.shadowmaskShader, UNIFORM_SHADOWMVP2, backEnd.refdef.sunShadowMvp[1]);
GLSL_SetUniformMat4(&tr.shadowmaskShader, UNIFORM_SHADOWMVP3, backEnd.refdef.sunShadowMvp[2]);
GLSL_SetUniformMat4(&tr.shadowmaskShader, UNIFORM_SHADOWMVP, backEnd.refdef.sunShadowMvp[0]);
GLSL_SetUniformMat4(&tr.shadowmaskShader, UNIFORM_SHADOWMVP2, backEnd.refdef.sunShadowMvp[1]);
GLSL_SetUniformMat4(&tr.shadowmaskShader, UNIFORM_SHADOWMVP3, backEnd.refdef.sunShadowMvp[2]);
GLSL_SetUniformMat4(&tr.shadowmaskShader, UNIFORM_SHADOWMVP4, backEnd.refdef.sunShadowMvp[3]);
}
else
{
GL_BindToTMU(tr.sunShadowDepthImage[3], TB_SHADOWMAP);
GLSL_SetUniformMat4(&tr.shadowmaskShader, UNIFORM_SHADOWMVP, backEnd.refdef.sunShadowMvp[3]);
}
GLSL_SetUniformVec3(&tr.shadowmaskShader, UNIFORM_VIEWORIGIN, backEnd.refdef.vieworg);
{
@ -1681,6 +1692,8 @@ const void *RB_PostProcess(const void *data)
FBO_BlitFromTexture(tr.sunShadowDepthImage[1], NULL, NULL, NULL, dstBox, NULL, NULL, 0);
VectorSet4(dstBox, 256, 0, 128, 128);
FBO_BlitFromTexture(tr.sunShadowDepthImage[2], NULL, NULL, NULL, dstBox, NULL, NULL, 0);
VectorSet4(dstBox, 384, 0, 128, 128);
FBO_BlitFromTexture(tr.sunShadowDepthImage[3], NULL, NULL, NULL, dstBox, NULL, NULL, 0);
}
if (0)

View file

@ -3313,6 +3313,9 @@ void RE_LoadWorldMap( const char *name ) {
tr.toneMinAvgMaxLevel[1] = -2.0f;
tr.toneMinAvgMaxLevel[2] = 0.0f;
// reset last cascade sun direction so last shadow cascade is rerendered
VectorClear(tr.lastCascadeSunDirection);
tr.worldMapLoaded = qtrue;
// load it

View file

@ -56,9 +56,6 @@ void Mat4SimpleInverse( const mat4_t in, mat4_t out);
#define ByteToFloat(a) ((float)(a) * 1.0f/255.0f)
#define FloatToByte(a) (byte)((a) * 255.0f)
#define RGBtosRGB(a) (((a) < 0.0031308f) ? (12.92f * (a)) : (1.055f * pow((a), 0.41666f) - 0.055f))
#define sRGBtoRGB(a) (((a) <= 0.04045f) ? ((a) / 12.92f) : (pow((((a) + 0.055f) / 1.055f), 2.4)) )
static ID_INLINE int VectorCompare4(const vec4_t v1, const vec4_t v2)
{
if(v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2] || v1[3] != v2[3])

View file

@ -484,7 +484,7 @@ void FBO_Init(void)
if (tr.sunShadowDepthImage[0])
{
for ( i = 0; i < 3; i++)
for ( i = 0; i < 4; i++)
{
tr.sunShadowFbo[i] = FBO_Create("_sunshadowmap", tr.sunShadowDepthImage[i]->width, tr.sunShadowDepthImage[i]->height);
FBO_Bind(tr.sunShadowFbo[i]);

View file

@ -79,10 +79,12 @@ static uniformInfo_t uniformsInfo[] =
{ "u_ShadowMap", GLSL_INT },
{ "u_ShadowMap2", GLSL_INT },
{ "u_ShadowMap3", GLSL_INT },
{ "u_ShadowMap4", GLSL_INT },
{ "u_ShadowMvp", GLSL_MAT16 },
{ "u_ShadowMvp2", GLSL_MAT16 },
{ "u_ShadowMvp3", GLSL_MAT16 },
{ "u_ShadowMvp4", GLSL_MAT16 },
{ "u_EnableTextures", GLSL_VEC4 },
@ -400,24 +402,30 @@ static int GLSL_LoadGPUShaderText(const char *name, const char *fallback,
Com_sprintf(filename, sizeof(filename), "glsl/%s_fp.glsl", name);
}
ri.Printf(PRINT_DEVELOPER, "...loading '%s'\n", filename);
size = ri.FS_ReadFile(filename, (void **)&buffer);
if ( r_externalGLSL->integer ) {
size = ri.FS_ReadFile(filename, (void **)&buffer);
} else {
size = 0;
buffer = NULL;
}
if(!buffer)
{
if (fallback)
{
ri.Printf(PRINT_DEVELOPER, "couldn't load, using fallback\n");
ri.Printf(PRINT_DEVELOPER, "...loading built-in '%s'\n", filename);
shaderText = fallback;
size = strlen(shaderText);
}
else
{
ri.Printf(PRINT_DEVELOPER, "couldn't load!\n");
ri.Printf(PRINT_DEVELOPER, "couldn't load '%s'\n", filename);
return 0;
}
}
else
{
ri.Printf(PRINT_DEVELOPER, "...loading '%s'\n", filename);
shaderText = buffer;
}
@ -1296,7 +1304,8 @@ void GLSL_InitGPUShaders(void)
if (r_shadowFilter->integer >= 2)
Q_strcat(extradefines, 1024, "#define USE_SHADOW_FILTER2\n");
Q_strcat(extradefines, 1024, "#define USE_SHADOW_CASCADE\n");
if (r_shadowCascadeZFar->integer != 0)
Q_strcat(extradefines, 1024, "#define USE_SHADOW_CASCADE\n");
Q_strcat(extradefines, 1024, va("#define r_shadowMapSize %d\n", r_shadowMapSize->integer));
Q_strcat(extradefines, 1024, va("#define r_shadowCascadeZFar %f\n", r_shadowCascadeZFar->value));
@ -1314,6 +1323,7 @@ void GLSL_InitGPUShaders(void)
GLSL_SetUniformInt(&tr.shadowmaskShader, UNIFORM_SHADOWMAP, TB_SHADOWMAP);
GLSL_SetUniformInt(&tr.shadowmaskShader, UNIFORM_SHADOWMAP2, TB_SHADOWMAP2);
GLSL_SetUniformInt(&tr.shadowmaskShader, UNIFORM_SHADOWMAP3, TB_SHADOWMAP3);
GLSL_SetUniformInt(&tr.shadowmaskShader, UNIFORM_SHADOWMAP4, TB_SHADOWMAP4);
qglUseProgramObjectARB(0);
GLSL_FinishGPUShader(&tr.shadowmaskShader);

View file

@ -1272,47 +1272,65 @@ void R_LightScaleTexture (byte *in, int inwidth, int inheight, qboolean only_gam
}
}
/*
================
R_MipMapsRGB
Operates in place, quartering the size of the texture
Colors are gamma correct
================
*/
static void R_MipMapsRGB( byte *in, int inWidth, int inHeight)
{
int i, j, k;
int outWidth, outHeight;
byte *temp;
int x, y, c, stride;
const byte *in2;
float total;
static float downmipSrgbLookup[256];
static int downmipSrgbLookupSet = 0;
byte *out = in;
outWidth = inWidth >> 1;
outHeight = inHeight >> 1;
temp = ri.Hunk_AllocateTempMemory( outWidth * outHeight * 4 );
for ( i = 0 ; i < outHeight ; i++ ) {
byte *outbyte = temp + ( i * outWidth ) * 4;
byte *inbyte1 = in + ( i * 2 * inWidth ) * 4;
byte *inbyte2 = in + ( (i * 2 + 1) * inWidth ) * 4;
for ( j = 0 ; j < outWidth ; j++ ) {
for ( k = 0 ; k < 3 ; k++ ) {
float total, current;
current = ByteToFloat(inbyte1[0]); total = sRGBtoRGB(current);
current = ByteToFloat(inbyte1[4]); total += sRGBtoRGB(current);
current = ByteToFloat(inbyte2[0]); total += sRGBtoRGB(current);
current = ByteToFloat(inbyte2[4]); total += sRGBtoRGB(current);
total *= 0.25f;
inbyte1++;
inbyte2++;
current = RGBtosRGB(total);
*outbyte++ = FloatToByte(current);
}
*outbyte++ = (inbyte1[0] + inbyte1[4] + inbyte2[0] + inbyte2[4]) >> 2;
inbyte1 += 5;
inbyte2 += 5;
}
if (!downmipSrgbLookupSet) {
for (x = 0; x < 256; x++)
downmipSrgbLookup[x] = powf(x / 255.0f, 2.2f) * 0.25f;
downmipSrgbLookupSet = 1;
}
Com_Memcpy( in, temp, outWidth * outHeight * 4 );
ri.Hunk_FreeTempMemory( temp );
if (inWidth == 1 && inHeight == 1)
return;
if (inWidth == 1 || inHeight == 1) {
for (x = (inWidth * inHeight) >> 1; x; x--) {
for (c = 3; c; c--, in++) {
total = (downmipSrgbLookup[*(in)] + downmipSrgbLookup[*(in + 4)]) * 2.0f;
*out++ = (byte)(powf(total, 1.0f / 2.2f) * 255.0f);
}
*out++ = (*(in) + *(in + 4)) >> 1; in += 5;
}
return;
}
stride = inWidth * 4;
inWidth >>= 1; inHeight >>= 1;
in2 = in + stride;
for (y = inHeight; y; y--, in += stride, in2 += stride) {
for (x = inWidth; x; x--) {
for (c = 3; c; c--, in++, in2++) {
total = downmipSrgbLookup[*(in)] + downmipSrgbLookup[*(in + 4)]
+ downmipSrgbLookup[*(in2)] + downmipSrgbLookup[*(in2 + 4)];
*out++ = (byte)(powf(total, 1.0f / 2.2f) * 255.0f);
}
*out++ = (*(in) + *(in + 4) + *(in2) + *(in2 + 4)) >> 2; in += 5, in2 += 5;
}
}
}
static void R_MipMapLuminanceAlpha (const byte *in, byte *out, int width, int height)
{
int i, j, row;
@ -2816,9 +2834,14 @@ void R_CreateBuiltinImages( void ) {
if (r_sunlightMode->integer)
{
for ( x = 0; x < 3; x++)
for ( x = 0; x < 4; x++)
{
tr.sunShadowDepthImage[x] = R_CreateImage(va("*sunshadowdepth%i", x), NULL, r_shadowMapSize->integer, r_shadowMapSize->integer, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24_ARB);
GL_Bind(tr.sunShadowDepthImage[x]);
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
}
tr.screenShadowImage = R_CreateImage("*screenShadow", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8);

View file

@ -110,6 +110,8 @@ cvar_t *r_mergeLeafSurfaces;
cvar_t *r_cameraExposure;
cvar_t *r_externalGLSL;
cvar_t *r_hdr;
cvar_t *r_floatLightmap;
cvar_t *r_postProcess;
@ -1166,6 +1168,8 @@ void R_Register( void )
r_greyscale = ri.Cvar_Get("r_greyscale", "0", CVAR_ARCHIVE | CVAR_LATCH);
ri.Cvar_CheckRange(r_greyscale, 0, 1, qfalse);
r_externalGLSL = ri.Cvar_Get( "r_externalGLSL", "0", CVAR_LATCH );
r_hdr = ri.Cvar_Get( "r_hdr", "1", CVAR_ARCHIVE | CVAR_LATCH );
r_floatLightmap = ri.Cvar_Get( "r_floatLightmap", "0", CVAR_ARCHIVE | CVAR_LATCH );
r_postProcess = ri.Cvar_Get( "r_postProcess", "1", CVAR_ARCHIVE );
@ -1221,9 +1225,9 @@ void R_Register( void )
r_sunShadows = ri.Cvar_Get( "r_sunShadows", "1", CVAR_ARCHIVE | CVAR_LATCH );
r_shadowFilter = ri.Cvar_Get( "r_shadowFilter", "1", CVAR_ARCHIVE | CVAR_LATCH );
r_shadowMapSize = ri.Cvar_Get( "r_shadowMapSize", "1024", CVAR_ARCHIVE | CVAR_LATCH );
r_shadowCascadeZNear = ri.Cvar_Get( "r_shadowCascadeZNear", "4", CVAR_ARCHIVE | CVAR_LATCH );
r_shadowCascadeZFar = ri.Cvar_Get( "r_shadowCascadeZFar", "3072", CVAR_ARCHIVE | CVAR_LATCH );
r_shadowCascadeZBias = ri.Cvar_Get( "r_shadowCascadeZBias", "-320", CVAR_ARCHIVE | CVAR_LATCH );
r_shadowCascadeZNear = ri.Cvar_Get( "r_shadowCascadeZNear", "8", CVAR_ARCHIVE | CVAR_LATCH );
r_shadowCascadeZFar = ri.Cvar_Get( "r_shadowCascadeZFar", "1024", CVAR_ARCHIVE | CVAR_LATCH );
r_shadowCascadeZBias = ri.Cvar_Get( "r_shadowCascadeZBias", "0", CVAR_ARCHIVE | CVAR_LATCH );
r_ignoreDstAlpha = ri.Cvar_Get( "r_ignoreDstAlpha", "1", CVAR_ARCHIVE | CVAR_LATCH );
//

View file

@ -364,6 +364,7 @@ enum
TB_SPECULARMAP = 4,
TB_SHADOWMAP = 5,
TB_CUBEMAP = 6,
TB_SHADOWMAP4 = 6,
NUM_TEXTURE_BUNDLES = 7
};
@ -633,10 +634,12 @@ typedef enum
UNIFORM_SHADOWMAP,
UNIFORM_SHADOWMAP2,
UNIFORM_SHADOWMAP3,
UNIFORM_SHADOWMAP4,
UNIFORM_SHADOWMVP,
UNIFORM_SHADOWMVP2,
UNIFORM_SHADOWMVP3,
UNIFORM_SHADOWMVP4,
UNIFORM_ENABLETEXTURES,
@ -760,7 +763,7 @@ typedef struct {
int num_pshadows;
struct pshadow_s *pshadows;
float sunShadowMvp[3][16];
float sunShadowMvp[4][16];
float sunDir[4];
float sunCol[4];
float sunAmbCol[4];
@ -1534,7 +1537,7 @@ typedef struct {
image_t *calcLevelsImage;
image_t *targetLevelsImage;
image_t *fixedLevelsImage;
image_t *sunShadowDepthImage[3];
image_t *sunShadowDepthImage[4];
image_t *screenShadowImage;
image_t *screenSsaoImage;
image_t *hdrDepthImage;
@ -1551,7 +1554,7 @@ typedef struct {
FBO_t *quarterFbo[2];
FBO_t *calcLevelsFbo;
FBO_t *targetLevelsFbo;
FBO_t *sunShadowFbo[3];
FBO_t *sunShadowFbo[4];
FBO_t *screenShadowFbo;
FBO_t *screenSsaoFbo;
FBO_t *hdrDepthFbo;
@ -1623,6 +1626,8 @@ typedef struct {
qboolean sunShadows;
vec3_t sunLight; // from the sky shader for this level
vec3_t sunDirection;
vec3_t lastCascadeSunDirection;
float lastCascadeSunMvp[16];
frontEndCounters_t pc;
int frontEndMsec; // not in pc due to clearing issue
@ -1766,6 +1771,8 @@ extern cvar_t *r_anaglyphMode;
extern cvar_t *r_mergeMultidraws;
extern cvar_t *r_mergeLeafSurfaces;
extern cvar_t *r_externalGLSL;
extern cvar_t *r_hdr;
extern cvar_t *r_floatLightmap;
extern cvar_t *r_postProcess;

View file

@ -2572,14 +2572,16 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level)
//splitZFar = 3072;
break;
}
VectorCopy(fd->vieworg, lightOrigin);
if (level != 3)
VectorCopy(fd->vieworg, lightOrigin);
else
VectorCopy(tr.world->lightGridOrigin, lightOrigin);
// Make up a projection
VectorScale(lightDir, -1.0f, lightViewAxis[0]);
if (lightViewIndependentOfCameraView)
if (level == 3 || lightViewIndependentOfCameraView)
{
// Use world up as light view up
VectorSet(lightViewAxis[2], 0, 0, 1);
@ -2599,7 +2601,7 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level)
// Check if too close to parallel to light direction
if (abs(DotProduct(lightViewAxis[2], lightViewAxis[0])) > 0.9f)
{
if (lightViewIndependentOfCameraView)
if (level == 3 || lightViewIndependentOfCameraView)
{
// Use world left as light view up
VectorSet(lightViewAxis[2], 0, 1, 0);
@ -2636,56 +2638,117 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level)
ClearBounds(lightviewBounds[0], lightviewBounds[1]);
// add view near plane
lx = splitZNear * tan(fd->fov_x * M_PI / 360.0f);
ly = splitZNear * tan(fd->fov_y * M_PI / 360.0f);
VectorMA(fd->vieworg, splitZNear, fd->viewaxis[0], base);
if (level != 3)
{
// add view near plane
lx = splitZNear * tan(fd->fov_x * M_PI / 360.0f);
ly = splitZNear * tan(fd->fov_y * M_PI / 360.0f);
VectorMA(fd->vieworg, splitZNear, fd->viewaxis[0], base);
VectorMA(base, lx, fd->viewaxis[1], point);
VectorMA(point, ly, fd->viewaxis[2], point);
Mat4Transform(lightViewMatrix, point, lightViewPoint);
AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]);
VectorMA(base, lx, fd->viewaxis[1], point);
VectorMA(point, ly, fd->viewaxis[2], point);
Mat4Transform(lightViewMatrix, point, lightViewPoint);
AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]);
VectorMA(base, -lx, fd->viewaxis[1], point);
VectorMA(point, ly, fd->viewaxis[2], point);
Mat4Transform(lightViewMatrix, point, lightViewPoint);
AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]);
VectorMA(base, -lx, fd->viewaxis[1], point);
VectorMA(point, ly, fd->viewaxis[2], point);
Mat4Transform(lightViewMatrix, point, lightViewPoint);
AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]);
VectorMA(base, lx, fd->viewaxis[1], point);
VectorMA(point, -ly, fd->viewaxis[2], point);
Mat4Transform(lightViewMatrix, point, lightViewPoint);
AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]);
VectorMA(base, lx, fd->viewaxis[1], point);
VectorMA(point, -ly, fd->viewaxis[2], point);
Mat4Transform(lightViewMatrix, point, lightViewPoint);
AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]);
VectorMA(base, -lx, fd->viewaxis[1], point);
VectorMA(point, -ly, fd->viewaxis[2], point);
Mat4Transform(lightViewMatrix, point, lightViewPoint);
AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]);
VectorMA(base, -lx, fd->viewaxis[1], point);
VectorMA(point, -ly, fd->viewaxis[2], point);
Mat4Transform(lightViewMatrix, point, lightViewPoint);
AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]);
// add view far plane
lx = splitZFar * tan(fd->fov_x * M_PI / 360.0f);
ly = splitZFar * tan(fd->fov_y * M_PI / 360.0f);
VectorMA(fd->vieworg, splitZFar, fd->viewaxis[0], base);
// add view far plane
lx = splitZFar * tan(fd->fov_x * M_PI / 360.0f);
ly = splitZFar * tan(fd->fov_y * M_PI / 360.0f);
VectorMA(fd->vieworg, splitZFar, fd->viewaxis[0], base);
VectorMA(base, lx, fd->viewaxis[1], point);
VectorMA(point, ly, fd->viewaxis[2], point);
Mat4Transform(lightViewMatrix, point, lightViewPoint);
AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]);
VectorMA(base, lx, fd->viewaxis[1], point);
VectorMA(point, ly, fd->viewaxis[2], point);
Mat4Transform(lightViewMatrix, point, lightViewPoint);
AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]);
VectorMA(base, -lx, fd->viewaxis[1], point);
VectorMA(point, ly, fd->viewaxis[2], point);
Mat4Transform(lightViewMatrix, point, lightViewPoint);
AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]);
VectorMA(base, -lx, fd->viewaxis[1], point);
VectorMA(point, ly, fd->viewaxis[2], point);
Mat4Transform(lightViewMatrix, point, lightViewPoint);
AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]);
VectorMA(base, lx, fd->viewaxis[1], point);
VectorMA(point, -ly, fd->viewaxis[2], point);
Mat4Transform(lightViewMatrix, point, lightViewPoint);
AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]);
VectorMA(base, lx, fd->viewaxis[1], point);
VectorMA(point, -ly, fd->viewaxis[2], point);
Mat4Transform(lightViewMatrix, point, lightViewPoint);
AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]);
VectorMA(base, -lx, fd->viewaxis[1], point);
VectorMA(point, -ly, fd->viewaxis[2], point);
Mat4Transform(lightViewMatrix, point, lightViewPoint);
AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]);
VectorMA(base, -lx, fd->viewaxis[1], point);
VectorMA(point, -ly, fd->viewaxis[2], point);
Mat4Transform(lightViewMatrix, point, lightViewPoint);
AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]);
}
else
{
// use light grid size as level size
// FIXME: could be tighter
vec3_t bounds;
bounds[0] = tr.world->lightGridSize[0] * tr.world->lightGridBounds[0];
bounds[1] = tr.world->lightGridSize[1] * tr.world->lightGridBounds[1];
bounds[2] = tr.world->lightGridSize[2] * tr.world->lightGridBounds[2];
point[0] = tr.world->lightGridOrigin[0];
point[1] = tr.world->lightGridOrigin[1];
point[2] = tr.world->lightGridOrigin[2];
Mat4Transform(lightViewMatrix, point, lightViewPoint);
AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]);
point[0] = tr.world->lightGridOrigin[0] + bounds[0];
point[1] = tr.world->lightGridOrigin[1];
point[2] = tr.world->lightGridOrigin[2];
Mat4Transform(lightViewMatrix, point, lightViewPoint);
AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]);
point[0] = tr.world->lightGridOrigin[0];
point[1] = tr.world->lightGridOrigin[1] + bounds[1];
point[2] = tr.world->lightGridOrigin[2];
Mat4Transform(lightViewMatrix, point, lightViewPoint);
AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]);
point[0] = tr.world->lightGridOrigin[0] + bounds[0];
point[1] = tr.world->lightGridOrigin[1] + bounds[1];
point[2] = tr.world->lightGridOrigin[2];
Mat4Transform(lightViewMatrix, point, lightViewPoint);
AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]);
point[0] = tr.world->lightGridOrigin[0];
point[1] = tr.world->lightGridOrigin[1];
point[2] = tr.world->lightGridOrigin[2] + bounds[2];
Mat4Transform(lightViewMatrix, point, lightViewPoint);
AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]);
point[0] = tr.world->lightGridOrigin[0] + bounds[0];
point[1] = tr.world->lightGridOrigin[1];
point[2] = tr.world->lightGridOrigin[2] + bounds[2];
Mat4Transform(lightViewMatrix, point, lightViewPoint);
AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]);
point[0] = tr.world->lightGridOrigin[0];
point[1] = tr.world->lightGridOrigin[1] + bounds[1];
point[2] = tr.world->lightGridOrigin[2] + bounds[2];
Mat4Transform(lightViewMatrix, point, lightViewPoint);
AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]);
point[0] = tr.world->lightGridOrigin[0] + bounds[0];
point[1] = tr.world->lightGridOrigin[1] + bounds[1];
point[2] = tr.world->lightGridOrigin[2] + bounds[2];
Mat4Transform(lightViewMatrix, point, lightViewPoint);
AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]);
}
if (!glRefConfig.depthClamp)
lightviewBounds[0][0] = lightviewBounds[1][0] - 8192;
@ -2715,11 +2778,10 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level)
VectorScale(lightviewBounds[1], worldUnitsPerTexel, lightviewBounds[1]);
}
//ri.Printf(PRINT_ALL, "znear %f zfar %f\n", lightviewBounds[0][0], lightviewBounds[1][0]);
//ri.Printf(PRINT_ALL, "fovx %f fovy %f xmin %f xmax %f ymin %f ymax %f\n", fd->fov_x, fd->fov_y, xmin, xmax, ymin, ymax);
//ri.Printf(PRINT_ALL, "level %d znear %f zfar %f\n", level, lightviewBounds[0][0], lightviewBounds[1][0]);
//ri.Printf(PRINT_ALL, "xmin %f xmax %f ymin %f ymax %f\n", lightviewBounds[0][1], lightviewBounds[1][1], -lightviewBounds[1][2], -lightviewBounds[0][2]);
}
{
int firstDrawSurf;
@ -2857,6 +2919,7 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene )
R_RenderSunShadowMaps(&refdef, 0);
R_RenderSunShadowMaps(&refdef, 1);
R_RenderSunShadowMaps(&refdef, 2);
R_RenderSunShadowMaps(&refdef, 3);
}
}

View file

@ -498,9 +498,30 @@ void RE_RenderScene( const refdef_t *fd ) {
// playing with even more shadows
if(glRefConfig.framebufferObject && r_sunlightMode->integer && !( fd->rdflags & RDF_NOWORLDMODEL ) && (r_forceSun->integer || tr.sunShadows))
{
R_RenderSunShadowMaps(fd, 0);
R_RenderSunShadowMaps(fd, 1);
R_RenderSunShadowMaps(fd, 2);
if (r_shadowCascadeZFar != 0)
{
R_RenderSunShadowMaps(fd, 0);
R_RenderSunShadowMaps(fd, 1);
R_RenderSunShadowMaps(fd, 2);
}
else
{
Mat4Zero(tr.refdef.sunShadowMvp[0]);
Mat4Zero(tr.refdef.sunShadowMvp[1]);
Mat4Zero(tr.refdef.sunShadowMvp[2]);
}
// only rerender last cascade if sun has changed position
if (r_forceSun->integer == 2 || !VectorCompare(tr.refdef.sunDir, tr.lastCascadeSunDirection))
{
VectorCopy(tr.refdef.sunDir, tr.lastCascadeSunDirection);
R_RenderSunShadowMaps(fd, 3);
Mat4Copy(tr.refdef.sunShadowMvp[3], tr.lastCascadeSunMvp);
}
else
{
Mat4Copy(tr.lastCascadeSunMvp, tr.refdef.sunShadowMvp[3]);
}
}
// playing with cube maps

View file

@ -330,7 +330,7 @@ static void R_AddWorldSurface( msurface_t *surf, int dlightBits, int pshadowBits
}
// check for dlighting
if ( dlightBits ) {
/*if ( dlightBits ) */{
dlightBits = R_DlightSurface( surf, dlightBits );
dlightBits = ( dlightBits != 0 );
}

View file

@ -44,7 +44,6 @@ static cvar_t *in_mouse = NULL;
static cvar_t *in_nograb;
static cvar_t *in_joystick = NULL;
static cvar_t *in_joystickDebug = NULL;
static cvar_t *in_joystickThreshold = NULL;
static cvar_t *in_joystickNo = NULL;
static cvar_t *in_joystickUseAnalog = NULL;
@ -507,7 +506,6 @@ IN_JoyMove
*/
static void IN_JoyMove( void )
{
qboolean joy_pressed[ARRAY_LEN(joy_keys)];
unsigned int axes = 0;
unsigned int hats = 0;
int total = 0;
@ -518,8 +516,6 @@ static void IN_JoyMove( void )
SDL_JoystickUpdate();
memset(joy_pressed, '\0', sizeof (joy_pressed));
// update the ball state.
total = SDL_JoystickNumBalls(stick);
if (total > 0)
@ -951,7 +947,6 @@ void IN_Init( void *windowData )
in_nograb = Cvar_Get( "in_nograb", "0", CVAR_ARCHIVE );
in_joystick = Cvar_Get( "in_joystick", "0", CVAR_ARCHIVE|CVAR_LATCH );
in_joystickDebug = Cvar_Get( "in_joystickDebug", "0", CVAR_TEMP );
in_joystickThreshold = Cvar_Get( "joy_threshold", "0.15", CVAR_ARCHIVE );
SDL_StartTextInput( );

View file

@ -61,6 +61,7 @@
WarningLevel="4"
SuppressStartupBanner="true"
CompileAs="1"
FloatingPointModel="2"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -161,6 +162,7 @@
SuppressStartupBanner="true"
DebugInformationFormat="4"
CompileAs="1"
FloatingPointModel="2"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -263,6 +265,7 @@
WarningLevel="4"
SuppressStartupBanner="true"
CompileAs="1"
FloatingPointModel="2"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -361,6 +364,7 @@
SuppressStartupBanner="true"
DebugInformationFormat="4"
CompileAs="1"
FloatingPointModel="2"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View file

@ -63,6 +63,7 @@
WarningLevel="4"
SuppressStartupBanner="true"
CompileAs="1"
FloatingPointModel="2"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -164,6 +165,7 @@
SuppressStartupBanner="true"
DebugInformationFormat="4"
CompileAs="1"
FloatingPointModel="2"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -267,6 +269,7 @@
WarningLevel="4"
SuppressStartupBanner="true"
CompileAs="1"
FloatingPointModel="2"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -366,6 +369,7 @@
SuppressStartupBanner="true"
DebugInformationFormat="4"
CompileAs="1"
FloatingPointModel="2"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View file

@ -60,6 +60,7 @@
WarningLevel="4"
SuppressStartupBanner="true"
CompileAs="1"
FloatingPointModel="2"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -159,6 +160,7 @@
SuppressStartupBanner="true"
DebugInformationFormat="4"
CompileAs="1"
FloatingPointModel="2"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -260,6 +262,7 @@
WarningLevel="4"
SuppressStartupBanner="true"
CompileAs="1"
FloatingPointModel="2"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -357,6 +360,7 @@
SuppressStartupBanner="true"
DebugInformationFormat="4"
CompileAs="1"
FloatingPointModel="2"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View file

@ -168,6 +168,7 @@
<WarningLevel>Level4</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<CompileAs>CompileAsC</CompileAs>
<FloatingPointModel>Fast</FloatingPointModel>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -220,6 +221,7 @@
<WarningLevel>Level4</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<CompileAs>CompileAsC</CompileAs>
<FloatingPointModel>Fast</FloatingPointModel>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -273,6 +275,7 @@
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>CompileAsC</CompileAs>
<FloatingPointModel>Fast</FloatingPointModel>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -327,6 +330,7 @@
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>CompileAsC</CompileAs>
<FloatingPointModel>Fast</FloatingPointModel>
<CallingConvention>FastCall</CallingConvention>
</ClCompile>
<ResourceCompile>
@ -382,6 +386,7 @@
<WarningLevel>Level4</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<CompileAs>CompileAsC</CompileAs>
<FloatingPointModel>Fast</FloatingPointModel>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -430,6 +435,7 @@
<WarningLevel>Level4</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<CompileAs>CompileAsC</CompileAs>
<FloatingPointModel>Fast</FloatingPointModel>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -478,6 +484,7 @@
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>CompileAsC</CompileAs>
<FloatingPointModel>Fast</FloatingPointModel>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -532,6 +539,7 @@
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>CompileAsC</CompileAs>
<FloatingPointModel>Fast</FloatingPointModel>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>

View file

@ -188,6 +188,7 @@
<WarningLevel>Level4</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<CompileAs>CompileAsC</CompileAs>
<FloatingPointModel>Fast</FloatingPointModel>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -241,6 +242,7 @@
<WarningLevel>Level4</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<CompileAs>CompileAsC</CompileAs>
<FloatingPointModel>Fast</FloatingPointModel>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -294,6 +296,7 @@
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>CompileAsC</CompileAs>
<FloatingPointModel>Fast</FloatingPointModel>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -349,6 +352,7 @@
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>CompileAsC</CompileAs>
<FloatingPointModel>Fast</FloatingPointModel>
<CallingConvention>FastCall</CallingConvention>
</ClCompile>
<ResourceCompile>
@ -404,6 +408,7 @@
<WarningLevel>Level4</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<CompileAs>CompileAsC</CompileAs>
<FloatingPointModel>Fast</FloatingPointModel>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -453,6 +458,7 @@
<WarningLevel>Level4</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<CompileAs>CompileAsC</CompileAs>
<FloatingPointModel>Fast</FloatingPointModel>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -501,6 +507,7 @@
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>CompileAsC</CompileAs>
<FloatingPointModel>Fast</FloatingPointModel>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -556,6 +563,7 @@
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>CompileAsC</CompileAs>
<FloatingPointModel>Fast</FloatingPointModel>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>