Render to Texture and Backbuffer in single pass

  • ShoterXX
  • Topic Author
More
8 years 1 week ago - 8 years 1 week ago #1 by ShoterXX Render to Texture and Backbuffer in single pass was created by ShoterXX
I was reading this: github.com/crosire/reshade-shaders/blob/master/REFERENCE.md

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?
Last edit: 8 years 1 week ago by ShoterXX.

Please Log in or Create an account to join the conversation.

  • kingeric1992
More
8 years 1 week ago - 8 years 1 week ago #2 by kingeric1992 Replied by kingeric1992 on topic Render to Texture and Backbuffer in single pass
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):

void ExamplePS0(float4 pos : SV_Position, float2 texcoord : TEXCOORD0, out float4 color : SV_Target)
{
    color = tex2D(samplerColor, texcoord);
}
To have multiple output texture, you can specify multiple render target, the implement detail is in the reference.
Last edit: 8 years 1 week ago by kingeric1992.

Please Log in or Create an account to join the conversation.

  • ShoterXX
  • Topic Author
More
8 years 1 week ago - 8 years 1 week ago #3 by ShoterXX Replied by ShoterXX on topic Render to Texture and Backbuffer in single pass

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):

void ExamplePS0(float4 pos : SV_Position, float2 texcoord : TEXCOORD0, out float4 color : SV_Target)
{
    color = tex2D(samplerColor, texcoord);
}
To have multiple output texture, you can specify multiple render target, the implement detail is in the reference.


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.
Last edit: 8 years 1 week ago by ShoterXX.

Please Log in or Create an account to join the conversation.

  • crosire
More
8 years 1 week ago #4 by crosire Replied by crosire on topic Render to Texture and Backbuffer in single pass
It is not currently possible. The backbuffer is unbound as soon as a custom rendertarget is bound.
The following user(s) said Thank You: ShoterXX

Please Log in or Create an account to join the conversation.

  • ShoterXX
  • Topic Author
More
8 years 1 week ago #5 by ShoterXX Replied by ShoterXX on topic Render to Texture and Backbuffer in single pass

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
More
8 years 1 week ago #6 by crosire Replied by crosire on topic Render to Texture and Backbuffer in single pass
Sure. The reason it's not there is that I could not decide for a syntax for binding the backbuffer to a certain rendertarget slot. Simplest option would be to simply always force target 0 to the backbuffer unless it is explicitly overwritten or a texture with different dimensions is bound to another slot.
The following user(s) said Thank You: ShoterXX

Please Log in or Create an account to join the conversation.

  • ShoterXX
  • Topic Author
More
8 years 1 week ago #7 by ShoterXX Replied by ShoterXX on topic Render to Texture and Backbuffer in single pass
Neat! Thanks!

Please Log in or Create an account to join the conversation.

We use cookies
We use cookies on our website. Some of them are essential for the operation of the forum. You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.