Welcome, Guest.
Username: Password: Remember me

TOPIC: Hue/brightness/contrast/saturation shift

Hue/brightness/contrast/satura​tion shift 1 month 4 weeks ago #1

  • 63OR63
  • 63OR63's Avatar
  • Offline
  • Posts: 2
  • Thank you received: 5
A small shader for ReShade 3 to change hue, brightness, contrast and saturation. Use it as you wish.
uniform float Hue <
	ui_type = "drag";
	ui_min = -180.0; ui_max = 180.0;
	ui_tooltip = "Hue";
> = 0.0;
uniform float Brightness <
	ui_type = "drag";
	ui_min = -1.0; ui_max = 1.0;
	ui_tooltip = "Brightness";
> = 0.0;
uniform float Contrast <
	ui_type = "drag";
	ui_min = 0.0; ui_max = 1.0;
	ui_tooltip = "Contrast";
> = 0.0;
uniform float Saturation <
	ui_type = "drag";
	ui_min = 0.0; ui_max = 2.0;
	ui_tooltip = "Saturation";
> = 1.0;

#include "Reshade.fxh"

float3x3 QuaternionToMatrix(float4 quat)
{
	float3 cross = quat.yzx * quat.zxy;
	float3 square= quat.xyz * quat.xyz;
	float3 wimag = quat.w * quat.xyz;

	square = square.xyz + square.yzx;

	float3 diag = 0.5 - square;
	float3 a = (cross + wimag);
	float3 b = (cross - wimag);

	return float3x3(
	2.0 * float3(diag.x, b.z, a.y),
	2.0 * float3(a.z, diag.y, b.x),
	2.0 * float3(b.y, a.x, diag.z));
}

float4 PS_ColorShift(float4 position : SV_Position, float2 texcoord : TexCoord) : SV_Target
{
	float4 outputColor = tex2D(ReShade::BackBuffer, texcoord);
	float3 intensity;           
	float3 root3 = float3(0.57735, 0.57735, 0.57735);
	float half_angle = 0.5 * radians(Hue);
	float4 rot_quat = float4( (root3 * sin(half_angle)), cos(half_angle));
	float3x3 rot_Matrix = QuaternionToMatrix(rot_quat);     
	outputColor.rgb = mul(rot_Matrix, outputColor.rgb);
	outputColor.rgb = (outputColor.rgb - 0.5) *(Contrast + 1.0) + 0.5;  
	outputColor.rgb = outputColor.rgb + Brightness;         
	float3 lumCoeff = float3(0.2125, 0.7154, 0.0721);
	intensity = float(dot(outputColor.rgb, lumCoeff));
	outputColor.rgb = lerp(intensity, outputColor.rgb, Saturation);            

	return outputColor;
}

technique ColorShift
{
	pass HudPass
	{
		VertexShader = PostProcessVS;
		PixelShader = PS_ColorShift;
	}
}
Last Edit: 1 month 3 weeks ago by 63OR63.
The administrator has disabled public write access.
The following user(s) said Thank You: Wicked Sick