mirror of
https://github.com/dhewm/dhewm3.git
synced 2024-12-01 16:52:29 +00:00
Allow Soft Particles for player-weapons after all, fix issue properly
The previous commit didn't fix the issue for the pistol and only was a workaround anyway. So I reverted that and fixed the issue properly. The underlying issue is that the particle's material sets the texture matrix (with "translate" or "scale" or whatever), and the soft particle rendering code (and shader) didn't take the texture matrix into account. Now it does, in a similar way as the interaction shader code. Fixes https://github.com/dhewm/dhewm3-sdk/issues/36
This commit is contained in:
parent
227071bb9a
commit
cef1178776
3 changed files with 38 additions and 4 deletions
|
@ -368,7 +368,12 @@ const char* softpartVShader = "!!ARBvp1.0 \n"
|
||||||
"OPTION ARB_position_invariant; \n"
|
"OPTION ARB_position_invariant; \n"
|
||||||
"# NOTE: unlike the TDM shader, the following lines use .texcoord and .color \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"
|
"# 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"
|
"MOV result.color, vertex.color; \n"
|
||||||
"END \n";
|
"END \n";
|
||||||
|
|
||||||
|
|
|
@ -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);
|
printf("XX mat: %s, src_blend = %s dest_blend = %s radius = %g\n", shader->GetName(), srcblendstr, dstblend, surf->particle_radius);
|
||||||
#endif
|
#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 }
|
// program.env[23] is the particle radius, given as { radius, 1/(faderange), 1/radius }
|
||||||
float fadeRange = 1.0f;
|
float fadeRange = 1.0f;
|
||||||
// fadeRange is the particle diameter for alpha blends (like smoke), but the particle radius for additive
|
// fadeRange is the particle diameter for alpha blends (like smoke), but the particle radius for additive
|
||||||
|
|
|
@ -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.
|
float particle_radius = -1.0f; // Default = disallow softening, but allow modelDepthHack if specified in the decl.
|
||||||
if ( r_useSoftParticles.GetBool() && r_enableDepthCapture.GetInteger() != 0
|
if ( r_useSoftParticles.GetBool() && r_enableDepthCapture.GetInteger() != 0
|
||||||
&& !shader->ReceivesLighting() // don't soften surfaces that are meant to be solid
|
&& !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)
|
&& 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
|
|
||||||
{
|
{
|
||||||
const idRenderModelPrt* prt = dynamic_cast<const idRenderModelPrt*>( def->parms.hModel ); // yuck.
|
const idRenderModelPrt* prt = dynamic_cast<const idRenderModelPrt*>( def->parms.hModel ); // yuck.
|
||||||
if ( prt )
|
if ( prt )
|
||||||
|
|
Loading…
Reference in a new issue