Primitive color grading controls
This commit is contained in:
parent
af2e8eb05c
commit
63561039c8
3 changed files with 49 additions and 27 deletions
52
combine.cc
52
combine.cc
|
@ -20,7 +20,10 @@ T_CombinePass::T_CombinePass(
|
||||||
bloomAttenuation_( 0.3 ) ,
|
bloomAttenuation_( 0.3 ) ,
|
||||||
vignette_{
|
vignette_{
|
||||||
1 , 8 , .5 , 1 , 0 , 1
|
1 , 8 , .5 , 1 , 0 , 1
|
||||||
}
|
} ,
|
||||||
|
cgLift_{ 0 , 0 , 0 } ,
|
||||||
|
cgGain_{ 1 , 1 , 1 } ,
|
||||||
|
cgGamma_{ 0 , 0 , 0 }
|
||||||
{
|
{
|
||||||
program_ = Globals::Shaders( ).pipeline({
|
program_ = Globals::Shaders( ).pipeline({
|
||||||
"fullscreen.v.glsl" , "combine.f.glsl" });
|
"fullscreen.v.glsl" , "combine.f.glsl" });
|
||||||
|
@ -40,6 +43,9 @@ void T_CombinePass::render( )
|
||||||
U_BLOOM_PARAMETERS ,
|
U_BLOOM_PARAMETERS ,
|
||||||
U_VIGNETTE_PARAMETERS_1 ,
|
U_VIGNETTE_PARAMETERS_1 ,
|
||||||
U_VIGNETTE_PARAMETERS_2 ,
|
U_VIGNETTE_PARAMETERS_2 ,
|
||||||
|
U_CG_LIFT ,
|
||||||
|
U_CG_GAIN ,
|
||||||
|
U_CG_GAMMA ,
|
||||||
};
|
};
|
||||||
auto& tm( Globals::Textures( ) );
|
auto& tm( Globals::Textures( ) );
|
||||||
tm.bind( 0 , txImage_ );
|
tm.bind( 0 , txImage_ );
|
||||||
|
@ -57,6 +63,9 @@ void T_CombinePass::render( )
|
||||||
vignette_ );
|
vignette_ );
|
||||||
glProgramUniform2fv( id , U_VIGNETTE_PARAMETERS_2 , 1 ,
|
glProgramUniform2fv( id , U_VIGNETTE_PARAMETERS_2 , 1 ,
|
||||||
vignette_ + 4 );
|
vignette_ + 4 );
|
||||||
|
glProgramUniform3fv( id , U_CG_LIFT , 1 , cgLift_ );
|
||||||
|
glProgramUniform3fv( id , U_CG_GAIN , 1 , cgGain_ );
|
||||||
|
glProgramUniform3fv( id , U_CG_GAMMA , 1 , cgGamma_ );
|
||||||
|
|
||||||
glDrawArrays( GL_TRIANGLE_STRIP , 0 , 4 );
|
glDrawArrays( GL_TRIANGLE_STRIP , 0 , 4 );
|
||||||
}
|
}
|
||||||
|
@ -65,20 +74,37 @@ void T_CombinePass::render( )
|
||||||
|
|
||||||
void T_CombinePass::makeUI( )
|
void T_CombinePass::makeUI( )
|
||||||
{
|
{
|
||||||
if ( !ImGui::CollapsingHeader( "Combine" ) ) {
|
using namespace ImGui;
|
||||||
|
if ( !CollapsingHeader( "Combine" ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::Text( "Bloom" );
|
if ( TreeNode( "combine-bloom" , "Bloom" ) ) {
|
||||||
ImGui::DragFloat( "Strength" , &bloomStrength_ , .001f , 0. , 10 );
|
DragFloat( "Strength" , &bloomStrength_ , .001f , 0. , 10 );
|
||||||
ImGui::DragFloat( "Attenuation" , &bloomAttenuation_ , .001f , 0. , 1 );
|
DragFloat( "Attenuation" , &bloomAttenuation_ , .001f , 0. , 1 );
|
||||||
|
TreePop( );
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::Text( "Vignette" );
|
if ( TreeNode( "Vignette" ) ) {
|
||||||
ImGui::DragFloat( "Shape mult." , &vignette_[ 0 ] , .01f , 0.5 , 20 );
|
DragFloat( "Shape mult." , &vignette_[ 0 ] , .01f , 0.5 , 20 );
|
||||||
ImGui::DragFloat( "Shape power" , &vignette_[ 1 ] , .01f , .5 , 50 );
|
DragFloat( "Shape power" , &vignette_[ 1 ] , .01f , .5 , 50 );
|
||||||
ImGui::DragFloat( "Aspect ratio" , &vignette_[ 2 ] , .001f , 0 , 1 );
|
DragFloat( "Aspect ratio" , &vignette_[ 2 ] , .001f , 0 , 1 );
|
||||||
ImGui::DragFloat( "Shape reverse" , &vignette_[ 3 ] , .001f , .2 , 5 );
|
DragFloat( "Shape reverse" , &vignette_[ 3 ] , .001f , .2 , 5 );
|
||||||
ImGui::DragFloat( "Apply base" , &vignette_[ 4 ] , .001f , 0 , 1 );
|
DragFloat( "Apply base" , &vignette_[ 4 ] , .001f , 0 , 1 );
|
||||||
ImGui::DragFloat( "Apply max" , &vignette_[ 5 ] , .001f , 0 , 1 );
|
DragFloat( "Apply max" , &vignette_[ 5 ] , .001f , 0 , 1 );
|
||||||
|
TreePop( );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( TreeNode( "Color grading" ) ) {
|
||||||
|
DragFloat( "Lift / R" , &cgLift_[ 0 ] , .0001f , -1 , 1 );
|
||||||
|
DragFloat( "Lift / G" , &cgLift_[ 1 ] , .0001f , -1 , 1 );
|
||||||
|
DragFloat( "Lift / B" , &cgLift_[ 2 ] , .0001f , -1 , 1 );
|
||||||
|
DragFloat( "Gain / R" , &cgGain_[ 0 ] , .001f , 0 , 2 );
|
||||||
|
DragFloat( "Gain / G" , &cgGain_[ 1 ] , .001f , 0 , 2 );
|
||||||
|
DragFloat( "Gain / B" , &cgGain_[ 2 ] , .001f , 0 , 2 );
|
||||||
|
DragFloat( "Gamma / R" , &cgGamma_[ 0 ] , .001f , -2 , 10 );
|
||||||
|
DragFloat( "Gamma / G" , &cgGamma_[ 1 ] , .001f , -2 , 10 );
|
||||||
|
DragFloat( "Gamma / B" , &cgGamma_[ 2 ] , .001f , -2 , 10 );
|
||||||
|
TreePop( );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,5 +26,9 @@ struct T_CombinePass
|
||||||
float bloomAttenuation_;
|
float bloomAttenuation_;
|
||||||
|
|
||||||
float vignette_[ 6 ];
|
float vignette_[ 6 ];
|
||||||
|
|
||||||
|
float cgLift_[ 3 ];
|
||||||
|
float cgGain_[ 3 ];
|
||||||
|
float cgGamma_[ 3 ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -6,16 +6,11 @@ layout( location = 0 ) uniform sampler2D u_MainInput;
|
||||||
layout( location = 1 ) uniform sampler2D u_BlurInput;
|
layout( location = 1 ) uniform sampler2D u_BlurInput;
|
||||||
layout( location = 2 ) uniform vec2 u_OutputSize;
|
layout( location = 2 ) uniform vec2 u_OutputSize;
|
||||||
layout( location = 3 ) uniform vec2 u_Bloom;
|
layout( location = 3 ) uniform vec2 u_Bloom;
|
||||||
|
|
||||||
// Vignette parameters
|
|
||||||
// 1.x = shape multiplier
|
|
||||||
// 1.y = shape power
|
|
||||||
// 1.z = aspect ratio
|
|
||||||
// 1.w = reverse power multiplier
|
|
||||||
// 2.x = apply base
|
|
||||||
// 2.y = apply max
|
|
||||||
layout( location = 4 ) uniform vec4 u_Vignette1;
|
layout( location = 4 ) uniform vec4 u_Vignette1;
|
||||||
layout( location = 5 ) uniform vec2 u_Vignette2;
|
layout( location = 5 ) uniform vec2 u_Vignette2;
|
||||||
|
layout( location = 6 ) uniform vec3 u_ColorLift;
|
||||||
|
layout( location = 7 ) uniform vec3 u_ColorGain;
|
||||||
|
layout( location = 8 ) uniform vec3 u_ColorGamma;
|
||||||
|
|
||||||
#define uVigShapeMul (u_Vignette1.x)
|
#define uVigShapeMul (u_Vignette1.x)
|
||||||
#define uVigShapePow (u_Vignette1.y)
|
#define uVigShapePow (u_Vignette1.y)
|
||||||
|
@ -41,11 +36,8 @@ void main( void )
|
||||||
}
|
}
|
||||||
o_Color = o_Color + bloom / 2.2;
|
o_Color = o_Color + bloom / 2.2;
|
||||||
|
|
||||||
// Color grading test
|
// Color grading
|
||||||
vec3 uColorGain = vec3( .95 , 1.1 , 1.4 ) ,
|
o_Color = ( o_Color * ( u_ColorGain - u_ColorLift ) ) + u_ColorLift;
|
||||||
uColorLift = vec3( 0 , 0 , .003 ) ,
|
|
||||||
uColorGamma = vec3( -.2 , 0.1 , .1 );
|
|
||||||
o_Color = ( o_Color * ( uColorGain - uColorLift ) ) + uColorLift;
|
|
||||||
|
|
||||||
// Vignette
|
// Vignette
|
||||||
vec2 vShape = pow( abs( pos * 2 - 1 ) * uVigShapeMul ,
|
vec2 vShape = pow( abs( pos * 2 - 1 ) * uVigShapeMul ,
|
||||||
|
@ -60,5 +52,5 @@ void main( void )
|
||||||
o_Color = o_Color / ( o_Color + 1. );
|
o_Color = o_Color / ( o_Color + 1. );
|
||||||
|
|
||||||
// Gamma
|
// Gamma
|
||||||
o_Color = pow( o_Color , vec3( 1 ) / ( uColorGamma + 2.2 ) );
|
o_Color = pow( o_Color , vec3( 1 ) / ( u_ColorGamma + 2.2 ) );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue