Executable Demo FREE

1 application Binary restricted distribution Non-commercial use only No modifications Read full license | More Info

Application License $19.99

Unlimited applications Binary restricted distribution Commercial use allowed Can modify source Read full license | More Info

Developer License $74.99

Unlimited projects Source and binary distribution Commercial use allowed Distribute modifications Read full license | More Info

You need to log-in or create an account
  • Create an account
  • Log-in
  • Please use your real name.
  • Account activation link will be sent to this address.
  • Minimum 8 characters

Clicking this button confirms you read and agreed to the terms of use and privacy policy.

Starting from FREE

View Pricing 14 days money-back guarantee
(1 ratings)

Sky Sphere / Cube / Dome Render

Three blisteringly fast classes for rendering sky textures in 3D games: sphere, cube and dome

Share and win up to $15k in prizes each month!Learn more

Share

Description

A very large percentage of games use textures to fake 'stuff' on or over the horizon. Distant mountains, buildings, clouds, hills, stars, nebula, sun, moon, etc, can all be painted into textures rather than rendered with actual geometry.

However, there are several geometries and mapping methods that can be used, each with their own advantages and disadvantages. This application showcases 3 types of environment geometry: sphere, cube and dome. Which one you choose depends on your requirements and how it will be used:

SkySphere:

  • Advantages: 1 texture, 1 draw call, only 1 seam, full 360 degree coverage
  • Disadvantages: texture singularity at poles
  • Example usage: racing game (no looking directly up)

SkyCube:

  • Advantages: minimal texture distortion, full 360 degree coverage, only 12 triangles
  • Disadvantages: 6 textures, 6 draw calls, more seams
  • Example usage: space battle game (full rotation)

SkyDome:

  • Advantages: 1 texture, 1 draw call, 0 seams, minimal texture distortion
  • Disadvantages: 50% coverage
  • Example usage: first-person shooter with fairly flat terrain

They all use vertex buffer objects and triangle strips for greatest speed. The code is clear, concise and optimized.

TIP: It is SOMETIMES a good idea to render your sky last. This is because the other geometry will have written to the depth buffer, and a large portion of the sky pixels will fail the z test and never be drawn. If you render the sky first, they will be drawn unnecessarily. Of course, this only works if you have no transparency in the scene.

Note: The example program uses freeglut for window creation but the Sky Geometry components themselves do not, so they are very portable.

Back to top

Documentation

How to use in your own application:

Create one of the objects:

SkySphere* _skysphere;
_skysphere = new SkySphere( SCALE, SLICES, STACKS, TEXTURE_HANDLE);

Where:

SCALE is the radius of the sky sphere
SLICES and STACKS are the number of horizontal and vertical tesslation divisions
TEXTURE_HANDLE is an opengl handle to a texture. Included is a function for reading TGA images but you'll probably want something better

Every frame simply use:

_skysphere->draw();

And finally, at the end, remember to clean up after yourself:

delete _skysphere;

Questions & Comments

Leave a comment

You must be logged-in to leave a comment.
Log-in now or register for a free account.
No comments have been posted yet.
You must be logged-in to vote. Log-in to your account or register now.
View all 1 reviews »

User Reviews

Starting from FREE

View Pricing 14 days money-back guarantee