Dears CG developer, I'm looking for how I could how to adjust contrast or hue of 3D object using CG ? Thx for any help
I did contrast image effect in cg before, in cg's pixel shader, adjust contrast: //custom data //you can control this in C# //SetFloat("contrastIntensity", contrastIntensity); uniform float contrastIntensity; float4 frag (v2f_img i) : COLOR { float4 temp = tex2D(_MainTex,i.uv); temp = (temp-0.5)*contrastIntensity + 0.5; return temp; } //when contrastIntensity = 1, the result is normal //when contrastIntensity < 1, the result is less contrast //when contrastIntensity > 1, the result is more contrast
Thank you! Did u worked on the noise, distortion or chromatic aberrations of the texture? that would be much inetresting for me. Thank you again for your help : ))
chromatic aberrations = Code (CSharp): Shader "C4Cat/Image Effects/Chromatic Aberration" { Properties { _MainTex ("Base (RGB)", RECT) = "white" {} } SubShader { Pass { ZTest Always Cull Off ZWrite Off Fog { Mode off } CGPROGRAM #pragma vertex vert_img #pragma fragment frag #pragma fragmentoption ARB_precision_hint_fastest #include "UnityCG.cginc" // frag shaders data uniform sampler2D _MainTex; //custom data uniform float chromaticAberrationIntensity; uniform float vignetteStrength; // frag shader float4 frag (v2f_img i) : COLOR { float uvOffsetModify = (abs(i.uv.y-0.5) * abs(i.uv.x-0.5)); //float uvOffsetModify = abs(i.uv.y-0.5); float2 uvOffset = float2(chromaticAberrationIntensity,0); uvOffset *= uvOffsetModify; //shift R to left a bit float2 uvR = i.uv - uvOffset; float4 temp = tex2D(_MainTex, uvR); float R = temp.r; //keep B in original position temp = tex2D(_MainTex, i.uv); float B = temp.b; //shift G to right a bit float2 uvG = i.uv + uvOffset; temp = tex2D(_MainTex, uvG); float G = temp.g; //combine R G B result float4 result = float4(R,G,B,1); result *= 1 - uvOffsetModify * vignetteStrength; return result; } ENDCG } } Fallback off } sample R a bit left, sample G a bit right, sample B as usually, combine RGB for output.
distortion = sample pixel color with offset UV, how each pixel offset when sampling texture is base on your need. noise, what kind of noise you need? Are you doing something like a TV shader?
In my case it's exactly to copy noise from a texture(I dunno how to do it) and put it my 3D object via the shader.