Blend effect based on fullscreen texture?

  • JohnnyFlash
  • Topic Author
More
4 years 3 months ago - 4 years 3 months ago #1 by JohnnyFlash Blend effect based on fullscreen texture? was created 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?
Last edit: 4 years 3 months ago by JohnnyFlash.

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

  • crosire
More
4 years 3 months ago - 4 years 3 months ago #2 by crosire Replied by crosire on topic Blend effect based on fullscreen texture?
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;
}
Last edit: 4 years 3 months ago by crosire.

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

  • JohnnyFlash
  • Topic Author
More
4 years 5 days ago - 4 years 5 days ago #3 by JohnnyFlash Replied by JohnnyFlash on topic Blend effect based on fullscreen texture?
Thank you very much. Gave me a good place to start.

Took a couple weeks of playing around with things, but I have it working. World of difference in dark scenes like Skyrim caves or Black Mesa.

Once I get it cleaned up a bit maybe I'll release it.
Last edit: 4 years 5 days ago by JohnnyFlash.

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.