Skip to content

Commit

Permalink
Merge branch 'rend2-unified-wip' into rend2-builds
Browse files Browse the repository at this point in the history
  • Loading branch information
SomaZ committed Jun 12, 2024
2 parents 718f0ba + 664bab7 commit 412f733
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 18 deletions.
19 changes: 4 additions & 15 deletions code/rd-rend2/G2_API.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2201,23 +2201,12 @@ qboolean G2API_SetNewOrigin(CGhoul2Info* ghlInfo, const int boltIndex)
{
if (G2_SetupModelPointers(ghlInfo))
{
if (boltIndex < 0)
// check for valid boltIndex before applying new origin
if (boltIndex >= 0 && boltIndex < (int)ghlInfo->mBltlist.size())
{
char modelName[MAX_QPATH];
if (ghlInfo->currentModel && ghlInfo->currentModel->name[0])
{
strcpy(modelName, ghlInfo->currentModel->name);
}
else
{
strcpy(modelName, "[Unknown - unexpected]");
}

Com_Error(ERR_DROP, "Bad boltindex (%i) trying to SetNewOrigin (naughty naughty!)\nModel %s\n", boltIndex, modelName);
ghlInfo->mNewOrigin = boltIndex;
ghlInfo->mFlags |= GHOUL2_NEWORIGIN;
}

ghlInfo->mNewOrigin = boltIndex;
ghlInfo->mFlags |= GHOUL2_NEWORIGIN;
return qtrue;
}
return qfalse;
Expand Down
12 changes: 10 additions & 2 deletions shared/rd-rend2/tr_bsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3823,7 +3823,8 @@ static int R_CreateSurfaceSpritesVertexData(
const srfVert_t *verts = bspSurf->verts;
const glIndex_t *indexes = bspSurf->indexes;

vec4_t color = { 1.0, 1.0, 1.0, 1.0 };
#if 0
vec4_t color = { 1.0f, 1.0f, 1.0f, 1.0f };
if (stage->rgbGen == CGEN_CONST)
{
color[0] = stage->constantColor[0];
Expand All @@ -3835,6 +3836,13 @@ static int R_CreateSurfaceSpritesVertexData(
stage->rgbGen == CGEN_EXACT_VERTEX ||
stage->rgbGen == CGEN_VERTEX_LIT ||
stage->rgbGen == CGEN_EXACT_VERTEX_LIT);
#else
// Vanilla behaviour is always: color by vertex color of the emitting surface
// even just the blue component used for all three color channels to be exact
// in pseudo code: outVert.rgb = inVert.bbb;
bool vertexLit = true;
vec4_t color = { 1.0f, 1.0f, 1.0f, 1.0f };
#endif

int numSprites = 0;
for ( int i = 0, numIndexes = bspSurf->numIndexes; i < numIndexes; i += 3 )
Expand Down Expand Up @@ -4017,7 +4025,7 @@ static void R_GenerateSurfaceSprites( const world_t *world, int worldIndex )
for (int i = 0; i < tr.numShaders; i++)
{
const shader_t *shader = tr.shaders[i];
if (shader->spriteUbo != -1)
if (shader->spriteUbo != 0)
continue;

numSpriteStages += shader->numSurfaceSpriteStages;
Expand Down
3 changes: 3 additions & 0 deletions shared/rd-rend2/tr_shade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,9 @@ static shaderProgram_t *SelectShaderProgram( int stageIndex, shaderStage_t *stag
{
index |= LIGHTDEF_USE_ALPHA_TEST;
}*/

if (stage->bundle[0].tcGen != TCGEN_TEXTURE || (stage->bundle[0].numTexMods))
index |= LIGHTDEF_USE_TCGEN_AND_TCMOD;

// TODO: remove light vertex def and fix parallax usage on unlit stages like glow stages
if (stage->glslShaderIndex & LIGHTDEF_USE_PARALLAXMAP &&
Expand Down
10 changes: 9 additions & 1 deletion shared/rd-rend2/tr_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3372,6 +3372,14 @@ static qboolean CollapseStagesToGLSL(void)
if (pStage->bundle[0].tcGen >= TCGEN_LIGHTMAP && pStage->bundle[0].tcGen <= TCGEN_LIGHTMAP3)
continue;

if (i > 0)
{
int blendBits = pStage->stateBits & (GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS);
if (blendBits == (GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO) ||
blendBits == (GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR))
continue;
}

diffuse = pStage;
parallax = qfalse;
lightmap = NULL;
Expand Down Expand Up @@ -3810,7 +3818,7 @@ static shader_t *GeneratePermanentShader( void ) {
}

RB_AddShaderToShaderInstanceUBO(newShader);
newShader->spriteUbo = -1;
newShader->spriteUbo = 0;

SortNewShader();

Expand Down

0 comments on commit 412f733

Please sign in to comment.