View topic - Lua Skybox



All times are UTC + 1 hour


Post new topic Reply to topic  [ 16 posts ] 
Author Message
 Post subject: Lua Skybox
PostPosted: 11 May 2010, 20:06 
Moderator
User avatar

Joined: 26 Oct 2007, 15:21
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!


Top
 Offline Profile  
 
 Post subject: Re: Lua Skybox
PostPosted: 12 May 2010, 00:20 
Kernel Panic Co-Developer
User avatar

Joined: 16 Nov 2004, 13:08
Can I have the texture? Or at least, know how you'd unwrap the cube?


Top
 Offline Profile  
 
 Post subject: Re: Lua Skybox
PostPosted: 12 May 2010, 00:26 
Spring Developer
User avatar

Joined: 28 Jun 2007, 06:30
The problem is that the current interface can't handle Cubemaps - except the engine ones and those only via shaders.


Top
 Offline Profile  
 
 Post subject: Re: Lua Skybox
PostPosted: 12 May 2010, 00:33 
Moderator
User avatar

Joined: 26 Oct 2007, 15:21
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_Carinea_Beherith.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?


Top
 Offline Profile  
 
 Post subject: Re: Lua Skybox
PostPosted: 12 May 2010, 00:35 
Journeywar Developer & Mapper
User avatar

Joined: 24 Jan 2006, 21:12
Location: There is no god - and reality is his prophetess
Behe you are the meanest battering ram evar approaching the gates of featurecastle. We are going to have tumbling meteroids - Hurray


Top
 Offline Profile  
 
 Post subject: Re: Lua Skybox
PostPosted: 12 May 2010, 00:39 
Spring Developer
User avatar

Joined: 28 Jun 2007, 06:30
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 ;)


Top
 Offline Profile  
 
 Post subject: Re: Lua Skybox
PostPosted: 12 May 2010, 08:59 
Moderator
User avatar

Joined: 26 Oct 2007, 15:21
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?


Top
 Offline Profile  
 
 Post subject: Re: Lua Skybox
PostPosted: 12 May 2010, 12:00 
Kernel Panic Co-Developer
User avatar

Joined: 16 Nov 2004, 13:08
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 110 times
Top
 Offline Profile  
 
 Post subject: Re: Lua Skybox
PostPosted: 12 May 2010, 14:03 
Moderator
User avatar

Joined: 26 Oct 2007, 15:21
Thank you very much, its all I ever dreamed it to be :D
What can I do for you?


Top
 Offline Profile  
 
 Post subject: Re: Lua Skybox
PostPosted: 12 May 2010, 20:48 
Kernel Panic Co-Developer
User avatar

Joined: 16 Nov 2004, 13:08
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:
File comment: 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.

GreatCubeInTheSky.lua [2.72 KiB]
Downloaded 109 times
Top
 Offline Profile  
 
 Post subject: Re: Lua Skybox
PostPosted: 12 May 2010, 21:13 
User avatar

Joined: 23 Oct 2004, 00:43
Heheh, I'd love to see a Beherith-designed KP map, personally - not that I'm in the position to ask.


Top
 Offline Profile  
 
 Post subject: Re: Lua Skybox
PostPosted: 12 May 2010, 22:00 
Cursed Zero-K Developer
User avatar

Joined: 07 Nov 2007, 21:48
Location: Horse
Does this mean we can finally draw a giant f--- in sky?

Oh man I just couldn't help myself. <3 emmanuel


Top
 Offline Profile  
 
 Post subject: Re: Lua Skybox
PostPosted: 13 May 2010, 11:04 
A.N.T.S. Developer
User avatar

Joined: 26 Sep 2009, 20:26
Location: Ukraine
yeah and we can animate said f*** in sky


Top
 Offline Profile  
 
 Post subject: Re: Lua Skybox
PostPosted: 13 May 2010, 11:23 
Moderator
User avatar

Joined: 26 Oct 2007, 15:21
Thanks, looks pretty freakin sweet ingame :D


Top
 Offline Profile  
 
 Post subject: Re: Lua Skybox
PostPosted: 13 May 2010, 12:12 

Joined: 17 Sep 2008, 03:36
Location: your imagination
Beherith wrote:
I would like to rotate it via lua to make it look like map is in orbit.

I sense epicness incoming


Top
 Offline Profile  
 
 Post subject: Re: Lua Skybox
PostPosted: 13 May 2010, 13:29 
Lobby Developer

Joined: 16 Mar 2007, 18:27
did you stop working on the ice map behe ? :D


Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Site layout created by Roflcopter et al.