Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render in the background #742

Open
Geniok opened this issue Sep 5, 2023 · 11 comments
Open

Render in the background #742

Geniok opened this issue Sep 5, 2023 · 11 comments
Labels
support Support for general questions

Comments

@Geniok
Copy link

Geniok commented Sep 5, 2023

Can I make the engine run in the background without putting the render in the window?
But it also needs me to be able to resize the render area.
Now the render sizes are directly tied to the window sizes.

@turanszkij
Copy link
Owner

Yes, you can modify the logic in the wiApplication.cpp. The default behaviour is that in SetWindow(), we set the canvas size to the size of the window, and also create a swapchain of the same size. The swapchain is the final texture that will be presented to the window. All the other rendering by RenderPath3D and RenderPath2D will use other internal textures that will be sized relative to the size of the canvas.
You can change this logic and size your canvas however you want, and draw to the swapchain however you want.

@turanszkij turanszkij added the support Support for general questions label Sep 5, 2023
@Geniok
Copy link
Author

Geniok commented Sep 6, 2023

Is it possible to do this without any modification of the Wicked Engine?
It used to be more convenient, it was possible to directly set the render dimensions, without being tied to the dimensions of a particular window.
Now the engine relies on the size of the window for its work, automatically tracking changes in its size, which reduced flexibility, in my opinion.

@turanszkij
Copy link
Owner

In the Editor it is currently possible to set a fixed resolution in the config.ini, and if you set it to borderless, then the window cannot be resized:

width = 1920
height = 1080
borderless = true

How do you want to set a custom resolution and what should happen with window resize? Stretch render resolution to window size?

@Geniok
Copy link
Author

Geniok commented Dec 16, 2023

Hello!
I'm trying to create a small editor. I need the render size to change dynamically when the window size changes.
Editor

In the "Scene" window I display render Path -> lastPostprocessRT.
Now the render size is set by the size of the window itself. Which leads to unnecessary waste of resources.

@Geniok
Copy link
Author

Geniok commented Dec 16, 2023

I also need to change the rendering proportions:
Editor_2

@turanszkij
Copy link
Owner

You can change the size of the canvas (RenderPath3D is a canvas) and the render resources will be resized to match. This is how the editor works, but the canvas size is set from the window size (from the WM_RESIZE OS message if I remember correctly), instead you can set it to your desired size.

@Geniok
Copy link
Author

Geniok commented Dec 17, 2023

Hello!

Not certainly in that way. In the editor example, the WM_SIZE handler calls the editor.SetWindow(hWnd) method, and from it the canvas.init(window) method is called, which adjusts the size of the Canvas each time the window is resized.
Directly calling wi::RenderPath3D.width = 300 or wi::RenderPath3D.height= 500 does not affect the size of the Canvas .
Previously, you could manually specify the Canvas size and it was much more flexible and convenient.

If you call the canvas.init(width, height) method each time, if necessary, change the render size, then the final render size does not change, but remains equal to the window size, since further in the RenderPath2D::Update(float dt) method the sizes are again redefined equal the size of the main window.

DirectXRenderPath -> wi::RenderPath3D

DirectXRenderPath* renderPath;

if (imageRectMax.x != renderPath->width || imageRectMax.y != renderPath->height) 
{
        renderPath->setSize(Vector2(imageRectMax.x, imageRectMax.y)); 
}
void DirectXRenderPath::setSize(const Vector2& size) 
{

	this->width = size.x;                     <--- not work

	this->height = size.y;

	this->init(size.x, size.y);               <--- not work

	ResizeLayout();
}
void RenderPath2D::Update(float dt)
{
	XMUINT2 internalResolution = GetInternalResolution();

	if (current_buffersize.x != internalResolution.x || current_buffersize.y != internalResolution.y)
	{
		ResizeBuffers();
	}
	if (current_layoutscale != GetDPIScaling())
	{
		ResizeLayout();
	}

@turanszkij
Copy link
Owner

You can manage your own renderpath and then the application will not resize it for you and not interfere. This renderpath you don't activate on the application, but you call its Update,Render etc. functions yourself. Then you can draw the render result of your render path on the screen wherever you want using the image renderer. For example you can get the last post process render texture from RenderPath3D with GetLastPostprocessRT function.

@Geniok
Copy link
Author

Geniok commented Dec 20, 2023

There is one problem. The fact is that I want to display the ImGUI interface also using WickedEngine, as is done in the ImGUI Example.
So I need WickedEngine to track the window, but at the same time I can directly set the render resolution.

Until 04/22/21, I could set the render resolution separately using the GraphicsDevice_DX12::SetResolution(int width, int height) method, which was later removed, breaking backward compatibility.

The solution that I see is to create a window with ImGUI yourself, without using WickedEngine, and take only render results from WickedEngine using GetLastPostprocessRT. But then you won’t be able to use WickedEngine methods for selecting objects in a window, etc.

Or somehow decouple the render resolution from the window resolution. But I can't find a suitable method in GraphicsDevice_DX12. In all the examples that I was able to find, the render resolution coincides with the window resolution.

@turanszkij
Copy link
Owner

The SetResolution was removed because now multiple windows (swapchains) can be created. But the base simple Application class only handles one. It should be possible to modify only the Application class to do what you want. You can override the Application class for example, or not use it, as it is just some high level logic tying engine functions together at the top level.

@Geniok
Copy link
Author

Geniok commented Dec 20, 2023

Thank you.
I'll try to come up with something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Support for general questions
Projects
None yet
Development

No branches or pull requests

2 participants