half3 HSVToRGB( half3 c)
{
float4 K = float4( 1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0 );
half3 p = abs( frac( c.xxx + K.xyz ) * 6.0 - K.www );
return c.z * lerp( K.xxx, saturate( p - K.xxx ), c.y );
}
half3 RGBToHSV(half3 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 half3( abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
baseMap.xyz =RGBToHSV(baseMap.xyz );
baseMap.x =baseMap.x+_AdjustHue*rcp(360);
baseMap.y *=_AdjustSaturation;
baseMap.z *=_AdjustValue;
baseMap.yz =saturate(baseMap.yz);
Unity色相饱和度
于 2024-08-08 19:16:20 首次发布