Simple sky shader

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
User avatar
Mangetsu
Kobold
Posts: 28
Joined: Sun Jul 17, 2005 6:15 pm
Location: Sweden

Simple sky shader

Post by Mangetsu »

ATI Render Monkey's "Atmospheric - Blue Sky" adapted to OGRE. Rather slow and dirty! Someone might find it useful though...

skyshader_demo.zip - modified SkyDome demo - dlls but no media dir.
shader & material

Image
Image 2
Image 2
Image 2
Image 2
Image 2

Sorry about the green sun btw, didn't bother to change it to a decent color. :wink:

EDIT: updated post (changed some links & "hid" some images)
Last edited by Mangetsu on Mon Jul 18, 2005 7:13 pm, edited 2 times in total.
User avatar
nartu
Halfling
Posts: 65
Joined: Sat May 28, 2005 7:51 am

Post by nartu »

thx I will try it tonight!
User avatar
SpannerMan
Gold Sponsor
Gold Sponsor
Posts: 446
Joined: Fri May 02, 2003 10:05 am
Location: UK
Contact:

Post by SpannerMan »

Hi Mangetsu, this looks very interesting indeed. Currently I cant test this on my dev box, so instead Ive got some questions for ya.

You mentioned that this effect is slow...how slow? Is this the sort of effect that you could plug into, say, a first person shooter without taking too much overhead for just the sky effects?
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post by :wumpus: »

Probably, if it's really that slow, you could get away with only doing it every few frames and interpolating in between.
User avatar
Mangetsu
Kobold
Posts: 28
Joined: Sun Jul 17, 2005 6:15 pm
Location: Sweden

Post by Mangetsu »

Another image showing color customization:

Image


EDIT: removed some images
EDIT: "new" demo files can now be found in original post


@SpannerMan:
On my machine (P4 2.53GHz, 512 MB RAM, GeForce FX 5600 Ultra, running Windows XP) the framerate in SkyDome demo drops from ~450 to ~70 after changing to this shader...

I'm completly new to both CG and material scripts, and have only played around a little bit with OGRE and 3d programming in general, but i suppose you could somehow use LOD materials and/or do like :wumpus: said. Clouds usually doesn't move all that fast, and the cloud formation speed that you can get in this script is plain ridiculous. Can create some nice effects though...
If you want to play with the settings I recommend downloading ATI RenderMonkey (DX effects, Atmosperic.rfx - Blue Sky).


EDIT: If anyone is interested, the effect is created by using perlin volume noise (perlinvolume.dds in media dir). Customizable parameters include cloud, sky & sun color, cloud coverage (noiseScale), sun direction, fallof & sharpness, cloud formation speed(cloudSpeed) and cloud movement speed(noiseSpeed).
Last edited by Mangetsu on Mon Jul 18, 2005 7:22 pm, edited 1 time in total.
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Post by betajaen »

Sorry for butting in, but with a little change of that script you can make some really impressive results. Like so!

Image

Bigger: http://www.ihoed.com/public/clouds.jpg


I put the material around huge sphere just flattened by half at the Y axis.

Then I changed part of the material to:

Code: Select all

		param_named cloudColor float4 1.0 1.0 1.0 1.0
		param_named skyColor float4 0.11 0.24 0.53 1.0
		param_named noiseScale float 4.1
		param_named noiseBias float -1.0
		param_named lightDir float4 0.92056 0.28344 0.26876 0.0
		param_named sunColor float4 1.0 1.0 0.5 1.0
		param_named sunFallOff float 3.5
		param_named sunSharpness float 0.42
		param_named cloudSpeed float 0.002
		param_named noiseSpeed float 0.002
Then added a little fog!

Code: Select all

	mSceneMgr->setFog(Ogre::FOG_EXP2,ColourValue(0.87,0.98,1,0.5),0.0025,9000,20000);
Thats it!


Also, this is my first post after lurking here almost for a year, so hello everyone!
User avatar
Mangetsu
Kobold
Posts: 28
Joined: Sun Jul 17, 2005 6:15 pm
Location: Sweden

Post by Mangetsu »

Nice!
It's good to see that there are people who aren't as lazy as me and actually creates something good-looking :wink:.

The main reason for uploading was to see what others would do with it (and to have others improve it for me :twisted:). The main issue is the speed though. If someone fix this, please let us now!
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Post by betajaen »

I'm getting between 60-80 FPS on a Radeon 9500. Which is not to bad, considering I have 128 OgreNewt cubes in the same scene falling on to a huge TreeCollision mesh.

I've also discovered if you, set the alpha of the background of the shader material to 0 so it's transparent. And put another sky sphere behind that (with the same colour but darker shade), you can come up with some even more convincing clouds.. Well the clouds around here look like that; full of water, ready to rain.

But Wumpus is correct, if the shader could be only "ran" every x frames, it'll certainly speed things up.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Post by jacmoe »

Hey, this thread is cool! :)
It's good to see some Ogre shaders in action. 8)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
Mangetsu
Kobold
Posts: 28
Joined: Sun Jul 17, 2005 6:15 pm
Location: Sweden

Post by Mangetsu »

I'm getting between 60-80 FPS on a Radeon 9500. Which is not to bad, considering I have 128 OgreNewt cubes in the same scene falling on to a huge TreeCollision mesh.
Yes, but the shader is running on the GPU, and the physics on the CPU? One of the benefits of using shaders is reducing the load on the CPU.

