[SOLVED?] - Snapping Cloud Textures and Bright-Night Clouds

Giawa

01-08-2009 02:20:07

Hi everyone,

I saw some videos of Caelum in action and loved it. I've written another port of Caelum to C#. Instead of using Mogre I'm using a custom graphics engine that I've developed. I'll be releasing the source code back to the project as soon as I get the quirks worked out. Anyways, everything has gone swimmingly except for the clouds. I've converted the cg shader code into equivalent (to the best of my knowledge) GLSL code. I've also made some small optimizations (eliminating the need for a world matrix by deriving the world co-ordinates using layerHeight and the vertex positions, etc). The vertex and fragment shader are posted on pastebin:

Fragment Shader: http://giawa.pastebin.com/m3a29b57e
Vertex Shader: http://giawa.pastebin.com/m4c55ff69
YouTube Video: http://www.youtube.com/watch?v=yA-FYvQWpnM
'Fixed' YouTube video: http://www.youtube.com/watch?v=5YljIL9N_sU

I've made a youtube video of what I'm experiencing (the youtube video is HD, but is still processing, so HD may take some time to become available). Can anyone make any suggestions as to what might be happening? Specifically I'm confused about the snapping cloud textures and bright clouds during night time. Thanks in advance, and thanks for the great plug-in!

Edit: I've uploaded a new youtube video that only exhibits the issue I am having with the clouds blending at night. I'm using a cheap hack at the moment, but if anyone has comments or suggestions, please let me know.

Edit: I think I'm okay with how it looks now. I'm basically only using the cloudColour value, and not using 'thickness', 'sunGlow', etc as defined in the fragment program. I'm not sure what is causing thickness to error and cause mix to fail, but perhaps I'll look into it in the future. For now, this is good enough :D I've uploaded another youtube video showcasing the 'fixes'.





Giawa

Giawa

01-08-2009 03:05:47

The snapping cloud texture problem is fixed. setCloudBlendPos was calling a C++ method called fmod. I should have done some more research before selecting IEEERemainder as my replacement function. I've written my own quick'n'dirty version of fmod, and there's no more snapping.

I'm curious about the clouds staying bright during the night. Any ideas?

Thanks,
Giawa

Fish

01-08-2009 11:44:19

Have a look at the GLSL shader code at this link. This code works as expected.

edit: and this probably does not affect all glsl compilers but most of the video cards I've tested (mostly older cards 1995+, Nvidia and ATI) will reject a shader that uses constant integer values (i.e. vec3(1, 0, 1.13983) ) instead of constant float values (i.e. vec3(1.0, 0.0, 1.13983) ).

-Fish

Giawa

01-08-2009 20:44:43

Hi Fish,

Thanks for the reply. I tried using that GLSL code, and it is equivalent to what I am using. The clouds still stay quite bright at night. Is there a particular place I should look in the shader and code to track this down?

Thanks,
Giawa

Giawa

02-08-2009 18:34:33

Here's the initialization code for the FlatCLoudLayer. My Material system is very different from Ogre's, and I don't have the ability (yet) to load shader defaults from a material file. So I've made sure to set all the defaults in this code.

public void Reset()
{
MeshDirty = true;
setMeshParameters(1000000, 1000000, 10, 10);

pCloudMassInvScale.SetValue(1.2f);
pCloudDetailInvScale.SetValue(4.8f);
pCloudDetailBlend.SetValue(0.5f);
pCloudSharpness.SetValue(4f);
pCloudThickness.SetValue(1f);

setCloudCover(.15f);
setCloudCoverVisibilityThreshold(0.001f);

setCloudMassOffset(new Orchard_Sun.Vector2(0, 0));
setCloudDetailOffset(new Orchard_Sun.Vector2(0.5, 0.5));
setCloudBlendPos(0.9f);

this.CloudBlendTime = 3600 * 24;
this.CloudSpeed = new Orchard_Sun.Vector2(0.000005, -0.000009);

setCloudUVFactor(50);
setHeightRedFactor(100000);

setFadeDistances(500, 5000);
setFadeDistMeasurementVector(new Orchard_Sun.Vector3(0, 1, 1));

setSunDirection(Orchard_Sun.Vector3.UnitY);
setFogColor(Color.Black);
setSunLightColor(Color.White);
setSunSphereColor(Color.White);
}


Giawa