namespace UnityEditor.ShaderGraph
{
[Title("Procedural/Voronoi Noise ")]
[Title("Procedural/Voronoi")]
name = "VoronoiNoise " ;
name = "Voronoi" ;
}
protected override MethodInfo GetFunctionToConvert ( )
static string Unity_VoronoiNoise (
[Slot(0, Binding.MeshUV0)] Vector2 uv ,
[Slot(1, Binding.None, 2.0f, 0, 0, 0)] Vector1 a ngleOffset,
[Slot(2, Binding.None)] out Vector1 n1 ,
[Slot(2, Binding.None)] out Vector1 n2 ,
[Slot(2, Binding.None)] out Vector1 n3 )
[Slot(0, Binding.MeshUV0)] Vector2 UV ,
[Slot(1, Binding.None, 2.0f, 0, 0, 0)] Vector1 A ngleOffset,
[Slot(2, Binding.None,5.0f,5.0f,5.0f,5.0f )] Vector1 CellDensity ,
[Slot(3, Binding.None)] out Vector1 Out ,
[Slot(4, Binding.None)] out Vector1 Cells )
float2 g = floor ( uv ) ;
float2 f = frac ( uv ) ;
float2 g = floor ( UV * CellDensity ) ;
float2 f = frac ( UV * CellDensity ) ;
float t = 8.0 ;
float3 res = float3 ( 8.0 , 0.0 , 0.0 ) ;
{
float2 lattice = float2 ( x , y ) ;
float2 offset = unity_voronoi_noise_randomVector ( lattice + g , a ngleOffset) ;
float2 offset = unity_voronoi_noise_randomVector ( lattice + g , A ngleOffset) ;
float d = distance ( lattice + offset , f ) ;
if ( d < res . x )
n1 = res . x ;
n2 = res . y ;
n3 = 1.0 - res . x ;
Out = res . x ;
Cells = res . y ;
}
";
}
var preamble = @ "
inline float2 unity_voronoi_noise_randomVector ( float2 uv , float offset )
inline float2 unity_voronoi_noise_randomVector ( float2 UV , float offset )
uv = frac ( sin ( mul ( uv , m ) ) * 4 6 8 3 9.32 ) ;
return float2 ( sin ( uv . y * + offset ) * 0.5 + 0.5 , cos ( uv . x * offset ) * 0.5 + 0.5 ) ;
UV = frac ( sin ( mul ( UV , m ) ) * 4 6 8 3 9.32 ) ;
return float2 ( sin ( UV . y * + offset ) * 0.5 + 0.5 , cos ( UV . x * offset ) * 0.5 + 0.5 ) ;
}
";
visitor . AddShaderChunk ( preamble , true ) ;