Build a Sky in Blender for Racer
by Bob Hojaboom - August 1, 2010

Software used in this Tutorial: Blender 2.45 from Blender.org Paint Shop Pro 7 or later from Jasc (now corel) or any graphical image manipulating program such as"GIMP". DOF exporter included in this folder "B.Burton_exporters.7z" by Brent Burton Python version 2.5 or later.

I assume that you have completed some of your track. Get a 360 degree image of the sky and put it in your texture and track folders. The image should be 2048 x 512 pixels for the best results. You can search the internet using "Google" to find free sky images or use the one included with this tutorial. You may rt-click and "save picture as" the one below to your texture folder as it is a .jpg and will work in RACER. A .tga image works but you have to make the special.ini file a bit different and the alpha channel may have to be inverted. I made the image using Microsoft Flight simulator.

sky.jpg

A night image is also needed and can be made from the sky.jpg or a sky.tga image by darkening a copy of either in PSP or Gimp. You can save the one below as before.

sky_night.jpg

1. Start Blender 2.45 and load your track.blend file.
2. Be in object mode and have only layer 1 visible, move any objects to another layer
3. Locate the cursor at 0,0,0 in top view and add a mesh>UVsphere with 24 Segments, 24 Rings and 100 Radius.
4. Make the track visible and in Wireframe mode scale the sphere up to cover your track. See left image below.
5. Switch to front view, 1-key, and in edit mode select all bottom vertices of the sphere as in center image below.
6. Delete the vertices with the X-key, press Alt-Z-key. Name the object sky in the bottom panel. See right image below.
7. Turn off double sided. Press A-key to select all vertices and flip normals so they point in.
8. While in front view and edit mode, 1-key, select vertices as in left image below. Check with 3-key to ensure vertices are selected all way round.
9. Switch to object mode, press F-key to enter face mode.Load the sky.tga image in the UV\ Image editor window. LMB click on the UVs menu and select Snap to Pixel.
10. Press U-key and select Cylinder from View, the image is now on the sphere as shown in center and right images below.
11. The image vertices need to be adjusted to fit the image. In right pane, select all image vertices and scale/move using S-key, G-key, and Y-key (to only move vertically) to match the left image below.
12. Zoom in on the image in the right pane and move to the lower left corner and adjust as in right image below if needed. Check the right corner and top vertex.
13. Exit face mode to object mode. This sky image has no sun illuminating a cloud so the sun can be placed anywhere desired in your special.ini file.
14. Use Brent Burton's DOF exporter to export the sky.dof sphere (included with instructions). Save the .blend file and exit Blender.
15. Make sure you move or have the sky.dof file in your track folder
16. Add the sky.dof to your track's geometry.ini file as shown below, note flag=0 and save it.

        objects
        {
          ground
          {
            file=ground.dof
            flags=6
          }
          road
          {
            file=road.dof
            flags=6
          }
          road-edge
          {
            file=road-edge.dof
            flags=6
          }
          sky
          {
            file=sky.dof
            flags=0
          }
        }

17. Open special.ini with notepad and enter the following text, then save the file.

        gfx
        {
           clear_color=0
          ; Sun location (XYZ); keep it far away to avoid too much movement
          ; sun=+2000000.0 5000000.0 0.0 ; high in sky  +Y up/down -Y
          ; sun=+1000000.0 1000000.0 0.0 ; low in sky   +X east/west -X
          ; sun=5000000.0 6000000.0 0.0  ; east         +Z north/south -Z
          ; sun=-5000000.0 4000000.0 0.0   ;west
          ; sun=-5000000.0 6000000.0 0.0  orig
          ; Night track? If 1, turns on car lights by default
          night=0
          ; Alternative with light sky
            sky=1.000000 1.000000 1.000000 0.000000
          ; Sky exposure
          exposure=1
          ; Day time (overrules sun if specified)
            time=1400
          ; Sun location (XYZ); keep it far away to avoid too much movement
          sun=-5000000.0 6000000.0 0.0
          {
            ; Flare?
            enable=1
            ; Sky Cg shaders
            intensity=1.0
        ;    diffuse=1 0.8 0.6
        ;    ambient=0.75 0.75 0.8
        ;    specular=1 1 1
            ; No global light
            ; global=0.1 0.1 0.1 1
          }
          shadows
          {
            ; Intensity of projected shadows (defaults to 0.3)
            intensity_projected=0.5
          }
        ;    fog
        ;    {
        ;    density=0.002
        ;    start=0
        ;    end=1
        ;    color=.3 .3 .37 1
        ;    ; Fog mode; 0=exp, 1=exp^2, 2=linear (start/end only used with linear!)
        ;    fog_mode=0
            ; Sky Cg shaders
            rayleigh=0.000008   ;0.0025
            mie=0.000001   ;0.0010
        	; Extinction factor (<1 = less fog)
            extinction_factor=0.001   ;0.5
            }
        }
        env
        {
          snow=0   ;1
          ; Amount of rain (0..1)
          rain=0
          ; Animate rain (X=time in seconds, Y=intensity)
          ;rain_curve=rain.crv
          ; Amount of clouds (0..1)
          clouds=1.25   ;0.9
        }

18. Adjust the rayleigh value and mie value for fog as needed, the values listed are starting points.
19. Adjust the clouds value for bright or dark sky as desired, the value listed is a starting point.
20. Now open the track.shd file in notepad and enter the following text. Save it.

        ; track(whatever) shaders by your name, date
        vf_sky
        {
          vertex_shader
          {
            file=sky_daynight_v.cg
          }
          fragment_shader
          {
            file=sky_daynight_f.cg
          }
        }
        ; =============================================================================
        ; shaders below
        ; =============================================================================
        shader_sky~vf_sky
        {
            compression=0
            sky=1
            fog=0
            cull=none
          layer0
          {
            map=sky.jpg
            depthwrite=0
          }
          layer1
          {
            map=sky_night.jpg
            depthwrite=0
          }
        }

21. Run the track in RACER and see your new sky!
22. You may have to adjust the dome up/down in Blender to your preference.

Have Fun