### New SkyLine object to fill the gap between SkyBox and ScatterSky

#### New SkyLine object to fill the gap between SkyBox and ScatterSky

RichardM
Posts: 32
Joined: Tue Feb 10, 2015 10:23 pm

Background
In my game The Master's Eye there are several missions which use the ScatterSky object combined with a TimeOfDay object. But there is the nasty problem that it is impossible to use the SkyBox object as a horizon/background (for the simple reason that this will cover the sky generated by the ScatterSky) and without this the transition from the terrain edge to the background is rather immediate (it is just from terrain to sky). You can modify the terrain or add a line of trees or somthing like that, but it is a workaround which I find quite lame.

The first thing I did was adding alpha information to the cubemap images and tried to use the SkyBox with these images (material with translucency set), but this did not give the desired result, I discovered that the SkyBox object was not able to handle transparancy. Dug any deeper and I saw that lighting was disabled for SkyBox materials. I enabled it and it did seem to work! Unfortunately, while running a debug build I got an assertion, stating that not all shaderconstants were defined for the skybox material . Also the lighting of this skybox was not that great at all, but okay. I decided to keep using this despite of the assertion when debugging, until I played this level, which also used the LightRay post effect, and I watched the sun sinking between the terrain and the skybox and the LightRay post effect did not perform well either. At that point I decided to create some sort of a SkyBox object that could be used with ScatterSky/TimeOfDay and here it is: the SkyLine object.

The SkyLine object
The SkyLine object is basically a SkyBox object that can handle transparancy (and do some other fancy tricks as well). Because of this it can be used with the ScatterSky and TimeOfDay objects; night sky cubemaps and moon are handled as one would expect (behind the skyline). The BasicClouds and the CloudLayer object both have a new option added, so they can be rendered behind the skyline (not necessary but just like the real thing). Finally the SkyLine object has an option to generate a mask that can be used with the LightRay postfx, so that the lightrays are covered by the skyline, giving a more realistic feeling. To demonstrate all of this I have a nice demo video, just take a look:

I want this thing, how do I get it
In contrast to the Volumetric Fog and the DoorClass objects (which are free), I have decided that this SkyLine Object Pack is available for the reasonable price of 5 Euro (approx. US$5.57) and can be obtained from the R.G.S. site here. A step-by-step installation guide is included in the download as well as a sample cubemap and user manual. Thanks for reading Richard #### Re: New SkyLine object to fill the gap between SkyBox and ScatterSky JeffR Steering Committee Posts: 813 Joined: Tue Feb 03, 2015 9:49 pm Man, that looks pretty slick! I know there was a PR put up by someone a few years back to do something similar, but it had some issues that made it not function right(sounds like you may have run into similar before just making an entirely new object class). Can't argue with the results, it definitely gives it that proper 'horizon' feel, especially with it working with the godrays shader. Nice work, man. #### Re: New SkyLine object to fill the gap between SkyBox and ScatterSky Duion Posts: 966 Joined: Sun Feb 08, 2015 1:51 am How about a campaign to open source it, so it can be added to the main repo? I would donate 5 Euro for that then. #### Re: New SkyLine object to fill the gap between SkyBox and ScatterSky Chelaru Posts: 199 Joined: Wed Jul 01, 2015 10:33 am Wooow. Going to sun set and sun rise. In nature, when the sun is near the edge of the horizon it creates a worm light and a yellow tint paralle with the horizon. With the mountains in this scene, this effect will help big time. I made a shader that will give the god ray effect more of a real effect with big worm rays. And you can change the color of the rays. Is done in 3 passes : the first pass is from the old shader in t3d. the second pass is a radial blur Code: Select all #include "shadergen:/autogenConditioners.h" #include "../postFx.hlsl" uniform sampler2D frameSampler : register( s0 ); uniform float2 screenSunPos; float4 main( PFXVertToPix IN ) : COLOR0 { float2 UV = IN.uv0.xy; float2 Center = screenSunPos; float BlurStart = 1.0f; float BlurWidth = -0.1; int nsamples = 100; UV -= Center; float4 c = 0; for(int i = 0; i < nsamples; i++) { float scale = BlurStart + BlurWidth * (i / (float)(nsamples-1)); c += tex2D(frameSampler, UV * scale + Center ); } c /= nsamples; return c; }  the last pass is mostly the old one + Code: Select all uniform float3 ColorShift; . . . return saturate( amount ) * float4( ColorShift * color * exposure, 1 ) + bbCol; //add color to the rays  The last part to combine it all: Code: Select all singleton PostEffect( LightRayPostFX ) { isEnabled = false; allowReflectPass = false; renderTime = "PFXBeforeBin"; renderBin = "EditorBin"; renderPriority = 10; shader = LightRayOccludeShader; stateBlock = LightRayStateBlock; texture[0] = "$backBuffer"; texture[1] = "#prepass"; target = "$outTex"; targetFormat = "GFXFormatR16G16B16A16F"; new PostEffect() { shader = LightRayBlurPass; stateBlock = LightRayStateBlock; internalName = "blurpass"; texture[0] = "$inTex"; target = "$outTex"; targetScale = "0.062 0.062"; //<-------THIS help with perfomance and gives the big ample rays }; new PostEffect() { shader = LightRayShader; stateBlock = LightRayStateBlock; internalName = "finalpass"; texture[0] = "$inTex"; texture[1] = "$backBuffer"; target = "$backBuffer"; }; };
If you want to use targetScale 0.125 you can use this settings to get nice result:

Code: Select all

$PostFXManager::Settings::LightRays::ColorShift = "1.0 1.0 1.0";$PostFXManager::Settings::LightRays::brightScalar = "1.08268"; $PostFXManager::Settings::LightRays::decay = "1.0";$PostFXManager::Settings::LightRays::density = "0.816811"; $PostFXManager::Settings::LightRays::numSamples = "40";$PostFXManager::Settings::LightRays::weight = "5.65"; 
If you use targetScale = "0.062 0.062"; you could up the numScamples to 70-80 to get even ample rays.

#### Re: New SkyLine object to fill the gap between SkyBox and ScatterSky

RichardM
Posts: 32
Joined: Tue Feb 10, 2015 10:23 pm

@
Duion
: I might be interested in starting a campaign, I have to think about it.

#### Who is online

Users browsing this forum: No registered users and 2 guests