+2
Completed

random

mikichen 10 years ago updated by Freya Holmér (Developer) 10 years ago 8
how to set a random value in shader forge

Answer

Answer
Completed
If you want to make it based on the position of the flag, append the object position X and Z, and put it into a Noise node, and then add that value to the Time node. If you need further help, ask in the forums, this place is more for improving shader forge itself, not really about how to make specific shaders
It depends. Random, per what?

Random per pixel?
Random per object?
Select Random texture?
Select Random color?
oh , i make a flag use vertex colour contro vertex animator,so i want to add some  random value let the time random (time contro the flag move range)
So you want a random offset on the time, per flag, to make sure multiple flags don't sync?
yes random offset
So, randomness needs to be based on something. You could for instance make it based on object X and Z position, using the noise node. However, this won't work if you want to move the flags around
// Shader created with Shader Forge Beta 0.23
// Shader Forge (c) Joachim Holmer - http://www.acegikmo.com/shaderforge/
// Note: Manually altering this data may prevent you from opening it in Shader Forge
/*SF_DATA;ver:0.23;sub:START;pass:START;ps:lgpr:1,nrmq:1,limd:1,blpr:0,bsrc:0,bdst:1,culm:2,dpts:2,wrdp:True,uamb:True,mssp:True,ufog:True,aust:True,igpj:False,qofs:0,lico:1,qpre:2,flbk:Transparent/Cutout/Diffuse,rntp:3,lmpd:True,lprd:False,enco:False,frtr:True,vitr:True,dbil:False,rmgx:True,hqsc:True,hqlp:False,fgom:False,fgoc:False,fgod:False,fgor:False,fgmd:0,fgcr:0.5,fgcg:0.5,fgcb:0.5,fgca:1,fgde:0.01,fgrn:0,fgrf:300,ofsf:0,ofsu:0;n:type:ShaderForge.SFN_Final,id:0,x:32768,y:32640|diff-322-OUT,spec-1477-OUT,gloss-1485-OUT,normal-2-RGB,transm-7-OUT,lwrap-6-OUT,clip-1-A,voffset-394-OUT;n:type:ShaderForge.SFN_Tex2d,id:1,x:33323,y:32627,ptlb:Diffuse,tex:8ba63e3399eca5d4a828dec7968523d3,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Tex2d,id:2,x:33266,y:32818,ptlb:Normal,tex:cb6c5165ed180c543be39ed70e72abc8,ntxv:3,isnm:True;n:type:ShaderForge.SFN_Vector3,id:6,x:33266,y:33075,v1:0.9,v2:0.9,v3:0.8;n:type:ShaderForge.SFN_Vector3,id:7,x:33266,y:32976,v1:0.9,v2:1,v3:0.5;n:type:ShaderForge.SFN_VertexColor,id:321,x:33565,y:32497;n:type:ShaderForge.SFN_Multiply,id:322,x:33118,y:32504|A-330-OUT,B-1-RGB;n:type:ShaderForge.SFN_Lerp,id:330,x:33323,y:32474|A-331-OUT,B-337-OUT,T-321-B;n:type:ShaderForge.SFN_Vector1,id:331,x:33565,y:32352,v1:1;n:type:ShaderForge.SFN_Vector3,id:337,x:33565,y:32406,v1:0.9632353,v2:0.8224623,v3:0.03541304;n:type:ShaderForge.SFN_NormalVector,id:391,x:33909,y:33033,pt:False;n:type:ShaderForge.SFN_Time,id:392,x:34375,y:33524;n:type:ShaderForge.SFN_Sin,id:393,x:33469,y:33377|IN-413-OUT;n:type:ShaderForge.SFN_Multiply,id:394,x:32905,y:33428,cmnt:Wind animation|A-562-OUT,B-393-OUT,C-1346-OUT,D-1103-OUT;n:type:ShaderForge.SFN_Add,id:413,x:33703,y:33311|A-699-OUT,B-1369-OUT;n:type:ShaderForge.SFN_Add,id:561,x:33605,y:33046|A-1152-XYZ,B-391-OUT;n:type:ShaderForge.SFN_Normalize,id:562,x:33433,y:33177|IN-561-OUT;n:type:ShaderForge.SFN_VertexColor,id:698,x:34607,y:32813;n:type:ShaderForge.SFN_Multiply,id:699,x:34163,y:33196|A-698-R,B-744-OUT,C-1057-OUT;n:type:ShaderForge.SFN_Slider,id:744,x:34402,y:33193,ptlb:blend,min:0,cur:0,max:20;n:type:ShaderForge.SFN_TexCoord,id:874,x:35877,y:33391,uv:0;n:type:ShaderForge.SFN_Rotator,id:975,x:35717,y:33181|UVIN-874-UVOUT,ANG-978-OUT;n:type:ShaderForge.SFN_ComponentMask,id:976,x:35516,y:33179,cc1:0,cc2:-1,cc3:-1,cc4:-1|IN-975-UVOUT;n:type:ShaderForge.SFN_Slider,id:978,x:35905,y:33183,ptlb:blend postion,min:0,cur:7.593987,max:90;n:type:ShaderForge.SFN_OneMinus,id:1056,x:35218,y:33484|IN-976-OUT;n:type:ShaderForge.SFN_Multiply,id:1057,x:34554,y:33346|A-976-OUT,B-1056-OUT,C-1160-OUT;n:type:ShaderForge.SFN_Slider,id:1103,x:33017,y:33538,ptlb:rang,min:0,cur:0,max:10;n:type:ShaderForge.SFN_Vector4Property,id:1152,x:33820,y:32761,ptlb:wind dir,v1:0,v2:0,v3:0,v4:0;n:type:ShaderForge.SFN_Slider,id:1160,x:34622,y:33503,ptlb:blend mode,min:0,cur:2,max:20;n:type:ShaderForge.SFN_Multiply,id:1346,x:33489,y:33539|A-698-R,B-976-OUT,C-1457-OUT;n:type:ShaderForge.SFN_Slider,id:1368,x:34303,y:33689,ptlb:speed,min:0,cur:0.2455128,max:10;n:type:ShaderForge.SFN_Multiply,id:1369,x:34010,y:33450|A-392-T,B-1368-OUT;n:type:ShaderForge.SFN_Slider,id:1413,x:34601,y:33081,ptlb:more random blend,min:0,cur:0,max:1;n:type:ShaderForge.SFN_Add,id:1457,x:34152,y:33057|A-1056-OUT,B-1413-OUT;n:type:ShaderForge.SFN_Slider,id:1477,x:32829,y:32461,ptlb:specular,min:0,cur:0,max:1;n:type:ShaderForge.SFN_Slider,id:1485,x:32817,y:32547,ptlb:gloss,min:0,cur:0,max:1;n:type:ShaderForge.SFN_Pi,id:1615,x:34149,y:33692;n:type:ShaderForge.SFN_Transform,id:1641,x:34372,y:33814,tffrom:0,tfto:1;proporder:1-2-744-978-1103-1152-1160-1368-1413-1477-1485;pass:END;sub:END;*/

Shader "Shader Forge/Examples/Animated Vegetation" {
Properties {
_Diffuse ("Diffuse", 2D) = "white" {}
_Normal ("Normal", 2D) = "bump" {}
_blend ("blend", Range(0, 20)) = 0
_blendpostion ("blend postion", Range(0, 90)) = 0
_rang ("rang", Range(0, 10)) = 0
_winddir ("wind dir", Vector) = (0,0,0,0)
_blendmode ("blend mode", Range(0, 20)) = 0
_speed ("speed", Range(0, 10)) = 0
_morerandomblend ("more random blend", Range(0, 1)) = 0
_specular ("specular", Range(0, 1)) = 0
_gloss ("gloss", Range(0, 1)) = 0
[HideInInspector]_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
}
SubShader {
Tags {
"Queue"="AlphaTest"
"RenderType"="TransparentCutout"
}
Pass {
Name "ForwardBase"
Tags {
"LightMode"="ForwardBase"
}
Cull Off


CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#define UNITY_PASS_FORWARDBASE
#include "UnityCG.cginc"
#include "AutoLight.cginc"
#include "Lighting.cginc"
#pragma multi_compile_fwdbase_fullshadows
#pragma exclude_renderers gles xbox360 ps3 flash
#pragma target 3.0
uniform float4 _TimeEditor;
#ifndef LIGHTMAP_OFF
sampler2D unity_Lightmap;
float4 unity_LightmapST;
#ifndef DIRLIGHTMAP_OFF
sampler2D unity_LightmapInd;
#endif
#endif
uniform sampler2D _Diffuse; uniform float4 _Diffuse_ST;
uniform sampler2D _Normal; uniform float4 _Normal_ST;
uniform float _blend;
uniform float _blendpostion;
uniform float _rang;
uniform float4 _winddir;
uniform float _blendmode;
uniform float _speed;
uniform float _morerandomblend;
uniform float _specular;
uniform float _gloss;
struct VertexInput {
float4 vertex : POSITION;
float3 normal : NORMAL;
float4 tangent : TANGENT;
float4 uv0 : TEXCOORD0;
float4 uv1 : TEXCOORD1;
float4 vertexColor : COLOR;
};
struct VertexOutput {
float4 pos : SV_POSITION;
float4 uv0 : TEXCOORD0;
float4 posWorld : TEXCOORD1;
float3 normalDir : TEXCOORD2;
float3 tangentDir : TEXCOORD3;
float3 binormalDir : TEXCOORD4;
float4 vertexColor : COLOR;
LIGHTING_COORDS(5,6)
#ifndef LIGHTMAP_OFF
float2 uvLM : TEXCOORD7;
#endif
};
VertexOutput vert (VertexInput v) {
VertexOutput o;
o.uv0 = v.uv0;
o.vertexColor = v.vertexColor;
o.normalDir = mul(float4(v.normal,0), _World2Object).xyz;
o.tangentDir = normalize( mul( _Object2World, float4( v.tangent.xyz, 0.0 ) ).xyz );
o.binormalDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
float4 node_698 = o.vertexColor;
float node_975_ang = _blendpostion;
float node_975_spd = 1.0;
float node_975_cos = cos(node_975_spd*node_975_ang);
float node_975_sin = sin(node_975_spd*node_975_ang);
float2 node_975_piv = float2(0.5,0.5);
float2 node_975 = (mul(o.uv0.rg-node_975_piv,float2x2( node_975_cos, -node_975_sin, node_975_sin, node_975_cos))+node_975_piv);
float node_976 = node_975.r;
float node_1056 = (1.0 - node_976);
float4 node_392 = _Time + _TimeEditor;
v.vertex.xyz += (normalize((_winddir.rgb+v.normal))*sin(((node_698.r*_blend*(node_976*node_1056*_blendmode))+(node_392.g*_speed)))*(node_698.r*node_976*(node_1056+_morerandomblend))*_rang);
o.posWorld = mul(_Object2World, v.vertex);
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
#ifndef LIGHTMAP_OFF
o.uvLM = v.uv1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
#endif
TRANSFER_VERTEX_TO_FRAGMENT(o)
return o;
}
fixed4 frag(VertexOutput i) : COLOR {
float2 node_1645 = i.uv0;
float4 node_1 = tex2D(_Diffuse,TRANSFORM_TEX(node_1645.rg, _Diffuse));
clip(node_1.a - 0.5);
i.normalDir = normalize(i.normalDir);
float3x3 tangentTransform = float3x3( i.tangentDir, i.binormalDir, i.normalDir);
float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
/////// Normals:
float3 normalLocal = UnpackNormal(tex2D(_Normal,TRANSFORM_TEX(node_1645.rg, _Normal))).rgb;
float3 normalDirection = mul( normalLocal, tangentTransform ); // Perturbed normals

float nSign = sign( dot( viewDirection, i.normalDir ) ); // Reverse normal if this is a backface
i.normalDir *= nSign;
normalDirection *= nSign;

#ifndef LIGHTMAP_OFF
float4 lmtex = tex2D(unity_Lightmap,i.uvLM);
#ifndef DIRLIGHTMAP_OFF
float3 lightmap = DecodeLightmap(lmtex);
float3 scalePerBasisVector = DecodeLightmap(tex2D(unity_LightmapInd,i.uvLM));
UNITY_DIRBASIS
half3 normalInRnmBasis = saturate (mul (unity_DirBasis, normalLocal));
lightmap *= dot (normalInRnmBasis, scalePerBasisVector);
#else
float3 lightmap = DecodeLightmap(tex2D(unity_Lightmap,i.uvLM));
#endif
#endif
#ifndef LIGHTMAP_OFF
#ifdef DIRLIGHTMAP_OFF
float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);
#else
float3 lightDirection = normalize (scalePerBasisVector.x * unity_DirBasis[0] + scalePerBasisVector.y * unity_DirBasis[1] + scalePerBasisVector.z * unity_DirBasis[2]);
lightDirection = mul(lightDirection,tangentTransform); // Tangent to world
#endif
#else
float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);
#endif
float3 halfDirection = normalize(viewDirection+lightDirection);
////// Lighting:
float attenuation = LIGHT_ATTENUATION(i);
float3 attenColor = attenuation * _LightColor0.xyz;
/////// Diffuse:
float NdotL = dot( normalDirection, lightDirection );
float3 w = float3(0.9,0.9,0.8)*0.5; // Light wrapping
float3 NdotLWrap = NdotL * ( 1.0 - w );
float3 forwardLight = max(float3(0.0,0.0,0.0), NdotLWrap + w );
float3 backLight = max(float3(0.0,0.0,0.0), -NdotLWrap + w ) * float3(0.9,1,0.5);
#ifndef LIGHTMAP_OFF
float3 diffuse = lightmap;
#else
float3 diffuse = (forwardLight+backLight) * attenColor + UNITY_LIGHTMODEL_AMBIENT.xyz;
#endif
///////// Gloss:
float gloss = exp2(_gloss*10.0+1.0);
////// Specular:
NdotL = max(0.0, NdotL);
float _specular_var = _specular;
float3 specularColor = float3(_specular_var,_specular_var,_specular_var);
float3 specular = (floor(attenuation) * _LightColor0.xyz) * pow(max(0,dot(halfDirection,normalDirection)),gloss) * specularColor;
float3 finalColor = 0;
float3 diffuseLight = diffuse;
float node_331 = 1.0;
finalColor += diffuseLight * (lerp(float3(node_331,node_331,node_331),float3(0.9632353,0.8224623,0.03541304),i.vertexColor.b)*node_1.rgb);
finalColor += specular;
/// Final Color:
return fixed4(finalColor,1);
}
ENDCG
}
Pass {
Name "ForwardAdd"
Tags {
"LightMode"="ForwardAdd"
}
Blend One One
Cull Off


Fog { Color (0,0,0,0) }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#define UNITY_PASS_FORWARDADD
#include "UnityCG.cginc"
#include "AutoLight.cginc"
#include "Lighting.cginc"
#pragma multi_compile_fwdadd_fullshadows
#pragma exclude_renderers gles xbox360 ps3 flash
#pragma target 3.0
uniform float4 _TimeEditor;
#ifndef LIGHTMAP_OFF
sampler2D unity_Lightmap;
float4 unity_LightmapST;
#ifndef DIRLIGHTMAP_OFF
sampler2D unity_LightmapInd;
#endif
#endif
uniform sampler2D _Diffuse; uniform float4 _Diffuse_ST;
uniform sampler2D _Normal; uniform float4 _Normal_ST;
uniform float _blend;
uniform float _blendpostion;
uniform float _rang;
uniform float4 _winddir;
uniform float _blendmode;
uniform float _speed;
uniform float _morerandomblend;
uniform float _specular;
uniform float _gloss;
struct VertexInput {
float4 vertex : POSITION;
float3 normal : NORMAL;
float4 tangent : TANGENT;
float4 uv0 : TEXCOORD0;
float4 uv1 : TEXCOORD1;
float4 vertexColor : COLOR;
};
struct VertexOutput {
float4 pos : SV_POSITION;
float4 uv0 : TEXCOORD0;
float4 posWorld : TEXCOORD1;
float3 normalDir : TEXCOORD2;
float3 tangentDir : TEXCOORD3;
float3 binormalDir : TEXCOORD4;
float4 vertexColor : COLOR;
LIGHTING_COORDS(5,6)
};
VertexOutput vert (VertexInput v) {
VertexOutput o;
o.uv0 = v.uv0;
o.vertexColor = v.vertexColor;
o.normalDir = mul(float4(v.normal,0), _World2Object).xyz;
o.tangentDir = normalize( mul( _Object2World, float4( v.tangent.xyz, 0.0 ) ).xyz );
o.binormalDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
float4 node_698 = o.vertexColor;
float node_975_ang = _blendpostion;
float node_975_spd = 1.0;
float node_975_cos = cos(node_975_spd*node_975_ang);
float node_975_sin = sin(node_975_spd*node_975_ang);
float2 node_975_piv = float2(0.5,0.5);
float2 node_975 = (mul(o.uv0.rg-node_975_piv,float2x2( node_975_cos, -node_975_sin, node_975_sin, node_975_cos))+node_975_piv);
float node_976 = node_975.r;
float node_1056 = (1.0 - node_976);
float4 node_392 = _Time + _TimeEditor;
v.vertex.xyz += (normalize((_winddir.rgb+v.normal))*sin(((node_698.r*_blend*(node_976*node_1056*_blendmode))+(node_392.g*_speed)))*(node_698.r*node_976*(node_1056+_morerandomblend))*_rang);
o.posWorld = mul(_Object2World, v.vertex);
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
TRANSFER_VERTEX_TO_FRAGMENT(o)
return o;
}
fixed4 frag(VertexOutput i) : COLOR {
float2 node_1646 = i.uv0;
float4 node_1 = tex2D(_Diffuse,TRANSFORM_TEX(node_1646.rg, _Diffuse));
clip(node_1.a - 0.5);
i.normalDir = normalize(i.normalDir);
float3x3 tangentTransform = float3x3( i.tangentDir, i.binormalDir, i.normalDir);
float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
/////// Normals:
float3 normalLocal = UnpackNormal(tex2D(_Normal,TRANSFORM_TEX(node_1646.rg, _Normal))).rgb;
float3 normalDirection = mul( normalLocal, tangentTransform ); // Perturbed normals

float nSign = sign( dot( viewDirection, i.normalDir ) ); // Reverse normal if this is a backface
i.normalDir *= nSign;
normalDirection *= nSign;

float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - i.posWorld.xyz,_WorldSpaceLightPos0.w));
float3 halfDirection = normalize(viewDirection+lightDirection);
////// Lighting:
float attenuation = LIGHT_ATTENUATION(i);
float3 attenColor = attenuation * _LightColor0.xyz;
/////// Diffuse:
float NdotL = dot( normalDirection, lightDirection );
float3 w = float3(0.9,0.9,0.8)*0.5; // Light wrapping
float3 NdotLWrap = NdotL * ( 1.0 - w );
float3 forwardLight = max(float3(0.0,0.0,0.0), NdotLWrap + w );
float3 backLight = max(float3(0.0,0.0,0.0), -NdotLWrap + w ) * float3(0.9,1,0.5);
float3 diffuse = (forwardLight+backLight) * attenColor;
///////// Gloss:
float gloss = exp2(_gloss*10.0+1.0);
////// Specular:
NdotL = max(0.0, NdotL);
float _specular_var = _specular;
float3 specularColor = float3(_specular_var,_specular_var,_specular_var);
float3 specular = attenColor * pow(max(0,dot(halfDirection,normalDirection)),gloss) * specularColor;
float3 finalColor = 0;
float3 diffuseLight = diffuse;
float node_331 = 1.0;
finalColor += diffuseLight * (lerp(float3(node_331,node_331,node_331),float3(0.9632353,0.8224623,0.03541304),i.vertexColor.b)*node_1.rgb);
finalColor += specular;
/// Final Color:
return fixed4(finalColor * 1,0);
}
ENDCG
}
Pass {
Name "ShadowCollector"
Tags {
"LightMode"="ShadowCollector"
}
Cull Off

Fog {Mode Off}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#define UNITY_PASS_SHADOWCOLLECTOR
#define SHADOW_COLLECTOR_PASS
#include "UnityCG.cginc"
#include "Lighting.cginc"
#pragma fragmentoption ARB_precision_hint_fastest
#pragma multi_compile_shadowcollector
#pragma exclude_renderers gles xbox360 ps3 flash
#pragma target 3.0
uniform float4 _TimeEditor;
#ifndef LIGHTMAP_OFF
sampler2D unity_Lightmap;
float4 unity_LightmapST;
#ifndef DIRLIGHTMAP_OFF
sampler2D unity_LightmapInd;
#endif
#endif
uniform sampler2D _Diffuse; uniform float4 _Diffuse_ST;
uniform float _blend;
uniform float _blendpostion;
uniform float _rang;
uniform float4 _winddir;
uniform float _blendmode;
uniform float _speed;
uniform float _morerandomblend;
struct VertexInput {
float4 vertex : POSITION;
float3 normal : NORMAL;
float4 uv0 : TEXCOORD0;
float4 vertexColor : COLOR;
};
struct VertexOutput {
V2F_SHADOW_COLLECTOR;
float4 uv0 : TEXCOORD5;
float3 normalDir : TEXCOORD6;
float4 vertexColor : COLOR;
};
VertexOutput vert (VertexInput v) {
VertexOutput o;
o.uv0 = v.uv0;
o.vertexColor = v.vertexColor;
o.normalDir = mul(float4(v.normal,0), _World2Object).xyz;
float4 node_698 = o.vertexColor;
float node_975_ang = _blendpostion;
float node_975_spd = 1.0;
float node_975_cos = cos(node_975_spd*node_975_ang);
float node_975_sin = sin(node_975_spd*node_975_ang);
float2 node_975_piv = float2(0.5,0.5);
float2 node_975 = (mul(o.uv0.rg-node_975_piv,float2x2( node_975_cos, -node_975_sin, node_975_sin, node_975_cos))+node_975_piv);
float node_976 = node_975.r;
float node_1056 = (1.0 - node_976);
float4 node_392 = _Time + _TimeEditor;
v.vertex.xyz += (normalize((_winddir.rgb+v.normal))*sin(((node_698.r*_blend*(node_976*node_1056*_blendmode))+(node_392.g*_speed)))*(node_698.r*node_976*(node_1056+_morerandomblend))*_rang);
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
TRANSFER_SHADOW_COLLECTOR(o)
return o;
}
fixed4 frag(VertexOutput i) : COLOR {
float2 node_1647 = i.uv0;
float4 node_1 = tex2D(_Diffuse,TRANSFORM_TEX(node_1647.rg, _Diffuse));
clip(node_1.a - 0.5);
i.normalDir = normalize(i.normalDir);
SHADOW_COLLECTOR_FRAGMENT(i)
}
ENDCG
}
Pass {
Name "ShadowCaster"
Tags {
"LightMode"="ShadowCaster"
}
Cull Off
Offset 1, 1

Fog {Mode Off}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#define UNITY_PASS_SHADOWCASTER
#include "UnityCG.cginc"
#include "Lighting.cginc"
#pragma fragmentoption ARB_precision_hint_fastest
#pragma multi_compile_shadowcaster
#pragma exclude_renderers gles xbox360 ps3 flash
#pragma target 3.0
uniform float4 _TimeEditor;
#ifndef LIGHTMAP_OFF
sampler2D unity_Lightmap;
float4 unity_LightmapST;
#ifndef DIRLIGHTMAP_OFF
sampler2D unity_LightmapInd;
#endif
#endif
uniform sampler2D _Diffuse; uniform float4 _Diffuse_ST;
uniform float _blend;
uniform float _blendpostion;
uniform float _rang;
uniform float4 _winddir;
uniform float _blendmode;
uniform float _speed;
uniform float _morerandomblend;
struct VertexInput {
float4 vertex : POSITION;
float3 normal : NORMAL;
float4 uv0 : TEXCOORD0;
float4 vertexColor : COLOR;
};
struct VertexOutput {
V2F_SHADOW_CASTER;
float4 uv0 : TEXCOORD1;
float3 normalDir : TEXCOORD2;
float4 vertexColor : COLOR;
};
VertexOutput vert (VertexInput v) {
VertexOutput o;
o.uv0 = v.uv0;
o.vertexColor = v.vertexColor;
o.normalDir = mul(float4(v.normal,0), _World2Object).xyz;
float4 node_698 = o.vertexColor;
float node_975_ang = _blendpostion;
float node_975_spd = 1.0;
float node_975_cos = cos(node_975_spd*node_975_ang);
float node_975_sin = sin(node_975_spd*node_975_ang);
float2 node_975_piv = float2(0.5,0.5);
float2 node_975 = (mul(o.uv0.rg-node_975_piv,float2x2( node_975_cos, -node_975_sin, node_975_sin, node_975_cos))+node_975_piv);
float node_976 = node_975.r;
float node_1056 = (1.0 - node_976);
float4 node_392 = _Time + _TimeEditor;
v.vertex.xyz += (normalize((_winddir.rgb+v.normal))*sin(((node_698.r*_blend*(node_976*node_1056*_blendmode))+(node_392.g*_speed)))*(node_698.r*node_976*(node_1056+_morerandomblend))*_rang);
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
TRANSFER_SHADOW_CASTER(o)
return o;
}
fixed4 frag(VertexOutput i) : COLOR {
float2 node_1648 = i.uv0;
float4 node_1 = tex2D(_Diffuse,TRANSFORM_TEX(node_1648.rg, _Diffuse));
clip(node_1.a - 0.5);
i.normalDir = normalize(i.normalDir);
SHADOW_CASTER_FRAGMENT(i)
}
ENDCG
}
}
FallBack "Transparent/Cutout/Diffuse"
CustomEditor "ShaderForgeMaterialInspector"
}
i dont know how ,but it work .
Answer
Completed
If you want to make it based on the position of the flag, append the object position X and Z, and put it into a Noise node, and then add that value to the Time node. If you need further help, ask in the forums, this place is more for improving shader forge itself, not really about how to make specific shaders