Strange yellow shadows

I enabled Shadows on my light source, and all my objects have CastShadows enabled. It seems like only some of the objects cast shadows, and the shadows display as yellow rays to the ground, instead of showing a shadow on the ground. What am I missing?

this is the Viewport - ShadowVolumesRender

Indeed, this looks like it :slight_smile: ShadowVolumesRender is a debug feature for shadow volumes.

My Mainviewport ShadowVolumesRender is False.

And you still experience the issue? Hm, that’s weird, your original screenshot definitely looks exactly like ShadowVolumesRender=true effect.

Note that nothing in CGE turns on ShadowVolumesRender. Can you check in your code?

If this doesn’t help, please submit a testcase to reproduce the problem, I’ll be happy to take a look :slight_smile:

It was set to True on my Minimap viewport. But when I set it to false, I still see no shadows. I suspect my models do not conform to the requirements. I am not worried about shadows at this point, but I was looking for an easy visual way to see that my models position themselves on the ground and/or roads. Some of them float before the physics is turned on.

If you saw the yellow geometry (with ShadowVolumesRender) then your models did meet the requirements – we did render shadow volumes.

See notes on Shadow Volumes | Manual | Castle Game Engine about the requirements (2-manifold). But if you saw yellow geometry before, you should be good.

So, check your lights.

  • Maybe there are other lights that are too bright?
  • There should be exactly 1 light source with Shadows=true, other lights should have Shadows=false (our shadow volumes support now only 1 light).
  • To test, make sure this single shadow-casting light is the brightest, maybe even turn off all other lights (you can set their Exists to false).
  • Note it only affects “lit” materials. The lights must shine for shadows to make sense. You can test using a simple TCastlePlane to receive shadows.

try WholeSceneManifold = true

Somtimes only some parts of the object make a shadow.

Okay, so I had also disabled ShadowVolumes, not just ShadowVolumesRender. Now I see the shadows… only bits of the vehicles cast shadows. But then if I create them all with WholeSceneManifold = true then I see good shadows. Thanks guys!


All the vehicles are floating. The stop floating when I turn on the physics. I am not sure why manually placing them without physics is putting them up so high, but shadows help see it.

1 Like

My roads don’t get shadows cast onto them. I have set their renderoptions to WholeSceneManifold = true, ReceiveSceneLights = true, Lighting = true.
They are built as x3d triangle strips. Perhaps I need to setup the materials for that to receive shadows?

Yep, if I also set in addition to texture the Shape.Appearance.Material to a TPhysicalMaterialNode of white, it displays the shadows.

Can shadows work with transparency? Probably not I am guessing. Here is one of my trees. The leaves are single faces with a picture of a leaf with transparency, but the shadow is the whole square face.

Haha, the front loader didn’t see (with a ray from the middle front) the low miata, so didn’t stop before running over it and instead stopping because it saw the steam roller stopped at the building. So cool to see the shadow of the front loader on the miata. Fun stuff.

1 Like

The material must be “lit” (affected by lights) for shadows to be visible – since “being in shadow” just means that “one of the lights is obscured, so doesn’t contribute to given color”. So the shadow receiver must indeed have a material like TPhysicalMaterialNode or TMaterialNode. The shadows will not be visible on TUnlitMaterialNode .

Note: You wrote earlier you enabled WholeSceneManifold on roads, you likely want to set it to false on the road pieces. WholeSceneManifold is only useful on shadow casters (shadow receivers don’t need it) and it is shall only enabled if you’re sure that the model is 2-manifold, as a whole (CGE doesn’t check it in this case, only assumes; and if it’s wrong assumption, rendering artifacts will occur). See Shadow Volumes | Manual | Castle Game Engine and Castle Game Engine: CastleRenderOptions: Class TCastleRenderOptions about WholeSceneManifold meaning.

Unfortunately, shadow volumes cannot work with transparency. The shadows are cast by the geometry, i.e. the leaves are quads, their texture (with alpha channel) doesn’t matter. We have another algorithm for shadows implemented: shadow maps ( Shadow Maps | Castle Game Engine ) that is better in this regard, it is affected by texture with alpha channel ( one of the demos of it indeed shows leaves on a tree – https://castle-engine.io/images/original_size/sunny_street_tree_hard.png , this is from model shadow_maps/castle_with_trees/castle_with_trees_final.x3dv inside GitHub - castle-engine/demo-models: Demo 3D models (mostly in X3D and VRML formats) of view3dscene and Castle Game Engine . But using shadow maps is right now not so comfortable, in particular both objects must be in a single X3D graph. It’s a TODO to make it better. See also Shadows for transparent textures - #2 by MBa .

1 Like

By the way, your project looks great. The shadow of the leaves looks good. Maybe you could make a lot more leaves, then the individual leaf can no longer be seen in the shadows.

1 Like

Thanks. I will probably end up moving more leaves into a single face as I am already running into memory issues at 200 or so trees. I want thousands and thousands.

Who knew shadows can be so fun. They made me simulate a day night cycle with moving sun. So cool to see the shadows move across the terrain, and the valleys fill in as the sun sets. A little wonky still at sunset, sunrise when it can shine under the terrain and create strange effects. I turn it off, when it goes below 0, but still a flash of oddity.

1 Like