Render to Texture and Backbuffer in single pass
- ShoterXX
- Topic Author
Is it possible? I know I supposedly can't read and write to the same texture at the same time, but I was looking at the function parameter qualifiers, it looked like "inout" could allow me to get the buffer, change it, then send it straight back. If so, I can pretty much shorten my whole shader (without defines, textures and all that stuff, ofc) to 2 lines. I've tried it, but not sure if I'm doing something wrong.
And before anyone asks, I'm a rookie as far as graphical stuff goes.
Edit: Ok, I went sideways on my question, so let me clarify it. Can I write to a texture and to the back buffer in the same pass? And how? And how do I use that "inout" parameter properly?
Please Log in or Create an account to join the conversation.
- kingeric1992
And reshade doesn't take "in" for the shader besides Semantics.
The alternative is to use it in function then load it to shader.
As shown in the reference, you can still have your 2-lines shader with some arrangement.
reference wrote: // The following pixel shader simply returns the color of the games output again without modifying it (via the "color" output parameter):
void ExamplePS0(float4 pos : SV_Position, float2 texcoord : TEXCOORD0, out float4 color : SV_Target)
{
color = tex2D(samplerColor, texcoord);
}
Please Log in or Create an account to join the conversation.
- ShoterXX
- Topic Author
kingeric1992 wrote: For a shader, you don't have the "in" , the color in the texture before even sampling in the shader, for the argument "inout".
And reshade doesn't take "in" for the shader besides Semantics.
The alternative is to use it in function then load it to shader.
As shown in the reference, you can still have your 2-lines shader with some arrangement.
reference wrote: // The following pixel shader simply returns the color of the games output again without modifying it (via the "color" output parameter):
To have multiple output texture, you can specify multiple render target, the implement detail is in the reference.void ExamplePS0(float4 pos : SV_Position, float2 texcoord : TEXCOORD0, out float4 color : SV_Target) { color = tex2D(samplerColor, texcoord); }
Problem A: I can't read from sample AND write it to RT at the same time, so if I sample it, I won't be able to output it.
Problem B: If I specify a new render target, it'll no longer use RT0 to send to backbuffer. The issue about it is that BackBuffer is read-only and I have no idea what I should use instead, since that is not specified in the reference. I tried poking around the other shaders and ReShade.fx, but found nothing.
Please Log in or Create an account to join the conversation.
- crosire
Please Log in or Create an account to join the conversation.
- ShoterXX
- Topic Author
crosire wrote: It is not currently possible. The backbuffer is unbound as soon as a custom rendertarget is bound.
Oh. Well, thanks for the reply! Is it possible to add it as a feature then, or is there a reason for it?
Please Log in or Create an account to join the conversation.
- crosire
Please Log in or Create an account to join the conversation.
- ShoterXX
- Topic Author
Please Log in or Create an account to join the conversation.
- lordbean
FWIW, what I'm intuitively inclined to try when just experimenting is:
RenderTarget0 = ReShade::BackBuffer
RenderTarget1 = texture_name
I know ReShade::BackBuffer is just a COLOR sampler defined in reshade.fxh, and therefore this won't actually work, but if I didn't know better that's what I'd try.
Please Log in or Create an account to join the conversation.