Shadow Area of Effect Limit

camz = 3
Distance from target area/character, 2.0

Is this the limit of shadow casting in P3D? (I’m sure it is)

Spotlights have to stay close to the ground/wall surface and any Fov or 90 equals no shadows…? :open_mouth:

I’m not sure which shadow algorithm you’re using, but in general, no–there aren’t specific hard limits like this. However, the different approaches for shadows do have their own different limitations and compromises.


P3D can only cast shadows with the spotlight; I have not been able to go outside the limitations I posted. Spotlights have to be very close to something in order for a shadow to even render, which means the area of light isn’t big enough to do anything with.

I guess I could bake shadows for game levels; with the way I do it, I can make those baked shadows soft shadows fairly easily. The problem is moving actors… You can’t bake those.

(Plus a lot of realism is lost because lighting will be missing its third part, shadow. Eg, light, shading, shadow)

struct MaterialSource
    vec3 Ambient;
    vec4 Diffuse;
    vec3 Specular;
    float Shininess;
    vec2 TextureOffset;
    vec2 TextureScale;

attribute vec3 Vertex;
attribute vec2 Uv;
attribute vec3 Normal;

uniform mat4 ProjectionMatrix;
uniform mat4 ViewMatrix;
uniform mat4 ModelMatrix;
uniform vec3 ModelScale;
uniform mat4 LightSourceProjectionMatrix;
uniform mat4 LightSourceViewMatrix;

uniform int NumLight;
uniform MaterialSource Material;

const mat4 ScaleMatrix = mat4(0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 1.0);

varying vec4 vWorldVertex;
varying vec3 vWorldNormal;
varying vec2 vUv;
varying vec3 vViewVec;
varying vec4 vPosition;

void main ()
    // Standard basic lighting preperation
    vWorldVertex = ModelMatrix * vec4(Vertex * ModelScale, 1.0);
    vec4 viewVertex = ViewMatrix * vWorldVertex;
    gl_Position = ProjectionMatrix * viewVertex;
    vUv = Material.TextureOffset + (Uv * Material.TextureScale);
    vWorldNormal = normalize(mat3(ModelMatrix) * Normal);
    vViewVec = normalize(;
    // Project the vertex from the light's point of view
    vPosition = ScaleMatrix * LightSourceProjectionMatrix * LightSourceViewMatrix * vWorldVertex;

Well this info wasn’t in the manual but I figured it out…

In order to set the spotlight farther away from a point and still get a reasonable shadow, you have to adjust the point light’s lens near value and the Fov of the pointlight.

Here’s the thing…

When I set my point light’s z value to 10 and kept the near/far as 1/100, there was no light at all. So I set my near value to 10, to match the z value and still received no light. Then it hit me… The near value should be slightly smaller to accommodate the view; so I set the near to 9 and sure enough… I had a much bigger spotlight area with a shadow showing.

Of course that shadow looked god awful. I knew adjusting the Fov altered shadows as well. Moving it to 180 would result in no shadows. Having it on 90 sucked, so I did the reasonable thing and dropped the Fov to 45; which seemed to be the mystic number because anything lower would result in a hard spotlight.

At least now I can save myself a lot of time (baked shadows would take a lot of work). Several spotlights in each portion of the level should do the trick (as far as shadows go). :smiley:


I think I’ll still use baked shadows (and dread the work load).