But Wumpus is correct, if the shader could be only "ran" every x frames, it'll certainly speed things up.
Does anyone know how to do this? I'm rather new to 3d programming so if someone could tell me how to do it that would be nice :). As far as I can tell you can't do it directly with material script, and adding it to the shader might slow it down and make it require a better profile (the material script uses ps_2_0 already though). Is there any way to change the technique used directly from code or something?
User avatar
Kencho
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4011
Joined: Fri Sep 19, 2003 6:28 pm
Location: Burgos, Spain
x 2
Contact:

Post by Kencho »

I'm not sure but, can't this be done with dynamic textures? I would bet it can be done. Also, a more controlled effect could give a 3D look (this is, adding some illumination) and dynamic colouring to the clouds. I planned on doing this for the Caelum project, but there was no dynamic texture support yet, and I didn't (still don't) know about how to generate the clouds (noise functions and such...)

I guess it's time to prepare a demo 8)
Image
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Post by betajaen »

I've found putting the clouds on it's own sphere with a transparent background and adding another sphere surrounding it with a shade of colours is a pretty good effect.

I've been trying to change the cloudColour via changing the parameters of the material within the program. Without any luck I may add.

But I'm looking forward to Caelum2 though!
User avatar
Mangetsu
Kobold
Posts: 28
Joined: Sun Jul 17, 2005 6:15 pm
Location: Sweden

Post by Mangetsu »

@betajaen:
Sorry, that's because I was so lazy. Didn't really think this would receive much attention. I updated the material script, so you can now set parameters by SubEntity->setCustomParameter. Look at the material script to see the parameter "bindings".
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Post by betajaen »

You sir are a God among insects.

Thankyou.

[Edit]

Call me stupid, but where is the SubEntity in my Entity? Actually what is a SubEntity?

[Edit again]

Got it!

Next I need a Sun.
User avatar
Mangetsu
Kobold
Posts: 28
Joined: Sun Jul 17, 2005 6:15 pm
Location: Sweden

Post by Mangetsu »

Check here. APIs are invaluable :).
But for non-compex meshes, you can do

Code: Select all

Entity->getSubEntity(0)->setCustomParameter(1, Vector4(0.0, 1.0, 0.0, 1.0)); 
to change the color of the clouds to green with full alpha. Any help?

[EDIT]
Sorry, too late :)
What do you mean by sun? Better than the one provided i suppose? Or do you use that for scattering effects?
[/EDIT]
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Post by betajaen »

Late, but thanks. :D

[Edit]

Well thats just a yellow (Well green in the case of yours) flare. I want a proper HDR one that melts your ice cream by looking at it.

The one that I can't export in the RenderMonkey demo's would do quite nicely. It also means that I can accurately track and move it and have nice sunset and sunrises.
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Post by betajaen »

Image


Like I said; I need a sun to complete this picture.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Post by jacmoe »

betajaen wrote:The one that I can't export in the RenderMonkey demo's would do quite nicely. It also means that I can accurately track and move it and have nice sunset and sunrises.
I believe there's a sun shader somewhere in the plsm2 map editor project? :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
Mangetsu
Kobold
Posts: 28
Joined: Sun Jul 17, 2005 6:15 pm
Location: Sweden

Post by Mangetsu »

Now, what's this yellow thing here? A new interesting shader perhaps? :shock:
Still needs some work though, so i'm not releasing it yet... :twisted:

EDIT:
Kencho wrote:I'm not sure but, can't this be done with dynamic textures? I would bet it can be done. Also, a more controlled effect could give a 3D look (this is, adding some illumination) and dynamic colouring to the clouds. I planned on doing this for the Caelum project, but there was no dynamic texture support yet, and I didn't (still don't) know about how to generate the clouds (noise functions and such...)
A bit of a late reply but yeah, it can probably be done with render to texture. I've decided to work on some shaders for now though. About the clouds illumination/coloring, that's what Terragen does, isn't it? I'm new to shaders so I don't really now how to do that. Might slow down quite a lot as well. Might not though...
BTW, the clouds uses premade noise, but could be changed to create it's own noise for a bit more variation. I don't think I'm going to work on such things for now however...
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Post by betajaen »

Mangetsu wrote:Now, what's this yellow thing here? A new interesting shader perhaps? :shock:
Still needs some work though, so i'm not releasing it yet... :twisted:
Oh you jammy monkey. I must have it. :D
User avatar
Azatoth
Gnome
Posts: 327
Joined: Sat Jul 10, 2004 6:46 pm
Location: Sweden
x 4
Contact:

Post by Azatoth »

This is looking really good! How similiar is it to this? http://www.alienstealth.de/mig/skysystem/
User avatar
skullfire
Gremlin
Posts: 150
Joined: Sat Mar 19, 2005 7:51 pm
Location: San Jose, Costa Rica
Contact:

Post by skullfire »

Azatoth wrote:This is looking really good! How similiar is it to this? http://www.alienstealth.de/mig/skysystem/
omg that sky system is awesome! Look at this!
http://www.alienstealth.de/mig/skysyste ... o_dusk.avi
I may have alzheimer, but at least I dont have alzheimer.
Post Reply