Jump to content
XPNG NOVEMBER SCREENSHOT COMPETITION Read more... ×
Ðŗąçø

A Decent Guide to Crisp Shadows

Recommended Posts

Wondering how to get better frame rates with shadows in X-Plane? Jagged and blocky shadows doing your square head in? Wondering if tweaking X-Plane's shadows are even possible? If the answer is a resounding YES to any of those questions, you're come to the right place! This guide details everything you need to know about modifying aircraft and scenery shadows in X-Plane 11.

jc.thumb.jpg.1694f5464892c30cb5093df4cf56fdb1.jpg

 

WARNING: X-PLANE 11.30 IS SET TO MODIFY X-PLANE'S CORE SHADERS. THIS MAY BLOW UP THE DATAREFS USED IN THIS GUIDE AND CRASH X-PLANE. IF THIS IS THE CASE, PLEASE PM ME AND I WILL INVESTIGATE NEW VALUES/DATAREFS!

WARNING: MAKE ABSOLUTELY SURE THERE ARE NO OTHER .LUA FILES USING THE SAME DATAREFS CONTAINED HERE WITHIN. PERFORMANCE ISSUES CAN BE EXPECTED OTHERWISE!

 

First of all, we need to understand what actually draws these shadows. And the simple answer is: it's your GPU. For reference, my GPU is an MSI GTX 970, which can draw shadows on a medium-high setting. Faster GPUs will be able to draw better shadows in terms of distance and quality. Back in X-Plane 10, we had quite a bit of control with shadows in the settings menu, but with X-Plane 11's new UI, all we can do is choose whether we want shadows on scenery or not. This guide will detail several datarefs, all of which can be modified through FlyWithLua, and tweaked to your preferences.

Like any good recipe for delicious results, the ingredients required are:

  • At least 60 minutes of time (recommended)
  • FlyWithLua COMPLETE edition*
  • A text editor. I'd recommend Notepad++, as it can read and format .lua files, but a default text editor also works just fine

Complete edition is a requirement as the datarefs listed below are private, which cannot be modified using the core edition

So, let's get started! Firstly, some useful information to keep in mind: you don't have to stick to values I recommend. Feel free to experiment and find what's right for you. Most guides and information just tell you settings you should use, but that's not the case here, albeit there are limits. Also, you can change any value at any time, remembering of course to save the file each time you make an edit, and to reload the script through the FlyWithLua menu.

The first dataref to consider is:

sim/private/controls/fbo/shadow_cam_size

Shadows aren't some sort of computing wizardry. They are in fact a texture, and the primary resolution of that texture is defined using this value. The value of this dataref plays a key part in the overall quality of your shadows, but keep in mind it also affects your frame rate if turned up too high. Some common values you might want to consider toying with are:

  • set( "sim/private/controls/fbo/shadow_cam_size", 1024) -- Recommended for low-tier GPUs/integrated graphics
  • set( "sim/private/controls/fbo/shadow_cam_size", 2048) -- Recommended for mid-tier GPUs
  • set( "sim/private/controls/fbo/shadow_cam_size", 4096) -- Recommended for mid-high-tier GPUs
  • set( "sim/private/controls/fbo/shadow_cam_size", 6144) -- Recommended for high-tier GPUs
  • set( "sim/private/controls/fbo/shadow_cam_size", 8192) -- Recommended for very high-tier GPUs

I personally set this value to 6144 for nice, crisp shadows, but it is borderline in terms of a high performance impact. 4096 will give you reasonable results without too much of a performance hit, whilst anything below will start to give less-desirable results. You can use any other value too, such as 3000, 5281 or 16,384, which is the largest texture size most GPUs can support.

Here are some comparison screenshots inside the flight deck (click to enlarge):

Default.jpg1024.jpg2048.jpg4096.jpg6144.jpg8192.jpg

(Note: The colour of the shadow in the first screenshot is not impacted by texture size, and I forgot that the sun moves!)

As you can see, the higher the number, the better the quality. Default seems to be somewhere between 6144-8192. Pay close attention to where the METAR display would be, the lower EICAM display knob, the 'MAX. TAKEOFF WEIGHT 78T' panel, the throttle quadrant and the shadows cast around the top-left corner of the screen. You'll notice higher quality shadows pay more respect to objects at closer distances, which can sometimes look quite unrealistic on lower resolutions.

Now take note of the same dataref and the same numbers, this time using shadows on scenery:

Default.jpg1024.jpg2048.jpg4096.jpg6144.jpg8192.jpg

(I learnt my lesson! Sim time is paused now, and I turned off depth of field)

In these screenshots, it may not be obvious at first judging by the shadow cast by the wing of the MD-80, but the exterior shadow quality in the default screenshot is worse than the 1024. MUCH WORSE, in-fact. Recall what I mentioned above, about how shadows with a higher resolution pay more attention to close objects. Now observe shadows under vehicles and under EGKK's Skybridge (floating because the airport is not flat). Makes sense now, right?

I'd like to introduce to you interior and exterior shadow quality. You'll note the shadow cast by the wing in the 1024 screenshot looks abysmal. Like... REALLY REALLY BAD!!! That's why in the interior cockpit views, two shadow qualities exist: interior shadows and exterior shadows. The interior shadows have, be default, a higher resolution than exterior shadows, because we want interior shadows to be more crisp and exterior less crisp. That way, we get satisfying results without too much of a performance hit.

But to complicate things even more, there's a third shadow parameter in the middle. This is the aircraft's volume-rendered shadow, calculated based on the .obj files initially loaded. It helps to explain the situation with the shadow of the wing. You can see approximately where this is with this screenshot, using the 737-900ER:

1492983507_X-Plane2018-07-2921-56-05.thumb.jpg.89123c1aba0d3e5b480ff227a1b75a33.jpg

Below the red lines, we have crispier shadows, compared to above where the shadow gets a bit pixelated. Brain a bit frazzled? Maybe this diagram will help clear things up. I know this is an external view, but let's pretend that we are looking out of the passenger window for the purposes of this handy diagram:

circles.thumb.jpg.6fba4c7a5bd3d27714cc70e352e8ec49.jpg

This summarises the boundaries of shadows in X-Plane. The interior/exterior boundary is pretty self-explanatory, and moves with the interior camera location. The volume-rendered shadow is fixed with the aircraft. All of these play a part in the quality of your shadows in X-Plane, and the remainder of this guide explains further datarefs and their usefulness in customising X-Plane's shadows.

Coming back to the interior and exterior shadows now, these are their respective datarefs:

sim/private/controls/shadow/csm_split_interior
sim/private/controls/shadow/csm_split_exterior

Like shadow_cam_size, these adjust the overall quality of interior and exterior shadows, respectively. These datarefs can take integers between 1 and 4, with higher values giving more desirable results, but poorer frame rate. Prior to X-Plane 11.10, these values could be set as high as 8, but unfortunately they now only go up to 4 (before you hit fatal OpenGL errors), which is high enough in my opinion. Unfortunately, the exterior dataref has a slight problem: it only looks good on its highest value (4); else it is slightly or moderately pixelated. This is of course only really beneficial if you use shadows on scenery, and can seriously degrade fps.

Another dataref you may consider using is:

sim/private/controls/shadow/cockpit_near_adjust

Take a look at the handy diagram I added above. This dataref is very simply the size of the green sphere on the diagram. Inside this sphere is of course the interior shadow quality. I'd recommend setting this value between 1.5-4, which is ideal for all cockpits. 2 is good enough in general.

This dataref adjusts the distance the interior shadows become exterior:

sim/private/controls/shadow/cockpit_near_proxy

Be wary that the higher this dataref goes, the worse closer shadows become. You can see this dataref's effect by turning interior quality up, exterior quality down, and messing about with this number. It's all about fiddling around with these datarefs.

And finally:

sim/private/controls/shadow/csm/far_limit

This dataref is the distance at which shadows will stop drawing. As simple as that. Same units as cockpit_near_adjust.

 

Well, there you have it. All the datarefs you need to get sublime shadows in X-Plane. Use the format below to easily copy and paste the datarefs into a new or existing .lua file (sorry if you've already done it!), taking care to ensure it really is a .lua file:

set( "sim/private/controls/shadow/csm_split_exterior", X)		--(Integers between 0-4)
set( "sim/private/controls/shadow/csm_split_interior", X)		--(Integers between 0-4)
set( "sim/private/controls/fbo/shadow_cam_size", XXXX)			--(Integers between 0-16,384)
set( "sim/private/controls/shadow/cockpit_near_adjust", X)		--(Values 0 or greater)
set( "sim/private/controls/shadow/cockpit_near_proxy", X)		--(Values 0 or greater)
set( "sim/private/controls/shadow/csm/far_limit", XXXXX)		--(Values 0 or greater)

Also, take note values can be decimal numbers. But not integers. Here's what I'm using right now:

set( "sim/private/controls/shadow/csm_split_exterior", 4)
set( "sim/private/controls/shadow/csm_split_interior", 4)
set( "sim/private/controls/fbo/shadow_cam_size", 6144)
set( "sim/private/controls/shadow/cockpit_near_adjust", 2)
set( "sim/private/controls/shadow/cockpit_near_proxy", 1.5)
set( "sim/private/controls/shadow/csm/far_limit", 1000)

Remember, I'm using an MSI GTX 970, so what I have may give you a small or humongous performance impact. PLAY AROUND WITH THE VALUES!!! You can get shots like these then:

3.jpg1.jpg2.jpg

I hope that you found this guide useful and appreciate the effort I put into making it. Please post any corrections/queries you may have, and I'll do my best to address them. I will be certainly be making more of these in the future!

Edited by Ðŗąçø
Minor edits
  • Like 5

Share this post


Link to post
Share on other sites
28 minutes ago, FlyAgi said:

On request I added some of the shadow stuff to my tweak utility so it can handle (and store) most of the shadow tweaks using the utility gui (submenu 'shadow control'). 

https://forum.thresholdx.net/files/file/83-flyagi-tweak-utility/

 

(I hope it's okay to post that here - there is not intention to hijack this thread)

So, it's some kind of Advanced options? because I see the FPS target and such...

I'll take a look later this week when I have some time ?

Share this post


Link to post
Share on other sites

It has many options. Originally it was a performance tuning script but the gui was to powerfull to stop there so it can handle different things now. If you don't want to use a certain feature you can just tun it of and just use those you really need. 

The main stuff it can do is:

  •  Performance tuning (just stuff that really has an fps impact and is changeable without scenery reload, except extended dsfs)
  •  Configure Bird Strikes
  •  Configure Shadows
  •  Configure Fog (and X-Visibility Haze Control if installed)
  •  Configure Controller Settings (deadzone, centerzones, sensitivity, stability)
  •  It can make Weight & Balance persistant and has some ohter aircraft related features
  •  All settings are stored per aircraft, so you can use different setups in different situations (and always the same setup using the sync function)

 

  • Like 1

Share this post


Link to post
Share on other sites

Excellent post, thanks Draco. BTW I recommend from my own experience only to increase the shadow_cam value. I've been spending extreme amounts of time getting the PBR for the new center pedestal etc right, checking it in all possible lighing scenarios. I noticed that some other tweaks tend to overbrighten the cockpit by reducing the actual shadow complexity which leads to odd lighting. I must say that with the actual shadow resolution and maybe angle, I'm absolutely happy and do not notice lighting aberrations.

  • Like 1

Share this post


Link to post
Share on other sites
On 10/15/2018 at 11:16 AM, audiobirdxp said:

Excellent post, thanks Draco. BTW I recommend from my own experience only to increase the shadow_cam value. I've been spending extreme amounts of time getting the PBR for the new center pedestal etc right, checking it in all possible lighing scenarios. I noticed that some other tweaks tend to overbrighten the cockpit by reducing the actual shadow complexity which leads to odd lighting. I must say that with the actual shadow resolution and maybe angle, I'm absolutely happy and do not notice lighting aberrations.

I noticed that too, but it does not always happen so that confuses me. I also don't fly much now as I have no spare time for it, but I had it pending. I guess you modified my script and cleaned from extra stuff, right?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

Please read the Terms of Use