Xonotic Forums
[SOLVED] Correct way to make entity with opacity depending on distance to player - Printable Version

+- Xonotic Forums (https://forums.xonotic.org)
+-- Forum: Creating & Contributing (https://forums.xonotic.org/forumdisplay.php?fid=10)
+--- Forum: Xonotic - Development (https://forums.xonotic.org/forumdisplay.php?fid=12)
+--- Thread: [SOLVED] Correct way to make entity with opacity depending on distance to player (/showthread.php?tid=5426)



Correct way to make entity with opacity depending on distance to player - Penguinum-tea - 04-02-2015

Hello. I'm trying to implement objects which are visible when you are close to them and are fading out when you're going from them (similar behavior you can find in some puzzle games, such as Antichamber). The first thought was about shaders, but the only thing I've found is "AlphaGen portal" which is not supported by DP. The second idea was about entity like func_wall but with alpha depending on distance from player. I've remembered about warpzone fadeout, looked at sources and tried to implement it like it's implemented in trigger_warpzone. The code became complicated and after all this entity isn't shown at all (not because of alpha (it's not even set), but because I'm doing something wrong).

So, the question is what is the correct way to implement this? Should I continue looking at sources of warpzones and other entities or is there simple way to update entitie's alpha? I understand that such entitiy is not very useful for Xonotic, but there is not much related information in Internet. Also, sorry for weird English.


RE: Correct way to make entity with opacity depending on distance to player - Mario - 04-03-2015

There is currently no shared handling of such fading.

The version in warpzones is the only fading function existing, I recently copied it for use with items (greatly improves performance to not render all items at once):
https://gitlab.com/xonotic/xonotic-data.pk3dir/commit/13c1991a74ee1392b3dc91cfce8571e8ca1810db


RE: Correct way to make entity with opacity depending on distance to player - Penguinum-tea - 04-03-2015

Quote:The version in warpzones is the only fading function existing, I recently copied it for use with items (greatly improves performance to not render all items at once):
https://gitlab.com/xonotic/xonotic-data.pk3dir/commit/13c1991a74ee1392b3dc91cfce8571e8ca1810db

Thank you, this helped a lot.