Page 1 of 1

Real-Time Skybox?

Posted: 2012-08-24, 15:38
by morvayn
before I use Cafu Engine for my project (a game), I have a question

I want my game real-time, which day and night cycles, so I think that needs real-time skybox. the question is, is real time skybox is already a feature or I must do that manually(such as scripting), if manually please provide me with tutorial :D

sorry for bad grammar, I am asian :cheesy:

Re: Real-Time Skybox?

Posted: 2012-08-24, 17:01
by HWGuy
If you need a dynamic 2D skybox, you could alter the skybox texture in realtime, this would let you have dynamic sun and the base sky colouring, a shader could do that for GPU acceleration.

For clouds you'd probably just want a transparent 2D ceiling texture, along with a shader you could have fake 3D volumetric clouds.

Re: Real-Time Skybox?

Posted: 2012-08-24, 17:05
by morvayn
HWGuy wrote:If you need a dynamic 2D skybox, you could alter the skybox texture in realtime, this would let you have dynamic sun and the base sky colouring, a shader could do that for GPU acceleration.

For clouds you'd probably just want a transparent 2D ceiling texture, along with a shader you could have fake 3D volumetric clouds.
thanks for the reply!
I will use Cafu Engine from now and will post for updates! :cheesy:

Re: Real-Time Skybox?

Posted: 2012-08-24, 23:31
by Carsten
Hi morvayn,
welcome to the Cafu forums! :welcome:

I think HWGuy said it all already. Just to be very precise: dynamic skyboxes are not a built-in feature yet. As he said, you'll have to add some code to achieve the desired effect yourself. :up:

Re: Real-Time Skybox?

Posted: 2012-08-25, 13:14
by Kai
Hi morvayn :)

Whenever it comes to dynamic elements you have to make sure to clearly state your term of "dynamic".
As i would understand it, it means to be able to fully control its features at any given time.

As for a sky system you also have to make sure to tell what your idea here is.
Is the sun casting a realtime shadow, will it change color and atmospheric haze over time ? Are there clouds and if so what is their influence (sunlit, scatter, change of shape casting shadows etc.. )

Sky is a complex element and one should think about how much features are needed and in what way.
also the todays skyboxes are actually domes due to the fact that there is a much better perpendicular surface which prevents distortion and todays cards can handle more polygons than a few years ago.

First and most important is the overall texture of the sky. This could be a color gradient (small memory print) or some photo or 3d render based average image including haze, clouds and so on.
If you use clouds in your sky texture, be aware those are static, so you could only move the entire texture\dome. Alternatively you could move clouds on their own layer in front of the pure sky.

Sun is a critical element here. If you really need it to move you would expect dynamic shadows and lit surfaces. This is something cafu is unfortunatly not really good at. You could have the sun cast shadows but the performance would pretty much drop due to it's hard shadow nature, and it would not look very natural as there is no penumbra (spreading or softening shadow based on distance)
Thats why Doom 3 only had few small outdoor areas.

But you could do a setup where you would blend between different stages of times .. if on cycle would really take a 24h of actual time that would be no problem.
For example Bethesda's "Fallout" Engine does NOT cast any shadows for environment elements like trees, stones and all that is outside , yet it does look really great !

It would require that terrain is not lit by a primary source but rather diffuse lit, like an ambient occlusion based approach, then lit surfaces with one primary light that does not cast shadows.

Re: Real-Time Skybox?

Posted: 2012-08-25, 19:54
by afgho
Don't know if that may help but i made (actually a modified fx composer shader) a sky shader once for the CgARB1 renderer, the shader seemed to work great but i did not found how to bind it with Cafu correctly, it is flickering along with many visual bugs and this flickering depend on the player position if i recall, guess it is some issue with Cafu <> the shader binding.

Anyway if someone is interested, the (bad, sorry) code is here:

https://dl.dropbox.com/u/64479453/code/cafu/A_Sky.cpp

It is very tricky, a brush need to be added with a material that contain A_Sky shader, the brush will not render, a large sphere of fixed size with the shader applied will replace the brush.

You could also use simpler method with simple gradients:
http://unt.academia.edu/IanParberry/Pap ... D_Hardware