Add r_parallaxMapOffset.

This commit is contained in:
James Canete 2021-07-05 21:59:20 -07:00
parent 66cb20a7f3
commit 69ec389335
5 changed files with 14 additions and 0 deletions

View file

@ -89,6 +89,9 @@ float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D normalMap)
// current size of search window
float size = 1.0 / float(linearSearchSteps);
// adjust position if offset above surface
dp -= ds * r_parallaxMapOffset;
// current depth position
float depth = 0.0;
@ -142,6 +145,7 @@ float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D normalMap)
#endif
return bestDepth;
return bestDepth - r_parallaxMapOffset;
}
float LightRay(vec2 dp, vec2 ds, sampler2D normalMap)

View file

@ -1125,6 +1125,8 @@ void GLSL_InitGPUShaders(void)
if (r_parallaxMapShadows->integer)
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_deluxeMapping;
cvar_t *r_parallaxMapping;
cvar_t *r_parallaxMapOffset;
cvar_t *r_parallaxMapShadows;
cvar_t *r_cubeMapping;
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_deluxeMapping = ri.Cvar_Get( "r_deluxeMapping", "1", 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_cubeMapping = ri.Cvar_Get( "r_cubeMapping", "0", 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_deluxeMapping;
extern cvar_t *r_parallaxMapping;
extern cvar_t *r_parallaxMapOffset;
extern cvar_t *r_parallaxMapShadows;
extern cvar_t *r_cubeMapping;
extern cvar_t *r_cubemapSize;

View file

@ -184,6 +184,11 @@ Cvars for advanced material usage:
1 - Use parallax occlusion mapping.
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
supported materials.
0 - No. (default)