Add # NatureManufacture Assets

This commit is contained in:
Williams
2026-05-19 16:48:22 +02:00
parent d4247a7a9b
commit b0f8a56bb0
1806 changed files with 264979 additions and 4 deletions
@@ -0,0 +1,265 @@
#define FLT_EPSILON 1.192092896e-07
#include "NMWindTouchRect.cginc"
sampler2D WIND_SETTINGS_TexNoise;
sampler2D WIND_SETTINGS_TexGust;
float _InitialBend;
float _Stiffness;
float _Drag;
float _ShiverDrag;
float _ShiverDirectionality;
float _WindNormalInfluence;
float4 _NewNormal;
float4 WIND_SETTINGS_WorldDirectionAndSpeed;
float WIND_SETTINGS_FlexNoiseScale;
float WIND_SETTINGS_ShiverNoiseScale;
float WIND_SETTINGS_Turbulence;
float WIND_SETTINGS_GustSpeed;
float WIND_SETTINGS_GustScale;
float WIND_SETTINGS_GustWorldScale;
float4x4 WIND_SETTINGS_Points;
float4 WIND_SETTINGS_Points_Radius;
uniform half _CullFarStart = -1;
uniform half _CullFarDistance = -1;
float PositivePow(float base, float power)
{
return pow(max(abs(base), float(FLT_EPSILON)), power);
}
float AttenuateTrunk(float x, float s)
{
float r = (x / s);
return PositivePow(r, 1 / s);
}
float3 Rotate(float3 pivot, float3 position, float3 rotationAxis, float angle)
{
rotationAxis = normalize(rotationAxis);
float3 cpa = pivot + rotationAxis * dot(rotationAxis, position - pivot);
return cpa + ((position - cpa) * cos(angle) + cross(rotationAxis, (position - cpa)) * sin(angle));
}
struct WindData
{
float3 Direction;
float Strength;
float3 ShiverStrength;
float3 ShiverDirection;
float Gust;
};
float3 texNoise(float3 worldPos, float LOD)
{
return tex2Dlod(WIND_SETTINGS_TexNoise, float4(worldPos.xz, 0, LOD)).xyz - 0.5;
}
float texGust(float3 worldPos, float LOD)
{
return tex2Dlod(WIND_SETTINGS_TexGust, float4(worldPos.xz, 0, LOD)).x;
}
float4 PointDirection(float4 collumn, float radius)
{
float3 position = UNITY_MATRIX_M._m03_m13_m23;
float3 direction = position - collumn.rgb;
float3 norm = normalize(direction);
float leng = length(direction);
leng = clamp(leng / radius, 0, 1);
leng = lerp(collumn.a, 0, leng);
norm = norm * leng;
return float4(norm.rgb, leng);
}
float4 MatrixSplit(float4x4 mat, float column)
{
return float4(mat[0][column], mat[1][column], mat[2][column], mat[3][column]);
}
WindData GetAnalyticalWind(float3 WorldPosition, float3 PivotPosition, float drag, float shiverDrag, float initialBend, float4 time)
{
WindData result;
float4 newDirection = PointDirection(MatrixSplit(WIND_SETTINGS_Points, 0), WIND_SETTINGS_Points_Radius[0]);
newDirection += PointDirection(MatrixSplit(WIND_SETTINGS_Points, 1), WIND_SETTINGS_Points_Radius[1]);
newDirection += PointDirection(MatrixSplit(WIND_SETTINGS_Points, 2), WIND_SETTINGS_Points_Radius[2]);
newDirection += PointDirection(MatrixSplit(WIND_SETTINGS_Points, 3), WIND_SETTINGS_Points_Radius[3]);
float4 WIND_SETTINGS_WorldDirectionAndSpeednew = WIND_SETTINGS_WorldDirectionAndSpeed + newDirection;
float3 normalizedDir = normalize(WIND_SETTINGS_WorldDirectionAndSpeednew.xyz);
float3 worldOffset = float3(1, 0, 0) * WIND_SETTINGS_WorldDirectionAndSpeednew.w * time.y;
float3 gustWorldOffset = float3(1, 0, 0) * WIND_SETTINGS_GustSpeed * time.y;
// Trunk noise is base wind + gusts + noise
float3 trunk = float3(0, 0, 0);
if (WIND_SETTINGS_WorldDirectionAndSpeednew.w > 0.0 || WIND_SETTINGS_Turbulence > 0.0)
{
trunk = texNoise((PivotPosition - worldOffset) * WIND_SETTINGS_FlexNoiseScale, 3);
}
float gust = 0.0;
if (WIND_SETTINGS_GustSpeed > 0.0)
{
gust = texGust((PivotPosition - gustWorldOffset) * WIND_SETTINGS_GustWorldScale, 3);
gust = pow(gust, 2) * WIND_SETTINGS_GustScale;
}
float3 trunkNoise =
(
(normalizedDir * WIND_SETTINGS_WorldDirectionAndSpeednew.w)
+ (gust * normalizedDir * WIND_SETTINGS_GustSpeed)
+ (trunk * WIND_SETTINGS_Turbulence)
) * drag;
// Shiver Noise
float3 shiverNoise = texNoise((WorldPosition - worldOffset) * WIND_SETTINGS_ShiverNoiseScale, 0) * shiverDrag * WIND_SETTINGS_Turbulence;
float3 dir = trunkNoise;
float flex = length(trunkNoise) + initialBend;
float shiver = length(shiverNoise);
result.Direction = dir;
result.ShiverDirection = shiverNoise;
result.Strength = flex;
result.ShiverStrength = shiver + shiver * gust;
result.Gust = (gust * normalizedDir * WIND_SETTINGS_GustSpeed)
+ (trunk * WIND_SETTINGS_Turbulence);
return result;
}
void ApplyWindDisplacement(inout float3 positionWS,
inout WindData windData,
float3 normalWS,
float3 rootWP,
float stiffness,
float drag,
float shiverDrag,
float shiverDirectionality,
float initialBend,
float shiverMask,
float4 time)
{
WindData wind = GetAnalyticalWind(positionWS, rootWP, drag, shiverDrag, initialBend, time);
if (wind.Strength > 0.0)
{
float att = AttenuateTrunk(distance(positionWS, rootWP), stiffness);
float3 rotAxis = cross(float3(0, 1, 0), wind.Direction);
positionWS = Rotate(rootWP, positionWS, rotAxis, (wind.Strength) * 0.001 * att);
float3 shiverDirection = normalize(lerp(normalWS, normalize(wind.Direction + wind.ShiverDirection), shiverDirectionality));
positionWS += wind.ShiverStrength * shiverDirection * shiverMask;
}
windData = wind;
}
float4x4 GetObjectToWorldMatrix()
{
return unity_ObjectToWorld;
}
float4x4 GetWorldToObjectMatrix()
{
return unity_WorldToObject;
}
float3 TransformObjectToWorld(float3 positionOS)
{
return mul(GetObjectToWorldMatrix(), float4(positionOS, 1.0)).xyz;
}
float3 TransformObjectToWorldNormal(float3 normalOS)
{
#ifdef UNITY_ASSUME_UNIFORM_SCALING
return UnityObjectToWorldDir(normalOS);
#else
// Normal need to be multiply by inverse transpose
// mul(IT_M, norm) => mul(norm, I_M) => {dot(norm, I_M.col0), dot(norm, I_M.col1), dot(norm, I_M.col2)}
return normalize(mul(normalOS, (float3x3) GetWorldToObjectMatrix()));
#endif
}
float3 TransformWorldToObject(float3 positionWS)
{
return mul(GetWorldToObjectMatrix(), float4(positionWS, 1.0)).xyz;
}
void vert(inout appdata_full v)
{
float3 positionWS = TransformObjectToWorld(v.vertex.xyz);
float distanceToCamera = length(positionWS - _WorldSpaceCameraPos.xyz);
float cull = 1;
if(_CullFarStart>0)
cull = 1 - saturate((distanceToCamera -_CullFarStart) / _CullFarDistance);
float3 rootWP = mul(GetObjectToWorldMatrix(), float4(0, 0, 0, 1)).xyz;
float3 normalWS = TransformObjectToWorldNormal(v.normal);
WindData windData;
ApplyWindDisplacement(positionWS, windData, normalWS, rootWP, _Stiffness, _Drag, _ShiverDrag, _ShiverDirectionality, _InitialBend, v.color.a, _Time);
v.vertex.xyz = TransformWorldToObject(positionWS).xyz * cull;
if (_NewNormal.x != 0 || _NewNormal.y != 0 || _NewNormal.z != 0)
v.normal *= _NewNormal;
if (_WindNormalInfluence != 0)
v.normal.y += -_WindNormalInfluence + windData.ShiverStrength * (_WindNormalInfluence + _WindNormalInfluence);
v.color.r = windData.ShiverStrength;
//v.color.g = cull;
if (_TouchReactActive > 0)
v.vertex.xyz += TouchReactAdjustVertex(half4(v.vertex.xyz, 0.0).xyz);
}
void AdditionalWind(inout appdata_full v)
{
vert(v);
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 07e3b97e5e97f1c44b4c26960d9fb0a8
timeCreated: 1523437911
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,226 @@
#define FLT_EPSILON 1.192092896e-07
sampler2D WIND_SETTINGS_TexNoise;
sampler2D WIND_SETTINGS_TexGust;
float _InitialBend;
float _Stiffness;
float _Drag;
float4 _NewNormal;
float4 WIND_SETTINGS_WorldDirectionAndSpeed;
float WIND_SETTINGS_FlexNoiseScale;
float WIND_SETTINGS_Turbulence;
float WIND_SETTINGS_GustSpeed;
float WIND_SETTINGS_GustScale;
float WIND_SETTINGS_GustWorldScale;
float4x4 WIND_SETTINGS_Points;
float4 WIND_SETTINGS_Points_Radius;
float PositivePow(float base, float power)
{
return pow(max(abs(base), float(FLT_EPSILON)), power);
}
float AttenuateTrunk(float x, float s)
{
float r = (x / s);
return PositivePow(r, 1 / s);
}
float3 Rotate(float3 pivot, float3 position, float3 rotationAxis, float angle)
{
rotationAxis = normalize(rotationAxis);
float3 cpa = pivot + rotationAxis * dot(rotationAxis, position - pivot);
return cpa + ((position - cpa) * cos(angle) + cross(rotationAxis, (position - cpa)) * sin(angle));
}
struct WindData
{
float3 Direction;
float Strength;
float Gust;
};
float3 texNoise(float3 worldPos, float LOD)
{
return tex2Dlod(WIND_SETTINGS_TexNoise, float4(worldPos.xz, 0, LOD)).xyz - 0.5;
}
float texGust(float3 worldPos, float LOD)
{
return tex2Dlod(WIND_SETTINGS_TexGust, float4(worldPos.xz, 0, LOD)).x;
}
float4 PointDirection(float4 collumn, float radius)
{
float3 position = UNITY_MATRIX_M._m03_m13_m23;
float3 direction = position - collumn.rgb;
float3 norm = normalize(direction);
float leng = length(direction);
leng = clamp(leng / radius, 0, 1);
leng = lerp(collumn.a, 0, leng);
norm = norm * leng;
return float4(norm.rgb, leng);
}
float4 MatrixSplit(float4x4 mat, float column)
{
return float4(mat[0][column], mat[1][column], mat[2][column], mat[3][column]);
}
WindData GetAnalyticalWind(float3 WorldPosition, float3 PivotPosition, float drag, float initialBend, float4 time)
{
WindData result;
float4 newDirection = PointDirection(MatrixSplit(WIND_SETTINGS_Points, 0), WIND_SETTINGS_Points_Radius[0]);
newDirection += PointDirection(MatrixSplit(WIND_SETTINGS_Points, 1), WIND_SETTINGS_Points_Radius[1]);
newDirection += PointDirection(MatrixSplit(WIND_SETTINGS_Points, 2), WIND_SETTINGS_Points_Radius[2]);
newDirection += PointDirection(MatrixSplit(WIND_SETTINGS_Points, 3), WIND_SETTINGS_Points_Radius[3]);
float4 WIND_SETTINGS_WorldDirectionAndSpeednew = WIND_SETTINGS_WorldDirectionAndSpeed + newDirection;
float3 normalizedDir = normalize(WIND_SETTINGS_WorldDirectionAndSpeednew.xyz);
float3 worldOffset = float3(1, 0, 0) * WIND_SETTINGS_WorldDirectionAndSpeednew.w * time.y;
float3 gustWorldOffset = float3(1, 0, 0) * WIND_SETTINGS_GustSpeed * time.y;
// Trunk noise is base wind + gusts + noise
float3 trunk = float3(0, 0, 0);
if (WIND_SETTINGS_WorldDirectionAndSpeednew.w > 0.0 || WIND_SETTINGS_Turbulence > 0.0)
{
trunk = texNoise((PivotPosition - worldOffset) * WIND_SETTINGS_FlexNoiseScale, 3);
}
float gust = 0.0;
if (WIND_SETTINGS_GustSpeed > 0.0)
{
gust = texGust((PivotPosition - gustWorldOffset) * WIND_SETTINGS_GustWorldScale, 3);
gust = pow(gust, 2) * WIND_SETTINGS_GustScale;
}
float3 trunkNoise =
(
(normalizedDir * WIND_SETTINGS_WorldDirectionAndSpeednew.w)
+ (gust * normalizedDir * WIND_SETTINGS_GustSpeed)
+ (trunk * WIND_SETTINGS_Turbulence)
) * drag;
float3 dir = trunkNoise;
float flex = length(trunkNoise) + initialBend;
result.Direction = dir;
result.Strength = flex;
result.Gust = (gust * normalizedDir * WIND_SETTINGS_GustSpeed)
+ (trunk * WIND_SETTINGS_Turbulence);
return result;
}
void ApplyWindDisplacement(inout float3 positionWS,
inout WindData windData,
float3 normalWS,
float3 rootWP,
float stiffness,
float drag,
float initialBend,
float4 time)
{
WindData wind = GetAnalyticalWind(positionWS, rootWP, drag, initialBend, time);
if (wind.Strength > 0.0)
{
float att = AttenuateTrunk(distance(positionWS, rootWP), stiffness);
float3 rotAxis = cross(float3(0, 1, 0), wind.Direction);
positionWS = Rotate(rootWP, positionWS, rotAxis, (wind.Strength) * 0.001 * att);
}
windData = wind;
}
float4x4 GetObjectToWorldMatrix()
{
return unity_ObjectToWorld;
}
float4x4 GetWorldToObjectMatrix()
{
return unity_WorldToObject;
}
float3 TransformObjectToWorld(float3 positionOS)
{
return mul(GetObjectToWorldMatrix(), float4(positionOS, 1.0)).xyz;
}
float3 TransformObjectToWorldNormal(float3 normalOS)
{
#ifdef UNITY_ASSUME_UNIFORM_SCALING
return UnityObjectToWorldDir(normalOS);
#else
// Normal need to be multiply by inverse transpose
// mul(IT_M, norm) => mul(norm, I_M) => {dot(norm, I_M.col0), dot(norm, I_M.col1), dot(norm, I_M.col2)}
return normalize(mul(normalOS, (float3x3) GetWorldToObjectMatrix()));
#endif
}
float3 TransformWorldToObject(float3 positionWS)
{
return mul(GetWorldToObjectMatrix(), float4(positionWS, 1.0)).xyz;
}
void vert(inout appdata_full v)
{
float3 positionWS = TransformObjectToWorld(v.vertex.xyz);
float3 rootWP = mul(GetObjectToWorldMatrix(), float4(0, 0, 0, 1)).xyz;
float3 normalWS = TransformObjectToWorldNormal(v.normal);
WindData windData;
ApplyWindDisplacement(positionWS, windData, normalWS, rootWP, _Stiffness, _Drag, _InitialBend, _Time);
v.vertex.xyz = TransformWorldToObject(positionWS).xyz;
if (_NewNormal.x != 0 && _NewNormal.y != 0 && _NewNormal.z != 0)
v.normal *= _NewNormal;
}
void AdditionalWind(inout appdata_full v)
{
vert(v);
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 41a44dc6f4c76bf429bfb60cfaadc25e
timeCreated: 1526285641
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,18 @@
uniform half _TouchReactActive;
sampler2D _TouchReact_Buffer;
float4 _TouchReact_Pos;
float3 TouchReactAdjustVertex(float3 pos)
{
float3 worldPos = mul(unity_ObjectToWorld, float4(pos, 1));
float2 tbPos = saturate((float2(worldPos.x, -worldPos.z) - _TouchReact_Pos.xz) / _TouchReact_Pos.w);
float2 touchBend = tex2Dlod(_TouchReact_Buffer, float4(tbPos, 0, 0));
touchBend.y *= 1.0 - length(tbPos - 0.5) * 2;
if (touchBend.y > 0.01)
{
worldPos.y = min(worldPos.y, touchBend.x * 10000);
}
float3 changedLocalPos = mul(unity_WorldToObject, float4(worldPos, 1)).xyz;
return changedLocalPos - pos;
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 0b275005887200042bbf14338507431f
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,36 @@
void InjectSetup_float(float3 A, out float3 Out)
{
Out = A;
}
#ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED
struct IndirectShaderData
{
float4x4 PositionMatrix;
float4x4 InversePositionMatrix;
float4 ControlData;
};
#if defined(SHADER_API_GLCORE) || defined(SHADER_API_D3D11) || defined(SHADER_API_GLES3) || defined(SHADER_API_METAL) || defined(SHADER_API_VULKAN) || defined(SHADER_API_PSSL) || defined(SHADER_API_XBOXONE)
uniform StructuredBuffer<IndirectShaderData> VisibleShaderDataBuffer;
#endif
#endif
void setupVSPro()
{
#ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED
#ifdef unity_ObjectToWorld
#undef unity_ObjectToWorld
#endif
#ifdef unity_WorldToObject
#undef unity_WorldToObject
#endif
unity_ObjectToWorld = VisibleShaderDataBuffer[unity_InstanceID].PositionMatrix;
unity_WorldToObject = VisibleShaderDataBuffer[unity_InstanceID].InversePositionMatrix;
#endif
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 559eee01f465b9a459de8661f2f599e0
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,37 @@
#ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED
struct IndirectShaderData
{
float4x4 PositionMatrix;
float4x4 InversePositionMatrix;
float4 ControlData;
};
#if defined(SHADER_API_GLCORE) || defined(SHADER_API_D3D11) || defined(SHADER_API_GLES3) || defined(SHADER_API_METAL) || defined(SHADER_API_VULKAN) || defined(SHADER_API_PS4) || defined(SHADER_API_XBOXONE)
StructuredBuffer<IndirectShaderData> IndirectShaderDataBuffer;
StructuredBuffer<IndirectShaderData> VisibleShaderDataBuffer;
#endif
#endif
void setup()
{
#ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED
#ifdef GPU_FRUSTUM_ON
unity_ObjectToWorld = VisibleShaderDataBuffer[unity_InstanceID].PositionMatrix;
unity_WorldToObject = VisibleShaderDataBuffer[unity_InstanceID].InversePositionMatrix;
#else
unity_ObjectToWorld = IndirectShaderDataBuffer[unity_InstanceID].PositionMatrix;
unity_WorldToObject = IndirectShaderDataBuffer[unity_InstanceID].InversePositionMatrix;
#endif
#ifdef FAR_CULL_ON_PROCEDURAL_INSTANCING
#define transformPosition mul(unity_ObjectToWorld, float4(0,0,0,1)).xyz
#define distanceToCamera length(transformPosition - _WorldSpaceCameraPos.xyz)
float cull = 1.0 - saturate((distanceToCamera - _CullFarStart) / _CullFarDistance);
unity_ObjectToWorld = mul(unity_ObjectToWorld, float4x4(cull, 0, 0, 0, 0, cull, 0, 0, 0, 0, cull, 0, 0, 0, 0, 1));
#undef transformPosition
#undef distanceToCamera
#endif
#endif
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 735c6897e358b764fba39dc3ac6cc757
timeCreated: 1526544618
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant: