Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why this glsl shader isn't working on hdr content? #436

Open
geextahslex opened this issue May 12, 2024 · 4 comments
Open

why this glsl shader isn't working on hdr content? #436

geextahslex opened this issue May 12, 2024 · 4 comments

Comments

@geextahslex
Copy link

geextahslex commented May 12, 2024

Hi.
TLDR: Does someone know why this works on SDR but isn't on HDR? The original shader worked on both and only 3 lines of code have changed... I marked them at the end

more info: This is a vibrance shader that has 2 conditions. The first one is the srgb threshold float Thresh = 200.0/255.0; the 2nd one is the saturation of the pixel delta = smoothstep(0.8, 0.9, colorSat);

By "isn't working" I mean that it visually doesn't change anything. The shader is working in the pipeline but there is no visible effect.

Thank you :)

//!PARAM vibr
//!DESC Saturates/deSaturates
//!TYPE float
//!MINIMUM -1
-0.5

//!HOOK MAIN
//!BIND HOOKED
//!DESC Vibrance

#define CoefLuma vec4(0.2126, 0.7152, 0.0722, 0) //sRGB, HDTV
float Thresh = 200.0/255.0;
float w = 10.0/255.0;

vec4 hook() {
	vec4 c0 = HOOKED_texOff(0);
	float lum = (c0.r + c0.g + c0.b)/3.0;

	float colorSat = max(max(c0.r, c0.g), c0.b) - min(min(c0.r, c0.g), c0.b); 
	vec3 sat = mix(vec3(dot(c0, CoefLuma)), c0.rgb, 1+vibr - colorSat*abs(vibr));
	float delta = smoothstep(Thresh-w, Thresh+w, lum);
1	sat = mix(sat, c0.rgb, delta);
2	delta = smoothstep(0.8, 0.9, colorSat);
3	c0.rgb = mix(c0.rgb, sat, delta);
	return c0;
}

The original shader, works on SDR and HDR

//!PARAM vibr
//!DESC Saturates/deSaturates
//!TYPE float
//!MINIMUM -1
-0.5

//!HOOK MAIN
//!BIND HOOKED
//!DESC Vibrance

#define CoefLuma vec4(0.2126, 0.7152, 0.0722, 0) //sRGB, HDTV
float Thresh = 200.0/255.0;
float w = 10.0/255.0;

vec4 hook() {
vec4 c0 = HOOKED_texOff(0);
float lum = (c0.r + c0.g + c0.b)/3.0; 

float colorSat = max(max(c0.r, c0.g), c0.b) -min(min(c0.r, c0.g), c0.b); // >=0, 5 arithmetic
vec3 sat = mix(vec3(dot(c0, CoefLuma)), c0.rgb, 1+vibr -colorSat*abs(vibr));
float delta = smoothstep( Thresh-w, Thresh+w, lum);
c0.rgb = mix( sat, c0.rgb, delta);
return c0;
}
@hizzlekizzle
Copy link
Collaborator

When you said it doesn't work, what does that mean? looks wrong? If so, can you post some comparison screenshots?

@geextahslex
Copy link
Author

geextahslex commented May 13, 2024

Hi, thank you for your answer.
By that I mean that it visually doesn't change anything. The shader is working in the pipeline but there is no visible effect.

this is how it should look like, look at the blue suit color
on

this is how it looks now
off

@hizzlekizzle
Copy link
Collaborator

Hmm, that's a very subtle difference. Much too subtle for my crummy eyes and monitor lol

Have you tried doing a sanity check? That is, setting one of the values in your added lines to a very large value to make sure it's actually there and doing what it's supposed to?

@geextahslex
Copy link
Author

Yes. I maxed out settings and changed them around but there is simply no change to the image. And as mentioned, it works on SDR but not HDR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants