Jump to content

Shadowmap rendering and reflection


photo

Recommended Posts

Hi,

I have an object extern and I have hard time finding out when Unigine::Render::PASS_SHADOW pass is being called for reflection and when not. I have a single world light in the scene (4 cascades) and it seems that for certain settings, for some of the team members, this pass is called for reflection while I was never able to reproduce this on my end (it seems that, for me, the reflection rendering somehow is using the same shadowmap depth buffers as the normal view since the shadows do appear correctly in reflection without this pass being called). 

I am using Unigine 2.13.0.1 and I can see that in my case the following code in RenderLights::render_shadows:

	for (auto &it : lights)
	{
		if (it.key->isRenderDynamicDepthTexture())
			has_light_shadows = true;
		if (it.key->getType() == Node::LIGHT_WORLD)
			has_point_light = true;
	}

always fails for reflection rendering (has_light_shadows is false as isRenderDynamicDepthTexture always returns false) but I suspect this, based on some settings, returns true on other dev machines.

Can you shed some light and tell me when shadowmaps need to be computed and when not during reflection rendering?

Regards,
Adrian

Link to comment

Hello Adrian,

At first glance it seems that for WorldLight it's only possible if shadow rendering didn't happen during the main scene rendering. It may happen if there weren't surfaces for shadow rendering in the main scene.

If you can catch this situation with Renderer::isReflection and dump some more information about scene, camera position and settings, it would help localize this issue faster.

Link to comment

Hi, ok I see. So probably I need to move in the scene in some place where there are no objects to cast shadows but maybe have a reflective surface (like water)? In this case no shadows are rendered for main scene (no objects in the shadows frustum) but then maybe some distant objects are appearing in the reflection?

As I say I am having problems reproducing this on my end, so cannot provide some more scene information as of now.

Regards,
Adrian

Link to comment

Hi, based on your indications I think I've repro this and indeed is from the fact that main rendering view shadowmaps "fail" since they don't have any surfaces contained in their frustums:

	// get_shadow_surfaces
	const Vec3 &camera_position = renderer->getCameraPosition();
	WorldBoundSphere bs = WorldBoundSphere(camera_position, render->calcShadowDistance());
	get_shadow_surfaces(exclude, bs);
	if (surfaces_all.size() == 0)
		return;

The above code returns with surfaces_all blank for normal view. Then it proceeds with reflection which indeed catch some surfaces. So mystery solved!

Thanks again for the support.

On small question: am I right to assume that Unigine::Renderer::getViewport()->getID() returns the same id for both normal rendering and reflection (for the same viewport)?

Regards,
Adrian

Link to comment
1 hour ago, adrian.licuriceanu said:

am I right to assume that Unigine::Renderer::getViewport()->getID() returns the same id for both normal rendering and reflection (for the same viewport)?

Yes, I think so. It's only modified in Viewport::begin_frame/end_frame and not inside reflection rendering

Link to comment
×
×
  • Create New...