ioquake3 resync to revision 6925 from 6920.

Allow unwinding of qvmcall64 call-stub for msvc/masm.
Add epsilon to avoid division by zero in CalcSpecular().
Add r_parallaxMapOffset.
Fix line not removed in previous commit.
OpenGL2: Flip normals for backfacing triangles.
This commit is contained in:
zturtleman 2021-07-30 05:08:47 +00:00
parent ce7c0797c6
commit bcfd420250
7 changed files with 37 additions and 7 deletions

View file

@ -44,7 +44,7 @@ ifndef BUILD_DEFINES
endif endif
# ioquake3 svn version that this is based on # ioquake3 svn version that this is based on
IOQ3_REVISION = 6920 IOQ3_REVISION = 6925
############################################################################# #############################################################################
# #

View file

@ -28,19 +28,35 @@
; Call to compiled code after setting up the register environment for the VM ; Call to compiled code after setting up the register environment for the VM
; prototype: ; prototype:
; uint8_t qvmcall64(int *programStack, int *opStack, intptr_t *instructionPointers, byte *dataBase); ; uint8_t qvmcall64(int *programStack, int *opStack, intptr_t *instructionPointers, byte *dataBase);
;
; This call-stub has its own custom calling convention due to pushing all non-volatile registers
; to the stack. The game uses set/longjmp which on Windows uses "RtlUnwindEx" to unwind the callstack.
; This function cannot be unwound by default due to the custom calling convention.
; To allow unwinding, we need to add custom SEH unwind data to the function.
qvmcall64 PROC qvmcall64 PROC FRAME
push r12 ; push all non-volatile registers to stack push r12 ; push all non-volatile registers to stack
.pushreg r12
push r13 push r13
.pushreg r13
push r14 push r14
.pushreg r14
push r15 push r15
.pushreg r15
push rdi push rdi
.pushreg rdi
push rsi push rsi
.pushreg rsi
push rbx push rbx
.pushreg rbx
push rbp push rbp
.pushreg rbp
; need to save pointer in rcx so we can write back the programData value to caller ; need to save pointer in rcx so we can write back the programData value to caller
push rcx push rcx
.pushreg rcx
.endprolog ; custom unwind data ends here
; registers r8 and r9 have correct value already thanx to __fastcall ; registers r8 and r9 have correct value already thanx to __fastcall
xor rbx, rbx ; opStackOfs starts out being 0 xor rbx, rbx ; opStackOfs starts out being 0

View file

@ -89,6 +89,9 @@ float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D normalMap)
// current size of search window // current size of search window
float size = 1.0 / float(linearSearchSteps); float size = 1.0 / float(linearSearchSteps);
// adjust position if offset above surface
dp -= ds * r_parallaxMapOffset;
// current depth position // current depth position
float depth = 0.0; float depth = 0.0;
@ -141,7 +144,7 @@ float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D normalMap)
} }
#endif #endif
return bestDepth; return bestDepth - r_parallaxMapOffset;
} }
float LightRay(vec2 dp, vec2 ds, sampler2D normalMap) float LightRay(vec2 dp, vec2 ds, sampler2D normalMap)
@ -201,7 +204,7 @@ vec3 CalcSpecular(vec3 specular, float NH, float EH, float roughness)
float rr = roughness*roughness; float rr = roughness*roughness;
float rrrr = rr*rr; float rrrr = rr*rr;
float d = (NH * NH) * (rrrr - 1.0) + 1.0; float d = (NH * NH) * (rrrr - 1.0) + 1.0;
float v = (EH * EH) * (roughness + 0.5); float v = (EH * EH) * (roughness + 0.5) + EPSILON;
return specular * (rrrr / (4.0 * d * d * v)); return specular * (rrrr / (4.0 * d * d * v));
} }
@ -261,7 +264,8 @@ void main()
float NL, NH, NE, EH, attenuation; float NL, NH, NE, EH, attenuation;
#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
mat3 tangentToWorld = mat3(var_Tangent.xyz, var_Bitangent.xyz, var_Normal.xyz); vec3 surfNormal = (!gl_FrontFacing ? var_Normal : -var_Normal).xyz;
mat3 tangentToWorld = mat3(var_Tangent.xyz, var_Bitangent.xyz, surfNormal);
viewDir = vec3(var_Normal.w, var_Tangent.w, var_Bitangent.w); viewDir = vec3(var_Normal.w, var_Tangent.w, var_Bitangent.w);
E = normalize(viewDir); E = normalize(viewDir);
#endif #endif
@ -332,7 +336,7 @@ void main()
N.z = sqrt(clamp((0.25 - N.x * N.x) - N.y * N.y, 0.0, 1.0)); N.z = sqrt(clamp((0.25 - N.x * N.x) - N.y * N.y, 0.0, 1.0));
N = tangentToWorld * N; N = tangentToWorld * N;
#else #else
N = var_Normal.xyz; N = surfNormal;
#endif #endif
N = normalize(N); N = normalize(N);
@ -358,7 +362,7 @@ void main()
#if !defined(USE_LIGHT_VECTOR) #if !defined(USE_LIGHT_VECTOR)
ambientColor = lightColor; ambientColor = lightColor;
float surfNL = clamp(dot(var_Normal.xyz, L), 0.0, 1.0); float surfNL = clamp(dot(surfNormal, L), 0.0, 1.0);
// reserve 25% ambient to avoid black areas on normalmaps // reserve 25% ambient to avoid black areas on normalmaps
lightColor *= 0.75; lightColor *= 0.75;

