Skip to content

Commit 35a4eff

Browse files
committed
Fix #798
1 parent 3ff5449 commit 35a4eff

File tree

7 files changed

+65
-26
lines changed

7 files changed

+65
-26
lines changed

Build/svencoop/renderer/shader/hdr_brightpass.frag.glsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ void main()
2424
vec4 vColor = texture(baseTex, texCoord.xy);
2525
float fLumValue = dot(vec3(0.27, 0.67, 0.06), vColor.rgb);
2626

27-
out_Color = max(vColor * (fLumValue - CalcLum()) * 5.0, vec4(0.0, 0.0, 0.0, 1.0));
27+
out_Color = min( max(vColor * (fLumValue - CalcLum()) * 5.0, vec4(0.0, 0.0, 0.0, 1.0)), vec4(16.0, 16.0, 16.0, 16.0));
2828
}
-1.31 KB
Binary file not shown.

Build/svencoop/sprites/laserbeam_external.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,4 @@
22
"classname" "sprite_frame_texture"
33
"frame" "0"
44
"replacetexture" "sprites/laserbeam_Frame_0.hdr"
5-
}
6-
{
7-
"classname" "sprite_efx"
8-
"flags" "FMODEL_NOBLOOM"
95
}

Plugins/Renderer/gl_hooks.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12364,6 +12364,7 @@ void Engine_FillAddress(const mh_dll_info_t &DllInfo, const mh_dll_info_t& RealD
1236412364
gPrivateFuncs.triapi_BoxInPVS = gEngfuncs.pTriAPI->BoxInPVS;
1236512365
gPrivateFuncs.triapi_Fog = gEngfuncs.pTriAPI->Fog;
1236612366
gPrivateFuncs.triapi_FogParams = gEngfuncs.pTriAPI->FogParams;
12367+
gPrivateFuncs.triapi_SpriteTexture = gEngfuncs.pTriAPI->SpriteTexture;
1236712368

1236812369
EngineSurface_FillAddress(DllInfo, RealDllInfo);
1236912370

@@ -12653,6 +12654,7 @@ void Engine_InstallHooks(void)
1265312654
gEngfuncs.pTriAPI->BoxInPVS = triapi_BoxInPVS;
1265412655
gEngfuncs.pTriAPI->Fog = triapi_Fog;
1265512656
gEngfuncs.pTriAPI->FogParams = triapi_FogParams;
12657+
gEngfuncs.pTriAPI->SpriteTexture = triapi_SpriteTexture;
1265612658

1265712659
Install_InlineHook(BuildGammaTable);
1265812660
Install_InlineHook(R_CullBox);

Plugins/Renderer/gl_local.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,7 @@ int triapi_BoxInPVS(float* mins, float* maxs);
533533
void triapi_GetMatrix(const int pname, float* matrix);
534534
void triapi_Fog(float* flFogColor, float flStart, float flEnd, qboolean bOn);
535535
void triapi_FogParams(float flDensity, qboolean bFogAffectsSkybox);
536+
qboolean triapi_SpriteTexture(model_t* pSpriteModel, int frame);
536537

537538
float* R_GetWorldMatrix();
538539
void R_PushWorldMatrix();

Plugins/Renderer/gl_rmain.cpp

Lines changed: 60 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,33 +1283,13 @@ class CTriAPICommand
12831283
int RenderMode{ };
12841284
int DrawRenderMode{ };
12851285
GLuint hVAO{};
1286+
std::shared_ptr<CSpriteModelRenderData> pSpriteRenderData;
12861287
};
12871288

12881289
CTriAPICommand gTriAPICommand;
12891290
IPMBRingBuffer* g_TriAPIVertexBuffer{};
12901291
IPMBRingBuffer* g_TriAPIIndexBuffer{};
12911292

1292-
void triapi_Shutdown()
1293-
{
1294-
if (g_TriAPIVertexBuffer)
1295-
{
1296-
g_TriAPIVertexBuffer->Destroy();
1297-
g_TriAPIVertexBuffer = nullptr;
1298-
}
1299-
1300-
if (g_TriAPIIndexBuffer)
1301-
{
1302-
g_TriAPIIndexBuffer->Destroy();
1303-
g_TriAPIIndexBuffer = nullptr;
1304-
}
1305-
1306-
if (gTriAPICommand.hVAO)
1307-
{
1308-
GL_DeleteVAO(gTriAPICommand.hVAO);
1309-
gTriAPICommand.hVAO = 0;
1310-
}
1311-
}
1312-
13131293
void triapi_RenderMode(int mode)
13141294
{
13151295
gTriAPICommand.RenderMode = mode;
@@ -1345,6 +1325,29 @@ void triapi_EndClear()
13451325
gTriAPICommand.Indices.clear();
13461326
}
13471327

