Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Vulkan PBR: **anisotropic visibility** for direct light; optional **IBL roughness stretch** from the anisotropy map (`r_pbr_iblAnisoStretch`); **clearcoat** base attenuation and **Charlie sheen** with optional fourth `sheenScale` roughness token.

### Removed
- Stale Vulkan compile gates: dead non-PBR shader init (`USE_VK_PBR` `#else` branch), OpenGL glTF shader path (`RENDERER_OPENGL`), and unused `USE_TESS_NEEDS_*` / `needsNormal`/`needsST2` plumbing (normals and lightmap ST2 are always gathered on Vulkan).
- Legacy `r_vfog*` engine cvars and `vk_vfog.c`/`vk_vfog.h`: volumetric fog is configured only via `r_volumetricFog*` (and map/`r_fog*` as documented). Editor `worldspawn` keys `vfog_*` remain separate map data, not console cvars.

### Security
Expand Down
6 changes: 0 additions & 6 deletions src/renderers/vulkan/tr_animation.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,6 @@ void RB_MDRSurfaceAnim( mdrSurface_t *surface )
tempVert[1] += w->boneWeight * ( DotProduct( bone->matrix[1], w->offset ) + bone->matrix[1][3] );
tempVert[2] += w->boneWeight * ( DotProduct( bone->matrix[2], w->offset ) + bone->matrix[2][3] );

