[solved] Visual effect below ground (voidground/water)

[solved] Visual effect below ground (voidground/water)

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
qray
Posts: 377
Joined: 02 Feb 2009, 18:49

[solved] Visual effect below ground (voidground/water)

Post by qray »

I finally managed to get around and "finish" a small gadget (see attached file) for the map Core Platform.

It takes units that somehow manage to enter the voidground/voidwater zones and throws them into the void using movectrl (*). After a short time of falling and tumbling, the unit is destroyed (without wreckage).
*except units with "canFly" in unitDefs: they are pushed up a bit

When the unit is destroyed, I would like to have a visual and audio effect. Audio works well.
For the visual, I tried one of Forb's CEG effects. Unfortunately, this is only visible as long as it happens above the lowest level of the map (total black in the heightmap); even with all ceg visibility options enabled. If the unit is destroyed further down, the effect not visible anymore (but the falling unit is).
Since it needs some falling time/distance to look good, I basically ruled out modifying the height map levels that much.

So -after maybe too much introductory explanation- is there a way to have an effect displayed below the lowest map level?
Attachments
void.lua
(4.18 KiB) Downloaded 9 times
Last edited by qray on 06 Mar 2015, 16:34, edited 1 time in total.
8611
XTA Developer
Posts: 242
Joined: 29 Dec 2014, 08:22

Re: Visual effect below lowest map level (voidground/voidwat

Post by 8611 »

Sure you have underwater=true for visibility conditions? Exact ceg would be useful.

This looks related: https://github.com/spring/spring/blob/9 ... r.cpp#L104

Code: Select all

const float altitude = height - groundHeight;
if (altitude < -1.0f) {
/* underground! don't spawn CEG! */
Seems it is no possible to spawn a CEG below the terrain.
Your map does voidground and partly transparent terrain etc but I see no exceptions for that. (Whether the effect would 'in theory' be visible does not matter when it never gets spawned.)
Did not test but should be easy to confirm or refute like this:
Spring.SpawnCEG ("bla", x,Spring.GetGroundHeight (x,z),z)
then change it to see if it still spawns if the coordinates are a little lower:
Spring.SpawnCEG ("bla", x,Spring.GetGroundHeight (x,z)-10,z)
User avatar
qray
Posts: 377
Joined: 02 Feb 2009, 18:49

Re: Visual effect below lowest map level (voidground/voidwat

Post by qray »

Can't post the ceg script right now since not at home; will do later. But underwater is definitely true.
I had tested the y level from which on it isn't displayed anymore by changing the y position manually. And the limit is y=-90 which is the minheight of the map (and at that place also the ground level).

I don't insist on using a ceg effect; I just thought it might be the easiest way. But any method to give some small visual feedback is OK for me (*). And since I am not very familiar with spring lua scripting, I am looking for suggestions which method could be used :-)

* It doesn't even have to be performance optimized, since this situation does only happen very, very rarely.
8611
XTA Developer
Posts: 242
Joined: 29 Dec 2014, 08:22

Re: Visual effect below lowest map level (voidground/voidwat

Post by 8611 »

qray wrote: And the limit is y=-90 which is the minheight of the map (and at that place also the ground level).
I think only part that matters is if the CEG is spawned above terrain or below terrain.
(at least if that altitude check is correct part of engine)
It might be worth a feature-request to allow to call SpawnCEG() with below-ground coordinates: if some gadget does that then engine should just assume there is a good reason ;)
For example when the ground is invisible or even if just to see only the top part of effect clip through terrain.
But any method to give some small visual feedback is OK for me
Spring's Lua GL drawing does not care if it something is under terrain, so can use that. Maybe a billboarded sprite with a "flare" texture that fades out or something would already look okayish.
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: Visual effect below lowest map level (voidground/voidwat

Post by Anarchid »

Dirty hax available i think:

1) Write a ceg that takes the damage operator to shift the position of the second phase, a spawner.
2) Spawn the ceg via gadget while specifying damage = depth.

Alternatively second phase could be not a spawner but some other projectile class. Unsure if this woudl work at all.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Visual effect below lowest map level (voidground/voidwat

Post by Beherith »

I know this may seem like a hacky workaround, but it might make sense. You need to be using 16bit raw for heightmap in this case as you would lose too much precision otherwise.
Set one pixel (bottom right, or whichever, just make sure its not top left (x=0,z=0)) to be absolute black, and shift the rest of the heightmap up by 50%.
User avatar
qray
Posts: 377
Joined: 02 Feb 2009, 18:49

Re: Visual effect below lowest map level (voidground/voidwat

Post by qray »

Just for completeness: as promised above, the ceg script is attached to this post.
qray wrote: And the limit is y=-90 which is the minheight of the map (and at that place also the ground level).
You're right. It's only above/below ground. Which just coincidentally is the same at this position in the map.
8611 wrote: It might be worth a feature-request to allow to call SpawnCEG() with below-ground coordinates: if some gadget does that then engine should just assume there is a good reason ;)
Right. Or maybe an additional option to trigger below surface visibility?!


Thanks for all the suggestions! :-)

Since Anarchid's proposal seems like a hack (sorry :wink:) with unsure outcome and Beherith's idea would involve quite some effort(*) and still be limited depth wise and not cover the slope areas close to the visible grounds, I think I will give the GL solution proposed by 8611 a try.

Since I am really new to (Lua) GL and the wiki page lists all the functions but not much explanations, do you happen to know a simple example or some introduction which you could point me to?
Originally, my idea was to have some visual effect similar to switching off an old CRT TV (like when switching off an Android smartphone).



(*) height map is made manually in inkscape and krita
Attachments
blue_explosion.lua
(13.4 KiB) Downloaded 4 times
8611
XTA Developer
Posts: 242
Joined: 29 Dec 2014, 08:22

Re: Visual effect below lowest map level (voidground/voidwat

Post by 8611 »

*if* CEG never can get spawned under the ground the making some random pixel superdeep like Beherith suggest would not do anything.


Since I am really new to (Lua) GL and the wiki page lists all the functions but not much explanations, do you happen to know a simple example or some introduction which you could point me to?
For GL details better to trust wiki or some tutorial but something like this works:

Code: Select all

function widget:DrawWorld()
	gl.PushMatrix()
	gl.DepthTest (true)
	gl.Texture("bitmaps/wake.png") --this texture that exists in BA
	gl.Translate(100,100,100)
	gl.Billboard()
	gl.TexRect(0,0,50,50)	
	gl.PopMatrix()
end
User avatar
qray
Posts: 377
Joined: 02 Feb 2009, 18:49

Re: Visual effect below lowest map level (voidground/voidwat

Post by qray »

Thanks for the input! :-)

Already started on the side reading some basic OpenGL introductions. Will see what I can cook up.
8611 wrote:*if* CEG never can get spawned under the ground the making some random pixel superdeep like Beherith suggest would not do anything.
Yes, I would have had to change the complete ground in the void to superdeep - which admittedly would not have been very complicated if you touch height map anyway; but as mentioned above, this would have still left the (steep slope) transition borders uncovered.
With luaGL it will be probably also more reusable for other maps without adjustments...
User avatar
qray
Posts: 377
Joined: 02 Feb 2009, 18:49

Re: Visual effect below lowest map level (voidground/voidwat

Post by qray »

Found some time to implement it in the gadget and it works like a charm! 8)

Thanks again!
Post Reply

Return to “Lua Scripts”