Welcome, Guest.
Username: Password: Remember me

TOPIC: S-curves

S-curves 4 months 1 week ago #1

UPDATE:
Made shader a two stage one, adjusting high/lowlights and mids semi-separately:

#include "ReShadeUI.fxh";

uniform float hueRotateAmnt < __UNIFORM_SLIDER_FLOAT1
	ui_min = -360.000; ui_max=360.000;
> = 0;

uniform float satChangeAmnt < __UNIFORM_DRAG_FLOAT1
	ui_min = 0.000; ui_max=5.000; ui_category="High_lowlights";
> = 1;

uniform float valChangeAmnt < __UNIFORM_DRAG_FLOAT1
	ui_min = 0.0; ui_max = 5.0; ui_category="High_lowlights";
> = 1;

uniform float redChangeAmnt < __UNIFORM_DRAG_FLOAT1
	ui_min = 0.0; ui_max = 5.0; ui_category="High_lowlights";
> = 1;

uniform float greenChangeAmnt < __UNIFORM_DRAG_FLOAT1
	ui_min = 0.0; ui_max = 5.0; ui_category="High_lowlights";
> = 1;

uniform float blueChangeAmnt < __UNIFORM_DRAG_FLOAT1
	ui_min = 0.0; ui_max = 5.0; ui_category="High_lowlights";
> = 1;

uniform float rgbChangeAmnt < __UNIFORM_DRAG_FLOAT1
	ui_min = 0.0; ui_max = 5.0; ui_category="High_lowlights";
> = 1;

uniform float greyChangeAmnt < __UNIFORM_DRAG_FLOAT1
	ui_min = 0.0; ui_max = 5.0; ui_category="High_lowlights";
> = 1;

uniform float satChangeAmntMd < __UNIFORM_DRAG_FLOAT1
	ui_min = 0.000; ui_max=5.000; ui_category="Mids";
> = 1;

uniform float valChangeAmntMd < __UNIFORM_DRAG_FLOAT1
	ui_min = 0.0; ui_max = 5.0; ui_category="Mids";
> = 1;

uniform float redChangeAmntMd < __UNIFORM_DRAG_FLOAT1
	ui_min = 0.0; ui_max = 5.0; ui_category="Mids";
> = 1;

uniform float greenChangeAmntMd < __UNIFORM_DRAG_FLOAT1
	ui_min = 0.0; ui_max = 5.0; ui_category="Mids";
> = 1;

uniform float blueChangeAmntMd < __UNIFORM_DRAG_FLOAT1
	ui_min = 0.0; ui_max = 5.0; ui_category="Mids";
> = 1;

uniform float rgbChangeAmntMd < __UNIFORM_DRAG_FLOAT1
	ui_min = 0.0; ui_max = 5.0; ui_category="Mids";
> = 1;

uniform float greyChangeAmntMd < __UNIFORM_DRAG_FLOAT1
	ui_min = 0.0; ui_max = 5.0; ui_category="Mids";
> = 1;

uniform bool Split <> = false;

uniform bool Flip_split <> = false;

uniform float Split_position < __UNIFORM_SLIDER_FLOAT1
	ui_min = 0; ui_max =1;
	ui_tooltip = "0 is on the far left, 1 on the far right.";
> = 0.5;


#include "ReShade.fxh";


	float3 rgb2hsv(float3 c)
{
    float4 K = float4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
    float4 p = lerp(float4(c.bg, K.wz), float4(c.gb, K.xy), step(c.b, c.g));
    float4 q = lerp(float4(p.xyw, c.r), float4(c.r, p.yzx), step(p.x, c.r));
 
    float d = q.x - min(q.w, q.y);
    float e = 1.0e-10;
    return float3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}


float3 hsv2rgb(float3 c)
{
    float4 K = float4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
    float3 p = abs(frac(c.xxx + K.xyz) * 6.0 - K.www);
    return c.z * lerp(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
//Source: http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl


float s_curver(float color, float gamma){

color*=2;
color=(color<0.5)?pow(abs(0.5*color),gamma):1-(0.5*pow(abs(2-color),gamma));

return color;
}


float hue_rotate(float hue, float deg){

deg*=pow(360,-1);

float r=hue+deg;

float r1=(r<=1)?r:r-1;
hue=(r<0)?1+r:r1;

return hue;
}


float4 sCurve(float4 c0, float2 tex, float mids){
float3 colorHSV=rgb2hsv(c0.rgb);
float3 colorHSVOg=colorHSV;
float c0Max=max(c0.r,max(c0.g,c0.b));
	

[branch]if(mids==1){

colorHSV.y=(satChangeAmntMd==1)?colorHSV.y:s_curver(colorHSV.y,satChangeAmntMd);

colorHSV.z=(valChangeAmntMd==1)?colorHSV.z:s_curver(colorHSV.z,valChangeAmntMd);
	
c0.rgb=(colorHSVOg==colorHSV)?c0.rgb:hsv2rgb(colorHSV);

c0.r =(redChangeAmntMd==1)?c0.r:s_curver(c0.r,redChangeAmntMd);

c0.g =(greenChangeAmntMd==1)?c0.g:s_curver(c0.g,greenChangeAmntMd);

c0.b =(blueChangeAmntMd==1)?c0.b:s_curver(c0.b,blueChangeAmntMd);

c0.rgb =(rgbChangeAmntMd==1)?c0.rgb:float3(s_curver(c0.r,rgbChangeAmntMd),s_curver(c0.g,rgbChangeAmntMd),s_curver(c0.b,rgbChangeAmntMd));

c0.rgb =(greyChangeAmntMd==1)?c0.rgb:saturate(s_curver(c0Max,greyChangeAmntMd)*(c0.rgb/c0Max));

}else{

colorHSV.y=(satChangeAmnt==1)?colorHSV.y:s_curver(colorHSV.y,satChangeAmnt);

colorHSV.z=(valChangeAmnt==1)?colorHSV.z:s_curver(colorHSV.z,valChangeAmnt);
	
c0.rgb=(colorHSVOg==colorHSV)?c0.rgb:hsv2rgb(colorHSV);

c0.r =(redChangeAmnt==1)?c0.r:s_curver(c0.r,redChangeAmnt);

c0.g =(greenChangeAmnt==1)?c0.g:s_curver(c0.g,greenChangeAmnt);

c0.b =(blueChangeAmnt==1)?c0.b:s_curver(c0.b,blueChangeAmnt);

c0.rgb =(rgbChangeAmnt==1)?c0.rgb:float3(s_curver(c0.r,rgbChangeAmnt),s_curver(c0.g,rgbChangeAmnt),s_curver(c0.b,rgbChangeAmnt));

c0.rgb =(greyChangeAmnt==1)?c0.rgb:saturate(s_curver(c0Max,greyChangeAmnt)*(c0.rgb/c0Max));

}
return c0;
}

float4 ScurvePass(float4 vpos : SV_Position, float2 texcoord : TexCoord) : SV_Target
{
	
float4 c0=tex2D(ReShade::BackBuffer, texcoord);

float3 colorHSV=rgb2hsv(c0.rgb);
float3 colorHSVOg=colorHSV;

colorHSV.x=(hueRotateAmnt==0)?colorHSV.x:hue_rotate(colorHSV.x,hueRotateAmnt);

c0.rgb=(colorHSVOg==colorHSV)?c0.rgb:hsv2rgb(colorHSV);
float4 c1=c0;

c1=sCurve(c1, texcoord,0);
c1.rgb=(c0.rgb==c1.rgb)?c0.rgb:lerp(c0.rgb,c1.rgb,2*abs(0.5-c1.rgb));
float4 colHL=c1;

c1=sCurve(c1, texcoord,1);
c1.rgb=(c1.rgb==colHL.rgb)?colHL.rgb:lerp(c1.rgb,c0.rgb,2*abs(0.5-c1.rgb));

float4 c2=(texcoord.x>=Split_position*Split)?c1:c0;
float4 c3=(texcoord.x<=Split_position*Split)?c1:c0;

float4 c4=(Flip_split ==1 && Split==1)?c3:c2;

float divLine = abs(texcoord.x - Split_position) < BUFFER_RCP_WIDTH;
c4 =(Split==0)?c4: c4*(1.0 - divLine); //invert divline

return c4;
}



technique Scurve
{
	pass
	{
		VertexShader = PostProcessVS;
		PixelShader = ScurvePass;
	}
}

Version for videos here.
Last Edit: 2 months 1 week ago by crabshank. Reason: Fixed OpenGL compatibility issue + Removed a random empty function
The administrator has disabled public write access.
The following user(s) said Thank You: Wicked Sick, jas01, andrew, Ryukou36, Viper_Joe, Marty, Raughie, Faustus86

S-curves 4 months 1 week ago #2

I really like your dynamic debug/ split-screen options. I wish it could be used with other shaders as well.
The administrator has disabled public write access.

S-curves 4 months 1 week ago #3

I can make any shader have that cos I have a template I use.
The administrator has disabled public write access.
The following user(s) said Thank You: Faustus86

S-curves 4 months 3 days ago #4

Adjusted S-curves because grey dither was inherently lossy, it's lossless now so make sure to download the update.
The administrator has disabled public write access.
The following user(s) said Thank You: jas01, Faustus86

S-curves 3 months 3 weeks ago #5

Optimised ^. Now includes hue rotation.
The administrator has disabled public write access.
The following user(s) said Thank You: jas01, Faustus86

S-curves 3 months 1 week ago #6

UPDATE:
I have a new setting "Curve_mids" that affects the darks and highlights less and less as they approach 0 and 1 and thus only curves the mids.
The administrator has disabled public write access.
The following user(s) said Thank You: Wicked Sick, jas01, Faustus86

S-curves 3 months 1 week ago #7

UPDATE:
I semi-separated S-curves on the high/lowlights and on the mids in an effort to get that 'looking at the action through a window' look. Before, certain parts looked blown out and now this is much reduced.
The administrator has disabled public write access.
The following user(s) said Thank You: jas01, Faustus86

S-curves 2 months 3 weeks ago #8

Hey =)

I have just downloaded all your shaders and now i am testing with them.
Usually i am using photoshop + LUT Maps for color grading wich is pretty awesome but most often i still need a lot of fine tuning ingame by using Lightroom by Marty + HSLShift. After some testing i have to say your shader's are truly awesome and the splitscreen option is very helpful too, thank you so much =)

I hope crosire will add them to the standard shaders, i find them extremely helpful to get rid of tinting, fine tune shadows and change specific color values. Saves a lot of time and effort switching between photoshop and reshade, i can tell you that =)
Last Edit: 2 months 3 weeks ago by Faustus86.
The administrator has disabled public write access.
The following user(s) said Thank You: crabshank

S-curves 2 months 3 weeks ago #9

Thanks man. Make sure you try out my updated grey gamma shader for more control over the dynamic range.
The administrator has disabled public write access.

S-curves 2 months 1 week ago #10

I have fixed an issue that made all my shaders incompatible with OpenGL and I have removed a random empty function from this one.
The administrator has disabled public write access.
The following user(s) said Thank You: jas01

S-curves 2 months 1 week ago #11

  • Wicked Sick
  • Wicked Sick's Avatar
  • Offline
  • Die young or suffer (Forgive my poor English)
Man, thanks for updating this shader!
Finding relief somewhere between a tree's branch and its shade.
The administrator has disabled public write access.
The following user(s) said Thank You: crabshank