Jump to content

Custom projection matrix with render_border


photo

Recommended Posts

Dear Unigine Team,

during our investigations regarding the Water screen space reflections (as described here )

we encountered a tiny problem with render_border command.

We are "modifying" the projection matrix a bit (by adding a translation in Y) and that translation gets lost when I invoke the render_border console command.

That behaviour is not totally new to me, in the past, when we were using the app border plugin, we had the same issue, but it was easy to fix in the source code. In AppBorder.cpp in

void AppBorder::render_window() instead of

	if (projection.m32 == 0.0f)
		projection = ortho(-x, x, -y, y, znear, zfar);
	else
		projection = frustum(-x, x, -y, y, znear, zfar);

	camera->setProjection(projection);

	// render textures
	viewport->renderTexture2D(camera, texture);

we have been using

	if (projection.m32 == 0.0f)
		projection = ortho(-x, x, -y, y, znear, zfar);
	else
		projection = frustum(-x, x, -y, y, znear, zfar);

	camera->setProjection(translate(0, pmY, 0) * projection);

	// render textures
	viewport->renderTexture2D(camera, texture);

I wonder if that is also the issue with the render_border command and if there is a simple fix to that.

Thanks

Helmut

 

 

 

Link to comment

Hi Helmut,

There are two options:

  1. Resurrect ancient AppBorder plugin and modify it (so it will compile and link with current engine);
  2. Wait until we implement this behavior (saving translation inside the engine for current camera)

Btw, which SDK you are currently using for this project? Do you plan to upgrade to 2.11?

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

Hello Silent,

thanks for the quick reply -  at the moment we are using 2.10. But we plan to move to 2.11 soon (mainly because we want to make use of the updated solution for colorbanding in the sky).

Great that you are considering to add this feature -  I could imagine that it is also usefull for other applications.

Cheers

Helmut

Link to comment

Hello Helmut,

Could you elaborate what's the meaning of that translation after projection operation in context of your application? And what are usual values of pmY?

Link to comment

Hello Andrey,

i think the problem I'm describing also exists in photography. It is basically about vertical line distortion.

In order to demonstrate that what we want to solve, I use an 80 degree FOV in the following images. Lets take the following scene, where I have about 50% sky and 50% water.

water50.thumb.PNG.6b41537224daba829fb18fb25a3f8522.PNG

Now I want to change the camera so that I have only about 25% water. In order to do so I need to rotate the camera so that it points a bit up into the sky. Now I get a distorted cylinder:water25.thumb.PNG.4dad152949d8d4c71496811b07244893.PNG

However, if I change the projection I can have both - 25% water and an undistorted cylinder:

water25_pmy.thumb.PNG.969b94e41037a12b6ff677ff70511771.PNG

The last image shows the main camera in the background, which has a 50% water and 50% sky. The foreground window runs the attached Pmy C# component.

Thank you for looking at this, Andrey

 

Pmy.cs

Link to comment

Hello Silent,

sorry for the late reply, thank you very much, thats a great news!

We are using the engineering edition (actually we are still on 2.10. but I think upgrading should be straight forward and I will do that in the next couple of days).

Many thanks

Helmut

Link to comment
×
×
  • Create New...