day-night loop with sun/moon and sky

Problems building or running the engine, queries about how to use features etc.
slapin
Bronze Sponsor
Bronze Sponsor
Posts: 77
Joined: Fri May 23, 2025 5:04 pm
x 2

day-night loop with sun/moon and sky

Post by slapin »

Hi, all!
Is there some dynamic sky implementation? I don't need anything fancy, just Sun/Moon with directional light attached ans sky with ability to express a few periods during the day like sunset, no need to be photo-realistic or anything. I totally failed with ogre-caelum and I don't think it will ever work for me anyway.
Need it to work with GLES2 rendersystem.

User avatar
sercero
Bronze Sponsor
Bronze Sponsor
Posts: 513
Joined: Sun Jan 18, 2015 4:20 pm
Location: Buenos Aires, Argentina
x 188

Re: day-night loop with sun/moon and sky

Post by sercero »

Hello,

Have you seen this?
https://github.com/OGRECave/ogre-caelum

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 77
Joined: Fri May 23, 2025 5:04 pm
x 2

Re: day-night loop with sun/moon and sky

Post by slapin »

Yes, but I need something simpler and more flexible which I could make run over weekend (which ogre-caelum can't do).
The demo doesn't work on my computers and I need something much more simple. I just need gradient shader over skybox w/o any images, sun + moon meshes and all that synchronized to directional light. And I will be able to extend from there. The cartoonier/simpler the better.

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 77
Joined: Fri May 23, 2025 5:04 pm
x 2

Re: day-night loop with sun/moon and sky

Post by slapin »

Now I just made a few gradient (black-pink-blue) sets of textures for skyboxes. If I find how to disable filtering for them and modulate them by color
the skybox part will be solved. Or if there some vertical gradient shader in there usable with skybox, that's be fine too. I could do shaders maybe but not in Ogre yet.

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 77
Joined: Fri May 23, 2025 5:04 pm
x 2

Re: day-night loop with sun/moon and sky

Post by slapin »

Next I will need to steal somewhere the proper rotation of sun/moon over sky in relation to directional light, that part sounds most complicated to me.
But after that I'm totally good with sky system.

rpgplayerrobin
Orc Shaman
Posts: 741
Joined: Wed Mar 18, 2009 3:03 am
x 415

Re: day-night loop with sun/moon and sky

Post by rpgplayerrobin »

If I find how to disable filtering for them and modulate them by color

Search for "scene_blend" here:
https://ogrecave.github.io/ogre/api/lat ... otoc_md126

Search for "filtering" here:
https://ogrecave.github.io/ogre/api/lat ... otoc_md181

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 77
Joined: Fri May 23, 2025 5:04 pm
x 2

Re: day-night loop with sun/moon and sky

Post by slapin »

Thanks! Will try that.

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 77
Joined: Fri May 23, 2025 5:04 pm
x 2

Re: day-night loop with sun/moon and sky

Post by slapin »

need tutorial on skybox shaders (better without actual GLSL using internal shader generator if possible) and how to control these from code.
All I need is 3 color gradient on 4 cube planes and constant color on 2. Could not achieve much by now :(

paroj
OGRE Team Member
OGRE Team Member
Posts: 2180
Joined: Sun Mar 30, 2014 2:51 pm
x 1168

Re: day-night loop with sun/moon and sky

Post by paroj »

did you already try using a cube with vertex colors?

Image

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 77
Joined: Fri May 23, 2025 5:04 pm
x 2

Re: day-night loop with sun/moon and sky

Post by slapin »

paroj wrote: Sun Jun 08, 2025 12:42 pm

did you already try using a cube with vertex colors?

Image

Do you suggest replacing cubemap with regular cube?

rpgplayerrobin
Orc Shaman
Posts: 741
Joined: Wed Mar 18, 2009 3:03 am
x 415

Re: day-night loop with sun/moon and sky

Post by rpgplayerrobin »

I guess that is what he means.
Since what you wanted was just 2 planes (top and bottom most likely) to be a solid color (most likely two different solid colors), while the other 4 planes (forward, left, right, back) had a gradient between those colors.

You could easily then just make that cube in code and input the vertex colors of it by using a ManualObject.

You could also just place a cube there and render it with your own made shader that does this automatically from the positions of the vertices instead.

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 77
Joined: Fri May 23, 2025 5:04 pm
x 2

Re: day-night loop with sun/moon and sky

Post by slapin »

Still need help with this.
Lets abstract it with simple question:
How can I modify the following material to support shader parameters and tech:

Code: Select all

material Skybox
{
        technique
        {
                pass
                {
                        lighting off
                        depth_write off

                    texture_unit
                    {
                            texture simple_sky.jpg cubic
                            tex_address_mode clamp
                    }
            }
    }
}

a. modulate with color which I can set from code, Without making cube with vertex color.
b. add texture masks for 3 colors. to modulate stuff separately and blend back together.
c. use texture atlas for all that.

I want to do it using internal shader generation system because I want to learn it to avoid custom shader code
as the thing I want is pretty basic. If that is not possible that is fine too, but I need to understand. I want to stay as
platform compatible as possible with this.

Also I need advice on how to change shader parameters for shaders, generated by internal shader generation system
and to custom shader programs too.

paroj
OGRE Team Member
OGRE Team Member
Posts: 2180
Joined: Sun Mar 30, 2014 2:51 pm
x 1168

Re: day-night loop with sun/moon and sky

Post by paroj »

the cubemap is rendered by texturing the inside of a cube. Both vertex colors and the cubemap are shader parameters - just passed via different memory paths. You can also create a 8px cubemap instead of vertex colors (24px actually due to how cubemaps work).
You can probably force the RTSS somehow to modulate the vertex colors via a fake texture unit - or you can just multiply the vertex colors directly ;)

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 77
Joined: Fri May 23, 2025 5:04 pm
x 2

Re: day-night loop with sun/moon and sky

Post by slapin »

The advice is appreciated but example would be super cool to have.