I need help! Sky with clouds and starry night.

Adeon

terasology.ru
Contributor
Architecture
GUI
Logistics
Guys, I have a problem.

First I didn't know how to make the shadow on the clouds. But then I found the way to do it.I take two points near the current point in the fragment shader. So the nearer the point is situated to the Sun, the lighter it is.

This code responds for the shadow:
Code:
        for (float i=0.0; i<6.0; i+=1.0){
            posParticleCloud = 0.2*(cloudVec + sunDirection)*i;
            n2  = clouds ( posParticleCloud, time*10.5, vec2 ( 0.03, 0.01 ) ); 
            shadowCloud += 0.07*mix ( skyColor, vec4(1.0,1.0,1.0, 1.0), density ( n2.y, 3.5 ) );
        }
Sky with clouds:
Code:
vResColor = mix ( skyColor, vec4(clamp(ResColor.xyz*(ResColor.xyz - shadowCloud.xyz), 0.0, 1.0), 1.0), density ( n1.y, 3.5 ) );
As the result we get nice clouds:


It's possible to make several layers of clouds.
I made the animated night with the help of a texture.


The ability of the stars to be seen depends on how high the Sun is.:


This code responds for the transparency of the texture:
Code:
skyColor += alpha*textureCube ( texCube, skyVec );
And now I want to tell about the problem that I've been trying to understand and to solve for already three nights. Why when I mix the colour of the night and the colour with the clouds I get the sky coloured black? Please help me.I can't understand where I could make a mistake. The whole code is in my latest commit.
 

begla

Project Founder and Lead Developer
Contributor
Architecture
Logistics
First of all: Looks really cool! :shock:

Could you describe your problem a bit more deeply? I don't know where I should start looking exactly.
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Yeah, I second the "really cool" - but this is way out of my comfort zone. I like the diagram :D
 

Adeon

terasology.ru
Contributor
Architecture
GUI
Logistics
Thanks. =)

So, lets watch through the commit 467fd8b71f.

Line 70:
Code:
float alpha  = (0.7-posSunY) * (1.0 - lv);
The transparency of the colour of the texture of a starry sky is calculated.

Line 76:
Code:
vec4 skyColor = vec4	( clamp ( convertColor (), 0.0, 1.0 ) + sunHighlight + largeSunHighlight, 1.0 );
The result of this line is the final colour of the sky with the Sun.

Line 99:
Code:
 skyColor += alpha*textureCube ( texCube, skyVec );
The colour from a texture of a starry sky mixes with the current colour of the sky.

Line 109:
Code:
ResColor = mix ( skyColor, vec4(clamp(ResColor.xyz*(ResColor.xyz - shadowCloud.xyz), 0.0, 1.0), 1.0), density ( n1.y, 3.5 ) );
The result of this line is the clouds appearing in the sky.

Now, if we assign the result to gl_FragColor from line 99, then we will have the dinamic change of day and night. Or if hide the line 99 (with the help of /**/ or //) and assign the result to gl_FragColor from line 109, then we will have clouds in the sky. BUT, if we don't hide the line 99 and assign result to gl_FragColor from line 109, then the sky will be black.
Where could I make a mistake?
 

begla

Project Founder and Lead Developer
Contributor
Architecture
Logistics
I just checked out your the lastest changes from your branch "SkySphere" and I directly see a pitch black sky at any time of the day. Following your description this should not happend, since the output is assigned in the following form:

Code:
gl_FragColor = skyColor;
Looks like the error lies somewhere deeper. I will double check if this behavior is only related to Mac OS X.
 

begla

Project Founder and Lead Developer
Contributor
Architecture
Logistics
It works the way you described using Windows. This behavior under Mac OS X might be related to the actual problem. I'll start working through your code now. :)
 

begla

Project Founder and Lead Developer
Contributor
Architecture
Logistics
The error must be somehow related to the cube map of the stars. I can not display the cube map at all using OS X, while it works separately under Windows. Using Windows the error only occurs when the cube map is used in combination with the clouds. Very strange... Drives me mad already. :unsure:

But take it as a hint, that the cube map does not work at all under OS X. Maybe that'll help you narrowing down the problem. I'll continue digging.
 

begla

Project Founder and Lead Developer
Contributor
Architecture
Logistics
Okay, the cube map works fine under Mac OS X if no lookup on 3D texture has been performed. Very strange problem... Almost seems like if one of the textures was touched, the other one can no longer be accessed. :?
 

begla

Project Founder and Lead Developer
Contributor
Architecture
Logistics
Seems like this error arises when a 3D texture sampler and a cube map sampler are used in the same texture unit. The best idea might be to move the clouds to a separate shader and map them onto a simple plane? That would also remove the "effect" that the clouds stick on the skysphere (which looks somehow irritating to say the least).

Would that be a valid solution from your kind of perspective Anton? :)
 