1328+
void triapi_Shutdown()
1329+
{
1330+
if (g_TriAPIVertexBuffer)
1331+
{
1332+
g_TriAPIVertexBuffer->Destroy();
1333+
g_TriAPIVertexBuffer = nullptr;
1334+
}
1335+
1336+
if (g_TriAPIIndexBuffer)
1337+
{
1338+
g_TriAPIIndexBuffer->Destroy();
1339+
g_TriAPIIndexBuffer = nullptr;
1340+
}
1341+
1342+
if (gTriAPICommand.hVAO)
1343+
{
1344+
GL_DeleteVAO(gTriAPICommand.hVAO);
1345+
gTriAPICommand.hVAO = 0;
1346+
}
1347+
1348+
gTriAPICommand.pSpriteRenderData.reset();
1349+
}
1350+
13481351
void triapi_End()
13491352
{
13501353
size_t n = gTriAPICommand.Vertices.size();
@@ -1752,6 +1755,34 @@ void triapi_End()
17521755
}
17531756
}
17541757

1758+
if (gTriAPICommand.pSpriteRenderData)
1759+
{
1760+
if (r_draw_opaque)
1761+
{
1762+
int iStencilRef = 0;
1763+
1764+
if ((gTriAPICommand.pSpriteRenderData->flags & FMODEL_NOBLOOM))
1765+
{
1766+
iStencilRef |= STENCIL_MASK_NO_BLOOM;
1767+
1768+
//has stencil write-in
1769+
GL_BeginStencilWrite(iStencilRef, STENCIL_MASK_ALL);
1770+
}
1771+
}
1772+
else
1773+
{
1774+
int iStencilRef = 0;
1775+
1776+
if ((gTriAPICommand.pSpriteRenderData->flags & FMODEL_NOBLOOM))
1777+
{
1778+
iStencilRef |= STENCIL_MASK_NO_BLOOM;
1779+
1780+
//has stencil write-in
1781+
GL_BeginStencilWrite(iStencilRef, STENCIL_MASK_NO_BLOOM);
1782+
}
1783+
}
1784+
}
1785+
17551786
triapi_program_t prog{};
17561787
R_UseTriAPIProgram(ProgramState, &prog);
17571788

@@ -1769,6 +1800,7 @@ void triapi_End()
17691800
//Restore pipeline state
17701801
glDisable(GL_BLEND);
17711802
glDepthMask(GL_TRUE);
1803+
GL_EndStencil();
17721804

17731805
GL_BindVAO(0);
17741806

@@ -1913,6 +1945,13 @@ void triapi_FogParams(float flDensity, qboolean bFogAffectsSkybox)
19131945
gPrivateFuncs.triapi_FogParams(flDensity, bFogAffectsSkybox);
19141946
}
19151947

1948+
qboolean triapi_SpriteTexture(model_t* pSpriteModel, int frame)
1949+
{
1950+
gTriAPICommand.pSpriteRenderData = R_GetSpriteRenderDataFromModel(pSpriteModel);
1951+
1952+
return gPrivateFuncs.triapi_SpriteTexture(pSpriteModel, frame);
1953+
}
1954+
19161955
void __stdcall triapi_glBegin(int GLPrimitiveCode)
19171956
{
19181957
gTriAPICommand.GLPrimitiveCode = GLPrimitiveCode;

Plugins/Renderer/privatehook.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ typedef struct
122122
int (*triapi_BoxInPVS)(float* mins, float* maxs);
123123
void (*triapi_Fog)(float* flFogColor, float flStart, float flEnd, qboolean bOn);
124124
void (*triapi_FogParams)(float flDensity, qboolean bFogAffectsSkybox);
125+
qboolean(*triapi_SpriteTexture)(model_t* pSpriteModel, int frame);
125126
void (*Draw_Frame)(mspriteframe_t* pFrame, int x, int y, const wrect_t* prcSubRect);
126127
void (*Draw_SpriteFrameHoles)(mspriteframe_t* pFrame, unsigned short* pPalette, int x, int y, const wrect_t* prcSubRect);
127128
void (*Draw_SpriteFrameHoles_SvEngine)(mspriteframe_t* pFrame, int x, int y, const wrect_t* prcSubRect);

0 commit comments

Comments
 (0)