View file

@ -1125,6 +1125,8 @@ void GLSL_InitGPUShaders(void)
if (r_parallaxMapShadows->integer) if (r_parallaxMapShadows->integer)
Q_strcat(extradefines, 1024, "#define USE_PARALLAXMAP_SHADOWS\n"); Q_strcat(extradefines, 1024, "#define USE_PARALLAXMAP_SHADOWS\n");
Q_strcat(extradefines, 1024, va("#define r_parallaxMapOffset %f\n", r_parallaxMapOffset->value));
} }
} }

View file

@ -132,6 +132,7 @@ cvar_t *r_normalMapping;
cvar_t *r_specularMapping; cvar_t *r_specularMapping;
cvar_t *r_deluxeMapping; cvar_t *r_deluxeMapping;
cvar_t *r_parallaxMapping; cvar_t *r_parallaxMapping;
cvar_t *r_parallaxMapOffset;
cvar_t *r_parallaxMapShadows; cvar_t *r_parallaxMapShadows;
cvar_t *r_cubeMapping; cvar_t *r_cubeMapping;
cvar_t *r_cubemapSize; cvar_t *r_cubemapSize;
@ -1243,6 +1244,7 @@ void R_Register( void )
r_specularMapping = ri.Cvar_Get( "r_specularMapping", "1", CVAR_ARCHIVE | CVAR_LATCH ); r_specularMapping = ri.Cvar_Get( "r_specularMapping", "1", CVAR_ARCHIVE | CVAR_LATCH );
r_deluxeMapping = ri.Cvar_Get( "r_deluxeMapping", "1", CVAR_ARCHIVE | CVAR_LATCH ); r_deluxeMapping = ri.Cvar_Get( "r_deluxeMapping", "1", CVAR_ARCHIVE | CVAR_LATCH );
r_parallaxMapping = ri.Cvar_Get( "r_parallaxMapping", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_parallaxMapping = ri.Cvar_Get( "r_parallaxMapping", "0", CVAR_ARCHIVE | CVAR_LATCH );
r_parallaxMapOffset = ri.Cvar_Get( "r_parallaxMapOffset", "0", CVAR_ARCHIVE | CVAR_LATCH );
r_parallaxMapShadows = ri.Cvar_Get( "r_parallaxMapShadows", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_parallaxMapShadows = ri.Cvar_Get( "r_parallaxMapShadows", "0", CVAR_ARCHIVE | CVAR_LATCH );
r_cubeMapping = ri.Cvar_Get( "r_cubeMapping", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_cubeMapping = ri.Cvar_Get( "r_cubeMapping", "0", CVAR_ARCHIVE | CVAR_LATCH );
r_cubemapSize = ri.Cvar_Get( "r_cubemapSize", "128", CVAR_ARCHIVE | CVAR_LATCH ); r_cubemapSize = ri.Cvar_Get( "r_cubemapSize", "128", CVAR_ARCHIVE | CVAR_LATCH );

View file

@ -1778,6 +1778,7 @@ extern cvar_t *r_normalMapping;
extern cvar_t *r_specularMapping; extern cvar_t *r_specularMapping;
extern cvar_t *r_deluxeMapping; extern cvar_t *r_deluxeMapping;
extern cvar_t *r_parallaxMapping; extern cvar_t *r_parallaxMapping;
extern cvar_t *r_parallaxMapOffset;
extern cvar_t *r_parallaxMapShadows; extern cvar_t *r_parallaxMapShadows;
extern cvar_t *r_cubeMapping; extern cvar_t *r_cubeMapping;
extern cvar_t *r_cubemapSize; extern cvar_t *r_cubemapSize;

View file

@ -184,6 +184,11 @@ Cvars for advanced material usage:
1 - Use parallax occlusion mapping. 1 - Use parallax occlusion mapping.
2 - Use relief mapping. (slower) 2 - Use relief mapping. (slower)
* `r_parallaxMapOffset` - Set the parallax height offset.
0 - Values map to -255 - 0. (default)
0.5 - Values map to -127 - 127.
1.0 - Values map to 0 - 255.
* `r_parallaxMapShadows` - Enable self-shadowing on parallax map * `r_parallaxMapShadows` - Enable self-shadowing on parallax map
supported materials. supported materials.
0 - No. (default) 0 - No. (default)