#ifdef USE_TESS_NEEDS_NORMAL
if ( tess.needsNormal )
#endif
{
tempNormal[0] += w->boneWeight * DotProduct( bone->matrix[0], v->normal );
tempNormal[1] += w->boneWeight * DotProduct( bone->matrix[1], v->normal );
Expand All @@ -425,9 +422,6 @@ void RB_MDRSurfaceAnim( mdrSurface_t *surface )
tess.xyz[baseVertex + j][1] = tempVert[1];
tess.xyz[baseVertex + j][2] = tempVert[2];

#ifdef USE_TESS_NEEDS_NORMAL
if ( tess.needsNormal )
#endif
{
tess.normal[baseVertex + j][0] = tempNormal[0];
tess.normal[baseVertex + j][1] = tempNormal[1];
Expand Down
4 changes: 0 additions & 4 deletions src/renderers/vulkan/tr_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ cvar_t *r_firstPersonScaleEnabled;
cvar_t *r_firstPersonZNear;

cvar_t *r_skipBackEnd;
#ifdef USE_IMGUI
cvar_t *r_imgui;
cvar_t *r_imguiTheme;
#endif

cvar_t *r_greyscale;
cvar_t *r_dither;
Expand Down
11 changes: 0 additions & 11 deletions src/renderers/vulkan/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define USE_VBO_GRID /* put SF_GRID to VBO */
#endif

//#define USE_TESS_NEEDS_NORMAL
//#define USE_TESS_NEEDS_ST2

#define SH_COEFF_COUNT 9

#include "../../qcommon/q_shared.h"
Expand Down Expand Up @@ -546,9 +543,7 @@ typedef struct shader_s {

fogPass_t fogPass; // draw a blended pass, possibly with depth test equals

qboolean needsNormal; // not all shaders will need all data to be gathered
//qboolean needsST1;
qboolean needsST2;
//qboolean needsColor;

int numDeforms;
Expand Down Expand Up @@ -2115,12 +2110,6 @@ typedef struct shaderCommands_s
#endif

// info extracted from current shader
#ifdef USE_TESS_NEEDS_NORMAL
int needsNormal;
#endif
#ifdef USE_TESS_NEEDS_ST2
int needsST2;
#endif

int numPasses;
shaderStage_t **xstages;
Expand Down
5 changes: 1 addition & 4 deletions src/renderers/vulkan/tr_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1078,9 +1078,6 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, qboolean *isMirror
RB_BeginSurface( shader, fogNum );
#ifdef USE_VBO
tess.allowVBO = qfalse;
#endif
#ifdef USE_TESS_NEEDS_NORMAL
tess.needsNormal = qtrue;
#endif
rb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface );

Expand Down Expand Up @@ -1248,7 +1245,7 @@ static qboolean R_MirrorViewBySurface( const drawSurf_t *drawSurf, int entityNum
return qfalse;
}

if ( r_noportals->integer > 1 /*|| r_fastsky->integer == 1 */ ) {
if ( r_noportals->integer > 1 ) {
return qfalse;
}

Expand Down
51 changes: 0 additions & 51 deletions src/renderers/vulkan/tr_model_gltf.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,53 +41,9 @@ float R_GLTFPackGpuVertexMeta( int morphVertexIndex )
Com_Memcpy( &out, &packed, sizeof( out ) );
return out;
}
#ifdef RENDERER_VULKAN
#include "vk.h"
#endif
#include <math.h>

#ifdef RENDERER_OPENGL
/*
OpenGL: glTF materials only carry texture paths; engine shaders are separate .shader files.
When `normalTexture` is set, try **`stripExtension(path) + "_norm"`** first. If that shader is
missing and the stripped path ends with **`_n`** (e.g. `.../diffuse_n` from `diffuse_n.tga`),
also try **`strip trailing _n` + `_norm`** so `foo_norm` shaders resolve. Fall back to the
base-color texture shader name.
*/
static shader_t *R_GLTF_RegisterSurfaceShader( const gltfMaterial_t *mat ) {
char normName[MAX_QPATH];
size_t len;
qhandle_t h;

if ( mat->normalTexture[0] ) {
COM_StripExtension( mat->normalTexture, normName, sizeof( normName ) );
Q_strcat( normName, sizeof( normName ), "_norm" );
h = RE_RegisterShaderNoMip( normName );
if ( h ) {
return R_GetShaderByHandle( h );
}
COM_StripExtension( mat->normalTexture, normName, sizeof( normName ) );
len = strlen( normName );
if ( len >= 2 && normName[len - 2] == '_' &&
( normName[len - 1] == 'n' || normName[len - 1] == 'N' ) ) {
normName[len - 2] = '\0';
Q_strcat( normName, sizeof( normName ), "_norm" );
h = RE_RegisterShaderNoMip( normName );
if ( h ) {
return R_GetShaderByHandle( h );
}
}
}
if ( mat->baseColorTexture[0] ) {
h = RE_RegisterShaderNoMip( mat->baseColorTexture );
if ( h ) {
return R_GetShaderByHandle( h );
}
}
return tr.defaultShader;
}
#endif

static qboolean gltf_load_materials(const cgltf_data *data, gltfModel_t *model);
static qboolean gltf_load_meshes(const cgltf_data *data, gltfModel_t *model);
static qboolean gltf_load_skeleton(const cgltf_data *data, gltfModel_t *model);
Expand Down Expand Up @@ -1117,18 +1073,12 @@ qboolean R_RegisterGLTF(const char *name, model_t *mod) {

if (prim->materialIndex >= 0 && prim->materialIndex < gltfModel.numMaterials) {
gltfMaterial_t *mat = &rdata->model.materials[prim->materialIndex];
#ifdef RENDERER_OPENGL
surf->shader = R_GLTF_RegisterSurfaceShader( mat );
#else
if (mat->baseColorTexture[0]) {
qhandle_t h = RE_RegisterShaderNoMip(mat->baseColorTexture);
surf->shader = R_GetShaderByHandle(h);
}
#endif
}

/* VBO: pack vertex data (Vulkan only; OpenGL uses CPU tess path) */
#ifdef RENDERER_VULKAN
if (prim->numVertices > 0 && prim->numIndices > 0) {
int offXyz, offRgba, offSt, offNorm, offJoint, offWeight;
int n = prim->numVertices;
Expand Down Expand Up @@ -1182,7 +1132,6 @@ qboolean R_RegisterGLTF(const char *name, model_t *mod) {
}
ri.Hunk_FreeTempMemory(vboPack);
}
#endif /* RENDERER_VULKAN */
}
}

Expand Down
11 changes: 0 additions & 11 deletions src/renderers/vulkan/tr_shade.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,17 +390,6 @@ void RB_BeginSurface( shader_t *shader, int fogNum ) {
tess.dlightUpdateParams = qtrue;
}

#ifdef USE_TESS_NEEDS_NORMAL
tess.needsNormal = state->needsNormal || tess.dlightPass || r_shownormals->integer ||
( backEnd.currentEntity == &tr.worldEntity &&
( ( r_shDebugView && r_shDebugView->integer ) ||
( r_shWorldLighting && r_shWorldLighting->integer && r_shLighting && r_shLighting->integer ) ) );
#endif

#ifdef USE_TESS_NEEDS_ST2
tess.needsST2 = state->needsST2;
#endif

tess.numIndexes = 0;
tess.numVertexes = 0;
tess.sdfUiEdge = -1.0f;
Expand Down
70 changes: 0 additions & 70 deletions src/renderers/vulkan/tr_shader.c
Original file line number Diff line number Diff line change
Expand Up @@ -3888,64 +3888,6 @@ static void InitShader( const char *name, int lightmapIndex ) {
}


static void DetectNeeds( void )
{
int i, n;

for ( i = 0; i < MAX_SHADER_STAGES; i++ )
{
if ( !stages[i].active )
break;

for ( n = 0; n < NUM_TEXTURE_BUNDLES; n++ ) {
const texCoordGen_t t = stages[i].bundle[n].tcGen;
if ( t == TCGEN_LIGHTMAP )
{
shader.needsST2 = qtrue;
}
if ( t == TCGEN_ENVIRONMENT_MAPPED || t == TCGEN_ENVIRONMENT_MAPPED_FP )
{
shader.needsNormal = qtrue;
}
if ( stages[i].bundle[n].alphaGen == AGEN_LIGHTING_SPECULAR || stages[i].bundle[n].rgbGen == CGEN_LIGHTING_DIFFUSE )
{
shader.needsNormal = qtrue;
}
}
#if 0
t1 = stages[i].bundle[0].tcGen;
t2 = stages[i].bundle[1].tcGen;

if ( t1 == TCGEN_LIGHTMAP || t2 == TCGEN_LIGHTMAP )
{
shader.needsST2 = qtrue;
}
if ( t1 == TCGEN_ENVIRONMENT_MAPPED || t1 == TCGEN_ENVIRONMENT_MAPPED_FP )
{
shader.needsNormal = qtrue;
}
if ( t2 == TCGEN_ENVIRONMENT_MAPPED || t2 == TCGEN_ENVIRONMENT_MAPPED_FP )
{
shader.needsNormal = qtrue;
}
if ( stages[i].bundle[0].alphaGen == AGEN_LIGHTING_SPECULAR || stages[i].bundle[0].rgbGen == CGEN_LIGHTING_DIFFUSE )
{
shader.needsNormal = qtrue;
}
#endif
}
for ( i = 0; i < shader.numDeforms; i++ )
{
if ( shader.deforms[i].deformation == DEFORM_WAVE || shader.deforms[i].deformation == DEFORM_NORMALS || shader.deforms[i].deformation == DEFORM_BULGE ) {
shader.needsNormal = qtrue;
}
if ( shader.deforms[i].deformation >= DEFORM_TEXT0 && shader.deforms[i].deformation <= DEFORM_TEXT7 ) {
shader.needsNormal = qtrue;
}
}
}


/*
=========================
FinishShader
Expand Down Expand Up @@ -4104,8 +4046,6 @@ static shader_t *FinishShader( void ) {
}
}

DetectNeeds();

// fix alphaGen flags to avoid redundant comparisons in R_ComputeColors()
for ( i = 0; i < MAX_SHADER_STAGES; i++ ) {
shaderStage_t *pStage = &stages[ i ];
Expand Down Expand Up @@ -4844,11 +4784,6 @@ shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImag

InitShader( strippedName, lightmapIndex );

/* needsNormal etc. could be set based on stage requirements. */
//shader.needsST1 = qtrue;
//shader.needsST2 = qtrue;
//shader.needsColor = qtrue;

//
// attempt to define shader from an explicit parameter file
//
Expand Down Expand Up @@ -4933,11 +4868,6 @@ qhandle_t RE_RegisterShaderFromImage(const char *name, int lightmapIndex, image_

InitShader( name, lightmapIndex );

/* needsNormal etc. could be set based on stage requirements. */
//shader.needsST1 = qtrue;
//shader.needsST2 = qtrue;
//shader.needsColor = qtrue;

//
// create the default shading commands
//
Expand Down
21 changes: 0 additions & 21 deletions src/renderers/vulkan/tr_surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,6 @@ static void RB_SurfaceTriangles( const srfTriangles_t *srf ) {
xyz[1] = dv->xyz[1];
xyz[2] = dv->xyz[2];

#ifdef USE_TESS_NEEDS_NORMAL
if ( tess.needsNormal )
#endif
{
normal[0] = dv->normal[0];
normal[1] = dv->normal[1];
Expand All @@ -433,9 +430,6 @@ static void RB_SurfaceTriangles( const srfTriangles_t *srf ) {
texCoords0[0] = dv->st[0];
texCoords0[1] = dv->st[1];

#ifdef USE_TESS_NEEDS_ST2
if ( tess.needsST2 )
#endif
{
texCoords1[0] = dv->lightmap[0];
texCoords1[1] = dv->lightmap[1];
Expand Down Expand Up @@ -988,9 +982,6 @@ static void RB_SurfaceFace( const srfSurfaceFace_t *surf ) {

numPoints = surf->numPoints;

#ifdef USE_TESS_NEEDS_NORMAL
if ( tess.needsNormal )
#endif
{
if ( surf->normals ) {
// per-vertex normals for non-coplanar faces
Expand All @@ -1017,9 +1008,6 @@ static void RB_SurfaceFace( const srfSurfaceFace_t *surf ) {
#ifdef USE_VK_PBR
tess.texCoords[0][ndx][0] = v[6];
tess.texCoords[0][ndx][1] = v[7];
#ifdef USE_TESS_NEEDS_ST2
if ( tess.needsST2 )
#endif
{
tess.texCoords[1][ndx][0] = v[8];
tess.texCoords[1][ndx][1] = v[9];
Expand All @@ -1032,9 +1020,6 @@ static void RB_SurfaceFace( const srfSurfaceFace_t *surf ) {
#else
tess.texCoords[0][ndx][0] = v[3];
tess.texCoords[0][ndx][1] = v[4];
#ifdef USE_TESS_NEEDS_ST2
if ( tess.needsST2 )
#endif
{
tess.texCoords[1][ndx][0] = v[5];
tess.texCoords[1][ndx][1] = v[6];
Expand Down Expand Up @@ -1300,17 +1285,11 @@ static void RB_SurfaceGrid( srfGridMesh_t *cv ) {
xyz[2] = dv->xyz[2];
texCoords0[0] = dv->st[0];
texCoords0[1] = dv->st[1];
#ifdef USE_TESS_NEEDS_ST2
if ( tess.needsST2 )
#endif
{
texCoords1[0] = dv->lightmap[0];
texCoords1[1] = dv->lightmap[1];
texCoords1 += 2;
}
#ifdef USE_TESS_NEEDS_NORMAL
if ( tess.needsNormal )
#endif
{
normal[0] = dv->normal[0];
normal[1] = dv->normal[1];
Expand Down
Loading
Loading