enabled live fog changes from the shader editor

This commit is contained in:
myT 2025-01-31 18:11:10 +01:00
parent 25b7cd5667
commit 8d9556578e
5 changed files with 12 additions and 32 deletions

View file

@ -771,7 +771,8 @@ void VolumetricLight::ProcessWorld(world_t& world)
const float transmittanceThreshold = 1.0 / 256.0f;
const float lnThreshold = logf(transmittanceThreshold);
const fog_t& q3fog = world.fogs[f];
const float distance = q3fog.parms.depthForOpaque;
const fogParms_t& q3parms = q3fog.shader->fogParms;
const float distance = q3parms.depthForOpaque;
const float extinction = -lnThreshold / distance;
Fog& fog = fogs[fogCount++];
@ -783,7 +784,7 @@ void VolumetricLight::ProcessWorld(world_t& world)
}
fog.extinction = extinction;
fog.albedo = 0.75f;
VectorCopy(q3fog.parms.color, fog.scatterColor);
VectorCopy(q3parms.color, fog.scatterColor);
fog.emissive = 0.0f;
VectorSet(fog.emissiveColor, 1, 1, 1);
fog.anisotropy = 0.0f;

View file

@ -1263,6 +1263,7 @@ void World::DrawFog()
}
const fog_t& fog = tr.world->fogs[f];
const fogParms_t& parms = fog.shader->fogParms;
FogVertexRC vertexRC = {};
memcpy(vertexRC.modelViewMatrix, backEnd.viewParms.world.modelMatrix, sizeof(vertexRC.modelViewMatrix));
@ -1272,8 +1273,8 @@ void World::DrawFog()
CmdSetRootConstants(fogRootSignature, ShaderStage::Vertex, &vertexRC);
FogPixelRC pixelRC = {};
VectorScale(fog.parms.color, tr.identityLight, pixelRC.colorDepth);
pixelRC.colorDepth[3] = fog.parms.depthForOpaque;
VectorScale(parms.color, tr.identityLight, pixelRC.colorDepth);
pixelRC.colorDepth[3] = parms.depthForOpaque;
CmdSetRootConstants(fogRootSignature, ShaderStage::Pixel, &pixelRC);
CmdDrawIndexed(36, 0, 0);
@ -1287,6 +1288,7 @@ void World::DrawFog()
CmdBindDescriptorTable(fogRootSignature, fogDescriptorTable);
const fog_t& fog = tr.world->fogs[insideIndex];
const fogParms_t& parms = fog.shader->fogParms;
FogVertexRC vertexRC = {};
memcpy(vertexRC.modelViewMatrix, backEnd.viewParms.world.modelMatrix, sizeof(vertexRC.modelViewMatrix));
@ -1296,8 +1298,8 @@ void World::DrawFog()
CmdSetRootConstants(fogRootSignature, ShaderStage::Vertex, &vertexRC);
FogPixelRC pixelRC = {};
VectorScale(fog.parms.color, tr.identityLight, pixelRC.colorDepth);
pixelRC.colorDepth[3] = fog.parms.depthForOpaque;
VectorScale(parms.color, tr.identityLight, pixelRC.colorDepth);
pixelRC.colorDepth[3] = parms.depthForOpaque;
CmdSetRootConstants(fogRootSignature, ShaderStage::Pixel, &pixelRC);
CmdDrawIndexed(36, 0, 0);

View file

@ -1438,19 +1438,6 @@ static void R_LoadPlanes( const lump_t* l )
}
static unsigned ColorBytes4( float r, float g, float b, float a )
{
unsigned i;
( (byte *)&i )[0] = r * 255;
( (byte *)&i )[1] = g * 255;
( (byte *)&i )[2] = b * 255;
( (byte *)&i )[3] = a * 255;
return i;
}
static void R_LoadFogs( const lump_t* l, const lump_t* brushesLump, const lump_t* sidesLump )
{
const dfog_t* fogs = ReadLump<dfog_t>( l, &s_worldData.numfogs );
@ -1511,15 +1498,7 @@ static void R_LoadFogs( const lump_t* l, const lump_t* brushesLump, const lump_t
shader_t* shader = R_FindShader( fogs->shader, LIGHTMAP_NONE, FINDSHADER_MIPRAWIMAGE_BIT );
shader->isFog = qtrue;
out->parms = shader->fogParms;
out->colorInt = ColorBytes4(
shader->fogParms.color[0] * tr.identityLight,
shader->fogParms.color[1] * tr.identityLight,
shader->fogParms.color[2] * tr.identityLight,
1.0 );
out->tcScale = 1.0f / (8 * max( 1.0f, shader->fogParms.depthForOpaque ));
out->shader = shader;
// set the gradient vector
sideNum = LittleLong( fogs->visibleSide );

View file

@ -471,10 +471,7 @@ struct skin_t {
typedef struct {
int originalBrushNumber;
vec3_t bounds[2];
unsigned colorInt; // in packed byte format
float tcScale; // texture coordinate vector scales
fogParms_t parms;
shader_t* shader;
// for clipping distance in fog when outside
qbool hasSurface;

View file

@ -2652,6 +2652,7 @@ qbool R_EditShader( shader_t* sh, const shader_t* original, const char* shaderTe
}
FinishShader( sh );
sh->isFog = original->isFog;
Q_strncpyz( sh->name, original->name, sizeof( sh->name ) );
sh->index = original->index;