Adeon

terasology.ru
Contributor
Architecture
GUI
Logistics
Yes, I had an idea like that.
But then we'll have to calculate the colour of the sky twice in order to apply it on the clouds (for example, at sunset) futher.:(
 

begla

Project Founder and Lead Developer
Contributor
Architecture
Logistics
Adeon said:
Yes, I had an idea like that.
But then we'll have to calculate the colour of the sky twice in order to apply it on the clouds (for example, at sunset) futher.:(
Damn it. I knew there was a downside to that approach. Working with transparency is not going to work?
 

Adeon

terasology.ru
Contributor
Architecture
GUI
Logistics
Yes, Benjamin, you were right.
It would be better to create a little distorted plane. All my attempts to transform texture coordinates failed. By the way I want to ask you such a question: should I also do clouds like that?
 

begla

Project Founder and Lead Developer
Contributor
Architecture
Logistics
Adeon said:
Yes, Benjamin, you were right.
It would be better to create a little distorted plane. All my attempts to transform texture coordinates failed. By the way I want to ask you such a question: should I also do clouds like that?
Three words: Yes, of course! :D How could I possibly say no? I've skimmed the paper and as far I can see those clouds already found their way into many current games. The only problem I can see is that such realistic clouds might not fit the style of the game (and maybe have a drastic impact on the performance). What do you think?
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
I think all options are still open, and super super pretty clouds would be great, but yeah, we need to start thinking more about performance soon enough - so keep that in mind :)

I have no clue how intensive the clouds would be, or whether they'd be able to take advantage of GPU power rather than CPU (which seems our primary power source so far).

Style - well, super realistic clouds would go best in a game where they're matched by the rest of the world, true, which I don't think we can imagine. But at the same time I don't think we should limit ourselves to blocky-only stuff either (would help gain distinction). So a good compromise with nice clouds that don't cause a CPU meltdown would be best :)
 

Adeon

terasology.ru
Contributor
Architecture
GUI
Logistics
Yes, you're right, both of you. We should follow the style of the game. And yes, the clouds occupy many CPU resources. It's a pity, a thousand pities. I had an idea - for example if the player had a dragon, it would be great to fligh through them (I mean the clouds). Or the player could craft the device, which could draw (pull) them to his "castle in the air", hiding it.:) I offer to do the following - I will give up that idea for some time. I'll leave only those clouds which we have now. And the skySphere will paintonly day and night. And for the clouds... I'll come up with something soon. At the moment my priorities are post and hdr effects.
 

begla

Project Founder and Lead Developer
Contributor
Architecture
Logistics
Adeon said:
Yes, you're right, both of you. We should follow the style of the game. And yes, the clouds occupy many CPU resources. It's a pity, a thousand pities. I had an idea - for example if the player had a dragon, it would be great to fligh through them (I mean the clouds). Or the player could craft the device, which could draw (pull) them to his "castle in the air", hiding it.:) I offer to do the following - I will give up that idea for some time. I'll leave only those clouds which we have now. And the skySphere will paintonly day and night. And for the clouds... I'll come up with something soon. At the moment my priorities are post and hdr effects.
Sounds great Anton. Just tell me when you got something ready I can merge into our develop branch. Can't wait to see your day-night-cycle going live! :D I'm curious how HDR rendering in Blockmania is going to look.
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
As for super fancy sky stuff, there are always expansion packs :D
 

Adeon

terasology.ru
Contributor
Architecture
GUI
Logistics
So, I deleted unnecessary code and corrected the time. Benjamin, please update your main branch. Well now I can say, HDR I comming to you!
 

begla

Project Founder and Lead Developer
Contributor
Architecture
Logistics
Adeon said:
So, I deleted unnecessary code and corrected the time. Benjamin, please update your main branch. Well now I can say, HDR I comming to you!
Will do so right now! :D
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Curiously, is there much of any use to setting up the Pull requests via GitHub? I guess it might not really matter (certainly don't wait for one if something is ready), but maybe something for us to get used to :)

I tossed my understanding of one from last we tried here: http://wiki.movingblocks.net/Main/DevSe ... ll_request

Looking forward to seeing the new stuff in action!
 
Top