Skip to content

Commit

Permalink
even more garbage
Browse files Browse the repository at this point in the history
  • Loading branch information
dsvensson committed Jan 6, 2025
1 parent 74cbe2a commit c7d2b1e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
32 changes: 14 additions & 18 deletions src/glm_rsurf.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,8 @@ static glm_worldmodel_req_t* GLM_NextBatchRequest(model_t* model, float alpha, i
glm_brushmodel_drawcall_t* drawcall = &drawcalls[current_drawcall];
float mvMatrix[16];

glm_brushmodel_drawcall_type desired_type = alpha < 1.0f ? alpha_surfaces : opaque_world;

R_GetModelviewMatrix(mvMatrix);

// If user has switched off caustics (or no texture), ignore
Expand All @@ -410,7 +412,12 @@ static glm_worldmodel_req_t* GLM_NextBatchRequest(model_t* model, float alpha, i
}

// See if previous batch has same texture & matrix, if so just continue
if (drawcall->batch_count) {
if (drawcall->type != desired_type)
{
drawcall = GL_FlushWorldModelBatch();
drawcall->type = desired_type;
}
else if (drawcall->batch_count) {
req = &drawcall->worldmodel_requests[drawcall->batch_count - 1];

if (allow_duplicate && model == req->model && req->samplerMappingCount == num_textures && req->firstTexture == first_texture && drawcall->batch_count < MAX_WORLDMODEL_BATCH && isAlphaTested == req->isAlphaTested) {
Expand All @@ -430,7 +437,7 @@ static glm_worldmodel_req_t* GLM_NextBatchRequest(model_t* model, float alpha, i
}

// Try and continue the previous batch
if (worldmodel == req->worldmodel && !memcmp(req->mvMatrix, mvMatrix, sizeof(req->mvMatrix)) && polygonOffset == req->polygonOffset && req->flags == flags && req->isAlphaTested == isAlphaTested && ((req->alpha < 1.0f) == (alpha < 1.0f))) {
if (worldmodel == req->worldmodel && !memcmp(req->mvMatrix, mvMatrix, sizeof(req->mvMatrix)) && polygonOffset == req->polygonOffset && req->flags == flags && req->isAlphaTested == isAlphaTested && req->alpha == alpha) {
if (num_textures == 0) {
// We don't care about materials, so can draw with previous batch
return req;
Expand All @@ -452,19 +459,6 @@ static glm_worldmodel_req_t* GLM_NextBatchRequest(model_t* model, float alpha, i
drawcall = GL_FlushWorldModelBatch();
}

if (alpha < 1.0f)
{
if (drawcall->type != alpha_surfaces) {
drawcall = GL_FlushWorldModelBatch();
drawcall->type = alpha_surfaces;
}
} else {
if (drawcall->type != opaque_world) {
drawcall = GL_FlushWorldModelBatch();
drawcall->type = opaque_world;
}
}

req = &drawcall->worldmodel_requests[drawcall->batch_count];

// If matrix list was full previously, will be okay now
Expand Down Expand Up @@ -825,7 +819,6 @@ void GLM_DrawBrushModel(entity_t* ent, qbool polygonOffset, qbool caustics)
}
}

/* TODO: rerenable when respecting alpha
static int GL_DrawCallComparison(const void* lhs_, const void* rhs_)
{
const glm_worldmodel_req_t* lhs = (glm_worldmodel_req_t*)lhs_;
Expand All @@ -847,7 +840,6 @@ static int GL_DrawCallComparison(const void* lhs_, const void* rhs_)

return lhs->nonDynamicSampler - rhs->nonDynamicSampler;
}
*/

static void GL_SortDrawCalls(glm_brushmodel_drawcall_t* drawcall)
{
Expand All @@ -870,7 +862,11 @@ static void GL_SortDrawCalls(glm_brushmodel_drawcall_t* drawcall)
}
}

//qsort(drawcall->worldmodel_requests, drawcall->batch_count, sizeof(drawcall->worldmodel_requests[0]), GL_DrawCallComparison);
// Translucent bmodels are put into requests based on their distance from view
// and sorting here will break that order.
if (drawcall->type == opaque_world) {
qsort(drawcall->worldmodel_requests, drawcall->batch_count, sizeof(drawcall->worldmodel_requests[0]), GL_DrawCallComparison);
}

for (i = 0; i < drawcall->batch_count; ++i) {
glm_worldmodel_req_t* thisReq = &drawcall->worldmodel_requests[i];
Expand Down
2 changes: 1 addition & 1 deletion src/glsl/draw_world.fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ void main()
#endif
}
else {
frag_colour = texColor * waterAlpha;
frag_colour = texColor;
if ((Flags & EZQ_SURFACE_LIT_TURB) > 0) {
frag_colour = vec4(lmColor.rgb, 1) * frag_colour;
}
Expand Down

0 comments on commit c7d2b1e

Please sign in to comment.