Blend effect based on fullscreen texture?

  • Posts: 1
1 month 1 week ago - 1 month 1 week ago #1 by JohnnyFlash
Howdy,

I have the concept and math mapped out for VA gamma shift correction, but I don't know the language yet.

Before I sink time in, I just wanted to make sure: Can you blend a post effect (gamma) using a fullscreen texture all the way from 0 to 255? And if so, can it handle odd texture sizes like 3840x2160 or does the texture need to be power of 2 then stretched to monitor res?

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

  • Posts: 3633
1 month 1 week ago - 1 month 1 week ago #2 by crosire
Sure.
texture foobar < source = "some_image.png";
{
  Width = 3840;
  Height = 2160;
};

sampler foobar_sampler
{
  Texture = foobar;
};

...

float4 blablub(float2 texcoord : TEXCOORD) : SV_TARGET
{
  float4 color = tex2D(ReShade::BackBuffer);
  float4 color_post_effect = ...;

  // Assuming the 0-255 blending value is stored in the red channel of the image.
  // This looks it up and linearizes it to 0.0-1.0 float, since colors are represented as 0.0-1.0 in shaders.
  float blending = tex2D(foobar_sampler, texcoord).r;
  // Linearly interpolate between original color and whatever the post effect did, using that blending value.
  color = lerp(color, color_post_effect, blending);

  return color;
}

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