VC Shadowing Continued

Someone posted a question at avsim saying that the VC shadows even with my tweak were still rather poor in the jets.

I thought that the problem was probably that the cockpit is relatively small in jet as a proportion of the plane as a whole and so less pixels (strictly texels) of the shadowmap would be available leading to lower resolution. I therefore tried to increase the amount of sampling used but to no avail.

The following shows an example of a poor shadow in the default 747.  There is a shadow A that runs from the top of the window up and a shadow B at the boundary of the light patch in the bottom RH corner.

The shadow B isn’t too bad but the shadow A is very poor indeed. Now I tried various things such as increasing the number of samples to little or no effect.

So the next step was to look into Shadow A in a bit more detail.

FSX creates the shadow in two stages. Firstly it draws what is called a shadowmap. This is view of the 747 orientated from the viewpoint of the light. What this records at each point is the distance of the nearest part of the plane to the sun. Although it can be viewed as an image it can also be considered as just a lookup table of distances.

Then as it renders the inside of the plane from the eyepoint view it looks up for each pixel being drawn to see whether the nearest part of the plane to the Sun at that point is actually nearer than the pixel being drawn. If it was then the pixel is in shadow, else it is being lit (i.e through a window)

Here is the actual 4096x 4096 shadowmap for the 747 image above and also a 4096x 4096 shadowmap for the Beechcraft for comparison.

The first thing to notice is that FSX is really rather clever. It has identified just the portions of the aircraft that are visible from the cockpit and only draws those in the shadowmap. The argument being is that if you cannot see the wings they cannot generate shadows! However its also rather dim in that it hasn’t then identified that it could scale up the 747 cockpit. It has written it to the shadowmap at the same scale as it would draw the whole 747 when calculating outside shadows.

Here is zoom on the 747 cockpit. I fear that you may not be able to see this clearly on a web page so you may have to take my word for some of what follows. Firstly ignore the pitch angle or perhaps regard the original image as being of a plane at that pitch angle. I can clearly see that shadow B comes from the rear most window and the Left Hand seat which acts as a cutout. Shadow A seems to be the top of the cockpit?!

If you think about it, it makes no sense for the top of the far side of the cockpit to be in sun in a plane banked towards the light source.

So whats going on? The answer is the way that FSX does the shadowing. What Aces did was follow the standard approach to deal with “shadow acne”. The shadowmapping technique described above, was that for each pixel we test whether there is another part of the plane between that pixel and the light by looking for an entry in the depth buffer less than the depth of the pixel being drawn.

This always correctly calculates when a pixel is shaded, but there is a problem with sunny areas. In those areas the object being drawn (in this case the cockpit wall) will itself be in the depth buffer. However you do the calculation, rounding of floating point values combined with the small number of value sin the shadowmap mean that some sunny patches will be incorrectly calculated as in shade.

The standard soloution is to add a small offset towards the light source when doing the test. So the question that is asked is

“is the value in the depth value less than my depth adjusted towards the light source by a small amount”

So when calculating the shadowing on the small blue shape, the shadow is actually calculate using the adjusted red shape.

That’s a perfectly fine way to do shadowing so long as you don’t want to calculate shadows inside a box at an angle to the light source, like err a plane cockpit.

Imagine the tilted blue box is now the 747 cockpit and we are calculating shadows. In this case you can see that the bias means that the top of the far wall is now nearer the light source than the top of the cockpit and so is calculated to be in sun!! and thus you get a sub/shade boundary along the top of the wall following the shape of the internal cockpit model in the 747 shadowmap above.

So is there a solution? I think so. One solution is to reduce the problem by making the bias smaller. I am also experimenting with applying transformation when doing the shadowmap lookup to shrink the cockpit slightly. The idea being that instead of applying a bias towards the light we apply a bias towards the eye point as shown below . Its not a good technique for normal shadow mapping but in this case may be the way to go.

About stevefsx

I don't use FSX that much. But I am very annoyed when it doesn't work properly!
This entry was posted in Uncategorized. Bookmark the permalink.

2 Responses to VC Shadowing Continued

  1. Andrew says:

    I went from DX9 to DX10 and didn’t like the darkness over the gauges. I tried to go back to DX9 back the gauges are still very dark. I’ve deleted the shader cache but it’s still dark. Would you have any suggestions short of reinstalling FSX?

    Andrew

    • stevefsx says:

      Andrew this is a comment against a 2012 post! Can you explain what you have done – are you referring to the commercial product, the free patches or just DX10 preview.
      What did you do exactly?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s