Lua Skybox

Lua Skybox

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

Moderator: Moderators

Post Reply
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Lua Skybox

Post by Beherith »

Hi dear Lua Coders!

I highly dislike asking for favors, but could someone, who is better at lua and openGL than me, please make a widget that draws a skycube around the map? I would like to rotate it via lua to make it look like map is in orbit.

I would be very grateful, and help your project in return with whatever you need and I can provide.

Thanks!
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7049
Joined: 16 Nov 2004, 13:08

Re: Lua Skybox

Post by zwzsg »

Can I have the texture? Or at least, know how you'd unwrap the cube?
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Lua Skybox

Post by jK »

The problem is that the current interface can't handle Cubemaps - except the engine ones and those only via shaders.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Lua Skybox

Post by Beherith »

Well, I was thinking all I need is 6 drawn quads, I can set the textures for them manually. Dont know if 6 textures are better than 1 in this case.
Unwrap could be standard cross? But this wastes half the tex space, so maybe a compressed run of 2x3 squares? But thats not pow2 size...

Thanks zw:

Skybox:
http://beherith.eat-peet.net/stuff/Eta_ ... eherith.7z
Image

jK, How much of a performance hit would it really be if i had lua just draw 6 quads way outside before drawworld?
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10450
Joined: 24 Jan 2006, 21:12

Re: Lua Skybox

Post by PicassoCT »

Behe you are the meanest battering ram evar approaching the gates of featurecastle. We are going to have tumbling meteroids - Hurray
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Lua Skybox

Post by jK »

Beherith wrote:jK, How much of a performance hit would it really be if i had lua just draw 6 quads way outside before drawworld?
The advantages of Cubemaps are:
* you need to bind just 1 texture instead of 6
* you just need to render 1 fullscreen-quad instead of a cube


PS: a 24MB uncompressed dds is everything else than fast to render ;)
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Lua Skybox

Post by Beherith »

I am familiar with the advantages of a cubemap, jK.
Though you yourself just pointed out that the bindings for such are unavailable at the moment. So the question was, is it gonna be that big of a performance hit on modern gpus to manually render the cube for a cubemap?
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7049
Joined: 16 Nov 2004, 13:08

Re: Lua Skybox

Post by zwzsg »

Beherith wrote:please make a widget
I tested it as a \LuaRules\Gadgets\ but I assume it would work as well in LuaGaia. Read it for details about the texture.

In :nc: the :n: means nearest and the :c: clamped. You will probably want :l: (linear interpolation) instead of :n:

Since polygons are one-sided, I would have expected half my faces to be inverted, but somehow it's not the case. If it happened to be the case, then iterate through the vertice of each face the other way by exchanging some pair of lines positions in the script.

I am not sure about my TexCoord, feel free to edit their values if you find oddities in the UV-mapping.

Oh by the way, for the bottom face I recommend replacing the 1/3 by 0.33, so you have at least one pixel margin on the two edges of the bottom face that touch west and south faces. All the others /3 can stay /3 as anyway every other edge is either actually shared, touching border (and thanks to the :c: won't interpolate to the opposing border), or touching an unused UV space.

My local d= is too low. I'm pretty sure that you could see a face of the cube cutting a corner of the map if you look at it from the opposite corner while the cube is sideway. So replace 1.2 with 1.5. Also, instead of recalculating d every frame, you could make it a constant. Anything bigger than the map diagonal + camera height, but lower than whatever values makes OpenGL coordinates overflow.


Image
Attachments
GreatCubeInTheSky.lua
(2.83 KiB) Downloaded 142 times
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Lua Skybox

Post by Beherith »

Thank you very much, its all I ever dreamed it to be :D
What can I do for you?
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7049
Joined: 16 Nov 2004, 13:08

Re: Lua Skybox

Post by zwzsg »

Beherith wrote:What can I do for you?
I want to just save that voucher for a Beherith hand for later. I'm sure I could use it, but I wouldn't want to waste such an offer only to find it spent when I'll really need it.
Attachments
GreatCubeInTheSky.lua
V2
- Corrected comments about faces.
- Made it spin in a dizzier way.
- Texture not mirrored anymore.
- Bug: When interpolating on the picture border, Spring fades to transparent.
(2.72 KiB) Downloaded 135 times
User avatar
Pxtl
Posts: 6112
Joined: 23 Oct 2004, 01:43

Re: Lua Skybox

Post by Pxtl »

Heheh, I'd love to see a Beherith-designed KP map, personally - not that I'm in the position to ask.
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Lua Skybox

Post by CarRepairer »

Does this mean we can finally draw a giant f--- in sky?

Oh man I just couldn't help myself. <3 emmanuel
User avatar
Tribulex
A.N.T.S. Developer
Posts: 1894
Joined: 26 Sep 2009, 21:26

Re: Lua Skybox

Post by Tribulex »

yeah and we can animate said f*** in sky
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Lua Skybox

Post by Beherith »

Thanks, looks pretty freakin sweet ingame :D
luckywaldo7
Posts: 1398
Joined: 17 Sep 2008, 04:36

Re: Lua Skybox

Post by luckywaldo7 »

Beherith wrote:I would like to rotate it via lua to make it look like map is in orbit.
I sense epicness incoming
Satirik
Lobby Developer
Posts: 1688
Joined: 16 Mar 2007, 18:27

Re: Lua Skybox

Post by Satirik »

did you stop working on the ice map behe ? :D
Post Reply

Return to “Lua Scripts”