diff --git a/neo/renderer/draw_arb2.cpp b/neo/renderer/draw_arb2.cpp index c40f9666..c1d0d3e3 100644 --- a/neo/renderer/draw_arb2.cpp +++ b/neo/renderer/draw_arb2.cpp @@ -368,7 +368,12 @@ const char* softpartVShader = "!!ARBvp1.0 \n" "OPTION ARB_position_invariant; \n" "# NOTE: unlike the TDM shader, the following lines use .texcoord and .color \n" "# instead of .attrib[8] and .attrib[3], to make it work with non-nvidia drivers \n" - "MOV result.texcoord, vertex.texcoord; \n" + "# Furthermore, I added support for a texture matrix \n" + "PARAM defaultTexCoord = { 0, 0.5, 0, 1 }; \n" + "MOV result.texcoord, defaultTexCoord; \n" + "# program.env[12] is PP_DIFFUSE_MATRIX_S, 13 is PP_DIFFUSE_MATRIX_T \n" + "DP4 result.texcoord.x, vertex.texcoord, program.env[12]; \n" + "DP4 result.texcoord.y, vertex.texcoord, program.env[13]; \n" "MOV result.color, vertex.color; \n" "END \n"; diff --git a/neo/renderer/draw_common.cpp b/neo/renderer/draw_common.cpp index 86f9acbf..0cabbfdd 100644 --- a/neo/renderer/draw_common.cpp +++ b/neo/renderer/draw_common.cpp @@ -1010,6 +1010,37 @@ void RB_STD_T_RenderShaderPasses( const drawSurf_t *surf ) { printf("XX mat: %s, src_blend = %s dest_blend = %s radius = %g\n", shader->GetName(), srcblendstr, dstblend, surf->particle_radius); #endif + // DG: some particle materials (at least the muzzle flash in dentonmod) set the + // texture matrix (with scroll, translate, scale, centerScale, shear or rotate). + // Support that like in R_SetDrawInteraction() (the soft particle shader only + // uses one texture, so I set the diffuse matrix for it) + idVec4 texMatrix[2]; + if ( pStage->texture.hasMatrix ) { + texMatrix[0][0] = regs[pStage->texture.matrix[0][0]]; + texMatrix[0][1] = regs[pStage->texture.matrix[0][1]]; + texMatrix[0][2] = 0; + texMatrix[0][3] = regs[pStage->texture.matrix[0][2]]; + + texMatrix[1][0] = regs[pStage->texture.matrix[1][0]]; + texMatrix[1][1] = regs[pStage->texture.matrix[1][1]]; + texMatrix[1][2] = 0; + texMatrix[1][3] = regs[pStage->texture.matrix[1][2]]; + + // we attempt to keep scrolls from generating incredibly large texture values, but + // center rotations and center scales can still generate offsets that need to be > 1 + if ( texMatrix[0][3] < -40 || texMatrix[0][3] > 40 ) { + texMatrix[0][3] -= (int)texMatrix[0][3]; + } + if ( texMatrix[1][3] < -40 || texMatrix[1][3] > 40 ) { + texMatrix[1][3] -= (int)texMatrix[1][3]; + } + } else { + texMatrix[0].Set( 1, 0, 0, 0 ); + texMatrix[1].Set( 0, 1, 0, 0 ); + } + qglProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_DIFFUSE_MATRIX_S, texMatrix[0].ToFloatPtr() ); + qglProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_DIFFUSE_MATRIX_T, texMatrix[1].ToFloatPtr() ); + // program.env[23] is the particle radius, given as { radius, 1/(faderange), 1/radius } float fadeRange = 1.0f; // fadeRange is the particle diameter for alpha blends (like smoke), but the particle radius for additive diff --git a/neo/renderer/tr_light.cpp b/neo/renderer/tr_light.cpp index 58076c10..523a08a2 100644 --- a/neo/renderer/tr_light.cpp +++ b/neo/renderer/tr_light.cpp @@ -1443,9 +1443,7 @@ static void R_AddAmbientDrawsurfs( viewEntity_t *vEntity ) { float particle_radius = -1.0f; // Default = disallow softening, but allow modelDepthHack if specified in the decl. if ( r_useSoftParticles.GetBool() && r_enableDepthCapture.GetInteger() != 0 && !shader->ReceivesLighting() // don't soften surfaces that are meant to be solid - && tr.viewDef->renderView.viewID >= 0 // Skip during "invisible" rendering passes (e.g. lightgem) - // don't apply to particles spawned at the player-weapon (like muzzle flash) - && !vEntity->weaponDepthHack ) // to fix https://github.com/dhewm/dhewm3-sdk/issues/36 + && tr.viewDef->renderView.viewID >= 0 ) // Skip during "invisible" rendering passes (e.g. lightgem) { const idRenderModelPrt* prt = dynamic_cast( def->parms.hModel ); // yuck. if ( prt )