Shader color Adjustment: Hue, lightness, saturation, contrast

Source: Internet
Author: User

Shader"unlit/colorful"{Properties {_maintex ("Texture", 2D) =" White"{} _brightnessamount ("Brightness Amount", Range (0.0,2.0)) =1.0_saturationamount ("saturation Amount", Range (0.0,2.0)) =1.0_contrastamount ("contrast Amount", Range (0.0,2.0)) =1.0} subshader {Tags {"Rendertype"="Opaque"} LOD -Pass {Cgprogram#pragmaVertex vert#pragmaFragment Frag//Make fog work            #pragmaMulti_compile_fog#include"Unitycg.cginc"sampler2d _maintex;            FLOAT4 _maintex_st; fixed_brightnessamount; fixed_saturationamount; fixed_contrastamount; structAppData {float4 vertex:position;            FLOAT2 uv:texcoord0;            }; structv2f {float4 pos:sv_position;            FLOAT2 uv:texcoord0;            }; FLOAT3 contrastsaturationbrightness (float3 color,floatBrtfloatSatfloatcon) {                //increase or decrease these values to//adjust R, G and B color channels separately                floatAVGLUMR =0.5; floatAVGLUMG =0.5; floatAvglumb =0.5; //luminance coefficients for getting luminance from the imageFLOAT3 Luminancecoeff = FLOAT3 (0.2125,0.7154,0.0721); //Operation for BrightmessFLOAT3 Avglumin =float3 (AVGLUMR, AVGLUMG, Avglumb); FLOAT3 Brtcolor= Color *BRT; floatINTENSITYF =dot (Brtcolor, Luminancecoeff); FLOAT3 intensity=float3 (INTENSITYF, INTENSITYF, INTENSITYF); //operation for SaturationFLOAT3 Satcolor =lerp (intensity, brtcolor, Sat); //Operation for contrastFLOAT3 concolor =lerp (avglumin, Satcolor, con); returnconcolor;                } v2f Vert (AppData v) {v2f o; O.pos=Mul (UNITY_MATRIX_MVP, V.vertex); O.uv=Transform_tex (V.UV, _maintex); returno; } fixed4 Frag (v2f i): sv_target {fixed4 col=tex2d (_maintex, I.UV); Col.rgb=contrastsaturationbrightness (col, _brightnessamount, _saturationamount, _contrastamount); returnCol; } ENDCG} }}

Shader color Adjustment: Hue, lightness, saturation, contrast

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.