2
\$\begingroup\$

I am developing a 3D game in DarkBASIC Professional, and I have a theoretical problem with the combination of skydomes and fog in general. My question is not specific to a programming language, so I am not refering to code.

What I want to achive

  1. The player can see a night sky with stars

  2. The sky should rotate slowly

  3. Trees will block the light of the stars

  4. Trees will be dark when far away and colorful when player is near (normal shader work).

  5. A tree at the horizont should not "pop up" randomly when it enters the skydome. It should slowly fade, as the player comes near.


Techniques I use

  1. Instead of a skybox, I have choosen a skydome with a night-sky-texture. This texture scrolls.

  2. DarkBASIC has a "fog" feature. If enabled, I can choose a fog color and a fog distance. Things like trees will slowly fade and vanish into this fog color and will be completely faded when they reach the fog distance. I am using black colored "fog" for the night scene, so that the trees far away will vanish in the dark night.

  3. DarkBASIC's "fog" and "ambient light" features automatically shade the trees, so that far away trees are dark, and trees close to the camera, colorful.

  4. The skydome will always enclosure the camera. It will automatically move when the camera moves. (Note: Since the landscape is very big, I couldn't choose a giant skydome that covers the whole level, because the rendering of the texture on a giant skydome requires too much rendering time (at least for DarkBASIC's engine).)


I have tried several things now, and I am don't know what to do to fulfill all requirements.

Version 1

What I did:

  • I am using black fog with a fog distance of 1000.

Pro:

  • Trees are perfectly faded horizontally and vertically and no tree "pops up" at the horizont

Contra:

  • There is no skydome, so the sky is just 100% black, without any stars.

Version 1


Version 2

What I did:

  • I am using a sky sphere with diameter 300
  • I am using black fog with fog distance 1000

Pro:

  • Since I am using the fog feature, trees will slowly fade to black when the camera diverges from them.
  • The sky can be seen completely (also at the horizont) because the sky sphere is smaller than the fog distance

Contra:

  • The trees are taller than 300, and therefore poke through the skydome! So I only see half trees... (Note: I cannot increase the value "300", because otherwise the skydome will be shaded too much by the fog, which would result in a extremely low star light.)
  • Since the skydome is smaller than the fog distance, trees will "pop up" at the sky, once they come close (and pass the skydome)

Version 2


Version 3

What I did:

  • I set black fog with a distance of 1000
  • The skydome is an ellipsis with height 300 and width 1200.

Pro:

  • The sky can be seen when the camera looks up (because the skydome does not exceed the fog distance)
  • Trees at the horizont are faded and do not "pop up"

Contra:

  • The trees are taller than 300, and therefore poke through the skydome! So I only see half trees... (Note: I cannot increase the value "300", because otherwise the skydome will be shaded too much by the fog, which would result in a extremely low star light.)
  • The sky at the horizont is black and no stars can be seen. (But this is not a big deal in my opinion, since there will be always things at the horizont which block star light)

Version 3


What I actually need

I think I need something like an "elliptic fog". A fog that will shade objects at the horizont stronger than objects above the player (sky). But such a thing does not exist in DarkBASIC.

So I am trying to find out a good solution using the standard techniques fog, ambient light and skydomes to achive my goal. Do you have a solution for me?

\$\endgroup\$
-1
\$\begingroup\$

You're stuck in a bit of a predicament using an older engine like DarkBasic. The problem as you've already described yourself, is that you can't afford to make the skydome bigger. The reason the trees are popping, you already know, is that they are clipping through the geometry of the skydome. If you cannot make the skydome bigger, there's not much you can do to get rid of the problem. I'm not a programmer so I'm not sure what the limitations are with the engine, but one approach might be to create a pixel depth fade on the skydome material. This is a technique that's used by modern game engines (unreal 4) to give a faded edge around meshes that protrude through the mesh they are intersecting with. They use it most commonly on water meshes where you have rocks jutting out of the water and they don't want the intersection to look sharp. This won't eliminate the problem because the trees will still be intersecting with the skydome, but it will fade the point of intersection around the trees so it might look less terrible.

Another alternative would be to make the stars using a different method. You could try using a particle system (not likely in DarkBasic) or you could make a custom star mesh for the stars that's not a sphere.

The other more obvious alternative now that I think of it is to change the shape of your skydome to be elliptical instead of trying to create elliptical fog.

\$\endgroup\$
  • \$\begingroup\$ Thank you for your answer. I will try out these things soon. About your last point, I have tried an elliptical skydome - it is my version 3 \$\endgroup\$ – Daniel Marschall Jul 20 '16 at 21:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.