From 1a89307ee721a9234de94bb7587e21b8a025f421 Mon Sep 17 00:00:00 2001 From: nashmuhandes Date: Sat, 15 Jun 2024 18:08:37 +0800 Subject: [PATCH] Rename SourceRadius to SoftShadowRadius --- specs/udmf_zdoom.txt | 2 +- .../rendering/hwrenderer/data/hw_levelmeshlight.h | 2 +- src/common/rendering/vulkan/vk_levelmesh.cpp | 2 +- src/common/rendering/vulkan/vk_levelmesh.h | 2 +- src/doomdata.h | 2 +- src/maploader/udmf.cpp | 6 +++--- src/namedef_custom.h | 2 +- src/playsim/a_dynlight.cpp | 2 +- src/playsim/a_dynlight.h | 6 +++--- src/playsim/actor.h | 2 +- src/playsim/p_mobj.cpp | 4 ++-- src/r_data/a_dynlightdata.cpp | 2 +- src/rendering/hwrenderer/doom_levelmesh.cpp | 2 +- src/rendering/hwrenderer/hw_dynlightdata.cpp | 4 ++-- .../shaders/lightmap/binding_lightmapper.glsl | 2 +- wadsrc/static/shaders/lightmap/trace_light.glsl | 4 ++-- wadsrc/static/shaders/scene/light_shadow.glsl | 14 +++++++------- 17 files changed, 30 insertions(+), 30 deletions(-) diff --git a/specs/udmf_zdoom.txt b/specs/udmf_zdoom.txt index 10d357712..75ae3c474 100644 --- a/specs/udmf_zdoom.txt +++ b/specs/udmf_zdoom.txt @@ -424,7 +424,7 @@ Note: All fields default to false unless mentioned otherwise. lm_sampledist = ; // ZDRay lightmap sample distance for the entire map. Defines the map units each lightmap texel covers. Must be in powers of two. Default = 8 lm_suncolor = ; // ZDRay lightmap sun color in hex. Default = "FFFFFF" - SourceRadius = ; // ZDRay lightmap light and raytraced dynamic light soft shadow amount. Higher values produce softer shadows. Default = 5.0 + SoftShadowRadius = ; // ZDRay lightmap light and raytraced dynamic light soft shadow amount. Higher values produce softer shadows. Default = 5.0 friendlyseeblocks = ; // How far (in block units) a friendly monster can see other monsters. Default 10 diff --git a/src/common/rendering/hwrenderer/data/hw_levelmeshlight.h b/src/common/rendering/hwrenderer/data/hw_levelmeshlight.h index b18ca38eb..ca8b063fa 100644 --- a/src/common/rendering/hwrenderer/data/hw_levelmeshlight.h +++ b/src/common/rendering/hwrenderer/data/hw_levelmeshlight.h @@ -15,5 +15,5 @@ public: FVector3 SpotDir; FVector3 Color; int SectorGroup; - float SourceRadius; + float SoftShadowRadius; }; diff --git a/src/common/rendering/vulkan/vk_levelmesh.cpp b/src/common/rendering/vulkan/vk_levelmesh.cpp index 171d3c3a5..e985578fd 100644 --- a/src/common/rendering/vulkan/vk_levelmesh.cpp +++ b/src/common/rendering/vulkan/vk_levelmesh.cpp @@ -674,7 +674,7 @@ void VkLevelMeshUploader::UploadLights() info.OuterAngleCos = light.OuterAngleCos; info.SpotDir = SwapYZ(light.SpotDir); info.Color = light.Color; - info.SourceRadius = light.SourceRadius; + info.SoftShadowRadius = light.SoftShadowRadius; *(lights++) = info; } diff --git a/src/common/rendering/vulkan/vk_levelmesh.h b/src/common/rendering/vulkan/vk_levelmesh.h index 6b6eec003..b7d5f04b0 100644 --- a/src/common/rendering/vulkan/vk_levelmesh.h +++ b/src/common/rendering/vulkan/vk_levelmesh.h @@ -57,7 +57,7 @@ struct LightInfo float InnerAngleCos; float OuterAngleCos; FVector3 SpotDir; - float SourceRadius; + float SoftShadowRadius; FVector3 Color; float Padding3; }; diff --git a/src/doomdata.h b/src/doomdata.h index 40d3b6862..09235c03a 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -382,7 +382,7 @@ struct FMapThing int FloatbobPhase; int friendlyseeblocks; FName arg0str; - double SourceRadius; + double SoftShadowRadius; }; diff --git a/src/maploader/udmf.cpp b/src/maploader/udmf.cpp index ab2c939ed..f71f60fa6 100644 --- a/src/maploader/udmf.cpp +++ b/src/maploader/udmf.cpp @@ -518,7 +518,7 @@ public: th->Alpha = -1; th->Health = 1; th->FloatbobPhase = -1; - th->SourceRadius = -1.0; + th->SoftShadowRadius = -1.0; sc.MustGetToken('{'); while (!sc.CheckToken('}')) { @@ -792,8 +792,8 @@ public: th->friendlyseeblocks = CheckInt(key); break; - case NAME_SourceRadius: - th->SourceRadius = (float)CheckFloat(key); + case NAME_SoftShadowRadius: + th->SoftShadowRadius = (float)CheckFloat(key); break; case NAME_lm_suncolor: diff --git a/src/namedef_custom.h b/src/namedef_custom.h index 39bba8085..9359888e4 100644 --- a/src/namedef_custom.h +++ b/src/namedef_custom.h @@ -864,7 +864,7 @@ xx(lm_dynamic) xx(lm_suncolor) // Light keywords -xx(SourceRadius) +xx(SoftShadowRadius) xx(skew_bottom_type) xx(skew_middle_type) diff --git a/src/playsim/a_dynlight.cpp b/src/playsim/a_dynlight.cpp index 42ccb8fef..98d105acb 100644 --- a/src/playsim/a_dynlight.cpp +++ b/src/playsim/a_dynlight.cpp @@ -115,7 +115,7 @@ void AttachLight(AActor *self) light->pPitch = &self->Angles.Pitch; light->pLightFlags = (LightFlags*)&self->IntVar(NAME_lightflags); light->pArgs = self->args; - light->pSourceRadius = &self->SourceRadius; + light->pSoftShadowRadius = &self->SoftShadowRadius; light->specialf1 = DAngle::fromDeg(double(self->SpawnAngle)).Normalized360().Degrees(); light->Sector = self->Sector; light->target = self; diff --git a/src/playsim/a_dynlight.h b/src/playsim/a_dynlight.h index a73074b4f..ad9a04ec4 100644 --- a/src/playsim/a_dynlight.h +++ b/src/playsim/a_dynlight.h @@ -130,7 +130,7 @@ protected: DAngle m_spotInnerAngle = DAngle::fromDeg(10.0); DAngle m_spotOuterAngle = DAngle::fromDeg(25.0); DAngle m_pitch = nullAngle; - double SourceRadius = 5.0; + double SoftShadowRadius = 5.0; friend FSerializer &Serialize(FSerializer &arc, const char *key, FLightDefaults &value, FLightDefaults *def); }; @@ -223,7 +223,7 @@ struct FDynamicLight bool IsActive() const { return m_active; } float GetRadius() const { return (IsActive() ? m_currentRadius * 2.f : 0.f); } - float GetSourceRadius() const { return (float)(*pSourceRadius); } + float GetSoftShadowRadius() const { return (float)(*pSoftShadowRadius); } int GetRed() const { return pArgs[LIGHT_RED]; } int GetGreen() const { return pArgs[LIGHT_GREEN]; } int GetBlue() const { return pArgs[LIGHT_BLUE]; } @@ -270,7 +270,7 @@ public: const DAngle *pPitch; // This is to handle pitch overrides through GLDEFS, it can either point to the target's pitch or the light definition. const int *pArgs; const LightFlags *pLightFlags; - const double* pSourceRadius; // Softshadows. Physical size of the light source + const double* pSoftShadowRadius; // Softshadows. Physical size of the light source double specialf1; FDynamicLight *next, *prev; diff --git a/src/playsim/actor.h b/src/playsim/actor.h index 4cb0cd60b..ea0bd0538 100644 --- a/src/playsim/actor.h +++ b/src/playsim/actor.h @@ -1374,7 +1374,7 @@ public: // (note: this is put into AActor instead of the PlayerPawn because non-players also use the value) double LandingSpeed; - double SourceRadius = 5.0; // Light source radius + double SoftShadowRadius = 5.0; // Light source's soft shadow radius // ThingIDs void SetTID (int newTID); diff --git a/src/playsim/p_mobj.cpp b/src/playsim/p_mobj.cpp index 453ff5b78..09d4dfc9c 100644 --- a/src/playsim/p_mobj.cpp +++ b/src/playsim/p_mobj.cpp @@ -6046,8 +6046,8 @@ AActor *FLevelLocals::SpawnMapThing (FMapThing *mthing, int position) if (mthing->fillcolor) mobj->fillcolor = (mthing->fillcolor & 0xffffff) | (ColorMatcher.Pick((mthing->fillcolor & 0xff0000) >> 16, (mthing->fillcolor & 0xff00) >> 8, (mthing->fillcolor & 0xff)) << 24); - if (mthing->SourceRadius >= 0.0) - mobj->SourceRadius = mthing->SourceRadius; + if (mthing->SoftShadowRadius >= 0.0) + mobj->SoftShadowRadius = mthing->SoftShadowRadius; // allow color strings for lights and reshuffle the args for spot lights if (i->IsDescendantOf(NAME_DynamicLight)) diff --git a/src/r_data/a_dynlightdata.cpp b/src/r_data/a_dynlightdata.cpp index da451282e..bc692faec 100644 --- a/src/r_data/a_dynlightdata.cpp +++ b/src/r_data/a_dynlightdata.cpp @@ -126,7 +126,7 @@ void FLightDefaults::ApplyProperties(FDynamicLight * light) const light->lighttype = m_type; light->specialf1 = m_Param; light->pArgs = m_Args; - light->pSourceRadius = &SourceRadius; + light->pSoftShadowRadius = &SoftShadowRadius; light->pLightFlags = &m_lightFlags; if (m_lightFlags & LF_SPOT) { diff --git a/src/rendering/hwrenderer/doom_levelmesh.cpp b/src/rendering/hwrenderer/doom_levelmesh.cpp index 6d714f600..066fd55a8 100644 --- a/src/rendering/hwrenderer/doom_levelmesh.cpp +++ b/src/rendering/hwrenderer/doom_levelmesh.cpp @@ -255,7 +255,7 @@ int DoomLevelMesh::GetLightIndex(FDynamicLight* light, int portalgroup) meshlight.Color.Y = light->GetGreen() * (1.0f / 255.0f); meshlight.Color.Z = light->GetBlue() * (1.0f / 255.0f); - meshlight.SourceRadius = light->GetSourceRadius(); + meshlight.SoftShadowRadius = light->GetSoftShadowRadius(); if (light->Sector) meshlight.SectorGroup = sectorGroup[light->Sector->Index()]; diff --git a/src/rendering/hwrenderer/hw_dynlightdata.cpp b/src/rendering/hwrenderer/hw_dynlightdata.cpp index 2414f2901..517b8a501 100644 --- a/src/rendering/hwrenderer/hw_dynlightdata.cpp +++ b/src/rendering/hwrenderer/hw_dynlightdata.cpp @@ -135,7 +135,7 @@ void AddLightToList(FDynLightData &dld, int group, FDynamicLight * light, bool f spotDirY = float(-negPitch.Sin()); spotDirZ = float(-Angle.Sin() * xzLen); } - float sourceRadius = light->GetSourceRadius(); + float softShadowRadius = light->GetSoftShadowRadius(); float *data = &dld.arrays[i][dld.arrays[i].Reserve(16)]; data[0] = float(pos.X); @@ -152,7 +152,7 @@ void AddLightToList(FDynLightData &dld, int group, FDynamicLight * light, bool f data[11] = lightType; data[12] = spotInnerAngle; data[13] = spotOuterAngle; - data[14] = sourceRadius; + data[14] = softShadowRadius; data[15] = 0.0f; // unused } diff --git a/wadsrc/static/shaders/lightmap/binding_lightmapper.glsl b/wadsrc/static/shaders/lightmap/binding_lightmapper.glsl index e23406f12..a03e2ab49 100644 --- a/wadsrc/static/shaders/lightmap/binding_lightmapper.glsl +++ b/wadsrc/static/shaders/lightmap/binding_lightmapper.glsl @@ -37,7 +37,7 @@ struct LightInfo float InnerAngleCos; float OuterAngleCos; vec3 SpotDir; - float SourceRadius; + float SoftShadowRadius; vec3 Color; float Padding3; }; diff --git a/wadsrc/static/shaders/lightmap/trace_light.glsl b/wadsrc/static/shaders/lightmap/trace_light.glsl index 742e961e2..1265909bb 100644 --- a/wadsrc/static/shaders/lightmap/trace_light.glsl +++ b/wadsrc/static/shaders/lightmap/trace_light.glsl @@ -29,13 +29,13 @@ vec3 TraceLight(vec3 origin, vec3 normal, LightInfo light, float extraDistance) #if defined(USE_SOFTSHADOWS) - if (light.SourceRadius != 0.0) + if (light.SoftShadowRadius != 0.0) { vec3 v = (abs(dir.x) > abs(dir.y)) ? vec3(0.0, 1.0, 0.0) : vec3(1.0, 0.0, 0.0); vec3 xdir = normalize(cross(dir, v)); vec3 ydir = cross(dir, xdir); - float lightsize = light.SourceRadius; + float lightsize = light.SoftShadowRadius; int step_count = 10; for (int i = 0; i < step_count; i++) { diff --git a/wadsrc/static/shaders/scene/light_shadow.glsl b/wadsrc/static/shaders/scene/light_shadow.glsl index e46421345..7ca90d173 100644 --- a/wadsrc/static/shaders/scene/light_shadow.glsl +++ b/wadsrc/static/shaders/scene/light_shadow.glsl @@ -182,7 +182,7 @@ vec2 getVogelDiskSample(int sampleIndex, int sampleCount, float phi) return vec2(cosine, sine) * r; } -float traceShadow(vec4 lightpos, int quality, float sourceRadius) +float traceShadow(vec4 lightpos, int quality, float softShadowRadius) { vec3 origin = pixelpos.xyz; vec3 target = lightpos.xyz + 0.01; // nudge light position slightly as Doom maps tend to have their lights perfectly aligned with planes @@ -190,7 +190,7 @@ float traceShadow(vec4 lightpos, int quality, float sourceRadius) vec3 direction = normalize(target - origin); float dist = distance(origin, target); - if (quality == 0 || sourceRadius == 0) + if (quality == 0 || softShadowRadius == 0) { return traceHit(origin, direction, dist) ? 0.0 : 1.0; } @@ -204,7 +204,7 @@ float traceShadow(vec4 lightpos, int quality, float sourceRadius) int step_count = quality * 4; for (int i = 0; i < step_count; i++) { - vec2 gridoffset = getVogelDiskSample(i, step_count, gl_FragCoord.x + gl_FragCoord.y * 13.37) * sourceRadius; + vec2 gridoffset = getVogelDiskSample(i, step_count, gl_FragCoord.x + gl_FragCoord.y * 13.37) * softShadowRadius; vec3 pos = target + xdir * gridoffset.x + ydir * gridoffset.y; sum += traceHit(origin, normalize(pos - origin), dist) ? 0.0 : 1.0; } @@ -212,11 +212,11 @@ float traceShadow(vec4 lightpos, int quality, float sourceRadius) } } -float shadowAttenuation(vec4 lightpos, float lightcolorA, float sourceRadius) +float shadowAttenuation(vec4 lightpos, float lightcolorA, float softShadowRadius) { if (lightpos.w > 1000000.0) return 1.0; // Sunlight - return traceShadow(lightpos, uShadowmapFilter, sourceRadius); + return traceShadow(lightpos, uShadowmapFilter, softShadowRadius); } #elif defined(USE_SHADOWMAP) @@ -346,7 +346,7 @@ float shadowmapAttenuation(vec4 lightpos, float shadowIndex) } } -float shadowAttenuation(vec4 lightpos, float lightcolorA, float sourceRadius) +float shadowAttenuation(vec4 lightpos, float lightcolorA, float softShadowRadius) { if (lightpos.w > 1000000.0) return 1.0; // Sunlight @@ -360,7 +360,7 @@ float shadowAttenuation(vec4 lightpos, float lightcolorA, float sourceRadius) #else -float shadowAttenuation(vec4 lightpos, float lightcolorA, float sourceRadius) +float shadowAttenuation(vec4 lightpos, float lightcolorA, float softShadowRadius) { return 1.0; }