Realtime Gradient Sky

Downloads

SkyGradient.rar [818kb] – VB 2005 (VS.NET 2005)

Description

I had a request from the same MMORPG developer which asked me for Non-Reflective Water to make a simpler version of my old “HLSL Sky Demo”, which I haven’t put on my blog yet because I’m not all that proud of the code.

Basically, I was asked to copy Worlds Of Warcraft’s skies; so make a tweakable gradient-based day sky solution, that renders fast and looks good, and most importantly that behaves well in huge worlds with big height variations.

Features

  • 5-Colors gradient updated in realtime : The sky colors is formed of 5 colors placed at different heights, from horizon to zenith. This allows for a huge variety of sky appearances, and realtime sky transitions.
  • Blends with fog seamlessly : The sky mesh is a sphere, so it doesn’t matter if you see lower than the horizon; you’ll just see the fog color.
  • Renders always at the back : Gone are the “is my sky mesh big enough” worries, because the sky shader does not write to the Z-Buffer! That means if you render it first, it’ll always appear in the background of the scene.
  • Tweakable clouds appearance : How “round” or how “flat” the clouds layer looks can be tweaked at initialization time of the sky module; the sample has a control on the information getting form.
  • Fancy color interpolation : There is a setting to choose between Hermite interpolation or plain Linear interpolation for the gradient transitions, which makes it all pretty and sophisticated.

Screenshots


8 thoughts on “Realtime Gradient Sky”

  1. Hey Zaknafein,

    Nice work with TV3D, I’m new to this engine and I’m quite impressed with the results you can achieve with it and wish to expand my knowledge in 3D graphics etc.

    Any way, I’m having trouble opening your project.

    I receive an error stating one of the Shader’s project file is not properly installed. I received the same error opening your Ocean Shader open-source project you hosted on TV3D forums.

    Could you suggest where I may be going wrong?

    Thanks and keep up the good work!
    Alvin.

  2. The shader project files errors is not a problem, it’s just that I use a Visual C++ project to compile and develop my HLSL shaders, and you probably don’t own VC++. But the Shaders project itself is not necessary to compile & run the sample, you can just remove it from the solution.

  3. Hey,

    How do I get your sample to work with landscapes, because I can render the shader, or the landscape, but not both at the same time? – not even in your sample. Is the shader source you supplied with the sample not the same as the compiled version??

  4. Zaknafein,
    Your work is amazing! I try to set a goal to be as good as you. Anyways, umm I was woundering if I could have the Visual C# Code for the SkyDemo. Thanks!

  5. Hi Shiv,

    Which SkyDemo do you mean, this one? I have only made it in VB 2005.
    Or… I had another sky demo based on a physically-correct model, made in C#, but it has aged quite a bit and the code may not compile under the latest TV3D.
    But I guess I can post it with a warning. :)

  6. Any way to persuade you into doing a delphi version of your non-simple version? Or even a VB project.. What about if I say PLEASE PLEASE PLEASE :P — I’m having an -extremely- hard time going through the C++ non-simple one. I found it because it was apparently indexed by Yahoo. Was searching for “+Clouds +Shaders +”.fx”” or something to that extent and needless to say when I seen the screenshots with the TV logo I began wondering if it was someone I recognized from the TV forums, that’s when I spotted your handle lol

    Anyhow I’m working my way through it, but I can’t help but to feel that I’m perhaps loosing lots of stuff in the translation because 1) I don’t have an -advanced- knowledge of C++ much less C# and 2) I don’t fully understand the technique which means I’m just trying to straight convert it syntaxually

  7. Just in case anyone is trying this with a later shader compiler and having problems, I’ve found that in the shader code around line 101:

    float4 cloudsColor=tex2D(sampClouds, IN.texCoord)*cloudsColor;

    this was giving an error, something like cloudsColor being referenced before being initialized. To fix, it’s simply a matter of removing the “float4” since the actual static declaration is made previously around line 34.

    Thanks muchly to Zak for all these great shaders.

Leave a Reply

Your email address will not be published. Required fields are marked *