- Posts: 14
Dynamic render target size?
- MajorPainTheCactus
-
Topic Author
- Offline
Is there any way to dynamically resize this render target from values set in ImGui?
Please Log in or Create an account to join the conversation.
- rj200
-
- Offline
1. (fastest but not such a nice GUI) Use preprocessor definitions in your shader. It will appear underneath all the runtime ImGUI sliders in the GUI (user may have to click to expand "preprocessor definitions" section). It must have a name 10 or more characters or it won't appear. Simplified example from Glamayre:
2. Use biggest possible buffer size. Only read and write from a subset of it. If you use "discard" in your pixel shader it will still be reasonably fast - discard makes it exit early and write nothing.#ifndef FAKE_GI_WIDTH
#define FAKE_GI_WIDTH 384
#endif
#ifndef FAKE_GI_HEIGHT
#define FAKE_GI_HEIGHT 216
#endif
texture GITexture {
Width = FAKE_GI_WIDTH;
Height = FAKE_GI_HEIGHT ;
Format = RGBA16F;
};
3. Use biggest possible buffer size. Change the position of the triangle created by the vertex shader to only cover the top left corner of the texture. control size of that triangle using a ImGUI slider. Anything outside won't be rendered. I believe this will be faster than using discard.//first line of pixel shader
if(pos.x > maxwidth || pox.y > maxheight) discard;
uniform float fraction_to_draw < __UNIFORM_SLIDER_FLOAT1
ui_min = 0; ui_max = 1; ui_step = .01;
ui_label = "fraction_to_draw";
> = .5;
// Vertex shader generating a triangle covering the top left quarter of screen
void PostProcessVS(in uint id : SV_VertexID, out float4 position : SV_Position, out float2 texcoord : TEXCOORD)
{
texcoord = fraction_to_draw;
texcoord.x = (id == 2) ? -fraction_to_draw : fraction_to_draw;
texcoord.y = (id == 1) ? -fraction_to_draw : fraction_to_draw;
position = float4(texcoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
}
Please Log in or Create an account to join the conversation.