solution for texture3D? (1st test) DayNightCycle

Texture3D-test - Webplayer


hi all,

was thinking about this for the last 2 weeks and i have some first ideas how to do it with scripting but i wonder if there isn’t still a solution for something like a texture-cube?

now what am i talking about?
what i want to achieve is sort of a animated texture for day-night-cycles, especially for the lightmaps.

my first attempt was to do a blend form a bright to a dark lightmap and back, but the transition doesnt look right.

the other extreme would be a movie-texture as lightmap, but there would be too few control on playback, no to speek about memory …

so i came up with the following:
to keep it simple lets say there are 4 lightmaps: morning, midday, dawn and night.
a special “shader” has an accessible rangeslider 0.0-1.0 (or 0-360)
the lightmaps are connected to the slider as follows:
night->0.00, morning->0.25, midday->0.50, dawn->0.75, and again night->1.0 to complete the cycle.

as daytime moves on, the rangesliders variable increases and the “shaders” output is a blend between the two appropriate lightmaps. ( e.g.: slider at 0.55 → blend midday(80%)*dawn(20%) )

of course, doing all this blending stuff by script at each fram-update would bloat the shader way up through the ceiling :wink:

my idea is to do all the blending stuff in an extra script which is called every few seconds to minutes, depending on the cycle speed etc. and export the output texture to the real shaders lightmap.

i also was thinking about some kind of script attached to the rangeslider doing all the cycle stuff automatically etc…

what do you think?
might this be working?
will it work with unity free?

cheers siggi

bump :smile:

Texture3D-test - webplayer

got it running.
works with 6 textures(1024²), the transitions aren’t perfect, but a good start, framerate could be better but i reassign the 2 blend-textures whith every FixedUpdate atm.

please no comments on the “superb” art asset :wink:

[edit] - updated sky and ground

yeah, so - bump again …

is there any specific information, if intel gma based hardware does not support lerp in shaders?

[edit] the “testing machine” which failed is a IBM NetVista with Intel GMA845-chipset. [/edit]

     SetTexture [_TEX_1] {}
     SetTexture [_TEX_2] {
          ConstantColor (1,1,1,[_Blend])
          combine texture lerp(constant) previous          
     }

in the shader renders simply black on some older intel gma devices.
done a few test and its with the “combine lerp()” - statement.
actually, theres nothing more than the 2 _TEX and the _BLEND (0.0 - 1.0) in the shader at this point, lighting is off, the textures fully baked, no lightsource in the scene.

found some info on combine src1*scr2+scr3 not supported on all hardware, but nothing specific about lerp.

maybe someone more experienced can enlighten me …

thank you, siggi

P.S.: maybe this thread would be better placed in the shaderlab section? if one of you almighty admins read this, feel free to do so :sweat_smile: