PointLight, high radius and shadow artifacts...

rated by 0 users
This post has 7 Replies | 2 Followers

Top 10 Contributor
Posts 1,289
SunBurn_Community_Licensee
SunBurn_Contributor
SunBurn_Pro_Licensee
Philippe Da Silva Posted: 06-14-2010 4:13 AM

Hi,

I'm using a single PointLight for my solar system (deferred) rendering which I'm setting the following way:

this.sunLight = new PointLight()
{
      Intensity = 0.8f,
      FillLight = false,
      ObjectType = SynapseGaming.LightingSystem.Core.ObjectType.Static,
      Position = this.World.Translation,
      Radius = 100000,
      ShadowType = SynapseGaming.LightingSystem.Shadows.ShadowType.AllObjects,
};
state.SceneRenderer.LightManager.Submit(this.sunLight);

Note the Radius property which I am setting to 100000.

With such settings, I'm getting shadow artifacts such as this one:

I've been playing with the light following properties with no success:

      ShadowPrimaryBias = 10.0f,
      ShadowSecondaryBias = 2.0f,
      ShadowQuality = 1.0f,

Moreover, setting the PointLight radius to 1000000, the light seems simply switched off.

What would you recommend me to do?

Out of my head, one of the options I may consider is replace my PointLight with a DirectionalLight that I would update each frame using my Camera.Position and Sun.Position to define its direction. It should work but I would like to see if there isn't any other option to still use PointLight.

Thanks

Philippe

Top 10 Contributor
Posts 5,368
Employee
SunBurn_Studio_Licensee

Hi Philippe,

For very large light radii you may need to enable full precision shadow maps (set ShadowMapManager.PreferHalfFloatTextureFormat to false).

In deferred rendering geometry light volumes render the illumination area.  If a light's radius is too large the volume can clip with the far plane and cause gaps in the lighting.  This rarely happens and is easy to avoid (increase the far plane or decrease the light radius).

Why not try using a directional light?  Directional lights do not use light volumes and have the advantage of fewer shadows maps (3 vs point light's 6).

Let me know if this helps!

Follow me on Twitter – development and personal tweets
Awesome XNA Videos – Lighting, Rendering, and game videos

Top 10 Contributor
Posts 1,289
SunBurn_Community_Licensee
SunBurn_Contributor
SunBurn_Pro_Licensee

Thanks John, didn't thought looking at the ShadowMapManager :)

It's also obvious that if my farplane is nearer the PointLight radius, it shouldn't work :p

The DirectionalLight is an option but I would have to update its direction each frame as player can go on any side of the star in the solar system.

I'll give it a try and if can't get the expected end result, I'll go for an updated directional light ;)

Philippe

Top 10 Contributor
Posts 1,289
SunBurn_Community_Licensee
SunBurn_Contributor
SunBurn_Pro_Licensee

By the way John, is there any place around the docs or community articles that explains how Shadow properties work on Materials and Lights and which ones override the others?

Say, what's the expected values on ShadowQuality, ShadowPrimaryBias and ShadowSecondaryBias floats?

Thanks,

Philippe

Top 10 Contributor
Posts 5,368
Employee
SunBurn_Studio_Licensee

Hi Philippe,

Good point, I didn't realize the player could move so much relative to the environment.  You should be able to get a nice effect by setting the light direction per-frame using:

(viewer_pos - sun_pos).Normalize();

Object property information is available in the Editor tooltips, on the class members in Visual C#, and the API docs.

Light shadow properties are only for that light, but the preference shadow properties are global.  For instance if light A has a shadow quality of 1.0 and B has 0.5, B's resolution is lower.  If you then lower the global quality to 0.5, light A would drop to 0.5 and B to 0.25.

Shadow quality can be used to tune performance and also provide softer more subtle shadows.

The primary bias is able to remove most shadow mapping artifacts without disconnecting the shadow from the source (certainly not the standard brute force bias :).  But the primary bias does have its limits, so we also introduced the standard method as the secondary bias - they both work together to help tweak the shadows.

The values are very scene specific, but generally we use the primary when tweaking our scenes, falling back on the secondary if necessary.

Let me know if this helps!

Follow me on Twitter – development and personal tweets
Awesome XNA Videos – Lighting, Rendering, and game videos

Top 10 Contributor
Posts 1,289
SunBurn_Community_Licensee
SunBurn_Contributor
SunBurn_Pro_Licensee

Thanks John,

I'll try the DirectionalLight to see if it does the trick ;)

As for your explanations on the Shadow properties, I get how it all works: you use the product result of the Global preferences, lights and material shadow properties.

I would still like to know what are the max/min values for each as I can set any float value to any property such as 10.0f or 15.0f while it seems that you are more expecting values between 1.0f and 0.0f, am I right? what about negative values?

I'm asking because I don't really use the Editor (I'm procedurally generating the content of my game and it is no use ;) ).

Thanks again

Philippe

Top 10 Contributor
Posts 5,368
Employee
SunBurn_Studio_Licensee

Hi Philippe,

Excellent question:

Primary bias ranges from 0.0 - 2.0, however 0.75 - 1.5 is the usual range.

Secondary bias ranges from 0.0 - 1.0 and is very scene dependent, but frequently is less than 0.1.

Shadow quality ranges from 0.0 - 2.0, but is ultimately capped by the maximum shadow page size (set on the shadow manager).  When a light's shadow maps reach this size they cannot increase without first increasing the page size.

Let me know if this helps!

Follow me on Twitter – development and personal tweets
Awesome XNA Videos – Lighting, Rendering, and game videos

Top 10 Contributor
Posts 1,289
SunBurn_Community_Licensee
SunBurn_Contributor
SunBurn_Pro_Licensee

Thanks John, I think that would make a great addition to the Shadows article in the documentation ;)

Page 1 of 1 (8 items) | RSS