SpriteShadow v2.0 (now built into GZDoom 4.6.0!)
Forum rules
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.
Got a cool project idea but nothing else? Put it in the project ideas thread instead!
Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.
Please read the full rules for more details.
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.
Got a cool project idea but nothing else? Put it in the project ideas thread instead!
Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.
Please read the full rules for more details.
-
- Admin
- Posts: 6190
- Joined: Thu Feb 26, 2004 3:02 pm
- Preferred Pronouns: He/Him
Re: SpriteShadow (Duke3D Shadows) v1.85 [more optimization!]
@NightFright: Just open the .pk3 in SLADE or 7zip and delete the MENUDEF file. Everything else will continue working as normal, including the configuration cvars
-
- Spotlight Team
- Posts: 1373
- Joined: Fri May 02, 2008 12:29 pm
- Location: Germany
Re: SpriteShadow (Duke3D Shadows) v1.85 [more optimization!]
Actually the idea was to avoid cvar entries in the ini file, too. My apologies if that wasn't clear before.
-
- Posts: 2431
- Joined: Thu Jun 25, 2009 1:58 pm
- Location: Time Station 1: Moon of Glendale
Re: SpriteShadow (Duke3D Shadows) v1.85 [more optimization!]
If you want that you'll probably have to DIY it
-
-
- Posts: 17455
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: SpriteShadow (Duke3D Shadows) v1.9
Update July 10th 2019 (version 1.9)
- GZDoom version bump to 4.1.3.
- Do not serialize shadows. This means the shadow actors do not get written into saved games. Might help with multiplayer saved game stability.
- Github repository added.
- GZDoom version bump to 4.1.3.
- Do not serialize shadows. This means the shadow actors do not get written into saved games. Might help with multiplayer saved game stability.
- Github repository added.
-
- Posts: 80
- Joined: Wed Apr 10, 2019 11:22 pm
- Graphics Processor: nVidia with Vulkan support
Re: SpriteShadow (Duke3D Shadows) v1.9
Hello Nash, thank you for your SpriteShadow code !
I've adapted it with some changes you may found interesting:
- The Z_ShadeMe inventory is still added for all +ISMONSTER like you did, and is never removed afterwards, rather only the Z_Shadow is enebled/disabled.
- Added a CVAR to enable/disable shadows
- Cleanup of Shadows based on age, not distance re-computing.
Z_ShadeMe:
SpriteShadowHandler:
I've adapted it with some changes you may found interesting:
- The Z_ShadeMe inventory is still added for all +ISMONSTER like you did, and is never removed afterwards, rather only the Z_Shadow is enebled/disabled.
- Added a CVAR to enable/disable shadows
- Cleanup of Shadows based on age, not distance re-computing.
Z_ShadeMe:
Code: Select all
class Z_ShadeMe : CustomInventory
{
// reference to the shadow
Z_SpriteShadow myShadow;
int countFromLastUpdate;
int maxMonsterShadowAgeInTicks;
bool shadowCloseEnoughToPlayer;
...
void setEnableShadow(bool bEnable) {
countFromLastUpdate = 0;
if (bEnable != self.shadowCloseEnoughToPlayer) {
if (bEnable) {
if (!self.myShadow) {
let sh = Z_SpriteShadow(Spawn("Z_SpriteShadow", Owner.Pos, NO_REPLACE));
if (sh)
{
self.myShadow = sh;
self.myShadow.ownerRef = Owner;
}
}
} else {
//destroy the shadow because disabled, or too far from the player.
if (self.myShadow) {
self.myShadow.Destroy();
self.myShadow = null;
}
}
//update
self.shadowCloseEnoughToPlayer = bEnable;
}
}
override void PostBeginPlay() {
//by default is false, and is enabled in Handler WorldTick():
self.shadowCloseEnoughToPlayer = false;
//if countFromLastUpdate is bigger than 2s (35 * 2 ticks) remove the shadow unconditionally.
maxMonsterShadowAgeInTicks = 35 * 2;
Super.PostBeginPlay();
}
override void Tick() {
countFromLastUpdate++;
//Cleanup : shadow is too old, it means it has not been tested
//for player proximity for a long time, which means it is indeed too far !
if (countFromLastUpdate > maxMonsterShadowAgeInTicks) {
self.setEnableShadow(false);
}
Super.Tick();
}
...
}
Code: Select all
class SpriteShadowHandler : EventHandler
{
int countTicks;
// spawn shadows for monsters
override void WorldThingSpawned(WorldEvent e)
{
if (e.Thing.bIsMonster && !e.Thing.CountInv("Z_ShadeMe"))
{
//Every monster got a Z_ShadeMe inventory token, but your shadow is effectively enabled or not later.
e.Thing.A_GiveInventory("Z_ShadeMe", 1);
}
}
...
override void WorldTick(void)
{
//0) Save game : do not serialize shadows.
if (gameaction == ga_savegame || gameaction == ga_autosave)
{
ThinkerIterator it = ThinkerIterator.Create("Z_ShadeMe");
Z_ShadeMe shadeMe;
while (shadeMe = Z_ShadeMe(it.Next()))
{
//VSO: Destroy all shadows, NOT the Z_ShadeMe !
// monster Shadows will be re-created at nexts WorldTick().
if (shadeMe) {
shadeMe.setEnableShadow(false);
}
}
//VSO: Trick so that the next Shadow re-creation will only occur in 35 ticks = 1s.
countTicks = 0;
return;
}
countTicks++;
// no need to update this too often
if (countTicks % 35 != 0) return;
PlayerInfo p = players[consoleplayer];
if (!p) return;
double shadowDist = Cvar.FindCvar("spriteshadowdistance").GetFloat();
bool shadows_enabled = Cvar.FindCvar("spriteshadowenabled").GetBool();
//1) update shadows enabling flag to Z_ShadeMe according to distance to player:
// look for shadow casters around you
BlockThingsIterator it = BlockThingsIterator.Create(p.mo, shadowDist);
while (it.Next())
{
Actor mo = it.thing;
//only consider monster-tagged things:
if (mo.bIsMonster)
{
let shadeMe = Z_ShadeMe(mo.FindInventory("Z_ShadeMe"));
if (shadeMe)
{
if (shadows_enabled && (mo.Distance2DSquared(p.mo) < shadowDist ** 2)) {
shadeMe.setEnableShadow(true);
} else {
shadeMe.setEnableShadow(false);
}
}
}
}//end while.
}
}
-
-
- Posts: 17455
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: SpriteShadow (Duke3D Shadows) v1.9
Can you make a pull request at https://github.com/nashmuhandes/SpriteShadow ? It is more convenient to review code changes that way.
-
- Posts: 80
- Joined: Wed Apr 10, 2019 11:22 pm
- Graphics Processor: nVidia with Vulkan support
Re: SpriteShadow (Duke3D Shadows) v1.9
Thanks, I'll do it properly in a few days.Can you make a pull request at https://github.com/nashmuhandes/SpriteShadow ? It is more convenient to review code changes that way.
-
- Posts: 80
- Joined: Wed Apr 10, 2019 11:22 pm
- Graphics Processor: nVidia with Vulkan support
Re: SpriteShadow (Duke3D Shadows) v1.9
Hello Nash, I've submitted a PR you can look at: https://github.com/nashmuhandes/SpriteShadow/pull/1
-
- Spotlight Team
- Posts: 1373
- Joined: Fri May 02, 2008 12:29 pm
- Location: Germany
Re: SpriteShadow (Duke3D Shadows) v1.9
Did anybody have crashes to console with this? I have had some recently. Levels play fine after reloading the last savegame, though. Next time it happens I'll note down the message to track down the issue.
My impression is this happens since v1.9, can't remember the mod ever causing trouble before.
My impression is this happens since v1.9, can't remember the mod ever causing trouble before.
-
- Posts: 18
- Joined: Tue Aug 13, 2019 12:04 pm
- Graphics Processor: nVidia (Modern GZDoom)
Re: SpriteShadow (Duke3D Shadows) v1.9
1.9 seems to have broken something slightly.
In MAP09 of Valiant archviles teleport around in the starting areas of the map. With 1.9 they leave their shadows when they teleport away, 1.85 works fine.
In MAP09 of Valiant archviles teleport around in the starting areas of the map. With 1.9 they leave their shadows when they teleport away, 1.85 works fine.
-
-
- Posts: 17455
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: SpriteShadow (Duke3D Shadows) v1.9
Thanks, I've opened an issue on Github: https://github.com/nashmuhandes/SpriteShadow/issues/2
(Please feel free to leave other bug reports on the Github)
(Please feel free to leave other bug reports on the Github)
-
- Posts: 13
- Joined: Fri Jul 21, 2017 9:19 am
-
-
- Posts: 17455
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: SpriteShadow (Duke3D Shadows) v1.9
@panzerfaustmna: thank you, added to Github issues. Will fix when I have more spare time. :) https://github.com/nashmuhandes/SpriteShadow/issues/3
-
- Posts: 80
- Joined: Wed Apr 10, 2019 11:22 pm
- Graphics Processor: nVidia with Vulkan support
Re: SpriteShadow (Duke3D Shadows) v1.9
I've asubmitted a PR fixing this problem that I have encountered as well.@panzerfaustmna: thank you, added to Github issues. Will fix when I have more spare time. https://github.com/nashmuhandes/SpriteShadow/issues/3
-
-
- Posts: 17455
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: SpriteShadow (Duke3D Shadows) v1.9
Thanks, this is an easy one. :)vsonnier wrote:I've asubmitted a PR fixing this problem that I have encountered as well.@panzerfaustmna: thank you, added to Github issues. Will fix when I have more spare time. :) https://github.com/nashmuhandes/SpriteShadow/issues/3