Adaug proiectul Unity

This commit is contained in:
2026-11-01 23:39:55 +02:00
parent cb14d9d37d
commit 863eac8f2c
23463 changed files with 5412601 additions and 0 deletions
@@ -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: