This commit is contained in:
2026-11-24 15:51:02 +01:00
parent cca4d73e41
commit f4aa17114a
22092 changed files with 5042406 additions and 0 deletions
@@ -0,0 +1,4 @@
// This file is only to force Unity to load the ShaderLibrary's hlsl files in visual studio project via asmdef file, so they can be browse.
class DummyShaderGraphLibrary
{
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e1cfbf2a3c53e704ba1a9450da64c95c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,175 @@
// UNITY_SHADER_NO_UPGRADE
#ifndef UNITY_GRAPHFUNCTIONS_INCLUDED
#define UNITY_GRAPHFUNCTIONS_INCLUDED
// ----------------------------------------------------------------------------
// Included in generated graph shaders
// ----------------------------------------------------------------------------
#ifndef BUILTIN_TARGET_API
bool IsGammaSpace()
{
#ifdef UNITY_COLORSPACE_GAMMA
return true;
#else
return false;
#endif
}
#endif
float4 ComputeScreenPos (float4 pos, float projectionSign)
{
float4 o = pos * 0.5f;
o.xy = float2(o.x, o.y * projectionSign) + o.w;
o.zw = pos.zw;
return o;
}
struct Gradient
{
int type;
int colorsLength;
int alphasLength;
float4 colors[8];
float2 alphas[8];
};
Gradient NewGradient(int type, int colorsLength, int alphasLength,
float4 colors0, float4 colors1, float4 colors2, float4 colors3, float4 colors4, float4 colors5, float4 colors6, float4 colors7,
float2 alphas0, float2 alphas1, float2 alphas2, float2 alphas3, float2 alphas4, float2 alphas5, float2 alphas6, float2 alphas7)
{
Gradient output =
{
type, colorsLength, alphasLength,
{colors0, colors1, colors2, colors3, colors4, colors5, colors6, colors7},
{alphas0, alphas1, alphas2, alphas3, alphas4, alphas5, alphas6, alphas7}
};
return output;
}
// https://bottosson.github.io/posts/oklab/ for perceptual blend mode in gradients
float3 LinearToOklab(float3 rgb)
{
float l = 0.4122214708f * rgb.r + 0.5363325363f * rgb.g + 0.0514459929f * rgb.b;
float m = 0.2119034982f * rgb.r + 0.6806995451f * rgb.g + 0.1073969566f * rgb.b;
float s = 0.0883024619f * rgb.r + 0.2817188376f * rgb.g + 0.6299787005f * rgb.b;
float l_ = pow(l, 0.333333f);
float m_ = pow(m, 0.333333f);
float s_ = pow(s, 0.333333f);
return float3(
0.2104542553f * l_ + 0.7936177850f * m_ - 0.0040720468f * s_,
1.9779984951f * l_ - 2.4285922050f * m_ + 0.4505937099f * s_,
0.0259040371f * l_ + 0.7827717662f * m_ - 0.8086757660f * s_);
}
float3 OklabToLinear(float3 lab)
{
float l_ = lab.r + 0.3963377774f * lab.g + 0.2158037573f * lab.b;
float m_ = lab.r - 0.1055613458f * lab.g - 0.0638541728f * lab.b;
float s_ = lab.r - 0.0894841775f * lab.g - 1.2914855480f * lab.b;
float l = l_ * l_ * l_;
float m = m_ * m_ * m_;
float s = s_ * s_ * s_;
return float3(
4.0767416621f * l - 3.3077115913f * m + 0.2309699292f * s,
-1.2684380046f * l + 2.6097574011f * m - 0.3413193965f * s,
-0.0041960863f * l - 0.7034186147f * m + 1.7076147010f * s);
}
// Decodes data sampled from an lDLR- or RGBM-encoded HDR texture, given decode instructions as supplied by
// the built-in {textureName}_HDR property.
float4 DecodeHDRSample(float4 encoded, float4 decodeInstructions)
{
float alpha = decodeInstructions.w * (encoded.a - 1.0) + 1.0;
#if UNITY_COLORSPACE_GAMMA
encoded.rgb = (decodeInstructions.x * alpha) * encoded.rgb;
#else
encoded.rgb = (decodeInstructions.x * PositivePow(alpha, decodeInstructions.y)) * encoded.rgb;
#endif
encoded.a = 1;
return encoded;
}
#ifndef SHADERGRAPH_SAMPLE_SCENE_DEPTH
#define SHADERGRAPH_SAMPLE_SCENE_DEPTH(uv) shadergraph_SampleSceneDepth(uv)
#endif
#ifndef SHADERGRAPH_SAMPLE_SCENE_COLOR
#define SHADERGRAPH_SAMPLE_SCENE_COLOR(uv) shadergraph_SampleSceneColor(uv)
#endif
#ifndef SHADERGRAPH_SAMPLE_SCENE_NORMAL
#define SHADERGRAPH_SAMPLE_SCENE_NORMAL(uv) shadergraph_SampleSceneNormal(uv)
#endif
#ifndef SHADERGRAPH_BAKED_GI
#define SHADERGRAPH_BAKED_GI(positionWS, normalWS, positionSS, uvStaticLightmap, uvDynamicLightmap, applyScaling) shadergraph_BakedGI(positionWS, normalWS, positionSS, uvStaticLightmap, uvDynamicLightmap, applyScaling)
#endif
#ifndef SHADERGRAPH_REFLECTION_PROBE
#define SHADERGRAPH_REFLECTION_PROBE(viewDir, normalOS, lod) shadergraph_ReflectionProbe(viewDir, normalOS, lod)
#endif
#ifndef SHADERGRAPH_FOG
#define SHADERGRAPH_FOG(position, color, density) shadergraph_Fog(position, color, density)
#endif
#ifndef SHADERGRAPH_AMBIENT_SKY
#define SHADERGRAPH_AMBIENT_SKY float3(0,0,0)
#endif
#ifndef SHADERGRAPH_AMBIENT_EQUATOR
#define SHADERGRAPH_AMBIENT_EQUATOR float3(0,0,0)
#endif
#ifndef SHADERGRAPH_AMBIENT_GROUND
#define SHADERGRAPH_AMBIENT_GROUND float3(0,0,0)
#endif
#ifndef SHADERGRAPH_OBJECT_POSITION
#define SHADERGRAPH_OBJECT_POSITION GetAbsolutePositionWS(UNITY_MATRIX_M._m03_m13_m23)
#endif
#ifndef SHADERGRAPH_RENDERER_BOUNDS_MIN
#define SHADERGRAPH_RENDERER_BOUNDS_MIN float3(0, 0, 0)
#endif
#ifndef SHADERGRAPH_RENDERER_BOUNDS_MAX
#define SHADERGRAPH_RENDERER_BOUNDS_MAX float3(0, 0, 0)
#endif
float shadergraph_SampleSceneDepth(float2 uv)
{
return 1;
}
float3 shadergraph_SampleSceneColor(float2 uv)
{
return 0;
}
float3 shadergraph_SampleSceneNormal(float2 uv)
{
return 0;
}
float3 shadergraph_BakedGI(float3 positionWS, float3 normalWS, uint2 positionSS, float2 uvStaticLightmap, float2 uvDynamicLightmap, bool applyScaling)
{
return 0;
}
float3 shadergraph_ReflectionProbe(float3 viewDir, float3 normalOS, float lod)
{
return 0;
}
void shadergraph_Fog(float3 position, out float4 color, out float density)
{
color = 0;
density = 0;
}
#endif // UNITY_GRAPHFUNCTIONS_INCLUDED
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 76c5c0b7561134f0ca526e50f239a4a2
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,173 @@
#ifndef UNITY_GEOMETRICTOOLS_INCLUDED
#define UNITY_GEOMETRICTOOLS_INCLUDED
//-----------------------------------------------------------------------------
// Intersection functions
//-----------------------------------------------------------------------------
// return furthest near intersection in x and closest far intersection in y
// if (intersections.y > intersections.x) the ray hit the box, else it miss it
// Assume dir is normalize
float2 BoxRayIntersect(float3 start, float3 dir, float3 boxMin, float3 boxMax)
{
float3 invDir = 1.0 / dir;
// Find the ray intersection with box plane
float3 firstPlaneIntersect = (boxMin - start) * invDir;
float3 secondPlaneIntersect = (boxMax - start) * invDir;
// Get the closest/furthest of these intersections along the ray (Ok because x/0 give +inf and -x/0 give -inf )
float3 closestPlane = min(firstPlaneIntersect, secondPlaneIntersect);
float3 furthestPlane = max(firstPlaneIntersect, secondPlaneIntersect);
float2 intersections;
// Find the furthest near intersection
intersections.x = max(closestPlane.x, max(closestPlane.y, closestPlane.z));
// Find the closest far intersection
intersections.y = min(min(furthestPlane.x, furthestPlane.y), furthestPlane.z);
return intersections;
}
// This simplified version assume that we care about the result only when we are inside the box
// Assume dir is normalize
float BoxRayIntersectSimple(float3 start, float3 dir, float3 boxMin, float3 boxMax)
{
float3 invDir = 1.0 / dir;
// Find the ray intersection with box plane
float3 rbmin = (boxMin - start) * invDir;
float3 rbmax = (boxMax - start) * invDir;
float3 rbminmax = (dir > 0.0) ? rbmax : rbmin;
return min(min(rbminmax.x, rbminmax.y), rbminmax.z);
}
// Assume Sphere is at the origin (i.e start = position - spherePosition)
float2 SphereRayIntersect(float3 start, float3 dir, float radius, out bool intersect)
{
float a = dot(dir, dir);
float b = dot(dir, start) * 2.0;
float c = dot(start, start) - radius * radius;
float discriminant = b * b - 4.0 * a * c;
float2 intersections = float2(0.0, 0.0);
intersect = false;
if (discriminant < 0.0 || a == 0.0)
{
intersections.x = 0.0;
intersections.y = 0.0;
}
else
{
float sqrtDiscriminant = sqrt(discriminant);
intersections.x = (-b - sqrtDiscriminant) / (2.0 * a);
intersections.y = (-b + sqrtDiscriminant) / (2.0 * a);
intersect = true;
}
return intersections;
}
// This simplified version assume that we care about the result only when we are inside the sphere
// Assume Sphere is at the origin (i.e start = position - spherePosition) and dir is normalized
// Ref: http://http.developer.nvidia.com/GPUGems/gpugems_ch19.html
float SphereRayIntersectSimple(float3 start, float3 dir, float radius)
{
float b = dot(dir, start) * 2.0;
float c = dot(start, start) - radius * radius;
float discriminant = b * b - 4.0 * c;
return abs(sqrt(discriminant) - b) * 0.5;
}
float3 RayPlaneIntersect(in float3 rayOrigin, in float3 rayDirection, in float3 planeOrigin, in float3 planeNormal)
{
float dist = dot(planeNormal, planeOrigin - rayOrigin) / dot(planeNormal, rayDirection);
return rayOrigin + rayDirection * dist;
}
//-----------------------------------------------------------------------------
// Miscellaneous functions
//-----------------------------------------------------------------------------
// Box is AABB
float DistancePointBox(float3 position, float3 boxMin, float3 boxMax)
{
return length(max(max(position - boxMax, boxMin - position), float3(0.0, 0.0, 0.0)));
}
float3 ProjectPointOnPlane(float3 position, float3 planePosition, float3 planeNormal)
{
return position - (dot(position - planePosition, planeNormal) * planeNormal);
}
// Plane equation: {(a, b, c) = N, d = -dot(N, P)}.
// Returns the distance from the plane to the point 'p' along the normal.
// Positive -> in front (above), negative -> behind (below).
float DistanceFromPlane(float3 p, float4 plane)
{
return dot(float4(p, 1.0), plane);
}
// Returns 'true' if the triangle is outside of the frustum.
// 'epsilon' is the (negative) distance to (outside of) the frustum below which we cull the triangle.
bool CullTriangleFrustum(float3 p0, float3 p1, float3 p2, float epsilon, float4 frustumPlanes[6], int numPlanes)
{
bool outside = false;
for (int i = 0; i < numPlanes; i++)
{
// If all 3 points are behind any of the planes, we cull.
outside = outside || Max3(DistanceFromPlane(p0, frustumPlanes[i]),
DistanceFromPlane(p1, frustumPlanes[i]),
DistanceFromPlane(p2, frustumPlanes[i])) < epsilon;
}
return outside;
}
// Returns 'true' if the edge of the triangle is outside of the frustum.
// The edges are defined s.t. they are on the opposite side of the point with the given index.
// 'epsilon' is the (negative) distance to (outside of) the frustum below which we cull the triangle.
bool3 CullTriangleEdgesFrustum(float3 p0, float3 p1, float3 p2, float epsilon, float4 frustumPlanes[6], int numPlanes)
{
bool3 edgesOutside = false;
for (int i = 0; i < numPlanes; i++)
{
bool3 pointsOutside = bool3(DistanceFromPlane(p0, frustumPlanes[i]) < epsilon,
DistanceFromPlane(p1, frustumPlanes[i]) < epsilon,
DistanceFromPlane(p2, frustumPlanes[i]) < epsilon);
// If both points of the edge are behind any of the planes, we cull.
edgesOutside.x = edgesOutside.x || (pointsOutside.y && pointsOutside.z);
edgesOutside.y = edgesOutside.y || (pointsOutside.x && pointsOutside.z);
edgesOutside.z = edgesOutside.z || (pointsOutside.x && pointsOutside.y);
}
return edgesOutside;
}
// Returns 'true' if a triangle defined by 3 vertices is back-facing.
// 'epsilon' is the (negative) value of dot(N, V) below which we cull the triangle.
// 'winding' can be used to change the order: pass 1 for (p0 -> p1 -> p2), or -1 for (p0 -> p2 -> p1).
bool CullTriangleBackFace(float3 p0, float3 p1, float3 p2, float epsilon, float3 viewPos, float winding)
{
float3 edge1 = p1 - p0;
float3 edge2 = p2 - p0;
float3 N = cross(edge1, edge2);
float3 V = viewPos - p0;
float NdotV = dot(N, V) * winding;
// Optimize:
// NdotV / (length(N) * length(V)) < Epsilon
// NdotV < Epsilon * length(N) * length(V)
// NdotV < Epsilon * sqrt(dot(N, N)) * sqrt(dot(V, V))
// NdotV < Epsilon * sqrt(dot(N, N) * dot(V, V))
return NdotV < epsilon * sqrt(dot(N, N) * dot(V, V));
}
#endif // UNITY_GEOMETRICTOOLS_INCLUDED
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 07d3f5482ecfe425f91b12cd32be4cbe
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,58 @@
// Shadergraph-friendly implementation of LODDitheringTransition.
// The function as defined in Common.hlsl terminates on clip(f).
// However, since it does not return or output anything, shadergraph
// doesn't recognize it as code that gets used. This file can be removed
// and replaced with a string custom function if Shader Graph ever adds
// support for flagging custom function nodes as used, even if not
// connected to anything.
#ifndef SHADERGRAPH_CROSSFADE_INCLUDED
#define SHADERGRAPH_CROSSFADE_INCLUDED
#ifndef UNITY_MATERIAL_INCLUDED
uint2 ComputeFadeMaskSeed(float3 V, uint2 positionSS)
{
uint2 fadeMaskSeed;
// Is this a reasonable quality gate?
#if defined(SHADER_QUALITY_HIGH)
if (IsPerspectiveProjection())
{
// Start with the world-space direction V. It is independent from the orientation of the camera,
// and only depends on the position of the camera and the position of the fragment.
// Now, project and transform it into [-1, 1].
float2 pv = PackNormalOctQuadEncode(V);
// Rescale it to account for the resolution of the screen.
pv *= _ScreenParams.xy;
// The camera only sees a small portion of the sphere, limited by hFoV and vFoV.
// Therefore, we must rescale again (before quantization), roughly, by 1/tan(FoV/2).
pv *= UNITY_MATRIX_P._m00_m11;
// Truncate and quantize.
fadeMaskSeed = asuint((int2)pv);
}
else
#endif
{
// Can't use the view direction, it is the same across the entire screen.
fadeMaskSeed = positionSS;
}
return fadeMaskSeed;
}
#endif
void LODDitheringTransitionSG_float(float3 viewDirWS, float4 screenPos, out float multiplyAlpha)
{
#if !defined(SHADER_STAGE_RAY_TRACING)
float p = GenerateHashedRandomFloat(ComputeFadeMaskSeed(viewDirWS, screenPos.xy));
float f = unity_LODFade.x - CopySign(p, unity_LODFade.x);
multiplyAlpha = f < 0 ? 0.0f : 1.0f;
#endif
}
void LODDitheringTransitionSG_half(float3 viewDirWS, float4 screenPos, out half halfAlpha)
{
#if !defined(SHADER_STAGE_RAY_TRACING)
float p = GenerateHashedRandomFloat(ComputeFadeMaskSeed(viewDirWS, screenPos.xy));
float f = unity_LODFade.x - CopySign(p, unity_LODFade.x);
float multiplyAlpha = f < 0 ? 0.0f : 1.0f;
halfAlpha = (half)multiplyAlpha;
#endif
}
#endif
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 5248225944112fb418a213fa587fe10d
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4cc7da0ede79c9248a9e2e96a546813d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 89c32740b629abb41bf9b65e3a64c373
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3}
documentationPath: SpeedTree8-SubGraphAssets
@@ -0,0 +1,659 @@
{
"m_SGVersion": 3,
"m_Type": "UnityEditor.ShaderGraph.GraphData",
"m_ObjectId": "b442e96e92cf47f58945d47254293335",
"m_Properties": [
{
"m_Id": "512e8ebb5ae84c469321af83a03eb4b2"
}
],
"m_Keywords": [],
"m_Dropdowns": [],
"m_CategoryData": [
{
"m_Id": "1c23319c796542cbb41709783aed209b"
}
],
"m_Nodes": [
{
"m_Id": "38b788f3a953058a8b4cda0de8d0b960"
},
{
"m_Id": "7096d11633c942af93e2e63e3d33b97d"
},
{
"m_Id": "a3cb2271188545d084a76c374630118c"
},
{
"m_Id": "64ff11d7a32d40e1b44f0a324697eee0"
},
{
"m_Id": "988078c6904d4b80a30349f80f391c4b"
},
{
"m_Id": "b6be9a8f128b4fd4ab1b92d6f5821a09"
}
],
"m_GroupDatas": [],
"m_StickyNoteDatas": [],
"m_Edges": [
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "64ff11d7a32d40e1b44f0a324697eee0"
},
"m_SlotId": 0
},
"m_InputSlot": {
"m_Node": {
"m_Id": "a3cb2271188545d084a76c374630118c"
},
"m_SlotId": 1
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "7096d11633c942af93e2e63e3d33b97d"
},
"m_SlotId": 0
},
"m_InputSlot": {
"m_Node": {
"m_Id": "a3cb2271188545d084a76c374630118c"
},
"m_SlotId": 0
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "988078c6904d4b80a30349f80f391c4b"
},
"m_SlotId": 0
},
"m_InputSlot": {
"m_Node": {
"m_Id": "a3cb2271188545d084a76c374630118c"
},
"m_SlotId": 2
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "a3cb2271188545d084a76c374630118c"
},
"m_SlotId": 4
},
"m_InputSlot": {
"m_Node": {
"m_Id": "38b788f3a953058a8b4cda0de8d0b960"
},
"m_SlotId": 1
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "b6be9a8f128b4fd4ab1b92d6f5821a09"
},
"m_SlotId": 0
},
"m_InputSlot": {
"m_Node": {
"m_Id": "a3cb2271188545d084a76c374630118c"
},
"m_SlotId": 3
}
}
],
"m_VertexContext": {
"m_Position": {
"x": -163.0000457763672,
"y": -63.000003814697269
},
"m_Blocks": []
},
"m_FragmentContext": {
"m_Position": {
"x": -163.0000457763672,
"y": 137.0
},
"m_Blocks": []
},
"m_PreviewData": {
"serializedMesh": {
"m_SerializedMesh": "{\"mesh\":{\"instanceID\":0}}",
"m_Guid": ""
},
"preventRotation": false
},
"m_Path": "SpeedTree",
"m_GraphPrecision": 0,
"m_PreviewMode": 2,
"m_OutputNode": {
"m_Id": "38b788f3a953058a8b4cda0de8d0b960"
},
"m_SubDatas": [],
"m_ActiveTargets": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
"m_ObjectId": "0b38a19f84db420d9b7da6d07b60faa6",
"m_Id": 0,
"m_DisplayName": "Out",
"m_SlotType": 1,
"m_Hidden": false,
"m_ShaderOutputName": "Out",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot",
"m_ObjectId": "1b5c41bf969144ce9fa073a134bc8093",
"m_Id": 0,
"m_DisplayName": "ObjectSpacePosition",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "ObjectSpacePosition",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.CategoryData",
"m_ObjectId": "1c23319c796542cbb41709783aed209b",
"m_Name": "",
"m_ChildObjectList": [
{
"m_Id": "512e8ebb5ae84c469321af83a03eb4b2"
}
]
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
"m_ObjectId": "1d84e23d1cc442169e02265f95c66b50",
"m_Id": 0,
"m_DisplayName": "Out",
"m_SlotType": 1,
"m_Hidden": false,
"m_ShaderOutputName": "Out",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.SubGraphOutputNode",
"m_ObjectId": "38b788f3a953058a8b4cda0de8d0b960",
"m_Group": {
"m_Id": ""
},
"m_Name": "Out_Vector4",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": 348.7999267578125,
"y": -280.0,
"width": 182.400146484375,
"height": 76.79998779296875
}
},
"m_Slots": [
{
"m_Id": "6a59e69fa68c4c10a3caabb9c673afd4"
}
],
"synonyms": [],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"IsFirstSlotValid": true
}
{
"m_SGVersion": 1,
"m_Type": "UnityEditor.ShaderGraph.Internal.Vector3ShaderProperty",
"m_ObjectId": "512e8ebb5ae84c469321af83a03eb4b2",
"m_Guid": {
"m_GuidSerialized": "8cb87837-b6cc-4485-afbc-36ac6e828b9c"
},
"m_Name": "ObjectSpacePositionIn",
"m_DefaultRefNameVersion": 1,
"m_RefNameGeneratedByDisplayName": "ObjectSpacePositionIn",
"m_DefaultReferenceName": "_ObjectSpacePositionIn",
"m_OverrideReferenceName": "",
"m_GeneratePropertyBlock": true,
"m_UseCustomSlotLabel": false,
"m_CustomSlotLabel": "",
"m_DismissedVersion": 0,
"m_Precision": 0,
"overrideHLSLDeclaration": false,
"hlslDeclarationOverride": 0,
"m_Hidden": false,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
}
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot",
"m_ObjectId": "57a8726829314d47ac46209378ac759f",
"m_Id": 0,
"m_DisplayName": "ObjectSpacePositionIn",
"m_SlotType": 1,
"m_Hidden": false,
"m_ShaderOutputName": "Out",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.UVNode",
"m_ObjectId": "64ff11d7a32d40e1b44f0a324697eee0",
"m_Group": {
"m_Id": ""
},
"m_Name": "UV",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": -224.7999725341797,
"y": -316.79998779296877,
"width": 145.59996032714845,
"height": 127.20001220703125
}
},
"m_Slots": [
{
"m_Id": "1d84e23d1cc442169e02265f95c66b50"
}
],
"synonyms": [
"texcoords",
"coords",
"coordinates"
],
"m_Precision": 0,
"m_PreviewExpanded": false,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_OutputChannel": 1
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot",
"m_ObjectId": "6a59e69fa68c4c10a3caabb9c673afd4",
"m_Id": 1,
"m_DisplayName": "ObjectSpacePositionOut",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "ObjectSpacePositionOut",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
"m_ObjectId": "6df6cdcdb5a741298fd43792b9125068",
"m_Id": 2,
"m_DisplayName": "UV2",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "UV2",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.PropertyNode",
"m_ObjectId": "7096d11633c942af93e2e63e3d33b97d",
"m_Group": {
"m_Id": ""
},
"m_Name": "Property",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": -274.4000244140625,
"y": -350.3999938964844,
"width": 195.20001220703126,
"height": 33.600006103515628
}
},
"m_Slots": [
{
"m_Id": "57a8726829314d47ac46209378ac759f"
}
],
"synonyms": [],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_Property": {
"m_Id": "512e8ebb5ae84c469321af83a03eb4b2"
}
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
"m_ObjectId": "7a2efff76e2a4a80ba1bd340b0e959aa",
"m_Id": 3,
"m_DisplayName": "UV3",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "UV3",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.UVNode",
"m_ObjectId": "988078c6904d4b80a30349f80f391c4b",
"m_Group": {
"m_Id": ""
},
"m_Name": "UV",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": -224.7999725341797,
"y": -189.5999755859375,
"width": 145.59996032714845,
"height": 127.19998168945313
}
},
"m_Slots": [
{
"m_Id": "d2ef3e828250461fab1869328bff67ed"
}
],
"synonyms": [
"texcoords",
"coords",
"coordinates"
],
"m_Precision": 0,
"m_PreviewExpanded": false,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_OutputChannel": 2
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
"m_ObjectId": "9b55ec38fa29402583a7da6283ae8ad1",
"m_Id": 1,
"m_DisplayName": "UV1",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "UV1",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_Labels": []
}
{
"m_SGVersion": 1,
"m_Type": "UnityEditor.ShaderGraph.CustomFunctionNode",
"m_ObjectId": "a3cb2271188545d084a76c374630118c",
"m_Group": {
"m_Id": ""
},
"m_Name": "SpeedTree8LeafFacing (Custom Function)",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": -28.0,
"y": -280.0,
"width": 339.2000732421875,
"height": 349.5999755859375
}
},
"m_Slots": [
{
"m_Id": "1b5c41bf969144ce9fa073a134bc8093"
},
{
"m_Id": "9b55ec38fa29402583a7da6283ae8ad1"
},
{
"m_Id": "6df6cdcdb5a741298fd43792b9125068"
},
{
"m_Id": "7a2efff76e2a4a80ba1bd340b0e959aa"
},
{
"m_Id": "d2234ae41498430fb7635bf1d0b67787"
}
],
"synonyms": [
"code",
"HLSL"
],
"m_Precision": 0,
"m_PreviewExpanded": false,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_SourceType": 0,
"m_FunctionName": "SpeedTree8LeafFacing",
"m_FunctionSource": "33eafb83c6bce0842b6887eebaf95436",
"m_FunctionBody": "Enter function body here..."
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.UVNode",
"m_ObjectId": "b6be9a8f128b4fd4ab1b92d6f5821a09",
"m_Group": {
"m_Id": ""
},
"m_Name": "UV",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": -224.79998779296876,
"y": -62.4000244140625,
"width": 145.5999755859375,
"height": 127.20001220703125
}
},
"m_Slots": [
{
"m_Id": "0b38a19f84db420d9b7da6d07b60faa6"
}
],
"synonyms": [
"texcoords",
"coords",
"coordinates"
],
"m_Precision": 0,
"m_PreviewExpanded": false,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_OutputChannel": 3
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot",
"m_ObjectId": "d2234ae41498430fb7635bf1d0b67787",
"m_Id": 4,
"m_DisplayName": "ObjectSpacePositionOut",
"m_SlotType": 1,
"m_Hidden": false,
"m_ShaderOutputName": "ObjectSpacePositionOut",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
"m_ObjectId": "d2ef3e828250461fab1869328bff67ed",
"m_Id": 0,
"m_DisplayName": "Out",
"m_SlotType": 1,
"m_Hidden": false,
"m_ShaderOutputName": "Out",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_Labels": []
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8258ab4a37f447c48ac3c26cbdb4c032
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3}
documentationPath: SpeedTree8-SubGraphAssets
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1b4ecad27a9bc714e8d3af3ffb8a368c
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3}
documentationPath: SpeedTree8-SubGraphAssets
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b04441f4a83ad224d92d547d170c366b
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3}
documentationPath: SpeedTree8-SubGraphAssets
@@ -0,0 +1,557 @@
{
"m_SGVersion": 3,
"m_Type": "UnityEditor.ShaderGraph.GraphData",
"m_ObjectId": "5df95f7679bf4cfc8ff03ba5c2e9bd9a",
"m_Properties": [
{
"m_Id": "be4498ae834e45b880f9a673b5a1c985"
},
{
"m_Id": "df8a63625fb74b9db38b7dfe9ddf3b31"
}
],
"m_Keywords": [],
"m_Dropdowns": [],
"m_CategoryData": [
{
"m_Id": "41610b9c955045e4985b2a7a3c250128"
}
],
"m_Nodes": [
{
"m_Id": "a7cc8110386a4246aca9cd7d92f4547b"
},
{
"m_Id": "c0cddf2ae9c6488e89f3ce0712ca5e55"
},
{
"m_Id": "f4a1125310d54961a6958ee8ff2c4f7c"
},
{
"m_Id": "9fb28ee20c4e4b21ba90f8846043c15a"
},
{
"m_Id": "98e96a1ad39749298b605f999db7dbe2"
}
],
"m_GroupDatas": [],
"m_StickyNoteDatas": [],
"m_Edges": [
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "98e96a1ad39749298b605f999db7dbe2"
},
"m_SlotId": 0
},
"m_InputSlot": {
"m_Node": {
"m_Id": "c0cddf2ae9c6488e89f3ce0712ca5e55"
},
"m_SlotId": 5
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "9fb28ee20c4e4b21ba90f8846043c15a"
},
"m_SlotId": 0
},
"m_InputSlot": {
"m_Node": {
"m_Id": "c0cddf2ae9c6488e89f3ce0712ca5e55"
},
"m_SlotId": 0
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "c0cddf2ae9c6488e89f3ce0712ca5e55"
},
"m_SlotId": 4
},
"m_InputSlot": {
"m_Node": {
"m_Id": "a7cc8110386a4246aca9cd7d92f4547b"
},
"m_SlotId": 1
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "f4a1125310d54961a6958ee8ff2c4f7c"
},
"m_SlotId": 0
},
"m_InputSlot": {
"m_Node": {
"m_Id": "c0cddf2ae9c6488e89f3ce0712ca5e55"
},
"m_SlotId": 1
}
}
],
"m_VertexContext": {
"m_Position": {
"x": 0.0,
"y": 0.0
},
"m_Blocks": []
},
"m_FragmentContext": {
"m_Position": {
"x": 0.0,
"y": 0.0
},
"m_Blocks": []
},
"m_PreviewData": {
"serializedMesh": {
"m_SerializedMesh": "{\"mesh\":{\"instanceID\":0}}",
"m_Guid": ""
},
"preventRotation": false
},
"m_Path": "SpeedTree",
"m_GraphPrecision": 1,
"m_PreviewMode": 2,
"m_OutputNode": {
"m_Id": "a7cc8110386a4246aca9cd7d92f4547b"
},
"m_SubDatas": [],
"m_ActiveTargets": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot",
"m_ObjectId": "0aac7827b0e04e0db61b568b356fb8d5",
"m_Id": 1,
"m_DisplayName": "ObjectSpacePositionOut",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "ObjectSpacePositionOut",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
"m_ObjectId": "26cb83fb0d024be6b58b64aab4cae3bc",
"m_Id": 0,
"m_DisplayName": "Out",
"m_SlotType": 1,
"m_Hidden": false,
"m_ShaderOutputName": "Out",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot",
"m_ObjectId": "2839097f17704237b5abd0a2ea33427f",
"m_Id": 4,
"m_DisplayName": "ObjectSpacePositionOut",
"m_SlotType": 1,
"m_Hidden": false,
"m_ShaderOutputName": "ObjectSpacePositionOut",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot",
"m_ObjectId": "3da7ee97d49d41b481c6f617b3e43777",
"m_Id": 0,
"m_DisplayName": "ObjectSpacePosition",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "ObjectSpacePosition",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.CategoryData",
"m_ObjectId": "41610b9c955045e4985b2a7a3c250128",
"m_Name": "",
"m_ChildObjectList": [
{
"m_Id": "df8a63625fb74b9db38b7dfe9ddf3b31"
},
{
"m_Id": "be4498ae834e45b880f9a673b5a1c985"
}
]
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
"m_ObjectId": "8b8f30e472bb4be8a31391986e7eda10",
"m_Id": 1,
"m_DisplayName": "ObjectSpacePositionNextLOD",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "ObjectSpacePositionNextLOD",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.PropertyNode",
"m_ObjectId": "98e96a1ad39749298b605f999db7dbe2",
"m_Group": {
"m_Id": ""
},
"m_Name": "Property",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": -370.3999938964844,
"y": -270.4000549316406,
"width": 134.3999786376953,
"height": 33.60008239746094
}
},
"m_Slots": [
{
"m_Id": "ee441aa7b06b45c08ea3aebee59a87f7"
}
],
"synonyms": [],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_Property": {
"m_Id": "be4498ae834e45b880f9a673b5a1c985"
}
}
{
"m_SGVersion": 1,
"m_Type": "UnityEditor.ShaderGraph.PositionNode",
"m_ObjectId": "9fb28ee20c4e4b21ba90f8846043c15a",
"m_Group": {
"m_Id": ""
},
"m_Name": "Position",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": -442.39996337890627,
"y": -553.5999755859375,
"width": 206.3999481201172,
"height": 128.79995727539063
}
},
"m_Slots": [
{
"m_Id": "dec5f161e725461a86d5a9bea6c30a3e"
}
],
"synonyms": [
"location"
],
"m_Precision": 1,
"m_PreviewExpanded": false,
"m_DismissedVersion": 0,
"m_PreviewMode": 2,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_Space": 0,
"m_PositionSource": 0
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.SubGraphOutputNode",
"m_ObjectId": "a7cc8110386a4246aca9cd7d92f4547b",
"m_Group": {
"m_Id": ""
},
"m_Name": "Output",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": 231.99998474121095,
"y": -443.2000427246094,
"width": 182.3999786376953,
"height": 76.80001831054688
}
},
"m_Slots": [
{
"m_Id": "0aac7827b0e04e0db61b568b356fb8d5"
}
],
"synonyms": [],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"IsFirstSlotValid": true
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Internal.BooleanShaderProperty",
"m_ObjectId": "be4498ae834e45b880f9a673b5a1c985",
"m_Guid": {
"m_GuidSerialized": "78de9e69-4ebd-41a4-a79e-89308af6789f"
},
"m_Name": "Is Billboard",
"m_DefaultRefNameVersion": 1,
"m_RefNameGeneratedByDisplayName": "Is Billboard",
"m_DefaultReferenceName": "Is_Billboard",
"m_OverrideReferenceName": "",
"m_GeneratePropertyBlock": true,
"m_UseCustomSlotLabel": false,
"m_CustomSlotLabel": "",
"m_DismissedVersion": 0,
"m_Precision": 0,
"overrideHLSLDeclaration": false,
"hlslDeclarationOverride": 0,
"m_Hidden": false,
"m_Value": false
}
{
"m_SGVersion": 1,
"m_Type": "UnityEditor.ShaderGraph.CustomFunctionNode",
"m_ObjectId": "c0cddf2ae9c6488e89f3ce0712ca5e55",
"m_Group": {
"m_Id": ""
},
"m_Name": "SpeedTreeLODTransition (Custom Function)",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": -192.0,
"y": -443.2000427246094,
"width": 385.5999755859375,
"height": 325.60003662109377
}
},
"m_Slots": [
{
"m_Id": "3da7ee97d49d41b481c6f617b3e43777"
},
{
"m_Id": "8b8f30e472bb4be8a31391986e7eda10"
},
{
"m_Id": "f7d6ab4ca1864e22b9a05ea7b653afa5"
},
{
"m_Id": "2839097f17704237b5abd0a2ea33427f"
}
],
"synonyms": [
"code",
"HLSL"
],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_SourceType": 0,
"m_FunctionName": "SpeedTreeLODTransition",
"m_FunctionSource": "33eafb83c6bce0842b6887eebaf95436",
"m_FunctionBody": "Enter function body here..."
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot",
"m_ObjectId": "dec5f161e725461a86d5a9bea6c30a3e",
"m_Id": 0,
"m_DisplayName": "Out",
"m_SlotType": 1,
"m_Hidden": false,
"m_ShaderOutputName": "Out",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"m_Labels": []
}
{
"m_SGVersion": 1,
"m_Type": "UnityEditor.ShaderGraph.Internal.Vector3ShaderProperty",
"m_ObjectId": "df8a63625fb74b9db38b7dfe9ddf3b31",
"m_Guid": {
"m_GuidSerialized": "dfcfcf03-7dec-4747-be7e-73fc3618f563"
},
"m_Name": "ObjectSpacePosition",
"m_DefaultRefNameVersion": 1,
"m_RefNameGeneratedByDisplayName": "ObjectSpacePosition",
"m_DefaultReferenceName": "_ObjectSpacePosition",
"m_OverrideReferenceName": "",
"m_GeneratePropertyBlock": true,
"m_UseCustomSlotLabel": false,
"m_CustomSlotLabel": "",
"m_DismissedVersion": 0,
"m_Precision": 0,
"overrideHLSLDeclaration": false,
"hlslDeclarationOverride": 0,
"m_Hidden": false,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
}
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.BooleanMaterialSlot",
"m_ObjectId": "ee441aa7b06b45c08ea3aebee59a87f7",
"m_Id": 0,
"m_DisplayName": "Is Billboard",
"m_SlotType": 1,
"m_Hidden": false,
"m_ShaderOutputName": "Out",
"m_StageCapability": 3,
"m_Value": false,
"m_DefaultValue": false
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.UVNode",
"m_ObjectId": "f4a1125310d54961a6958ee8ff2c4f7c",
"m_Group": {
"m_Id": ""
},
"m_Name": "UV",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": -380.79998779296877,
"y": -408.0000305175781,
"width": 144.7999725341797,
"height": 127.20004272460938
}
},
"m_Slots": [
{
"m_Id": "26cb83fb0d024be6b58b64aab4cae3bc"
}
],
"synonyms": [
"texcoords",
"coords",
"coordinates"
],
"m_Precision": 0,
"m_PreviewExpanded": false,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_OutputChannel": 2
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.BooleanMaterialSlot",
"m_ObjectId": "f7d6ab4ca1864e22b9a05ea7b653afa5",
"m_Id": 5,
"m_DisplayName": "IsBillboard",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "IsBillboard",
"m_StageCapability": 3,
"m_Value": false,
"m_DefaultValue": false
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 74ce720b09dcad14690aca1cb7b6f2dc
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3}
documentationPath: SpeedTree8-SubGraphAssets
@@ -0,0 +1,977 @@
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
#ifndef SPEEDTREE_WIND_8_INCLUDED
#define SPEEDTREE_WIND_8_INCLUDED
#define SPEEDTREE_VERSION_8 1
#include "SpeedTreeCommon.hlsl"
///////////////////////////////////////////////////////////////////////
// Wind Info
CBUFFER_START(SpeedTreeWind)
float4 _ST_WindVector;
float4 _ST_WindGlobal;
float4 _ST_WindBranch;
float4 _ST_WindBranchTwitch;
float4 _ST_WindBranchWhip;
float4 _ST_WindBranchAnchor;
float4 _ST_WindBranchAdherences;
float4 _ST_WindTurbulences;
float4 _ST_WindLeaf1Ripple;
float4 _ST_WindLeaf1Tumble;
float4 _ST_WindLeaf1Twitch;
float4 _ST_WindLeaf2Ripple;
float4 _ST_WindLeaf2Tumble;
float4 _ST_WindLeaf2Twitch;
float4 _ST_WindFrondRipple;
float4 _ST_WindAnimation;
CBUFFER_END
CBUFFER_START(SpeedTreeWindHistory)
float4 _ST_WindVectorHistory;
float4 _ST_WindGlobalHistory;
float4 _ST_WindBranchHistory;
float4 _ST_WindBranchTwitchHistory;
float4 _ST_WindBranchWhipHistory;
float4 _ST_WindBranchAnchorHistory;
float4 _ST_WindBranchAdherencesHistory;
float4 _ST_WindTurbulencesHistory;
float4 _ST_WindLeaf1RippleHistory;
float4 _ST_WindLeaf1TumbleHistory;
float4 _ST_WindLeaf1TwitchHistory;
float4 _ST_WindLeaf2RippleHistory;
float4 _ST_WindLeaf2TumbleHistory;
float4 _ST_WindLeaf2TwitchHistory;
float4 _ST_WindFrondRippleHistory;
float4 _ST_WindAnimationHistory;
CBUFFER_END
#ifdef UNITY_DOTS_INSTANCING_ENABLED
#define DOTS_ST_WindVector DOTS_ST_WindParam0
#define DOTS_ST_WindGlobal DOTS_ST_WindParam1
#define DOTS_ST_WindBranch DOTS_ST_WindParam2
#define DOTS_ST_WindBranchTwitch DOTS_ST_WindParam3
#define DOTS_ST_WindBranchWhip DOTS_ST_WindParam4
#define DOTS_ST_WindBranchAnchor DOTS_ST_WindParam5
#define DOTS_ST_WindBranchAdherences DOTS_ST_WindParam6
#define DOTS_ST_WindTurbulences DOTS_ST_WindParam7
#define DOTS_ST_WindLeaf1Ripple DOTS_ST_WindParam8
#define DOTS_ST_WindLeaf1Tumble DOTS_ST_WindParam9
#define DOTS_ST_WindLeaf1Twitch DOTS_ST_WindParam10
#define DOTS_ST_WindLeaf2Ripple DOTS_ST_WindParam11
#define DOTS_ST_WindLeaf2Tumble DOTS_ST_WindParam12
#define DOTS_ST_WindLeaf2Twitch DOTS_ST_WindParam13
#define DOTS_ST_WindFrondRipple DOTS_ST_WindParam14
#define DOTS_ST_WindAnimation DOTS_ST_WindParam15
#define DOTS_ST_WindVectorHistory DOTS_ST_WindHistoryParam0
#define DOTS_ST_WindGlobalHistory DOTS_ST_WindHistoryParam1
#define DOTS_ST_WindBranchHistory DOTS_ST_WindHistoryParam2
#define DOTS_ST_WindBranchTwitchHistory DOTS_ST_WindHistoryParam3
#define DOTS_ST_WindBranchWhipHistory DOTS_ST_WindHistoryParam4
#define DOTS_ST_WindBranchAnchorHistory DOTS_ST_WindHistoryParam5
#define DOTS_ST_WindBranchAdherencesHistory DOTS_ST_WindHistoryParam6
#define DOTS_ST_WindTurbulencesHistory DOTS_ST_WindHistoryParam7
#define DOTS_ST_WindLeaf1RippleHistory DOTS_ST_WindHistoryParam8
#define DOTS_ST_WindLeaf1TumbleHistory DOTS_ST_WindHistoryParam9
#define DOTS_ST_WindLeaf1TwitchHistory DOTS_ST_WindHistoryParam10
#define DOTS_ST_WindLeaf2RippleHistory DOTS_ST_WindHistoryParam11
#define DOTS_ST_WindLeaf2TumbleHistory DOTS_ST_WindHistoryParam12
#define DOTS_ST_WindLeaf2TwitchHistory DOTS_ST_WindHistoryParam13
#define DOTS_ST_WindFrondRippleHistory DOTS_ST_WindHistoryParam14
#define DOTS_ST_WindAnimationHistory DOTS_ST_WindHistoryParam15
UNITY_DOTS_INSTANCING_START(UserPropertyMetadata)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindVector)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindGlobal)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindBranch)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindBranchTwitch)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindBranchWhip)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindBranchAnchor)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindBranchAdherences)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindTurbulences)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindLeaf1Ripple)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindLeaf1Tumble)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindLeaf1Twitch)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindLeaf2Ripple)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindLeaf2Tumble)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindLeaf2Twitch)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindFrondRipple)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindAnimation)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindVectorHistory)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindGlobalHistory)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindBranchHistory)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindBranchTwitchHistory)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindBranchWhipHistory)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindBranchAnchorHistory)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindBranchAdherencesHistory)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindTurbulencesHistory)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindLeaf1RippleHistory)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindLeaf1TumbleHistory)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindLeaf1TwitchHistory)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindLeaf2RippleHistory)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindLeaf2TumbleHistory)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindLeaf2TwitchHistory)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindFrondRippleHistory)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindAnimationHistory)
UNITY_DOTS_INSTANCING_END(UserPropertyMetadata)
#define _ST_WindVector UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindVector)
#define _ST_WindGlobal UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindGlobal)
#define _ST_WindBranch UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindBranch)
#define _ST_WindBranchTwitch UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindBranchTwitch)
#define _ST_WindBranchWhip UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindBranchWhip)
#define _ST_WindBranchAnchor UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindBranchAnchor)
#define _ST_WindBranchAdherences UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindBranchAdherences)
#define _ST_WindTurbulences UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindTurbulences)
#define _ST_WindLeaf1Ripple UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindLeaf1Ripple)
#define _ST_WindLeaf1Tumble UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindLeaf1Tumble)
#define _ST_WindLeaf1Twitch UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindLeaf1Twitch)
#define _ST_WindLeaf2Ripple UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindLeaf2Ripple)
#define _ST_WindLeaf2Tumble UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindLeaf2Tumble)
#define _ST_WindLeaf2Twitch UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindLeaf2Twitch)
#define _ST_WindFrondRipple UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindFrondRipple)
#define _ST_WindAnimation UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindAnimation)
#define _ST_WindVectorHistory UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindVectorHistory)
#define _ST_WindGlobalHistory UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindGlobalHistory)
#define _ST_WindBranchHistory UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindBranchHistory)
#define _ST_WindBranchTwitchHistory UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindBranchTwitchHistory)
#define _ST_WindBranchWhipHistory UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindBranchWhipHistory)
#define _ST_WindBranchAnchorHistory UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindBranchAnchorHistory)
#define _ST_WindBranchAdherencesHistory UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindBranchAdherencesHistory)
#define _ST_WindTurbulencesHistory UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindTurbulencesHistory)
#define _ST_WindLeaf1RippleHistory UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindLeaf1RippleHistory)
#define _ST_WindLeaf1TumbleHistory UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindLeaf1TumbleHistory)
#define _ST_WindLeaf1TwitchHistory UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindLeaf1TwitchHistory)
#define _ST_WindLeaf2RippleHistory UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindLeaf2RippleHistory)
#define _ST_WindLeaf2TumbleHistory UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindLeaf2TumbleHistory)
#define _ST_WindLeaf2TwitchHistory UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindLeaf2TwitchHistory)
#define _ST_WindFrondRippleHistory UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindFrondRippleHistory)
#define _ST_WindAnimationHistory UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindAnimationHistory)
#endif
#define ST_WIND_QUALITY_NONE 0
#define ST_WIND_QUALITY_FASTEST 1
#define ST_WIND_QUALITY_FAST 2
#define ST_WIND_QUALITY_BETTER 3
#define ST_WIND_QUALITY_BEST 4
#define ST_WIND_QUALITY_PALM 5
///////////////////////////////////////////////////////////////////////
// Get_Wind*() functions
float4 Get_WindVector(bool bHistory) { return bHistory ? _ST_WindVectorHistory : _ST_WindVector; }
float4 Get_WindGlobal(bool bHistory) { return bHistory ? _ST_WindGlobalHistory : _ST_WindGlobal; }
float4 Get_WindBranch(bool bHistory) { return bHistory ? _ST_WindBranchHistory : _ST_WindBranch; }
float4 Get_WindBranchTwitch(bool bHistory) { return bHistory ? _ST_WindBranchTwitchHistory : _ST_WindBranchTwitch; }
float4 Get_WindBranchWhip(bool bHistory) { return bHistory ? _ST_WindBranchWhipHistory : _ST_WindBranchWhip; }
float4 Get_WindBranchAnchor(bool bHistory) { return bHistory ? _ST_WindBranchAnchorHistory : _ST_WindBranchAnchor; }
float4 Get_WindBranchAdherences(bool bHistory) { return bHistory ? _ST_WindBranchAdherencesHistory : _ST_WindBranchAdherences; }
float4 Get_WindTurbulences(bool bHistory) { return bHistory ? _ST_WindTurbulencesHistory : _ST_WindTurbulences; }
float4 Get_WindLeaf1Ripple(bool bHistory) { return bHistory ? _ST_WindLeaf1RippleHistory : _ST_WindLeaf1Ripple; }
float4 Get_WindLeaf1Tumble(bool bHistory) { return bHistory ? _ST_WindLeaf1TumbleHistory : _ST_WindLeaf1Tumble; }
float4 Get_WindLeaf1Twitch(bool bHistory) { return bHistory ? _ST_WindLeaf1TwitchHistory : _ST_WindLeaf1Twitch; }
float4 Get_WindLeaf2Ripple(bool bHistory) { return bHistory ? _ST_WindLeaf2RippleHistory : _ST_WindLeaf2Ripple; }
float4 Get_WindLeaf2Tumble(bool bHistory) { return bHistory ? _ST_WindLeaf2TumbleHistory : _ST_WindLeaf2Tumble; }
float4 Get_WindLeaf2Twitch(bool bHistory) { return bHistory ? _ST_WindLeaf2TwitchHistory : _ST_WindLeaf2Twitch; }
float4 Get_WindFrondRipple(bool bHistory) { return bHistory ? _ST_WindFrondRippleHistory : _ST_WindFrondRipple; }
float4 Get_WindAnimation(bool bHistory) { return bHistory ? _ST_WindAnimationHistory : _ST_WindAnimation; }
///////////////////////////////////////////////////////////////////////
// UnpackNormalFromFloat
float3 UnpackNormalFromFloat(float fValue)
{
float3 vDecodeKey = float3(16.0, 1.0, 0.0625);
// decode into [0,1] range
float3 vDecodedValue = frac(fValue / vDecodeKey);
// move back into [-1,1] range & normalize
return (vDecodedValue * 2.0 - 1.0);
}
///////////////////////////////////////////////////////////////////////
// CubicSmooth
float4 CubicSmooth(float4 vData)
{
return vData * vData * (3.0 - 2.0 * vData);
}
///////////////////////////////////////////////////////////////////////
// TriangleWave
float4 TriangleWave(float4 vData)
{
return abs((frac(vData + 0.5) * 2.0) - 1.0);
}
///////////////////////////////////////////////////////////////////////
// TrigApproximate
float4 TrigApproximate(float4 vData)
{
return (CubicSmooth(TriangleWave(vData)) - 0.5) * 2.0;
}
///////////////////////////////////////////////////////////////////////
// RotationMatrix
//
// Constructs an arbitrary axis rotation matrix
float3x3 RotationMatrix(float3 vAxis, float fAngle)
{
// compute sin/cos of fAngle
float2 vSinCos;
#ifdef OPENGL
vSinCos.x = sin(fAngle);
vSinCos.y = cos(fAngle);
#else
sincos(fAngle, vSinCos.x, vSinCos.y);
#endif
const float c = vSinCos.y;
const float s = vSinCos.x;
const float t = 1.0 - c;
const float x = vAxis.x;
const float y = vAxis.y;
const float z = vAxis.z;
return float3x3(t * x * x + c, t * x * y - s * z, t * x * z + s * y,
t * x * y + s * z, t * y * y + c, t * y * z - s * x,
t * x * z - s * y, t * y * z + s * x, t * z * z + c);
}
///////////////////////////////////////////////////////////////////////
// mul_float3x3_float3x3
float3x3 mul_float3x3_float3x3(float3x3 mMatrixA, float3x3 mMatrixB)
{
return mul(mMatrixA, mMatrixB);
}
///////////////////////////////////////////////////////////////////////
// mul_float3x3_float3
float3 mul_float3x3_float3(float3x3 mMatrix, float3 vVector)
{
return mul(mMatrix, vVector);
}
///////////////////////////////////////////////////////////////////////
// cross()'s parameters are backwards in GLSL
#define wind_cross(a, b) cross((a), (b))
///////////////////////////////////////////////////////////////////////
// Roll
float Roll(float fCurrent,
float fMaxScale,
float fMinScale,
float fSpeed,
float fRipple,
float3 vPos,
float fTime,
float3 vRotatedWindVector)
{
float fWindAngle = dot(vPos, -vRotatedWindVector) * fRipple;
float fAdjust = TrigApproximate(float4(fWindAngle + fTime * fSpeed, 0.0, 0.0, 0.0)).x;
fAdjust = (fAdjust + 1.0) * 0.5;
return lerp(fCurrent * fMinScale, fCurrent * fMaxScale, fAdjust);
}
///////////////////////////////////////////////////////////////////////
// Twitch
float Twitch(float3 vPos, float fAmount, float fSharpness, float fTime)
{
const float c_fTwitchFudge = 0.87;
float4 vOscillations = TrigApproximate(float4(fTime + (vPos.x + vPos.z), c_fTwitchFudge * fTime + vPos.y, 0.0, 0.0));
//float fTwitch = sin(fFreq1 * fTime + (vPos.x + vPos.z)) * cos(fFreq2 * fTime + vPos.y);
float fTwitch = vOscillations.x * vOscillations.y * vOscillations.y;
fTwitch = (fTwitch + 1.0) * 0.5;
return fAmount * pow(saturate(fTwitch), fSharpness);
}
///////////////////////////////////////////////////////////////////////
// Oscillate
//
// This function computes an oscillation value and whip value if necessary.
// Whip and oscillation are combined like this to minimize calls to
// TrigApproximate( ) when possible.
float Oscillate(float3 vPos,
float fTime,
float fOffset,
float fWeight,
float fWhip,
bool bWhip,
bool bRoll,
bool bComplex,
float fTwitch,
float fTwitchFreqScale,
inout float4 vOscillations,
float3 vRotatedWindVector,
bool bHistory)
{
float fOscillation = 1.0;
if (bComplex)
{
if (bWhip)
vOscillations = TrigApproximate(float4(fTime + fOffset, fTime * fTwitchFreqScale + fOffset, fTwitchFreqScale * 0.5 * (fTime + fOffset), fTime + fOffset + (1.0 - fWeight)));
else
vOscillations = TrigApproximate(float4(fTime + fOffset, fTime * fTwitchFreqScale + fOffset, fTwitchFreqScale * 0.5 * (fTime + fOffset), 0.0));
float fFineDetail = vOscillations.x;
float fBroadDetail = vOscillations.y * vOscillations.z;
float fTarget = 1.0;
float fAmount = fBroadDetail;
if (fBroadDetail < 0.0)
{
fTarget = -fTarget;
fAmount = -fAmount;
}
fBroadDetail = lerp(fBroadDetail, fTarget, fAmount);
fBroadDetail = lerp(fBroadDetail, fTarget, fAmount);
fOscillation = fBroadDetail * fTwitch * (1.0 - Get_WindVector(bHistory).w) + fFineDetail * (1.0 - fTwitch);
if (bWhip)
fOscillation *= 1.0 + (vOscillations.w * fWhip);
}
else
{
if (bWhip)
vOscillations = TrigApproximate(float4(fTime + fOffset, fTime * 0.689 + fOffset, 0.0, fTime + fOffset + (1.0 - fWeight)));
else
vOscillations = TrigApproximate(float4(fTime + fOffset, fTime * 0.689 + fOffset, 0.0, 0.0));
fOscillation = vOscillations.x + vOscillations.y * vOscillations.x;
if (bWhip)
fOscillation *= 1.0 + (vOscillations.w * fWhip);
}
//if (bRoll)
//{
// fOscillation = Roll(fOscillation, _ST_WindRollingBranches.x, _ST_WindRollingBranches.y, _ST_WindRollingBranches.z, _ST_WindRollingBranches.w, vPos.xyz, fTime + fOffset, vRotatedWindVector);
//}
return fOscillation;
}
///////////////////////////////////////////////////////////////////////
// Turbulence
float Turbulence(float fTime, float fOffset, float fGlobalTime, float fTurbulence)
{
const float c_fTurbulenceFactor = 0.1;
float4 vOscillations = TrigApproximate(float4(fTime * c_fTurbulenceFactor + fOffset, fGlobalTime * fTurbulence * c_fTurbulenceFactor + fOffset, 0.0, 0.0));
return 1.0 - (vOscillations.x * vOscillations.y * vOscillations.x * vOscillations.y * fTurbulence);
}
///////////////////////////////////////////////////////////////////////
// GlobalWind
//
// This function positions any tree geometry based on their untransformed
// position and 4 wind floats.
float3 GlobalWind(float3 vPos, float3 vInstancePos, bool bPreserveShape, float3 vRotatedWindVector, float time, bool bHistory)
{
// WIND_LOD_GLOBAL may be on, but if the global wind effect (WIND_EFFECT_GLOBAL_ST_Wind)
// was disabled for the tree in the Modeler, we should skip it
const float4 windGlobal = Get_WindGlobal(bHistory);
const float4 windBranchAdherences = Get_WindBranchAdherences(bHistory);
float fLength = 1.0;
if (bPreserveShape)
fLength = length(vPos.xyz);
// compute how much the height contributes
#ifdef SPEEDTREE_Z_UP
float fAdjust = max(vPos.z - (1.0 / windGlobal.z) * 0.25, 0.0) * windGlobal.z;
#else
float fAdjust = max(vPos.y - (1.0 / windGlobal.z) * 0.25, 0.0) * windGlobal.z;
#endif
if (fAdjust != 0.0)
fAdjust = pow(abs(fAdjust), windGlobal.w);
// primary oscillation
float4 vOscillations = TrigApproximate(float4(vInstancePos.x + time, vInstancePos.y + time * 0.8, 0.0, 0.0));
float fOsc = vOscillations.x + (vOscillations.y * vOscillations.y);
float fMoveAmount = windGlobal.y * fOsc;
// move a minimum amount based on direction adherence
fMoveAmount += windBranchAdherences.x / windGlobal.z;
// adjust based on how high up the tree this vertex is
fMoveAmount *= fAdjust;
// xy component
#ifdef SPEEDTREE_Z_UP
vPos.xy += vRotatedWindVector.xy * fMoveAmount;
#else
vPos.xz += vRotatedWindVector.xz * fMoveAmount;
#endif
if (bPreserveShape)
vPos.xyz = normalize(vPos.xyz) * fLength;
return vPos;
}
///////////////////////////////////////////////////////////////////////
// SimpleBranchWind
float3 SimpleBranchWind(float3 vPos,
float3 vInstancePos,
float fWeight,
float fOffset,
float fTime,
float fDistance,
float fTwitch,
float fTwitchScale,
float fWhip,
bool bWhip,
bool bRoll,
bool bComplex,
float3 vRotatedWindVector,
bool bHistory)
{
// turn the offset back into a nearly normalized vector
float3 vWindVector = UnpackNormalFromFloat(fOffset);
vWindVector = vWindVector * fWeight;
// try to fudge time a bit so that instances aren't in sync
fTime += vInstancePos.x + vInstancePos.y;
// oscillate
float4 vOscillations;
float fOsc = Oscillate(vPos, fTime, fOffset, fWeight, fWhip, bWhip, bRoll, bComplex, fTwitch, fTwitchScale, vOscillations, vRotatedWindVector, bHistory);
vPos.xyz += vWindVector * fOsc * fDistance;
return vPos;
}
///////////////////////////////////////////////////////////////////////
// DirectionalBranchWind
float3 DirectionalBranchWind(float3 vPos,
float3 vInstancePos,
float fWeight,
float fOffset,
float fTime,
float fDistance,
float fTurbulence,
float fAdherence,
float fTwitch,
float fTwitchScale,
float fWhip,
bool bWhip,
bool bRoll,
bool bComplex,
bool bTurbulence,
float3 vRotatedWindVector,
bool bHistory)
{
// turn the offset back into a nearly normalized vector
float3 vWindVector = UnpackNormalFromFloat(fOffset);
vWindVector = vWindVector * fWeight;
// try to fudge time a bit so that instances aren't in sync
fTime += vInstancePos.x + vInstancePos.y;
// oscillate
float4 vOscillations;
float fOsc = Oscillate(vPos, fTime, fOffset, fWeight, fWhip, bWhip, false, bComplex, fTwitch, fTwitchScale, vOscillations, vRotatedWindVector, bHistory);
vPos.xyz += vWindVector * fOsc * fDistance;
// add in the direction, accounting for turbulence
float fAdherenceScale = 1.0;
if (bTurbulence)
fAdherenceScale = Turbulence(fTime, fOffset, Get_WindAnimation(bHistory).x, fTurbulence);
if (bWhip)
fAdherenceScale += vOscillations.w * Get_WindVector(bHistory).w * fWhip;
//if (bRoll)
// fAdherenceScale = Roll(fAdherenceScale, _ST_WindRollingBranches.x, _ST_WindRollingBranches.y, _ST_WindRollingBranches.z, _ST_WindRollingBranches.w, vPos.xyz, fTime + fOffset, vRotatedWindVector);
vPos.xyz += vRotatedWindVector * fAdherence * fAdherenceScale * fWeight;
return vPos;
}
///////////////////////////////////////////////////////////////////////
// DirectionalBranchWindFrondStyle
float3 DirectionalBranchWindFrondStyle(float3 vPos,
float3 vInstancePos,
float fWeight,
float fOffset,
float fTime,
float fDistance,
float fTurbulence,
float fAdherence,
float fTwitch,
float fTwitchScale,
float fWhip,
bool bWhip,
bool bRoll,
bool bComplex,
bool bTurbulence,
float3 vRotatedWindVector,
float3 vRotatedBranchAnchor,
bool bHistory)
{
// turn the offset back into a nearly normalized vector
float3 vWindVector = UnpackNormalFromFloat(fOffset);
vWindVector = vWindVector * fWeight;
// try to fudge time a bit so that instances aren't in sync
fTime += vInstancePos.x + vInstancePos.y;
// oscillate
float4 vOscillations;
float fOsc = Oscillate(vPos, fTime, fOffset, fWeight, fWhip, bWhip, false, bComplex, fTwitch, fTwitchScale, vOscillations, vRotatedWindVector, bHistory);
vPos.xyz += vWindVector * fOsc * fDistance;
// add in the direction, accounting for turbulence
float fAdherenceScale = 1.0;
if (bTurbulence)
fAdherenceScale = Turbulence(fTime, fOffset, Get_WindAnimation(bHistory).x, fTurbulence);
//if (bRoll)
// fAdherenceScale = Roll(fAdherenceScale, _ST_WindRollingBranches.x, _ST_WindRollingBranches.y, _ST_WindRollingBranches.z, _ST_WindRollingBranches.w, vPos.xyz, fTime + fOffset, vRotatedWindVector);
if (bWhip)
fAdherenceScale += vOscillations.w * Get_WindVector(bHistory).w * fWhip;
float3 vWindAdherenceVector = vRotatedBranchAnchor - vPos.xyz;
vPos.xyz += vWindAdherenceVector * fAdherence * fAdherenceScale * fWeight;
return vPos;
}
///////////////////////////////////////////////////////////////////////
// BranchWind
// Apply only to better, best, palm winds
float3 BranchWind(bool isPalmWind, float3 vPos, float3 vInstancePos, float4 vWindData, float3 vRotatedWindVector, float3 vRotatedBranchAnchor, bool bHistory)
{
const float4 windBranch = Get_WindBranch(bHistory);
const float4 windBranchTwitch = Get_WindBranchTwitch(bHistory);
const float4 windBranchAdherences = Get_WindBranchAdherences(bHistory);
const float4 windBarnchWhip = Get_WindBranchWhip(bHistory);
const float4 windTurbulences = Get_WindTurbulences(bHistory);
const bool bWhip = isPalmWind;
const bool bRoll = false;
const bool bComplex = true;
if (isPalmWind)
{
const bool bTurbulence = true;
vPos = DirectionalBranchWindFrondStyle(
vPos,
vInstancePos,
vWindData.x, vWindData.y,
windBranch.x, windBranch.y,
windTurbulences.x, windBranchAdherences.y,
windBranchTwitch.x, windBranchTwitch.y,
windBarnchWhip.x,
bWhip,
bRoll,
bComplex,
bTurbulence,
vRotatedWindVector,
vRotatedBranchAnchor,
bHistory
);
}
else
{
vPos = SimpleBranchWind(
vPos,
vInstancePos,
vWindData.x, vWindData.y,
windBranch.x, windBranch.y,
windBranchTwitch.x, windBranchTwitch.y,
windBarnchWhip.x,
bWhip,
bRoll,
bComplex,
vRotatedWindVector,
bHistory
);
}
return vPos;
}
///////////////////////////////////////////////////////////////////////
// LeafRipple
float3 LeafRipple(float3 vPos,
inout float3 vDirection,
float fScale,
float fPackedRippleDir,
float fTime,
float fAmount,
bool bDirectional,
float fTrigOffset)
{
// compute how much to move
float4 vInput = float4(fTime + fTrigOffset, 0.0, 0.0, 0.0);
float fMoveAmount = fAmount * TrigApproximate(vInput).x;
if (bDirectional)
{
vPos.xyz += vDirection.xyz * fMoveAmount * fScale;
}
else
{
float3 vRippleDir = UnpackNormalFromFloat(fPackedRippleDir);
vPos.xyz += vRippleDir * fMoveAmount * fScale;
}
return vPos;
}
///////////////////////////////////////////////////////////////////////
// LeafTumble
float3 LeafTumble(float3 vPos,
inout float3 vDirection,
float fScale,
float3 vAnchor,
float3 vGrowthDir,
float fTrigOffset,
float fTime,
float fFlip,
float fTwist,
float fAdherence,
float3 vTwitch,
float4 vRoll,
bool bTwitch,
bool bRoll,
float3 vRotatedWindVector)
{
// compute all oscillations up front
float3 vFracs = frac((vAnchor + fTrigOffset) * 30.3);
float fOffset = vFracs.x + vFracs.y + vFracs.z;
float4 vOscillations = TrigApproximate(float4(fTime + fOffset, fTime * 0.75 - fOffset, fTime * 0.01 + fOffset, fTime * 1.0 + fOffset));
// move to the origin and get the growth direction
float3 vOriginPos = vPos.xyz - vAnchor;
float fLength = length(vOriginPos);
// twist
float fOsc = vOscillations.x + vOscillations.y * vOscillations.y;
float3x3 matTumble = RotationMatrix(vGrowthDir, fScale * fTwist * fOsc);
// with wind
float3 vAxis = wind_cross(vGrowthDir.xyz, vRotatedWindVector.xyz);
float fDot = clamp(dot(vRotatedWindVector, vGrowthDir), -1.0, 1.0);
#ifdef SPEEDTREE_Z_UP
vAxis.z += fDot;
#else
vAxis.y += fDot;
#endif
vAxis = normalize(vAxis);
float fAngle = acos(fDot);
float fAdherenceScale = 1.0;
//if (bRoll)
//{
// fAdherenceScale = Roll(fAdherenceScale, vRoll.x, vRoll.y, vRoll.z, vRoll.w, vAnchor.xyz, fTime, vRotatedWindVector);
//}
fOsc = vOscillations.y - vOscillations.x * vOscillations.x;
float fTwitch = 0.0;
if (bTwitch)
fTwitch = Twitch(vAnchor.xyz, vTwitch.x, vTwitch.y, vTwitch.z + fOffset);
matTumble = mul_float3x3_float3x3(matTumble, RotationMatrix(vAxis, fScale * (fAngle * fAdherence * fAdherenceScale + fOsc * fFlip + fTwitch)));
vDirection = mul_float3x3_float3(matTumble, vDirection);
vOriginPos = mul_float3x3_float3(matTumble, vOriginPos);
vOriginPos = normalize(vOriginPos) * fLength;
return (vOriginPos + vAnchor);
}
///////////////////////////////////////////////////////////////////////
// LeafWind
// Optimized (for instruction count) version. Assumes leaf 1 and 2 have the same options
float3 LeafWind(bool isBestWind,
bool bLeaf2,
float3 vPos,
inout float3 vDirection,
float fScale,
float3 vAnchor,
float fPackedGrowthDir,
float fPackedRippleDir,
float fRippleTrigOffset,
float3 vRotatedWindVector,
bool bHistory)
{
const float4 windLeaf2Ripple = Get_WindLeaf2Ripple(bHistory);
const float4 windLeaf1Ripple = Get_WindLeaf1Ripple(bHistory);
const float4 windLeaf1Tumble = Get_WindLeaf1Tumble(bHistory);
const float4 windLeaf2Tumble = Get_WindLeaf2Tumble(bHistory);
const float4 windLeaf1Twitch = Get_WindLeaf2Twitch(bHistory);
const float4 windLeaf2Twitch = Get_WindLeaf2Twitch(bHistory);
vPos = LeafRipple(vPos, vDirection, fScale, fPackedRippleDir,
(bLeaf2 ? windLeaf2Ripple.x : windLeaf1Ripple.x),
(bLeaf2 ? windLeaf2Ripple.y : windLeaf1Ripple.y),
false, fRippleTrigOffset);
if (isBestWind)
{
float3 vGrowthDir = UnpackNormalFromFloat(fPackedGrowthDir);
vPos = LeafTumble(vPos, vDirection, fScale, vAnchor, vGrowthDir, fPackedGrowthDir,
(bLeaf2 ? windLeaf2Tumble.x : windLeaf1Tumble.x),
(bLeaf2 ? windLeaf2Tumble.y : windLeaf1Tumble.y),
(bLeaf2 ? windLeaf2Tumble.z : windLeaf1Tumble.z),
(bLeaf2 ? windLeaf2Tumble.w : windLeaf1Tumble.w),
(bLeaf2 ? windLeaf2Twitch.xyz : windLeaf1Twitch.xyz),
0.0f,
true,
true,
vRotatedWindVector);
}
return vPos;
}
///////////////////////////////////////////////////////////////////////
// RippleFrondOneSided
float3 RippleFrondOneSided(float3 vPos,
inout float3 vDirection,
float fU,
float fV,
float fRippleScale,
bool bHistory
#ifdef WIND_EFFECT_FROND_RIPPLE_ADJUST_LIGHTING
, float3 vBinormal
, float3 vTangent
#endif
)
{
float fOffset = 0.0;
if (fU < 0.5)
fOffset = 0.75;
const float4 windFrondRipple = Get_WindFrondRipple(bHistory);
float4 vOscillations = TrigApproximate(float4((windFrondRipple.x + fV) * windFrondRipple.z + fOffset, 0.0, 0.0, 0.0));
float fAmount = fRippleScale * vOscillations.x * windFrondRipple.y;
float3 vOffset = fAmount * vDirection;
vPos.xyz += vOffset;
#ifdef WIND_EFFECT_FROND_RIPPLE_ADJUST_LIGHTING
vTangent.xyz = normalize(vTangent.xyz + vOffset * windFrondRipple.w);
float3 vNewNormal = normalize(wind_cross(vBinormal.xyz, vTangent.xyz));
if (dot(vNewNormal, vDirection.xyz) < 0.0)
vNewNormal = -vNewNormal;
vDirection.xyz = vNewNormal;
#endif
return vPos;
}
///////////////////////////////////////////////////////////////////////
// RippleFrondTwoSided
float3 RippleFrondTwoSided(float3 vPos,
inout float3 vDirection,
float fU,
float fLengthPercent,
float fPackedRippleDir,
float fRippleScale,
bool bHistory
#ifdef WIND_EFFECT_FROND_RIPPLE_ADJUST_LIGHTING
, float3 vBinormal
, float3 vTangent
#endif
)
{
const float4 windFrondRipple = Get_WindFrondRipple(bHistory);
float4 vOscillations = TrigApproximate(float4(windFrondRipple.x * fLengthPercent * windFrondRipple.z, 0.0, 0.0, 0.0));
float3 vRippleDir = UnpackNormalFromFloat(fPackedRippleDir);
float fAmount = fRippleScale * vOscillations.x * windFrondRipple.y;
float3 vOffset = fAmount * vRippleDir;
vPos.xyz += vOffset;
#ifdef WIND_EFFECT_FROND_RIPPLE_ADJUST_LIGHTING
vTangent.xyz = normalize(vTangent.xyz + vOffset * windFrondRipple.w);
float3 vNewNormal = normalize(wind_cross(vBinormal.xyz, vTangent.xyz));
if (dot(vNewNormal, vDirection.xyz) < 0.0)
vNewNormal = -vNewNormal;
vDirection.xyz = vNewNormal;
#endif
return vPos;
}
///////////////////////////////////////////////////////////////////////
// RippleFrond
float3 RippleFrond(float3 vPos,
inout float3 vDirection,
float fU,
float fV,
float fPackedRippleDir,
float fRippleScale,
float fLenghtPercent,
bool bHistory
#ifdef WIND_EFFECT_FROND_RIPPLE_ADJUST_LIGHTING
, float3 vBinormal
, float3 vTangent
#endif
)
{
return RippleFrondOneSided(vPos,
vDirection,
fU,
fV,
fRippleScale,
bHistory
#ifdef WIND_EFFECT_FROND_RIPPLE_ADJUST_LIGHTING
, vBinormal
, vTangent
#endif
);
}
///////////////////////////////////////////////////////////////////////
// SpeedTreeWind
float3 SpeedTreeWind(
float3 vPos,
float3 vNormal,
float4 vTexcoord0,
float4 vTexcoord1,
float4 vTexcoord2,
float4 vTexcoord3,
int iWindQuality,
bool bBillboard,
bool bHistory
)
{
float3 vReturnPos = vPos;
// check wind enabled & data available
float3 windVector = Get_WindVector(bHistory).xyz;
float3 rotatedWindVector = TransformWindVectorFromWorldToLocalSpace(windVector);
if (iWindQuality == 0 || (length(rotatedWindVector) < 1.0e-5) )
{
return vReturnPos; // sanity check that wind data is available
}
// do wind
float4x4 matObjectToWorld = GetObjectToWorldMatrix();
float3 treePos = GetAbsolutePositionWS(float3(matObjectToWorld[0].w, matObjectToWorld[1].w, matObjectToWorld[2].w));
float globalWindTime = Get_WindGlobal(bHistory).x;
// BILLBOARD WIND =======================================================================================================================
if(bBillboard)
{
vReturnPos = GlobalWind(vReturnPos, treePos, true, rotatedWindVector, globalWindTime, bHistory);
return vReturnPos;
}
// 3D GEOMETRY WIND =====================================================================================================================
// leaf
bool leafTwo = false;
const int geometryType = GetGeometryType(vTexcoord3, leafTwo);
const bool bDoLeafWind = ((iWindQuality == ST_WIND_QUALITY_FAST) || (iWindQuality == ST_WIND_QUALITY_BETTER) || (iWindQuality == ST_WIND_QUALITY_BEST))
&& geometryType > ST_GEOM_TYPE_FROND;
if (bDoLeafWind)
{
const float3 anchor = float3(vTexcoord1.zw, vTexcoord2.w);
const float leafWindTrigOffset = anchor.x + anchor.y;
const bool bBestWind = (iWindQuality == ST_WIND_QUALITY_BEST);
vReturnPos -= anchor; // remove anchor position
vReturnPos = LeafWind(bBestWind, leafTwo, vReturnPos, vNormal, vTexcoord3.x, float3(0, 0, 0), vTexcoord3.y, vTexcoord3.z, leafWindTrigOffset, rotatedWindVector, bHistory);
vReturnPos += anchor; // move back out to anchor
}
// frond wind (palm-only)
const bool bDoPalmWind = iWindQuality == ST_WIND_QUALITY_PALM && geometryType == ST_GEOM_TYPE_FROND;
if (bDoPalmWind)
{
vReturnPos = RippleFrond(vReturnPos, vNormal, vTexcoord0.x, vTexcoord0.y, vTexcoord3.x, vTexcoord3.y, vTexcoord3.z, bHistory);
}
// branch wind (applies to all 3D geometry)
const bool bDoBranchWind = (iWindQuality == ST_WIND_QUALITY_BETTER) || (iWindQuality == ST_WIND_QUALITY_BEST) || (iWindQuality == ST_WIND_QUALITY_PALM);
if (bDoBranchWind)
{
const float4 windBranchAnchorHistory = Get_WindBranchAnchor(bHistory);
const float3 rotatedBranchAnchor = TransformWorldToObjectDir(windBranchAnchorHistory.xyz) * windBranchAnchorHistory.w;
vReturnPos = BranchWind(bDoPalmWind, vReturnPos, treePos, float4(vTexcoord0.zw, 0, 0), rotatedWindVector, rotatedBranchAnchor, bHistory);
}
// global wind
vReturnPos = GlobalWind(vReturnPos, treePos, true, rotatedWindVector, globalWindTime, bHistory);
return vReturnPos;
}
// ShaderGraph stub
void SpeedTreeWind_float(float3 vPos, float3 vNormal, float4 vTexcoord0, float4 vTexcoord1, float4 vTexcoord2, float4 vTexcoord3, int iWindQuality, bool bBillboard, bool bHistory, out float3 outPos)
{
outPos = SpeedTreeWind(vPos, vNormal, vTexcoord0, vTexcoord1, vTexcoord2, vTexcoord3, iWindQuality, bBillboard, bHistory);
}
#endif // SPEEDTREE_WIND_8_INCLUDED
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 8b4aa8c48881d4142b1c30e408b503d8
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e9398b7940890a74eafc240b5a593541
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3}
documentationPath: SpeedTree8-SubGraphAssets
@@ -0,0 +1,810 @@
{
"m_SGVersion": 3,
"m_Type": "UnityEditor.ShaderGraph.GraphData",
"m_ObjectId": "755a93254141488399087b3308ad36ef",
"m_Properties": [
{
"m_Id": "8ab10da2124da78dbf0ae0289b56de8b"
},
{
"m_Id": "e5ff779cf6e24d76bcf888e4273eca23"
}
],
"m_Keywords": [],
"m_Dropdowns": [],
"m_CategoryData": [
{
"m_Id": "47713774a4eb4299ba8b2a71387db83b"
}
],
"m_Nodes": [
{
"m_Id": "515415114022d483bfcdfd550d1665da"
},
{
"m_Id": "c43251a50a5947879de8aba4500e9614"
},
{
"m_Id": "fe2a3c68665e44c1a68cb56972054411"
},
{
"m_Id": "dd2f62e9497e449783da8a10acb800f0"
},
{
"m_Id": "b3fadcf6ec584e5facf413fb91de479b"
},
{
"m_Id": "055ab909694b4e8bbe0b2cfd584a4fd0"
},
{
"m_Id": "c5401ca55ff7479a943cd8e195cce606"
}
],
"m_GroupDatas": [],
"m_StickyNoteDatas": [],
"m_Edges": [
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "055ab909694b4e8bbe0b2cfd584a4fd0"
},
"m_SlotId": 0
},
"m_InputSlot": {
"m_Node": {
"m_Id": "c5401ca55ff7479a943cd8e195cce606"
},
"m_SlotId": 0
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "b3fadcf6ec584e5facf413fb91de479b"
},
"m_SlotId": 0
},
"m_InputSlot": {
"m_Node": {
"m_Id": "c5401ca55ff7479a943cd8e195cce606"
},
"m_SlotId": 1
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "b3fadcf6ec584e5facf413fb91de479b"
},
"m_SlotId": 0
},
"m_InputSlot": {
"m_Node": {
"m_Id": "dd2f62e9497e449783da8a10acb800f0"
},
"m_SlotId": 0
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "c43251a50a5947879de8aba4500e9614"
},
"m_SlotId": 0
},
"m_InputSlot": {
"m_Node": {
"m_Id": "dd2f62e9497e449783da8a10acb800f0"
},
"m_SlotId": 5
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "c5401ca55ff7479a943cd8e195cce606"
},
"m_SlotId": 3
},
"m_InputSlot": {
"m_Node": {
"m_Id": "515415114022d483bfcdfd550d1665da"
},
"m_SlotId": 1
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "dd2f62e9497e449783da8a10acb800f0"
},
"m_SlotId": 2
},
"m_InputSlot": {
"m_Node": {
"m_Id": "c5401ca55ff7479a943cd8e195cce606"
},
"m_SlotId": 2
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "fe2a3c68665e44c1a68cb56972054411"
},
"m_SlotId": 0
},
"m_InputSlot": {
"m_Node": {
"m_Id": "dd2f62e9497e449783da8a10acb800f0"
},
"m_SlotId": 4
}
}
],
"m_VertexContext": {
"m_Position": {
"x": 1894.0,
"y": -349.5000305175781
},
"m_Blocks": []
},
"m_FragmentContext": {
"m_Position": {
"x": 1894.0,
"y": -149.50003051757813
},
"m_Blocks": []
},
"m_PreviewData": {
"serializedMesh": {
"m_SerializedMesh": "{\"mesh\":{\"instanceID\":0}}",
"m_Guid": ""
},
"preventRotation": false
},
"m_Path": "SpeedTree",
"m_GraphPrecision": 0,
"m_PreviewMode": 2,
"m_OutputNode": {
"m_Id": "515415114022d483bfcdfd550d1665da"
},
"m_SubDatas": [],
"m_ActiveTargets": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.PropertyNode",
"m_ObjectId": "055ab909694b4e8bbe0b2cfd584a4fd0",
"m_Group": {
"m_Id": ""
},
"m_Name": "Property",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": 943.2000122070313,
"y": -1398.4000244140625,
"width": 131.99993896484376,
"height": 33.5999755859375
}
},
"m_Slots": [
{
"m_Id": "25fe22afbafd40eb923c8bd7da0590e4"
}
],
"synonyms": [],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_Property": {
"m_Id": "e5ff779cf6e24d76bcf888e4273eca23"
}
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.BooleanMaterialSlot",
"m_ObjectId": "25fe22afbafd40eb923c8bd7da0590e4",
"m_Id": 0,
"m_DisplayName": "IsBillboard",
"m_SlotType": 1,
"m_Hidden": false,
"m_ShaderOutputName": "Out",
"m_StageCapability": 3,
"m_Value": false,
"m_DefaultValue": false
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
"m_ObjectId": "33c7d1f937f84de88dab6b78171ea330",
"m_Id": 0,
"m_DisplayName": "Out",
"m_SlotType": 1,
"m_Hidden": false,
"m_ShaderOutputName": "Out",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.CategoryData",
"m_ObjectId": "47713774a4eb4299ba8b2a71387db83b",
"m_Name": "",
"m_ChildObjectList": [
{
"m_Id": "8ab10da2124da78dbf0ae0289b56de8b"
},
{
"m_Id": "e5ff779cf6e24d76bcf888e4273eca23"
}
]
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.SubGraphOutputNode",
"m_ObjectId": "515415114022d483bfcdfd550d1665da",
"m_Group": {
"m_Id": ""
},
"m_Name": "Out_Vector4",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": 1373.5999755859375,
"y": -1305.5999755859375,
"width": 182.4000244140625,
"height": 100.7999267578125
}
},
"m_Slots": [
{
"m_Id": "f3a9bebf31974f7eb2e9efd993bab257"
}
],
"synonyms": [],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"IsFirstSlotValid": true
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
"m_ObjectId": "84eab20a36c442c39d153322718082df",
"m_Id": 0,
"m_DisplayName": "Out",
"m_SlotType": 1,
"m_Hidden": false,
"m_ShaderOutputName": "Out",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_Labels": []
}
{
"m_SGVersion": 1,
"m_Type": "UnityEditor.ShaderGraph.Internal.Vector3ShaderProperty",
"m_ObjectId": "8ab10da2124da78dbf0ae0289b56de8b",
"m_Guid": {
"m_GuidSerialized": "14cc25ba-b995-478e-9d66-13c304e58e96"
},
"m_Name": "ObjectSpacePosition",
"m_DefaultRefNameVersion": 0,
"m_RefNameGeneratedByDisplayName": "",
"m_DefaultReferenceName": "Vector3_DF61F3B",
"m_OverrideReferenceName": "",
"m_GeneratePropertyBlock": true,
"m_UseCustomSlotLabel": false,
"m_CustomSlotLabel": "",
"m_DismissedVersion": 0,
"m_Precision": 0,
"overrideHLSLDeclaration": false,
"hlslDeclarationOverride": 0,
"m_Hidden": false,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
}
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot",
"m_ObjectId": "985f4d22277e4c848f1a4e8599825c1e",
"m_Id": 2,
"m_DisplayName": "False",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "False",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
}
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot",
"m_ObjectId": "9865b2e64e2f4147967bb32a63ad7e47",
"m_Id": 1,
"m_DisplayName": "True",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "True",
"m_StageCapability": 3,
"m_Value": {
"x": 1.0,
"y": 1.0,
"z": 1.0,
"w": 1.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
}
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
"m_ObjectId": "99211ac232b942c7a446624cc6276ea0",
"m_Id": 5,
"m_DisplayName": "UV3",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "UV3",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.PropertyNode",
"m_ObjectId": "b3fadcf6ec584e5facf413fb91de479b",
"m_Group": {
"m_Id": ""
},
"m_Name": "Property",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": 528.0,
"y": -1288.800048828125,
"width": 186.4000244140625,
"height": 33.60009765625
}
},
"m_Slots": [
{
"m_Id": "c8285dacdfe94e1a8ec6d81261661975"
}
],
"synonyms": [],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_Property": {
"m_Id": "8ab10da2124da78dbf0ae0289b56de8b"
}
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot",
"m_ObjectId": "b4d3ad6c92014bc4926e0dce5607559b",
"m_Id": 3,
"m_DisplayName": "Out",
"m_SlotType": 1,
"m_Hidden": false,
"m_ShaderOutputName": "Out",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
}
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
"m_ObjectId": "bd0e784d2ccf46558fb47a1faf722661",
"m_Id": 4,
"m_DisplayName": "UV2",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "UV2",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.UVNode",
"m_ObjectId": "c43251a50a5947879de8aba4500e9614",
"m_Group": {
"m_Id": ""
},
"m_Name": "UV",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": 543.9999389648438,
"y": -1100.0,
"width": 145.5999755859375,
"height": 127.2000732421875
}
},
"m_Slots": [
{
"m_Id": "33c7d1f937f84de88dab6b78171ea330"
}
],
"synonyms": [
"texcoords",
"coords",
"coordinates"
],
"m_Precision": 0,
"m_PreviewExpanded": false,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_OutputChannel": 3
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.BranchNode",
"m_ObjectId": "c5401ca55ff7479a943cd8e195cce606",
"m_Group": {
"m_Id": ""
},
"m_Name": "Branch",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": 1100.0,
"y": -1350.4000244140625,
"width": 172.0,
"height": 141.5999755859375
}
},
"m_Slots": [
{
"m_Id": "f2bab7af64f74b16a0e2682158527c3e"
},
{
"m_Id": "9865b2e64e2f4147967bb32a63ad7e47"
},
{
"m_Id": "985f4d22277e4c848f1a4e8599825c1e"
},
{
"m_Id": "b4d3ad6c92014bc4926e0dce5607559b"
}
],
"synonyms": [
"switch",
"if",
"else"
],
"m_Precision": 0,
"m_PreviewExpanded": false,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
}
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot",
"m_ObjectId": "c7ceaf04428e4c13802efd03d5ccecc8",
"m_Id": 0,
"m_DisplayName": "ObjectSpacePosition",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "ObjectSpacePosition",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot",
"m_ObjectId": "c8285dacdfe94e1a8ec6d81261661975",
"m_Id": 0,
"m_DisplayName": "ObjectSpacePosition",
"m_SlotType": 1,
"m_Hidden": false,
"m_ShaderOutputName": "Out",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"m_Labels": []
}
{
"m_SGVersion": 1,
"m_Type": "UnityEditor.ShaderGraph.CustomFunctionNode",
"m_ObjectId": "dd2f62e9497e449783da8a10acb800f0",
"m_Group": {
"m_Id": ""
},
"m_Name": "SpeedTree9LeafFacing (Custom Function)",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": 730.4000244140625,
"y": -1216.800048828125,
"width": 344.7999267578125,
"height": 165.5999755859375
}
},
"m_Slots": [
{
"m_Id": "c7ceaf04428e4c13802efd03d5ccecc8"
},
{
"m_Id": "bd0e784d2ccf46558fb47a1faf722661"
},
{
"m_Id": "99211ac232b942c7a446624cc6276ea0"
},
{
"m_Id": "fa8172d0491c4feaaeed417f19db78b6"
}
],
"synonyms": [
"code",
"HLSL"
],
"m_Precision": 0,
"m_PreviewExpanded": false,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_SourceType": 0,
"m_FunctionName": "SpeedTree9LeafFacing",
"m_FunctionSource": "33eafb83c6bce0842b6887eebaf95436",
"m_FunctionBody": "Enter function body here..."
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Internal.BooleanShaderProperty",
"m_ObjectId": "e5ff779cf6e24d76bcf888e4273eca23",
"m_Guid": {
"m_GuidSerialized": "e666ebd7-9d99-4192-8bea-f431baeaedf5"
},
"m_Name": "IsBillboard",
"m_DefaultRefNameVersion": 1,
"m_RefNameGeneratedByDisplayName": "IsBillboard",
"m_DefaultReferenceName": "_IsBillboard",
"m_OverrideReferenceName": "",
"m_GeneratePropertyBlock": true,
"m_UseCustomSlotLabel": false,
"m_CustomSlotLabel": "",
"m_DismissedVersion": 0,
"m_Precision": 0,
"overrideHLSLDeclaration": false,
"hlslDeclarationOverride": 0,
"m_Hidden": false,
"m_Value": false
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.BooleanMaterialSlot",
"m_ObjectId": "f2bab7af64f74b16a0e2682158527c3e",
"m_Id": 0,
"m_DisplayName": "Predicate",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "Predicate",
"m_StageCapability": 3,
"m_Value": false,
"m_DefaultValue": false
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot",
"m_ObjectId": "f3a9bebf31974f7eb2e9efd993bab257",
"m_Id": 1,
"m_DisplayName": "ObjectSpacePositionOut",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "ObjectSpacePositionOut",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot",
"m_ObjectId": "fa8172d0491c4feaaeed417f19db78b6",
"m_Id": 2,
"m_DisplayName": "LeafFacingVertexPosition",
"m_SlotType": 1,
"m_Hidden": false,
"m_ShaderOutputName": "LeafFacingVertexPosition",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.UVNode",
"m_ObjectId": "fe2a3c68665e44c1a68cb56972054411",
"m_Group": {
"m_Id": ""
},
"m_Name": "UV",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": 543.9999389648438,
"y": -1234.39990234375,
"width": 145.5999755859375,
"height": 127.2000732421875
}
},
"m_Slots": [
{
"m_Id": "84eab20a36c442c39d153322718082df"
}
],
"synonyms": [
"texcoords",
"coords",
"coordinates"
],
"m_Precision": 0,
"m_PreviewExpanded": false,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_OutputChannel": 2
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 153b138ddd88e7b42a0c29bde1e7142c
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3}
documentationPath: SpeedTree8-SubGraphAssets
@@ -0,0 +1,648 @@
// Unity built-in shader source. Copyright (c) 2024 Unity Technologies. MIT license (see license.txt)
#ifndef SPEEDTREE_WIND_9_INCLUDED
#define SPEEDTREE_WIND_9_INCLUDED
#define SPEEDTREE_VERSION_9
#include "SpeedTreeCommon.hlsl"
//
// DATA DEFINITIONS
//
struct WindBranchState // 8 floats | 32B
{
float3 m_vNoisePosTurbulence;
float m_fIndependence;
float m_fBend;
float m_fOscillation;
float m_fTurbulence;
float m_fFlexibility;
};
struct WindRippleState // 8 floats | 32B
{
float3 m_vNoisePosTurbulence;
float m_fIndependence;
float m_fPlanar;
float m_fDirectional;
float m_fFlexibility;
float m_fShimmer;
};
struct CBufferSpeedTree9 // 44 floats | 176B
{
float3 m_vWindDirection;
float m_fWindStrength;
float3 m_vTreeExtents;
float m_fSharedHeightStart;
float m_fBranch1StretchLimit;
float m_fBranch2StretchLimit;
float m_fWindIndependence;
float m_fImportScaling;
WindBranchState m_sShared;
WindBranchState m_sBranch1;
WindBranchState m_sBranch2;
WindRippleState m_sRipple;
};
CBUFFER_START(SpeedTreeWind)
float4 _ST_WindVector;
float4 _ST_TreeExtents_SharedHeightStart;
float4 _ST_BranchStretchLimits;
float4 _ST_Shared_NoisePosTurbulence_Independence;
float4 _ST_Shared_Bend_Oscillation_Turbulence_Flexibility;
float4 _ST_Branch1_NoisePosTurbulence_Independence;
float4 _ST_Branch1_Bend_Oscillation_Turbulence_Flexibility;
float4 _ST_Branch2_NoisePosTurbulence_Independence;
float4 _ST_Branch2_Bend_Oscillation_Turbulence_Flexibility;
float4 _ST_Ripple_NoisePosTurbulence_Independence;
float4 _ST_Ripple_Planar_Directional_Flexibility_Shimmer;
CBUFFER_END
CBUFFER_START(SpeedTreeWindHistory)
float4 _ST_HistoryWindVector;
float4 _ST_HistoryTreeExtents_SharedHeightStart;
float4 _ST_HistoryBranchStretchLimits;
float4 _ST_HistoryShared_NoisePosTurbulence_Independence;
float4 _ST_HistoryShared_Bend_Oscillation_Turbulence_Flexibility;
float4 _ST_HistoryBranch1_NoisePosTurbulence_Independence;
float4 _ST_HistoryBranch1_Bend_Oscillation_Turbulence_Flexibility;
float4 _ST_HistoryBranch2_NoisePosTurbulence_Independence;
float4 _ST_HistoryBranch2_Bend_Oscillation_Turbulence_Flexibility;
float4 _ST_HistoryRipple_NoisePosTurbulence_Independence;
float4 _ST_HistoryRipple_Planar_Directional_Flexibility_Shimmer;
CBUFFER_END
#ifdef UNITY_DOTS_INSTANCING_ENABLED
#define DOTS_ST_WindVector DOTS_ST_WindParam0
#define DOTS_ST_TreeExtents_SharedHeightStart DOTS_ST_WindParam1
#define DOTS_ST_BranchStretchLimits DOTS_ST_WindParam2
#define DOTS_ST_Shared_NoisePosTurbulence_Independence DOTS_ST_WindParam3
#define DOTS_ST_Shared_Bend_Oscillation_Turbulence_Flexibility DOTS_ST_WindParam4
#define DOTS_ST_Branch1_NoisePosTurbulence_Independence DOTS_ST_WindParam5
#define DOTS_ST_Branch1_Bend_Oscillation_Turbulence_Flexibility DOTS_ST_WindParam6
#define DOTS_ST_Branch2_NoisePosTurbulence_Independence DOTS_ST_WindParam7
#define DOTS_ST_Branch2_Bend_Oscillation_Turbulence_Flexibility DOTS_ST_WindParam8
#define DOTS_ST_Ripple_NoisePosTurbulence_Independence DOTS_ST_WindParam9
#define DOTS_ST_Ripple_Planar_Directional_Flexibility_Shimmer DOTS_ST_WindParam10
#define DOTS_ST_HistoryWindVector DOTS_ST_WindHistoryParam0
#define DOTS_ST_HistoryTreeExtents_SharedHeightStart DOTS_ST_WindHistoryParam1
#define DOTS_ST_HistoryBranchStretchLimits DOTS_ST_WindHistoryParam2
#define DOTS_ST_HistoryShared_NoisePosTurbulence_Independence DOTS_ST_WindHistoryParam3
#define DOTS_ST_HistoryShared_Bend_Oscillation_Turbulence_Flexibility DOTS_ST_WindHistoryParam4
#define DOTS_ST_HistoryBranch1_NoisePosTurbulence_Independence DOTS_ST_WindHistoryParam5
#define DOTS_ST_HistoryBranch1_Bend_Oscillation_Turbulence_Flexibility DOTS_ST_WindHistoryParam6
#define DOTS_ST_HistoryBranch2_NoisePosTurbulence_Independence DOTS_ST_WindHistoryParam7
#define DOTS_ST_HistoryBranch2_Bend_Oscillation_Turbulence_Flexibility DOTS_ST_WindHistoryParam8
#define DOTS_ST_HistoryRipple_NoisePosTurbulence_Independence DOTS_ST_WindHistoryParam9
#define DOTS_ST_HistoryRipple_Planar_Directional_Flexibility_Shimmer DOTS_ST_WindHistoryParam10
UNITY_DOTS_INSTANCING_START(UserPropertyMetadata)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindVector)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_TreeExtents_SharedHeightStart)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_BranchStretchLimits)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_Shared_NoisePosTurbulence_Independence)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_Shared_Bend_Oscillation_Turbulence_Flexibility)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_Branch1_NoisePosTurbulence_Independence)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_Branch1_Bend_Oscillation_Turbulence_Flexibility)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_Branch2_NoisePosTurbulence_Independence)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_Branch2_Bend_Oscillation_Turbulence_Flexibility)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_Ripple_NoisePosTurbulence_Independence)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_Ripple_Planar_Directional_Flexibility_Shimmer)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_HistoryWindVector)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_HistoryTreeExtents_SharedHeightStart)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_HistoryBranchStretchLimits)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_HistoryShared_NoisePosTurbulence_Independence)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_HistoryShared_Bend_Oscillation_Turbulence_Flexibility)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_HistoryBranch1_NoisePosTurbulence_Independence)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_HistoryBranch1_Bend_Oscillation_Turbulence_Flexibility)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_HistoryBranch2_NoisePosTurbulence_Independence)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_HistoryBranch2_Bend_Oscillation_Turbulence_Flexibility)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_HistoryRipple_NoisePosTurbulence_Independence)
UNITY_DOTS_INSTANCED_PROP(float4, DOTS_ST_HistoryRipple_Planar_Directional_Flexibility_Shimmer)
UNITY_DOTS_INSTANCING_END(UserPropertyMetadata)
#define _ST_WindVector UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_WindVector)
#define _ST_TreeExtents_SharedHeightStart UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_TreeExtents_SharedHeightStart)
#define _ST_BranchStretchLimits UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_BranchStretchLimits)
#define _ST_Shared_NoisePosTurbulence_Independence UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_Shared_NoisePosTurbulence_Independence)
#define _ST_Shared_Bend_Oscillation_Turbulence_Flexibility UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_Shared_Bend_Oscillation_Turbulence_Flexibility)
#define _ST_Branch1_NoisePosTurbulence_Independence UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_Branch1_NoisePosTurbulence_Independence)
#define _ST_Branch1_Bend_Oscillation_Turbulence_Flexibility UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_Branch1_Bend_Oscillation_Turbulence_Flexibility)
#define _ST_Branch2_NoisePosTurbulence_Independence UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_Branch2_NoisePosTurbulence_Independence)
#define _ST_Branch2_Bend_Oscillation_Turbulence_Flexibility UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_Branch2_Bend_Oscillation_Turbulence_Flexibility)
#define _ST_Ripple_NoisePosTurbulence_Independence UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_Ripple_NoisePosTurbulence_Independence)
#define _ST_Ripple_Planar_Directional_Flexibility_Shimmer UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_Ripple_Planar_Directional_Flexibility_Shimmer)
#define _ST_HistoryWindVector UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_HistoryWindVector)
#define _ST_HistoryTreeExtents_SharedHeightStart UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_HistoryTreeExtents_SharedHeightStart)
#define _ST_HistoryBranchStretchLimits UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_HistoryBranchStretchLimits)
#define _ST_HistoryShared_NoisePosTurbulence_Independence UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_HistoryShared_NoisePosTurbulence_Independence)
#define _ST_HistoryShared_Bend_Oscillation_Turbulence_Flexibility UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_HistoryShared_Bend_Oscillation_Turbulence_Flexibility)
#define _ST_HistoryBranch1_NoisePosTurbulence_Independence UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_HistoryBranch1_NoisePosTurbulence_Independence)
#define _ST_HistoryBranch1_Bend_Oscillation_Turbulence_Flexibility UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_HistoryBranch1_Bend_Oscillation_Turbulence_Flexibility)
#define _ST_HistoryBranch2_NoisePosTurbulence_Independence UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_HistoryBranch2_NoisePosTurbulence_Independence)
#define _ST_HistoryBranch2_Bend_Oscillation_Turbulence_Flexibility UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_HistoryBranch2_Bend_Oscillation_Turbulence_Flexibility)
#define _ST_HistoryRipple_NoisePosTurbulence_Independence UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_HistoryRipple_NoisePosTurbulence_Independence)
#define _ST_HistoryRipple_Planar_Directional_Flexibility_Shimmer UNITY_ACCESS_DOTS_INSTANCED_PROP(float4, DOTS_ST_HistoryRipple_Planar_Directional_Flexibility_Shimmer)
#endif
CBufferSpeedTree9 ReadCBuffer(bool bHistory /*must be known compile-time*/)
{
CBufferSpeedTree9 cb;
cb.m_vWindDirection = bHistory ? _ST_HistoryWindVector.xyz : _ST_WindVector.xyz;
cb.m_fWindStrength = bHistory ? _ST_HistoryWindVector.w : _ST_WindVector.w;
cb.m_vTreeExtents = bHistory ? _ST_HistoryTreeExtents_SharedHeightStart.xyz : _ST_TreeExtents_SharedHeightStart.xyz;
cb.m_fSharedHeightStart = bHistory ? _ST_HistoryTreeExtents_SharedHeightStart.w : _ST_TreeExtents_SharedHeightStart.w;
cb.m_fBranch1StretchLimit = bHistory ? _ST_HistoryBranchStretchLimits.x : _ST_BranchStretchLimits.x;
cb.m_fBranch2StretchLimit = bHistory ? _ST_HistoryBranchStretchLimits.y : _ST_BranchStretchLimits.y;
cb.m_fWindIndependence = bHistory ? _ST_HistoryBranchStretchLimits.z : _ST_BranchStretchLimits.z;
cb.m_fImportScaling = bHistory ? _ST_HistoryBranchStretchLimits.w : _ST_BranchStretchLimits.w;
// Shared Wind State
cb.m_sShared.m_vNoisePosTurbulence = bHistory ? _ST_HistoryShared_NoisePosTurbulence_Independence.xyz : _ST_Shared_NoisePosTurbulence_Independence.xyz;
cb.m_sShared.m_fIndependence = bHistory ? _ST_HistoryShared_NoisePosTurbulence_Independence.w : _ST_Shared_NoisePosTurbulence_Independence.w;
cb.m_sShared.m_fBend = bHistory ? _ST_HistoryShared_Bend_Oscillation_Turbulence_Flexibility.x : _ST_Shared_Bend_Oscillation_Turbulence_Flexibility.x;
cb.m_sShared.m_fOscillation = bHistory ? _ST_HistoryShared_Bend_Oscillation_Turbulence_Flexibility.y : _ST_Shared_Bend_Oscillation_Turbulence_Flexibility.y;
cb.m_sShared.m_fTurbulence = bHistory ? _ST_HistoryShared_Bend_Oscillation_Turbulence_Flexibility.z : _ST_Shared_Bend_Oscillation_Turbulence_Flexibility.z;
cb.m_sShared.m_fFlexibility = bHistory ? _ST_HistoryShared_Bend_Oscillation_Turbulence_Flexibility.w : _ST_Shared_Bend_Oscillation_Turbulence_Flexibility.w;
// Branch1 Wind State
cb.m_sBranch1.m_vNoisePosTurbulence = bHistory ? _ST_HistoryBranch1_NoisePosTurbulence_Independence.xyz : _ST_Branch1_NoisePosTurbulence_Independence.xyz;
cb.m_sBranch1.m_fIndependence = bHistory ? _ST_HistoryBranch1_NoisePosTurbulence_Independence.w : _ST_Branch1_NoisePosTurbulence_Independence.w;
cb.m_sBranch1.m_fBend = bHistory ? _ST_HistoryBranch1_Bend_Oscillation_Turbulence_Flexibility.x : _ST_Branch1_Bend_Oscillation_Turbulence_Flexibility.x;
cb.m_sBranch1.m_fOscillation = bHistory ? _ST_HistoryBranch1_Bend_Oscillation_Turbulence_Flexibility.y : _ST_Branch1_Bend_Oscillation_Turbulence_Flexibility.y;
cb.m_sBranch1.m_fTurbulence = bHistory ? _ST_HistoryBranch1_Bend_Oscillation_Turbulence_Flexibility.z : _ST_Branch1_Bend_Oscillation_Turbulence_Flexibility.z;
cb.m_sBranch1.m_fFlexibility = bHistory ? _ST_HistoryBranch1_Bend_Oscillation_Turbulence_Flexibility.w : _ST_Branch1_Bend_Oscillation_Turbulence_Flexibility.w;
// Branch2 Wind State
cb.m_sBranch2.m_vNoisePosTurbulence = bHistory ? _ST_HistoryBranch2_NoisePosTurbulence_Independence.xyz : _ST_Branch2_NoisePosTurbulence_Independence.xyz;
cb.m_sBranch2.m_fIndependence = bHistory ? _ST_HistoryBranch2_NoisePosTurbulence_Independence.w : _ST_Branch2_NoisePosTurbulence_Independence.w;
cb.m_sBranch2.m_fBend = bHistory ? _ST_HistoryBranch2_Bend_Oscillation_Turbulence_Flexibility.x : _ST_Branch2_Bend_Oscillation_Turbulence_Flexibility.x;
cb.m_sBranch2.m_fOscillation = bHistory ? _ST_HistoryBranch2_Bend_Oscillation_Turbulence_Flexibility.y : _ST_Branch2_Bend_Oscillation_Turbulence_Flexibility.y;
cb.m_sBranch2.m_fTurbulence = bHistory ? _ST_HistoryBranch2_Bend_Oscillation_Turbulence_Flexibility.z : _ST_Branch2_Bend_Oscillation_Turbulence_Flexibility.z;
cb.m_sBranch2.m_fFlexibility = bHistory ? _ST_HistoryBranch2_Bend_Oscillation_Turbulence_Flexibility.w : _ST_Branch2_Bend_Oscillation_Turbulence_Flexibility.w;
// Ripple Wind State
cb.m_sRipple.m_vNoisePosTurbulence = bHistory ? _ST_HistoryRipple_NoisePosTurbulence_Independence.xyz : _ST_Ripple_NoisePosTurbulence_Independence.xyz;
cb.m_sRipple.m_fIndependence = bHistory ? _ST_HistoryRipple_NoisePosTurbulence_Independence.w : _ST_Ripple_NoisePosTurbulence_Independence.w;
cb.m_sRipple.m_fPlanar = bHistory ? _ST_HistoryRipple_Planar_Directional_Flexibility_Shimmer.x : _ST_Ripple_Planar_Directional_Flexibility_Shimmer.x;
cb.m_sRipple.m_fDirectional = bHistory ? _ST_HistoryRipple_Planar_Directional_Flexibility_Shimmer.y : _ST_Ripple_Planar_Directional_Flexibility_Shimmer.y;
cb.m_sRipple.m_fFlexibility = bHistory ? _ST_HistoryRipple_Planar_Directional_Flexibility_Shimmer.z : _ST_Ripple_Planar_Directional_Flexibility_Shimmer.z;
cb.m_sRipple.m_fShimmer = bHistory ? _ST_HistoryRipple_Planar_Directional_Flexibility_Shimmer.w : _ST_Ripple_Planar_Directional_Flexibility_Shimmer.w;
cb.m_vWindDirection = TransformWindVectorFromWorldToLocalSpace(cb.m_vWindDirection);
return cb;
}
//
// UTILS
//
float NoiseHash(float n) { return frac(sin(n) * 1e4); }
float NoiseHash(float2 p){ return frac(1e4 * sin(17.0f * p.x + p.y * 0.1f) * (0.1f + abs(sin(p.y * 13.0f + p.x)))); }
float QNoise(float2 x)
{
float2 i = floor(x);
float2 f = frac(x);
// four corners in 2D of a tile
float a = NoiseHash(i);
float b = NoiseHash(i + float2(1.0, 0.0));
float c = NoiseHash(i + float2(0.0, 1.0));
float d = NoiseHash(i + float2(1.0, 1.0));
// same code, with the clamps in smoothstep and common subexpressions optimized away.
float2 u = f * f * (float2(3.0, 3.0) - float2(2.0, 2.0) * f);
return lerp(a, b, u.x) + (c - a) * u.y * (1.0f - u.x) + (d - b) * u.x * u.y;
}
float4 RuntimeSdkNoise2DFlat(float3 vNoisePos3d)
{
float2 vNoisePos = vNoisePos3d.xz;
#ifdef USE_ST_NOISE_TEXTURE // test this toggle during shader perf tuning
return texture2D(g_samNoiseKernel, vNoisePos.xy) - float4(0.5f, 0.5f, 0.5f, 0.5f);
#else
// fallback, slower noise lookup method
const float c_fFrequecyScale = 20.0f;
const float c_fAmplitudeScale = 1.0f;
const float c_fAmplitueShift = 0.0f;
float fNoiseX = (QNoise(vNoisePos * c_fFrequecyScale) + c_fAmplitueShift) * c_fAmplitudeScale;
float fNoiseY = (QNoise(vNoisePos.yx * 0.5f * c_fFrequecyScale) + c_fAmplitueShift) * c_fAmplitudeScale;
return float4(fNoiseX, fNoiseY, fNoiseX+fNoiseY, 0.0f) - 0.5f.xxxx;
#endif
}
float WindUtil_Square(float fValue) { return fValue * fValue; }
float2 WindUtil_Square(float2 fValue) { return fValue * fValue; }
float3 WindUtil_Square(float3 fValue) { return fValue * fValue; }
float4 WindUtil_Square(float4 fValue) { return fValue * fValue; }
float3 WindUtil_UnpackNormalizedFloat(float fValue)
{
float3 vReturn = frac(float3(fValue * 0.01f, fValue, fValue * 100.0f));
vReturn -= 0.5f;
vReturn *= 2.0f;
vReturn = normalize(vReturn);
return vReturn;
}
//
// SPEEDTREE WIND 9 FUNCTIONS
//
// returns position offset (caller must apply to the vertex position)
float3 RippleWindMotion(
float3 vUp,
float3 vWindDirection,
float3 vVertexPositionIn,
float3 vGlobalNoisePosition,
float fRippleWeight,
float3 vRippleNoisePosTurbulence,
float fRippleIndependence,
float fRippleFlexibility,
float fRippleDirectional,
float fRipplePlanar,
float fTreeHeight,
float fImportScaling
)
{
float fImportScalingInv = (1.0f / fImportScaling);
float3 vNoisePosition = vGlobalNoisePosition
+ vRippleNoisePosTurbulence
+ (vVertexPositionIn * fImportScalingInv) * fRippleIndependence
+ vWindDirection * fRippleFlexibility * fRippleWeight;
float2 vNoise = RuntimeSdkNoise2DFlat(vNoisePosition);
vNoise.r += 0.25f;
float3 vMotion = vWindDirection * vNoise.r * fRippleDirectional
+ vUp * (vNoise.g * fRipplePlanar)
;
vMotion *= fRippleWeight;
return vMotion;
}
float3 RippleWindMotion_cb(
float3 vUpVector,
float3 vVertexPositionIn,
float3 vGlobalNoisePosition,
float fRippleWeight,
in CBufferSpeedTree9 cb
)
{
return RippleWindMotion(
vUpVector,
cb.m_vWindDirection,
vVertexPositionIn,
vGlobalNoisePosition,
fRippleWeight,
cb.m_sRipple.m_vNoisePosTurbulence,
cb.m_sRipple.m_fIndependence,
cb.m_sRipple.m_fFlexibility,
cb.m_sRipple.m_fDirectional,
cb.m_sRipple.m_fPlanar,
cb.m_vTreeExtents.y, // y-up = height
cb.m_fImportScaling
);
}
// returns updated position
float3 BranchWindPosition(
float3 vUp,
float3 vWindDirection,
float3 vVertexPositionIn,
float3 vGlobalNoisePosition,
float fPackedBranchDir,
float fPackedBranchNoiseOffset,
float fBranchWeight,
float fBranchStretchLimit,
float3 vBranchNoisePosTurbulence,
float fBranchIndependence,
float fBranchTurbulence,
float fBranchOscillation,
float fBranchBend,
float fBranchFlexibility,
float fTreeHeight,
float fImportScaling
)
{
float fImportScalingInv = (1.0f / fImportScaling);
float fLength = fBranchWeight * fBranchStretchLimit;
if (fBranchWeight * fBranchStretchLimit <= 0.0f)
{
return vVertexPositionIn;
}
float3 vBranchDir = WindUtil_UnpackNormalizedFloat(fPackedBranchDir);
float3 vBranchNoiseOffset = WindUtil_UnpackNormalizedFloat(fPackedBranchNoiseOffset);
// SpeedTree Modeler packs Z up, rotate around X for -90deg
vBranchDir = float3(vBranchDir.x, -vBranchDir.z, vBranchDir.y);
vBranchNoiseOffset = float3(vBranchNoiseOffset.x, -vBranchNoiseOffset.z, vBranchNoiseOffset.y);
float3 vAnchor = vVertexPositionIn - vBranchDir * fLength;
vVertexPositionIn -= vAnchor;
float fBranchDotWindSq = WindUtil_Square(dot(vBranchDir, vWindDirection));
float3 vWind = normalize(vWindDirection + vUp * fBranchDotWindSq);
// Undo modifications to fBranchIndependence:
// (1) Modeler divides fBranchIndependence by fTreeHeight before export
// (2) Importer scales fTreeHeight by fImportScaling during import
fBranchIndependence *= (fTreeHeight * fImportScalingInv);
float3 vNoisePosition = vGlobalNoisePosition
+ vBranchNoisePosTurbulence
+ vBranchNoiseOffset * fBranchIndependence
+ vWind * (fBranchFlexibility * fBranchWeight);
float4 vNoise = RuntimeSdkNoise2DFlat(vNoisePosition);
vNoise.r *= 0.65; // tune down the 'flexy' branches
vNoise.g *= 0.50; // tune down the 'flexy' branches
float3 vOscillationTurbulent = vUp * fBranchTurbulence;
float3 vMotion = (vWind * vNoise.r + vOscillationTurbulent * vNoise.g) * fBranchOscillation;
vMotion += vWind * (fBranchBend * (1.0f - vNoise.b));
vMotion *= fBranchWeight;
return normalize(vVertexPositionIn + vMotion) * fLength + vAnchor;
}
float3 BranchWindPosition_cb(
float3 vUp,
float3 vGlobalNoisePosition,
float3 vVertexPositionIn,
float fBranchWeight,
float fPackedBranchDir,
float fPackedBranchNoiseOffset,
in CBufferSpeedTree9 cb,
const int iBranch // 1 or 2, compile time constants
)
{
if (iBranch == 1)
{
return BranchWindPosition(
vUp,
cb.m_vWindDirection,
vVertexPositionIn,
vGlobalNoisePosition,
fPackedBranchDir,
fPackedBranchNoiseOffset,
fBranchWeight,
cb.m_fBranch1StretchLimit,
cb.m_sBranch1.m_vNoisePosTurbulence,
cb.m_sBranch1.m_fIndependence,
cb.m_sBranch1.m_fTurbulence,
cb.m_sBranch1.m_fOscillation,
cb.m_sBranch1.m_fBend,
cb.m_sBranch1.m_fFlexibility,
cb.m_vTreeExtents.y, // y-up = height
cb.m_fImportScaling
);
}
return BranchWindPosition(
vUp,
cb.m_vWindDirection,
vVertexPositionIn,
vGlobalNoisePosition,
fPackedBranchDir,
fPackedBranchNoiseOffset,
fBranchWeight,
cb.m_fBranch2StretchLimit,
cb.m_sBranch2.m_vNoisePosTurbulence,
cb.m_sBranch2.m_fIndependence,
cb.m_sBranch2.m_fTurbulence,
cb.m_sBranch2.m_fOscillation,
cb.m_sBranch2.m_fBend,
cb.m_sBranch2.m_fFlexibility,
cb.m_vTreeExtents.y, // y-up = height
cb.m_fImportScaling
);
}
// returns updated position
float3 SharedWindPosition(
float3 vUp,
float3 vWindDirection,
float3 vVertexPositionIn,
float3 vGlobalNoisePosition,
float fTreeHeight,
float fSharedHeightStart,
float3 vSharedNoisePosTurbulence,
float fSharedTurbulence,
float fSharedOscillation,
float fSharedBend,
float fSharedFlexibility,
float fImportScaling
)
{
float fImportScalingInv = (1.0f / fImportScaling);
float fLengthSq = dot(vVertexPositionIn, vVertexPositionIn);
if (fLengthSq == 0.0f)
{
return vVertexPositionIn;
}
float fLength = sqrt(fLengthSq);
float fHeight = vVertexPositionIn.y; // y-up
float fMaxHeight = fTreeHeight;
float fWeight = WindUtil_Square(max(fHeight - (fMaxHeight * fSharedHeightStart), 0.0f) / fMaxHeight);
float3 vNoisePosition = vGlobalNoisePosition
+ vSharedNoisePosTurbulence;
+ vWindDirection * (fSharedFlexibility * fWeight);
float4 vNoise = RuntimeSdkNoise2DFlat(vNoisePosition);
float3 vOscillationTurbulent = cross(vWindDirection, vUp) * fSharedTurbulence;
float3 vMotion = (vWindDirection * vNoise.r + vOscillationTurbulent * vNoise.g) * fSharedOscillation
+ vWindDirection * (fSharedBend * (1.0f - vNoise.b));
;
vMotion *= fWeight;
return normalize(vVertexPositionIn + vMotion) * fLength;
}
float3 SharedWindPosition_cb(
float3 vUp,
float3 vVertexPositionIn,
float3 vGlobalNoisePosition,
in CBufferSpeedTree9 cb
)
{
return SharedWindPosition(
vUp,
cb.m_vWindDirection,
vVertexPositionIn,
vGlobalNoisePosition,
cb.m_vTreeExtents.y, // y-up = height
cb.m_fSharedHeightStart,
cb.m_sShared.m_vNoisePosTurbulence,
cb.m_sShared.m_fTurbulence,
cb.m_sShared.m_fOscillation,
cb.m_sShared.m_fBend,
cb.m_sShared.m_fFlexibility,
cb.m_fImportScaling
);
}
//====================================================================================================
//
// SPEEDTREE WIND 9 ENTRY
//
float3 SpeedTree9Wind(
float3 vPos,
float3 vNormal,
float4 vTexcoord ,
float4 vTexcoord1,
float4 vTexcoord2,
float4 vTexcoord3,
bool bHistory
)
{
CBufferSpeedTree9 cb = ReadCBuffer(bHistory);
const float fWindDirectionLengthSq = dot(cb.m_vWindDirection, cb.m_vWindDirection);
if (fWindDirectionLengthSq == 0.0f) // check if we have valid wind vector
{
return vPos;
}
float3 vUp = float3(0.0, 1.0, 0.0);
float3 vWindyPosition = vPos;
// get world space sposition from the model matrix
float3 vWorldPosition = float3(UNITY_MATRIX_M[0].w, UNITY_MATRIX_M[1].w, UNITY_MATRIX_M[2].w);
#if SHADEROPTIONS_CAMERA_RELATIVE_RENDERING // HDRP has camera translation encoded in the matrix
vWorldPosition += _WorldSpaceCameraPos;
#endif
// global noise applied to animation instances to break off synchronized
// movement among multiple instances under wind effect.
float3 vGlobalNoisePosition = vWorldPosition * cb.m_fWindIndependence;
#if defined(_WIND_RIPPLE)
{
float fRippleWeight = vTexcoord1.w;
float3 vMotion = RippleWindMotion_cb(
vUp,
vWindyPosition,
vGlobalNoisePosition,
fRippleWeight,
cb
);
vWindyPosition += vMotion;
#if defined(_WIND_SHIMMER)
{
vNormal = normalize(vNormal - (vMotion * cb.m_sRipple.m_fShimmer));
}
#endif
}
#endif
#if defined(_WIND_BRANCH2)
{
const int BRANCH2 = 2;
float fBranch2Weight = vTexcoord2.z;
float fPackedBranch2Dir = vTexcoord2.y;
float fPackedBranch2NoiseOffset = vTexcoord2.x;
vWindyPosition = BranchWindPosition_cb(
vUp,
vGlobalNoisePosition,
vWindyPosition,
fBranch2Weight,
fPackedBranch2Dir,
fPackedBranch2NoiseOffset,
cb,
BRANCH2
);
}
#endif
#if defined(_WIND_BRANCH1)
{
const int BRANCH1 = 1;
float fBranch1Weight = vTexcoord1.z;
float fPackedBranch1Dir = vTexcoord.w;
float fPackedBranch1NoiseOffset = vTexcoord.z;
vWindyPosition = BranchWindPosition_cb(
vUp,
vGlobalNoisePosition,
vWindyPosition,
fBranch1Weight,
fPackedBranch1Dir,
fPackedBranch1NoiseOffset,
cb,
BRANCH1
);
}
#endif
#if defined(_WIND_SHARED)
{
vWindyPosition = SharedWindPosition_cb(
vUp,
vWindyPosition,
vGlobalNoisePosition,
cb
);
}
#endif
return vWindyPosition;
}
// This version is used by ShaderGraph
void SpeedTree9Wind_float(
// in
float3 vPos,
float3 vNormal,
float4 vTexcoord0,
float4 vTexcoord1,
float4 vTexcoord2,
float4 vTexcoord3,
bool bHistory,
// out
out float3 outPos
)
{
outPos = SpeedTree9Wind(
vPos,
vNormal,
vTexcoord0,
vTexcoord1,
vTexcoord2,
vTexcoord3,
bHistory
);
}
#endif // SPEEDTREE_WIND_9_INCLUDED
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: dbd0aaccbcc575f468323e8991e68e98
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e8af7a3452f45f542a042fef4a52065a
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3}
documentationPath: SpeedTree8-SubGraphAssets
@@ -0,0 +1,116 @@
// Unity built-in shader source. Copyright (c) 2023 Unity Technologies. MIT license (see license.txt)
#ifndef SPEEDTREE_COMMON_INCLUDED
#define SPEEDTREE_COMMON_INCLUDED
float3 DoLeafFacing(float3 vPos, float3 anchor)
{
float3 facingPosition = vPos - anchor; // move to origin
float offsetLen = length(facingPosition);
// rotate X -90deg: normals keep looking 'up' while cards/leaves now 'stand up' and face the view plane
facingPosition = float3(facingPosition.x, -facingPosition.z, facingPosition.y);
// extract scale from model matrix
float3x3 modelMatrix = (float3x3) GetObjectToWorldMatrix(); // UNITY_MATRIX_M
float3 scale = float3(
length(float3(modelMatrix[0][0], modelMatrix[1][0], modelMatrix[2][0])),
length(float3(modelMatrix[0][1], modelMatrix[1][1], modelMatrix[2][1])),
length(float3(modelMatrix[0][2], modelMatrix[1][2], modelMatrix[2][2]))
);
// inverse of model : discards object rotations & scale
// inverse of view : discards camera rotations
float3x3 modelMatrixInv = (float3x3) GetWorldToObjectMatrix(); // UNITY_MATRIX_I_M
float3x3 viewMatrixInv = (float3x3) GetViewToWorldMatrix(); // UNITY_MATRIX_I_V
float3x3 matCardFacingTransform = mul(modelMatrixInv, viewMatrixInv);
// re-encode the scale into the final transformation (otherwise cards would look small if tree is scaled up via world transform)
matCardFacingTransform[0] *= scale.x;
matCardFacingTransform[1] *= scale.y;
matCardFacingTransform[2] *= scale.z;
// make the leaves/cards face the camera
facingPosition = mul(matCardFacingTransform, facingPosition.xyz);
facingPosition = normalize(facingPosition) * offsetLen; // make sure the offset vector is still scaled
return facingPosition + anchor; // move back to branch
}
#define SPEEDTREE_SUPPORT_NON_UNIFORM_SCALING 0
float3 TransformWindVectorFromWorldToLocalSpace(float3 vWindDirection)
{
// we intend to transform the world-space wind vector into local space.
float3x3 modelMatrixInv = (float3x3) GetWorldToObjectMatrix(); // UNITY_MATRIX_I_M
#if SPEEDTREE_SUPPORT_NON_UNIFORM_SCALING
// the inverse world matrix would contain scale transformation as well, so we need
// to get rid of scaling of the wind direction while doing inverse rotation.
float3x3 modelMatrix = (float3x3) GetObjectToWorldMatrix(); // UNITY_MATRIX_M
float3 scaleInv = float3(
length(float3(modelMatrix[0][0], modelMatrix[1][0], modelMatrix[2][0])),
length(float3(modelMatrix[0][1], modelMatrix[1][1], modelMatrix[2][1])),
length(float3(modelMatrix[0][2], modelMatrix[1][2], modelMatrix[2][2]))
);
float3x3 matWorldToLocalSpaceRotation = float3x3( // 3x3 discards translation
modelMatrixInv[0][0] * scaleInv.x, modelMatrixInv[0][1] , modelMatrixInv[0][2],
modelMatrixInv[1][0] , modelMatrixInv[1][1] * scaleInv.y, modelMatrixInv[1][2],
modelMatrixInv[2][0] , modelMatrixInv[2][1] , modelMatrixInv[2][2] * scaleInv.z
);
float3 vLocalSpaceWind = mul(matWorldToLocalSpaceRotation, vWindDirection);
#else
// Assume uniform scaling for the object -- discard translation and invert object rotations (and scale).
// We'll normalize to get rid of scaling after the transformation.
float3 vLocalSpaceWind = mul(modelMatrixInv, vWindDirection);
#endif
float windVecLength = length(vLocalSpaceWind);
if (windVecLength > 1e-5)
vLocalSpaceWind *= (1.0f / windVecLength); // normalize
return vLocalSpaceWind;
}
#define ST_GEOM_TYPE_BRANCH 0
#define ST_GEOM_TYPE_FROND 1
#define ST_GEOM_TYPE_LEAF 2
#define ST_GEOM_TYPE_FACINGLEAF 3
int GetGeometryType(float4 uv3, out bool bLeafTwo)
{
int geometryType = (int) (uv3.w + 0.25);
bLeafTwo = geometryType > ST_GEOM_TYPE_FACINGLEAF;
if (bLeafTwo)
{
geometryType -= 2;
}
return geometryType;
}
// shadergraph stubs
void SpeedTree8LeafFacing_float(float3 vVertexLocalPosition, float4 UV1, float4 UV2, float4 UV3, out float3 vVertexLocalPositionOut)
{
vVertexLocalPositionOut = vVertexLocalPosition;
bool bDummy = false;
if (GetGeometryType(UV3, bDummy) == ST_GEOM_TYPE_FACINGLEAF)
{
float3 vAnchorPosition = float3(UV1.zw, UV2.w);
vVertexLocalPositionOut = DoLeafFacing(vVertexLocalPosition, vAnchorPosition);
}
}
void SpeedTree9LeafFacing_float(float3 vVertexLocalPosition, float4 UV2, float4 UV3, out float3 vVertexLocalPositionOut)
{
vVertexLocalPositionOut = vVertexLocalPosition;
const bool bHasCameraFacingLeaf = UV3.w > 0.0f || UV2.w > 0.0f;
if (bHasCameraFacingLeaf)
{
const float3 vAnchorPosition = UV3.w > 0.0f ? UV3.xyz : UV2.xyz;
vVertexLocalPositionOut = DoLeafFacing(vVertexLocalPosition, vAnchorPosition);
}
}
void SpeedTreeLODTransition_float(float3 ObjectSpacePosition, float4 ObjectSpacePositionNextLOD, const bool bBillboard, out float3 OutObjectSpacePosition)
{
OutObjectSpacePosition = bBillboard
? ObjectSpacePosition
: lerp(ObjectSpacePosition, ObjectSpacePositionNextLOD.xyz, unity_LODFade.x);
}
#endif // SPEEDTREE_COMMON_INCLUDED
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 33eafb83c6bce0842b6887eebaf95436
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,17 @@
PackedVaryings vert(Attributes input)
{
Varyings output = (Varyings)0;
output = BuildVaryings(input);
PackedVaryings packedOutput = PackVaryings(output);
return packedOutput;
}
half4 frag(PackedVaryings packedInput) : SV_TARGET
{
Varyings unpacked = UnpackVaryings(packedInput);
SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked);
SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs);
return surfaceDescription.Out;
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 0db5a27336918594d860a43da98f2b47
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,79 @@
Varyings BuildVaryings(Attributes input)
{
Varyings output = (Varyings)0;
// Returns the camera relative position (if enabled)
float3 positionWS = TransformObjectToWorld(input.positionOS);
#ifdef ATTRIBUTES_NEED_NORMAL
float3 normalWS = TransformObjectToWorldNormal(input.normalOS);
#else
// Required to compile ApplyVertexModification that doesn't use normal.
float3 normalWS = float3(0.0, 0.0, 0.0);
#endif
#ifdef ATTRIBUTES_NEED_TANGENT
float4 tangentWS = float4(TransformObjectToWorldDir(input.tangentOS.xyz), input.tangentOS.w);
#endif
#ifdef VARYINGS_NEED_POSITION_WS
output.positionWS = positionWS;
#endif
#ifdef VARYINGS_NEED_POSITIONPREDISPLACEMENT_WS
output.positionPredisplacementWS = positionWS;
#endif
#ifdef VARYINGS_NEED_NORMAL_WS
output.normalWS = normalize(normalWS);
#endif
#ifdef VARYINGS_NEED_TANGENT_WS
output.tangentWS = normalize(tangentWS);
#endif
output.positionCS = TransformWorldToHClip(positionWS);
#if defined(VARYINGS_NEED_TEXCOORD0) || defined(VARYINGS_DS_NEED_TEXCOORD0)
output.texCoord0 = input.uv0;
#endif
#if defined(VARYINGS_NEED_TEXCOORD1) || defined(VARYINGS_DS_NEED_TEXCOORD1)
output.texCoord1 = input.uv1;
#endif
#if defined(VARYINGS_NEED_TEXCOORD2) || defined(VARYINGS_DS_NEED_TEXCOORD2)
output.texCoord2 = input.uv2;
#endif
#if defined(VARYINGS_NEED_TEXCOORD3) || defined(VARYINGS_DS_NEED_TEXCOORD3)
output.texCoord3 = input.uv3;
#endif
#if defined(VARYINGS_NEED_TEXCOORD4) || defined(VARYINGS_DS_NEED_TEXCOORD4)
output.texCoord4 = input.uv4;
#endif
#if defined(VARYINGS_NEED_TEXCOORD5) || defined(VARYINGS_DS_NEED_TEXCOORD5)
output.texCoord5 = input.uv5;
#endif
#if defined(VARYINGS_NEED_TEXCOORD6) || defined(VARYINGS_DS_NEED_TEXCOORD6)
output.texCoord6 = input.uv6;
#endif
#if defined(VARYINGS_NEED_TEXCOORD7) || defined(VARYINGS_DS_NEED_TEXCOORD7)
output.texCoord7 = input.uv7;
#endif
#if defined(VARYINGS_NEED_COLOR) || defined(VARYINGS_DS_NEED_COLOR)
output.color = input.color;
#endif
#if defined(VARYINGS_NEED_VERTEXID)
output.vertexID = input.vertexID;
#endif
#ifdef VARYINGS_NEED_BITANGENT_WS
output.bitangentWS = cross(normalWS, tangentWS.xyz) * tangentWS.w;
#endif
#ifdef VARYINGS_NEED_SCREENPOSITION
output.screenPosition = ComputeScreenPos(output.positionCS, _ProjectionParams.x);
#endif
return output;
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 1634e4cba986f4a4aabc82c280e09d13
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,15 @@
//
// This file was automatically generated. Please don't edit by hand.
//
#ifndef SHADERCONFIG_CS_HLSL
#define SHADERCONFIG_CS_HLSL
//
// UnityEngine.Rendering.HighDefinition.ShaderOptions: static fields
//
#define SHADEROPTIONS_VELOCITY_IN_GBUFFER (0)
#define SHADEROPTIONS_PACK_GBUFFER_IN_U16 (0)
#define SHADEROPTIONS_CAMERA_RELATIVE_RENDERING (1)
#endif
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 2c6472a689b6ae34e806881d3066cfb3
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,295 @@
// UNITY_SHADER_NO_UPGRADE
#ifndef UNITY_SHADER_VARIABLES_INCLUDED
#define UNITY_SHADER_VARIABLES_INCLUDED
#include "ShaderConfig.cs.hlsl"
// CAUTION:
// Currently the shaders compiler always include regualr Unity shaderVariables, so I get a conflict here were UNITY_SHADER_VARIABLES_INCLUDED is already define, this need to be fixed.
// As I haven't change the variables name yet, I simply don't define anything, and I put the transform function at the end of the file outside the guard header.
// This need to be fixed.
#if defined (DIRECTIONAL_COOKIE) || defined (DIRECTIONAL)
#define USING_DIRECTIONAL_LIGHT
#endif
#if defined(UNITY_SINGLE_PASS_STEREO) || defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED)
#define USING_STEREO_MATRICES
#endif
#if defined(USING_STEREO_MATRICES)
#define glstate_matrix_projection unity_StereoMatrixP[unity_StereoEyeIndex]
#define unity_MatrixV unity_StereoMatrixV[unity_StereoEyeIndex]
#define unity_MatrixInvV unity_StereoMatrixInvV[unity_StereoEyeIndex]
#define unity_MatrixVP unity_StereoMatrixVP[unity_StereoEyeIndex]
#define unity_CameraProjection unity_StereoCameraProjection[unity_StereoEyeIndex]
#define unity_CameraInvProjection unity_StereoCameraInvProjection[unity_StereoEyeIndex]
#define unity_WorldToCamera unity_StereoWorldToCamera[unity_StereoEyeIndex]
#define unity_CameraToWorld unity_StereoCameraToWorld[unity_StereoEyeIndex]
#define _WorldSpaceCameraPos unity_StereoWorldSpaceCameraPos[unity_StereoEyeIndex]
#endif
#define UNITY_LIGHTMODEL_AMBIENT (glstate_lightmodel_ambient * 2)
// ----------------------------------------------------------------------------
CBUFFER_START(UnityPerCamera)
// Time (t = time since current level load) values from Unity
float4 _Time; // (t/20, t, t*2, t*3)
float4 _LastTime; // Last frame time (t/20, t, t*2, t*3)
float4 _SinTime; // sin(t/8), sin(t/4), sin(t/2), sin(t)
float4 _CosTime; // cos(t/8), cos(t/4), cos(t/2), cos(t)
float4 unity_DeltaTime; // dt, 1/dt, smoothdt, 1/smoothdt
float4 _TimeParameters;
#if !defined(USING_STEREO_MATRICES)
float3 _WorldSpaceCameraPos;
#endif
// x = 1 or -1 (-1 if projection is flipped)
// y = near plane
// z = far plane
// w = 1/far plane
float4 _ProjectionParams;
// x = width
// y = height
// z = 1 + 1.0/width
// w = 1 + 1.0/height
float4 _ScreenParams;
// Values used to linearize the Z buffer (http://www.humus.name/temp/Linearize%20depth.txt)
// x = 1-far/near
// y = far/near
// z = x/far
// w = y/far
// or in case of a reversed depth buffer (UNITY_REVERSED_Z is 1)
// x = -1+far/near
// y = 1
// z = x/far
// w = 1/far
float4 _ZBufferParams;
// x = orthographic camera's width
// y = orthographic camera's height
// z = unused
// w = 1.0 if camera is ortho, 0.0 if perspective
float4 unity_OrthoParams;
CBUFFER_END
CBUFFER_START(UnityPerCameraRare)
float4 unity_CameraWorldClipPlanes[6];
#if !defined(USING_STEREO_MATRICES)
// Projection matrices of the camera. Note that this might be different from projection matrix
// that is set right now, e.g. while rendering shadows the matrices below are still the projection
// of original camera.
float4x4 unity_CameraProjection;
float4x4 unity_CameraInvProjection;
float4x4 unity_WorldToCamera;
float4x4 unity_CameraToWorld;
#endif
CBUFFER_END
// ----------------------------------------------------------------------------
CBUFFER_START(UnityPerDraw)
#ifdef UNITY_USE_PREMULTIPLIED_MATRICES
float4x4 glstate_matrix_mvp;
float4x4 glstate_matrix_modelview0;
float4x4 glstate_matrix_invtrans_modelview0;
#endif
float4x4 unity_ObjectToWorld;
float4x4 unity_WorldToObject;
float4 unity_LODFade; // x is the fade value ranging within [0,1]. y is x quantized into 16 levels
float4 unity_WorldTransformParams; // w is usually 1.0, or -1.0 for odd-negative scale transforms
float4 unity_LightmapST;
float4 unity_DynamicLightmapST;
// SH lighting environment
float4 unity_SHAr;
float4 unity_SHAg;
float4 unity_SHAb;
float4 unity_SHBr;
float4 unity_SHBg;
float4 unity_SHBb;
float4 unity_SHC;
// x = Disabled(0)/Enabled(1)
// y = Computation are done in global space(0) or local space(1)
// z = Texel size on U texture coordinate
float4 unity_ProbeVolumeParams;
float4x4 unity_ProbeVolumeWorldToObject;
float3 unity_ProbeVolumeSizeInv;
float3 unity_ProbeVolumeMin;
// This contain occlusion factor from 0 to 1 for dynamic objects (no SH here)
float4 unity_ProbesOcclusion;
// HDR environment map decode instructions
half4 unity_SpecCube0_HDR;
CBUFFER_END
// Dummy Renderer User Value static constants to satisfy the shader graph preview mode shader compilation.
static const uint unity_RendererUserValue;
// The renderer user values are packed in unity_RenderingLayer. So we need a dummy property to be able to use Shader.PropertyToID.
uint unity_RendererUserValuesPropertyEntry;
#if defined(USING_STEREO_MATRICES)
CBUFFER_START(UnityStereoGlobals)
float4x4 unity_StereoMatrixP[2];
float4x4 unity_StereoMatrixV[2];
float4x4 unity_StereoMatrixInvV[2];
float4x4 unity_StereoMatrixVP[2];
float4x4 unity_StereoCameraProjection[2];
float4x4 unity_StereoCameraInvProjection[2];
float4x4 unity_StereoWorldToCamera[2];
float4x4 unity_StereoCameraToWorld[2];
float3 unity_StereoWorldSpaceCameraPos[2];
float4 unity_StereoScaleOffset[2];
CBUFFER_END
#endif
#if defined(UNITY_STEREO_MULTIVIEW_ENABLED) && defined(SHADER_STAGE_VERTEX)
#define unity_StereoEyeIndex UNITY_VIEWID
UNITY_DECLARE_MULTIVIEW(2);
#elif defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED)
static uint unity_StereoEyeIndex;
#elif defined(UNITY_SINGLE_PASS_STEREO)
CBUFFER_START(UnityStereoEyeIndex)
int unity_StereoEyeIndex;
CBUFFER_END
#endif
CBUFFER_START(UnityPerDrawRare)
float4x4 glstate_matrix_transpose_modelview0;
CBUFFER_END
// ----------------------------------------------------------------------------
CBUFFER_START(UnityPerFrame)
float4 glstate_lightmodel_ambient;
float4 unity_AmbientSky;
float4 unity_AmbientEquator;
float4 unity_AmbientGround;
float4 unity_IndirectSpecColor;
float4 unity_FogParams;
half4 unity_FogColor;
#if !defined(USING_STEREO_MATRICES)
float4x4 glstate_matrix_projection;
float4x4 unity_MatrixV;
float4x4 unity_MatrixInvV;
float4x4 unity_MatrixVP;
float4 unity_StereoScaleOffset;
int unity_StereoEyeIndex;
#endif
float3 unity_ShadowColor;
uint _TaaFrameIndex; // [0, 7]
CBUFFER_END
// ----------------------------------------------------------------------------
// These are the samplers available in the HDRenderPipeline.
// Avoid declaring extra samplers as they are 4x SGPR each on GCN.
SAMPLER(s_linear_clamp_sampler);
SAMPLER(s_trilinear_clamp_sampler);
// ----------------------------------------------------------------------------
TEXTURE2D(_MainDepthTexture);
SAMPLER(sampler_MainDepthTexture);
// Main lightmap
TEXTURE2D(unity_Lightmap);
SAMPLER(samplerunity_Lightmap);
TEXTURE2D_ARRAY(unity_Lightmaps);
SAMPLER(samplerunity_Lightmaps);
// Dual or directional lightmap (always used with unity_Lightmap, so can share sampler)
TEXTURE2D(unity_LightmapInd);
TEXTURE2D_ARRAY(unity_LightmapsInd);
// Dynamic GI lightmap
TEXTURE2D(unity_DynamicLightmap);
SAMPLER(samplerunity_DynamicLightmap);
TEXTURE2D(unity_DynamicDirectionality);
// Default reflection probe
TEXTURECUBE(unity_SpecCube0);
SAMPLER(samplerunity_SpecCube0);
// We can have shadowMask only if we have lightmap, so no sampler
TEXTURE2D(unity_ShadowMask);
TEXTURE2D_ARRAY(unity_ShadowMasks);
// TODO: Change code here so probe volume use only one transform instead of all this parameters!
TEXTURE3D(unity_ProbeVolumeSH);
SAMPLER(samplerunity_ProbeVolumeSH);
CBUFFER_START(UnityVelocityPass)
float4x4 unity_MatrixNonJitteredVP;
float4x4 unity_MatrixPreviousVP;
float4x4 unity_MatrixPreviousM;
float4x4 unity_MatrixPreviousMI;
//X : Use last frame positions (right now skinned meshes are the only objects that use this
//Y : Force No Motion
//Z : Z bias value
float4 unity_MotionVectorsParams;
CBUFFER_END
// ----------------------------------------------------------------------------
// TODO: all affine matrices should be 3x4.
// TODO: sort these vars by the frequency of use (descending), and put commonly used vars together.
// Note: please use UNITY_MATRIX_X macros instead of referencing matrix variables directly.
CBUFFER_START(UnityPerPass)
float4x4 _PrevViewProjMatrix;
float4x4 _ViewProjMatrix;
float4x4 _NonJitteredViewProjMatrix;
float4x4 _ViewMatrix;
float4x4 _ProjMatrix;
float4x4 _InvViewProjMatrix;
float4x4 _InvViewMatrix;
float4x4 _InvProjMatrix;
float4 _InvProjParam;
float4 _ScreenSize; // {w, h, 1/w, 1/h}
float4 _FrustumPlanes[6]; // {(a, b, c) = N, d = -dot(N, P)} [L, R, T, B, N, F]
CBUFFER_END
float4x4 OptimizeProjectionMatrix(float4x4 M)
{
// Matrix format (x = non-constant value).
// Orthographic Perspective Combined(OR)
// | x 0 0 x | | x 0 x 0 | | x 0 x x |
// | 0 x 0 x | | 0 x x 0 | | 0 x x x |
// | x x x x | | x x x x | | x x x x | <- oblique projection row
// | 0 0 0 1 | | 0 0 x 0 | | 0 0 x x |
// Notice that some values are always 0.
// We can avoid loading and doing math with constants.
// But not true under Vulkan swapchain pre-transform: a 90/270 degree rotation swaps rows 0 and 1
// (Runtime/GfxDevice/vulkan/VKPreTransform.cpp), moving the scale terms onto _21/_12; exactly
// the entries cleared below, which would leave UNITY_MATRIX_P with an all-zero 2x2
#ifndef UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION
M._21_41 = 0;
M._12_42 = 0;
#endif
return M;
}
// For the shader graph node preview, we use the legacy unity matrices because they are pipeline agnostic.
#include "ShaderVariablesMatrixDefsLegacyUnity.hlsl"
#include "ShaderVariablesFunctions.hlsl"
#endif // UNITY_SHADER_VARIABLES_INCLUDED
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 2bc64066748469e48861ed835a8b806d
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,92 @@
#ifndef UNITY_SHADER_VARIABLES_FUNCTIONS_INCLUDED
#define UNITY_SHADER_VARIABLES_FUNCTIONS_INCLUDED
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl"
// Note: '_WorldSpaceCameraPos' is set by the legacy Unity code.
float3 GetPrimaryCameraPosition()
{
#if (SHADEROPTIONS_CAMERA_RELATIVE_RENDERING != 0)
return float3(0, 0, 0);
#else
return _WorldSpaceCameraPos;
#endif
}
// Could be e.g. the position of a primary camera or a shadow-casting light.
float3 GetCurrentViewPosition()
{
#if defined(SHADERPASS) && (SHADERPASS != SHADERPASS_SHADOWS)
return GetPrimaryCameraPosition();
#else
// This is a generic solution.
// However, for the primary camera, using '_WorldSpaceCameraPos' is better for cache locality,
// and in case we enable camera-relative rendering, we can statically set the position is 0.
return UNITY_MATRIX_I_V._14_24_34;
#endif
}
// Returns the forward (central) direction of the current view in the world space.
float3 GetViewForwardDir()
{
float4x4 viewMat = GetWorldToViewMatrix();
return -viewMat[2].xyz;
}
// Returns 'true' if the current view performs a perspective projection.
bool IsPerspectiveProjection()
{
#if defined(SHADERPASS) && (SHADERPASS != SHADERPASS_SHADOWS)
return (unity_OrthoParams.w == 0);
#else
// TODO: set 'unity_OrthoParams' during the shadow pass.
return UNITY_MATRIX_P[3][3] == 0;
#endif
}
// Computes the world space view direction (pointing towards the viewer).
float3 GetWorldSpaceNormalizeViewDir(float3 positionWS)
{
if (IsPerspectiveProjection())
{
// Perspective
float3 V = GetCurrentViewPosition() - positionWS;
return normalize(V);
}
else
{
// Orthographic
return -GetViewForwardDir();
}
}
// UNITY_MATRIX_V defines a right-handed view space with the Z axis pointing towards the viewer.
// This function reverses the direction of the Z axis (so that it points forward),
// making the view space coordinate system left-handed.
void GetLeftHandedViewSpaceMatrices(out float4x4 viewMatrix, out float4x4 projMatrix)
{
viewMatrix = UNITY_MATRIX_V;
viewMatrix._31_32_33_34 = -viewMatrix._31_32_33_34;
projMatrix = UNITY_MATRIX_P;
projMatrix._13_23_33_43 = -projMatrix._13_23_33_43;
}
#if UNITY_REVERSED_Z
#if (defined(SHADER_API_GLCORE) && !defined(SHADER_API_SWITCH) && !defined(SHADER_API_SWITCH2)) || defined(SHADER_API_GLES3)
//GL with reversed z => z clip range is [near, -far] -> should remap in theory but dont do it in practice to save some perf (range is close enough)
#define UNITY_Z_0_FAR_FROM_CLIPSPACE(coord) max(-(coord), 0)
#else
//D3d with reversed Z => z clip range is [near, 0] -> remapping to [0, far]
//max is required to protect ourselves from near plane not being correct/meaningfull in case of oblique matrices.
#define UNITY_Z_0_FAR_FROM_CLIPSPACE(coord) max(((1.0-(coord)/_ProjectionParams.y)*_ProjectionParams.z),0)
#endif
#elif UNITY_UV_STARTS_AT_TOP
//D3d without reversed z => z clip range is [0, far] -> nothing to do
#define UNITY_Z_0_FAR_FROM_CLIPSPACE(coord) (coord)
#else
//Opengl => z clip range is [-near, far] -> should remap in theory but dont do it in practice to save some perf (range is close enough)
#define UNITY_Z_0_FAR_FROM_CLIPSPACE(coord) (coord)
#endif
#endif // UNITY_SHADER_VARIABLES_FUNCTIONS_INCLUDED
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 7084c0669cdb2af4ab8c669b3139e0df
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,23 @@
#ifdef UNITY_SHADER_VARIABLES_MATRIX_DEFS_HDCAMERA_INCLUDED
#error Mixing HDCamera and legacy Unity matrix definitions
#endif
#ifndef UNITY_SHADER_VARIABLES_MATRIX_DEFS_LEGACY_UNITY_INCLUDED
#define UNITY_SHADER_VARIABLES_MATRIX_DEFS_LEGACY_UNITY_INCLUDED
#define UNITY_MATRIX_M unity_ObjectToWorld
#define UNITY_MATRIX_I_M unity_WorldToObject
#define UNITY_MATRIX_V unity_MatrixV
#define UNITY_MATRIX_I_V unity_MatrixInvV
#define UNITY_MATRIX_P OptimizeProjectionMatrix(glstate_matrix_projection)
#define UNITY_MATRIX_I_P _InvProjMatrix
#define UNITY_MATRIX_VP unity_MatrixVP
#define UNITY_MATRIX_I_VP _InvViewProjMatrix
#define UNITY_MATRIX_MV mul(UNITY_MATRIX_V, UNITY_MATRIX_M)
#define UNITY_MATRIX_T_MV transpose(UNITY_MATRIX_MV)
#define UNITY_MATRIX_IT_MV transpose(mul(UNITY_MATRIX_I_M, UNITY_MATRIX_I_V))
#define UNITY_MATRIX_MVP mul(UNITY_MATRIX_VP, UNITY_MATRIX_M)
#define UNITY_PREV_MATRIX_M unity_MatrixPreviousM
#define UNITY_PREV_MATRIX_I_M unity_MatrixPreviousMI
#endif // UNITY_SHADER_VARIABLES_MATRIX_DEFS_LEGACY_UNITY_INCLUDED
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 0d85288be460c884bba7ec9ef5c6684d
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,12 @@
{
"name": "Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary",
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": []
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: de1079f91ae5b43499b7c7e4f1269884
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: