initial commit
This commit is contained in:
parent
6715289efe
commit
788c3389af
37645 changed files with 2526849 additions and 80 deletions
|
@ -0,0 +1,59 @@
|
|||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[Title("Procedural", "Noise", "Gradient Noise")]
|
||||
class GradientNoiseNode : CodeFunctionNode
|
||||
{
|
||||
public GradientNoiseNode()
|
||||
{
|
||||
name = "Gradient Noise";
|
||||
synonyms = new string[] { "perlin noise" };
|
||||
}
|
||||
|
||||
protected override MethodInfo GetFunctionToConvert()
|
||||
{
|
||||
return GetType().GetMethod("Unity_GradientNoise", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
}
|
||||
|
||||
static string Unity_GradientNoise(
|
||||
[Slot(0, Binding.MeshUV0)] Vector2 UV,
|
||||
[Slot(1, Binding.None, 10, 10, 10, 10)] Vector1 Scale,
|
||||
[Slot(2, Binding.None)] out Vector1 Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
$precision2 p = UV * Scale;
|
||||
$precision2 ip = floor(p);
|
||||
$precision2 fp = frac(p);
|
||||
$precision d00 = dot(Unity_GradientNoise_Dir_$precision(ip), fp);
|
||||
$precision d01 = dot(Unity_GradientNoise_Dir_$precision(ip + $precision2(0, 1)), fp - $precision2(0, 1));
|
||||
$precision d10 = dot(Unity_GradientNoise_Dir_$precision(ip + $precision2(1, 0)), fp - $precision2(1, 0));
|
||||
$precision d11 = dot(Unity_GradientNoise_Dir_$precision(ip + $precision2(1, 1)), fp - $precision2(1, 1));
|
||||
fp = fp * fp * fp * (fp * (fp * 6 - 15) + 10);
|
||||
Out = lerp(lerp(d00, d01, fp.y), lerp(d10, d11, fp.y), fp.x) + 0.5;
|
||||
}
|
||||
";
|
||||
}
|
||||
|
||||
public override void GenerateNodeFunction(FunctionRegistry registry, GenerationMode generationMode)
|
||||
{
|
||||
registry.ProvideFunction("Unity_GradientNoise_Dir_$precision", s => s.Append(@"
|
||||
$precision2 Unity_GradientNoise_Dir_$precision($precision2 p)
|
||||
{
|
||||
// Permutation and hashing used in webgl-nosie goo.gl/pX7HtC
|
||||
p = p % 289;
|
||||
// need full precision, otherwise half overflows when p > 1
|
||||
float x = float(34 * p.x + 1) * p.x % 289 + p.y;
|
||||
x = (34 * x + 1) * x % 289;
|
||||
x = frac(x / 41) * 2 - 1;
|
||||
return normalize($precision2(x - floor(x + 0.5), abs(x) - 0.5));
|
||||
}
|
||||
"));
|
||||
|
||||
base.GenerateNodeFunction(registry, generationMode);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c8e5f34a7e7cbfe4a9444e42ccfc7ea4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,93 @@
|
|||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[Title("Procedural", "Noise", "Simple Noise")]
|
||||
class NoiseNode : CodeFunctionNode
|
||||
{
|
||||
public NoiseNode()
|
||||
{
|
||||
name = "Simple Noise";
|
||||
synonyms = new string[] { "value noise" };
|
||||
}
|
||||
|
||||
protected override MethodInfo GetFunctionToConvert()
|
||||
{
|
||||
return GetType().GetMethod("Unity_SimpleNoise", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
}
|
||||
|
||||
static string Unity_SimpleNoise(
|
||||
[Slot(0, Binding.MeshUV0)] Vector2 UV,
|
||||
[Slot(1, Binding.None, 500f, 500f, 500f, 500f)] Vector1 Scale,
|
||||
[Slot(2, Binding.None)] out Vector1 Out)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
$precision t = 0.0;
|
||||
|
||||
$precision freq = pow(2.0, $precision(0));
|
||||
$precision amp = pow(0.5, $precision(3-0));
|
||||
t += Unity_SimpleNoise_ValueNoise_$precision($precision2(UV.x*Scale/freq, UV.y*Scale/freq))*amp;
|
||||
|
||||
freq = pow(2.0, $precision(1));
|
||||
amp = pow(0.5, $precision(3-1));
|
||||
t += Unity_SimpleNoise_ValueNoise_$precision($precision2(UV.x*Scale/freq, UV.y*Scale/freq))*amp;
|
||||
|
||||
freq = pow(2.0, $precision(2));
|
||||
amp = pow(0.5, $precision(3-2));
|
||||
t += Unity_SimpleNoise_ValueNoise_$precision($precision2(UV.x*Scale/freq, UV.y*Scale/freq))*amp;
|
||||
|
||||
Out = t;
|
||||
}
|
||||
";
|
||||
}
|
||||
|
||||
public override void GenerateNodeFunction(FunctionRegistry registry, GenerationMode generationMode)
|
||||
{
|
||||
registry.ProvideFunction("Unity_SimpleNoise_RandomValue_$precision", s => s.Append(@"
|
||||
inline $precision Unity_SimpleNoise_RandomValue_$precision ($precision2 uv)
|
||||
{
|
||||
$precision angle = dot(uv, $precision2(12.9898, 78.233));
|
||||
#if defined(SHADER_API_MOBILE) && (defined(SHADER_API_GLES) || defined(SHADER_API_GLES3) || defined(SHADER_API_VULKAN))
|
||||
// 'sin()' has bad precision on Mali GPUs for inputs > 10000
|
||||
angle = fmod(angle, TWO_PI); // Avoid large inputs to sin()
|
||||
#endif
|
||||
return frac(sin(angle)*43758.5453);
|
||||
}"));
|
||||
|
||||
registry.ProvideFunction($"Unity_SimpleNnoise_Interpolate_$precision", s => s.Append(@"
|
||||
inline $precision Unity_SimpleNnoise_Interpolate_$precision ($precision a, $precision b, $precision t)
|
||||
{
|
||||
return (1.0-t)*a + (t*b);
|
||||
}
|
||||
"));
|
||||
|
||||
registry.ProvideFunction($"Unity_SimpleNoise_ValueNoise_$precision", s => s.Append(@"
|
||||
inline $precision Unity_SimpleNoise_ValueNoise_$precision ($precision2 uv)
|
||||
{
|
||||
$precision2 i = floor(uv);
|
||||
$precision2 f = frac(uv);
|
||||
f = f * f * (3.0 - 2.0 * f);
|
||||
|
||||
uv = abs(frac(uv) - 0.5);
|
||||
$precision2 c0 = i + $precision2(0.0, 0.0);
|
||||
$precision2 c1 = i + $precision2(1.0, 0.0);
|
||||
$precision2 c2 = i + $precision2(0.0, 1.0);
|
||||
$precision2 c3 = i + $precision2(1.0, 1.0);
|
||||
$precision r0 = Unity_SimpleNoise_RandomValue_$precision(c0);
|
||||
$precision r1 = Unity_SimpleNoise_RandomValue_$precision(c1);
|
||||
$precision r2 = Unity_SimpleNoise_RandomValue_$precision(c2);
|
||||
$precision r3 = Unity_SimpleNoise_RandomValue_$precision(c3);
|
||||
|
||||
$precision bottomOfGrid = Unity_SimpleNnoise_Interpolate_$precision(r0, r1, f.x);
|
||||
$precision topOfGrid = Unity_SimpleNnoise_Interpolate_$precision(r2, r3, f.x);
|
||||
$precision t = Unity_SimpleNnoise_Interpolate_$precision(bottomOfGrid, topOfGrid, f.y);
|
||||
return t;
|
||||
}"));
|
||||
|
||||
base.GenerateNodeFunction(registry, generationMode);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3b0333da20fc0bf48a4d9b09a9d8d9db
|
||||
timeCreated: 1495718308
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,69 @@
|
|||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[FormerName("UnityEditor.ShaderGraph.VoronoAbstractMaterialNode")]
|
||||
[Title("Procedural", "Noise", "Voronoi")]
|
||||
class VoronoiNode : CodeFunctionNode
|
||||
{
|
||||
public VoronoiNode()
|
||||
{
|
||||
name = "Voronoi";
|
||||
synonyms = new string[] { "worley noise" };
|
||||
}
|
||||
|
||||
protected override MethodInfo GetFunctionToConvert()
|
||||
{
|
||||
return GetType().GetMethod("Unity_Voronoi", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
}
|
||||
|
||||
static string Unity_Voronoi(
|
||||
[Slot(0, Binding.MeshUV0)] Vector2 UV,
|
||||
[Slot(1, Binding.None, 2.0f, 0, 0, 0)] Vector1 AngleOffset,
|
||||
[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)
|
||||
{
|
||||
return
|
||||
@"
|
||||
{
|
||||
$precision2 g = floor(UV * CellDensity);
|
||||
$precision2 f = frac(UV * CellDensity);
|
||||
$precision t = 8.0;
|
||||
$precision3 res = $precision3(8.0, 0.0, 0.0);
|
||||
|
||||
for(int y=-1; y<=1; y++)
|
||||
{
|
||||
for(int x=-1; x<=1; x++)
|
||||
{
|
||||
$precision2 lattice = $precision2(x,y);
|
||||
$precision2 offset = Unity_Voronoi_RandomVector_$precision(lattice + g, AngleOffset);
|
||||
$precision d = distance(lattice + offset, f);
|
||||
|
||||
if(d < res.x)
|
||||
{
|
||||
res = $precision3(d, offset.x, offset.y);
|
||||
Out = res.x;
|
||||
Cells = res.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
";
|
||||
}
|
||||
|
||||
public override void GenerateNodeFunction(FunctionRegistry registry, GenerationMode generationMode)
|
||||
{
|
||||
registry.ProvideFunction("Unity_Voronoi_RandomVector_$precision", s => s.Append(@"
|
||||
inline $precision2 Unity_Voronoi_RandomVector_$precision ($precision2 UV, $precision offset)
|
||||
{
|
||||
$precision2x2 m = $precision2x2(15.27, 47.63, 99.41, 89.98);
|
||||
UV = frac(sin(mul(UV, m)));
|
||||
return $precision2(sin(UV.y*+offset)*0.5+0.5, cos(UV.x*offset)*0.5+0.5);
|
||||
}
|
||||
"));
|
||||
base.GenerateNodeFunction(registry, generationMode);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 38694b8d93b01e049ad6dafebebb60ba
|
||||
timeCreated: 1495535565
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue