Search Unity

Shader color value offset

Discussion in 'Shaders' started by EllieXY, Feb 21, 2021.

  1. EllieXY

    EllieXY

    Joined:
    Nov 9, 2019
    Posts:
    1
    upload_2021-2-21_19-46-12.png

    Is there any way to access this circular offset in an HDR color?
    I need to add an animation capable hue offset float to a shader so I can use it in a blend tree.

    I don't really know much about shader programmming. So far I've only been able to add the hue shift to the inspector but it's obviously not hooked up to anything.
    upload_2021-2-21_19-48-14.png
    {
    Properties
    {
    _FresnelPower("Fresnel Power", Range( 0 , 5)) = 2
    [HideInInspector]_FresnelScale("Fresnel Scale", Range( 0 , 0.3)) = 1.5
    _EdgeLength ( "Edge length", Range( 2, 50 ) ) = 13.5
    _FresnelBias("Fresnel Bias", Range( 0 , 0.2)) = 0.2364706
    [HDR]_Flamecolor2("Flame color 2", Color) = (1,0,0,0)
    [HDR]_FlameColor("Flame Color", Color) = (1,0.8068966,0,0)
    _MainHueShift ("Hue Shift", Range(0, 1)) = 0
    _Y_Mask("Y_Mask", Range( 0 , 5)) = 0
    _FlameHeight("Flame Height", Range( 0 , 1)) = 0
    _Flamenoise("Flame noise", 2D) = "white" {}
    _FlameWave("Flame Wave", 2D) = "white" {}
    _v("v", Range( -1 , 1)) = 0
    _u("u", Range( -1 , 1)) = 0
    _Alpha("Alpha", Range( 0 , 1)) = 0
    [HideInInspector] __dirty( "", Int ) = 1
    }

    SubShader
    {
    Tags{ "RenderType" = "Transparent" "Queue" = "Transparent+100" "IgnoreProjector" = "True" "IsEmissive" = "true" }
    Cull Front
    CGPROGRAM
    #include "UnityShaderVariables.cginc"
    #include "Tessellation.cginc"
    #pragma target 4.6
    #pragma surface surf Standard alpha:fade keepalpha noshadow exclude_path:deferred noambient novertexlights nolightmap nodynlightmap nodirlightmap vertex:vertexDataFunc tessellate:tessFunction
    struct Input
    {
    float3 worldPos;
    float3 worldNormal;
    };

    uniform sampler2D _FlameWave;
    uniform float _u;
    uniform float _v;
    uniform sampler2D _Flamenoise;
    uniform float4 _Flamenoise_ST;
    uniform float _Y_Mask;
    uniform float _FlameHeight;
    uniform float4 _Flamecolor2;
    uniform float4 _FlameColor;
    uniform float _FresnelBias;
    uniform float _FresnelScale;
    uniform float _FresnelPower;
    uniform float _Alpha;
    uniform float _EdgeLength;

    float4 tessFunction( appdata_full v0, appdata_full v1, appdata_full v2 )
    {
    return UnityEdgeLengthBasedTess (v0.vertex, v1.vertex, v2.vertex, _EdgeLength);
    }

    void vertexDataFunc( inout appdata_full v )
    {
    float4 transform17 = mul(unity_WorldToObject,float4( float3(0,1,0) , 0.0 ));
    float4 appendResult29 = (float4(_u , _v , 0.0 , 0.0));
    float2 uv_Flamenoise = v.texcoord.xy * _Flamenoise_ST.xy + _Flamenoise_ST.zw;
    float2 panner24 = ( 1.0 * _Time.y * appendResult29.xy + uv_Flamenoise);
    float4 lerpResult23 = lerp( float4( 0,0,0,0 ) , transform17 , ( tex2Dlod( _FlameWave, float4( panner24, 0, 0.0) ) * tex2Dlod( _Flamenoise, float4( panner24, 0, 0.0) ) ).r);
    float3 ase_worldNormal = UnityObjectToWorldNormal( v.normal );
    float clampResult12 = clamp( ( distance( ase_worldNormal.y , _Y_Mask ) - _Y_Mask ) , 0.0 , 1.0 );
    float temp_output_14_0 = ( 1.0 - clampResult12 );
    float4 lerpResult18 = lerp( float4( 0,0,0,0 ) , lerpResult23 , temp_output_14_0);
    v.vertex.xyz += ( lerpResult18 * _FlameHeight ).xyz;
    float3 ase_vertexNormal = v.normal.xyz;
    v.normal = ase_vertexNormal;
    }

    void surf( Input i , inout SurfaceOutputStandard o )
    {
    float3 ase_worldPos = i.worldPos;
    float3 ase_worldViewDir = normalize( UnityWorldSpaceViewDir( ase_worldPos ) );
    float3 ase_worldNormal = i.worldNormal;
    float fresnelNDotV1 = dot( normalize( ase_worldNormal ), ase_worldViewDir );
    float fresnelNode1 = ( _FresnelBias + _FresnelScale * pow( 1.0 - fresnelNDotV1, _FresnelPower ) );
    float4 lerpResult7 = lerp( _Flamecolor2 , _FlameColor , fresnelNode1);
    float4 temp_cast_0 = (0.0).xxxx;
    float4 temp_cast_1 = (5.0).xxxx;
    float4 clampResult31 = clamp( lerpResult7 , temp_cast_0 , temp_cast_1 );
    o.Emission = clampResult31.rgb;
    float clampResult12 = clamp( ( distance( ase_worldNormal.y , _Y_Mask ) - _Y_Mask ) , 0.0 , 1.0 );
    float temp_output_14_0 = ( 1.0 - clampResult12 );
    float lerpResult35 = lerp( 0.0 , ( fresnelNode1 * temp_output_14_0 ) , _Alpha);
    o.Alpha = lerpResult35;
    }

    ENDCG
    }
    CustomEditor "ASEMaterialInspector"
    }
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352