wip: Ray mapping

This commit is contained in:
Alexandre Coirier
2026-05-31 01:11:58 +02:00
parent aa82cacd5c
commit d63ef70e48
3 changed files with 752 additions and 68 deletions
@@ -206,6 +206,21 @@
},
{
"m_Id": "7314b149200e4e82843feb2fb739b749"
},
{
"m_Id": "8c33db14052d44f58d122f6121da5b71"
},
{
"m_Id": "674cec991594498c8756bf3f89639441"
},
{
"m_Id": "45427f0cc3994257be048fc580e65bba"
},
{
"m_Id": "356ead80edae4fa8b208a5b477611142"
},
{
"m_Id": "2027158d1653482996678059362a1de2"
}
],
"m_GroupDatas": [
@@ -372,6 +387,20 @@
"m_SlotId": 0
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "2027158d1653482996678059362a1de2"
},
"m_SlotId": 0
},
"m_InputSlot": {
"m_Node": {
"m_Id": "8c33db14052d44f58d122f6121da5b71"
},
"m_SlotId": 12
}
},
{
"m_OutputSlot": {
"m_Node": {
@@ -442,6 +471,20 @@
"m_SlotId": 0
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "356ead80edae4fa8b208a5b477611142"
},
"m_SlotId": 0
},
"m_InputSlot": {
"m_Node": {
"m_Id": "8c33db14052d44f58d122f6121da5b71"
},
"m_SlotId": 13
}
},
{
"m_OutputSlot": {
"m_Node": {
@@ -568,6 +611,20 @@
"m_SlotId": 0
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "674cec991594498c8756bf3f89639441"
},
"m_SlotId": 0
},
"m_InputSlot": {
"m_Node": {
"m_Id": "8c33db14052d44f58d122f6121da5b71"
},
"m_SlotId": 4
}
},
{
"m_OutputSlot": {
"m_Node": {
@@ -638,20 +695,6 @@
"m_SlotId": 0
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "752c8292d95244b289fbdb9b42225f53"
},
"m_SlotId": 3
},
"m_InputSlot": {
"m_Node": {
"m_Id": "b761b7065b85432e9105a2bb9beb2779"
},
"m_SlotId": 0
}
},
{
"m_OutputSlot": {
"m_Node": {
@@ -680,6 +723,48 @@
"m_SlotId": 2
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "8c33db14052d44f58d122f6121da5b71"
},
"m_SlotId": 1
},
"m_InputSlot": {
"m_Node": {
"m_Id": "b682354e389942e09e8fc3e929e94907"
},
"m_SlotId": 0
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "8c33db14052d44f58d122f6121da5b71"
},
"m_SlotId": 3
},
"m_InputSlot": {
"m_Node": {
"m_Id": "45427f0cc3994257be048fc580e65bba"
},
"m_SlotId": 2
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "8c33db14052d44f58d122f6121da5b71"
},
"m_SlotId": 3
},
"m_InputSlot": {
"m_Node": {
"m_Id": "b761b7065b85432e9105a2bb9beb2779"
},
"m_SlotId": 0
}
},
{
"m_OutputSlot": {
"m_Node": {
@@ -1016,20 +1101,6 @@
"m_SlotId": 0
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "e12190bfe8584f2f8d8a5a42ccab9ae9"
},
"m_SlotId": 6
},
"m_InputSlot": {
"m_Node": {
"m_Id": "b682354e389942e09e8fc3e929e94907"
},
"m_SlotId": 0
}
},
{
"m_OutputSlot": {
"m_Node": {
@@ -1044,20 +1115,6 @@
"m_SlotId": 1
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "e20c097dee274898a3390cd3d9837420"
},
"m_SlotId": 3
},
"m_InputSlot": {
"m_Node": {
"m_Id": "dfd7a434c75d4317b4ec5650b710e565"
},
"m_SlotId": 0
}
},
{
"m_OutputSlot": {
"m_Node": {
@@ -1145,8 +1202,8 @@
],
"m_VertexContext": {
"m_Position": {
"x": 1080.0,
"y": -72.0
"x": 1906.0001220703125,
"y": -106.99996948242188
},
"m_Blocks": [
{
@@ -1162,8 +1219,8 @@
},
"m_FragmentContext": {
"m_Position": {
"x": 1080.0,
"y": 128.0
"x": 1906.0001220703125,
"y": 93.00000762939453
},
"m_Blocks": [
{
@@ -1383,6 +1440,31 @@
"m_LiteralMode": false
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
"m_ObjectId": "08e27e150e004f2f9c3bd1d66fdfa8f4",
"m_Id": 0,
"m_DisplayName": "RGBA",
"m_SlotType": 1,
"m_Hidden": false,
"m_ShaderOutputName": "RGBA",
"m_StageCapability": 2,
"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.MultiplyNode",
@@ -1561,6 +1643,29 @@
}
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot",
"m_ObjectId": "0ad976f39cdb4bc78db45e87a169cbf8",
"m_Id": 1,
"m_DisplayName": "Position",
"m_SlotType": 1,
"m_Hidden": false,
"m_ShaderOutputName": "Position",
"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.Vector1MaterialSlot",
@@ -2230,6 +2335,22 @@
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot",
"m_ObjectId": "192261403e4c4727b79f19242c8b9ad3",
"m_Id": 7,
"m_DisplayName": "A",
"m_SlotType": 1,
"m_Hidden": false,
"m_ShaderOutputName": "A",
"m_StageCapability": 2,
"m_Value": 0.0,
"m_DefaultValue": 0.0,
"m_Labels": [],
"m_LiteralMode": false
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot",
@@ -2342,6 +2463,42 @@
"m_LiteralMode": false
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.PropertyNode",
"m_ObjectId": "2027158d1653482996678059362a1de2",
"m_Group": {
"m_Id": ""
},
"m_Name": "Property",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": 1281.9998779296875,
"y": -204.99998474121095,
"width": 105.0,
"height": 34.0
}
},
"m_Slots": [
{
"m_Id": "a4cd5385a9ae42569ee81555e96ef74c"
}
],
"synonyms": [],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_Property": {
"m_Id": "f8301001f4f843788881d0078777ce68"
}
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.DynamicValueMaterialSlot",
@@ -2486,6 +2643,22 @@
"m_LiteralMode": false
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot",
"m_ObjectId": "21d45d62daf74c2aa6143c789698588c",
"m_Id": 6,
"m_DisplayName": "B",
"m_SlotType": 1,
"m_Hidden": false,
"m_ShaderOutputName": "B",
"m_StageCapability": 2,
"m_Value": 0.0,
"m_DefaultValue": 0.0,
"m_Labels": [],
"m_LiteralMode": false
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot",
@@ -3008,6 +3181,40 @@
"m_LiteralMode": false
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.ScreenPositionNode",
"m_ObjectId": "356ead80edae4fa8b208a5b477611142",
"m_Group": {
"m_Id": ""
},
"m_Name": "Screen Position",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": 1256.9998779296875,
"y": -0.000011444091796875,
"width": 145.0,
"height": 127.99998474121094
}
},
"m_Slots": [
{
"m_Id": "4f2c17ae65834541aed70ada554d5e65"
}
],
"synonyms": [],
"m_Precision": 0,
"m_PreviewExpanded": false,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_ScreenSpaceType": 0
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.PowerNode",
@@ -3047,6 +3254,19 @@
}
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.SamplerStateMaterialSlot",
"m_ObjectId": "38d8294fee7146508d624ea3b513ab31",
"m_Id": 3,
"m_DisplayName": "Sampler",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "Sampler",
"m_StageCapability": 3,
"m_BareResource": false
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.DynamicValueMaterialSlot",
@@ -3255,6 +3475,20 @@
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.BooleanMaterialSlot",
"m_ObjectId": "4087f03500c74575947fac907d28ba80",
"m_Id": 9,
"m_DisplayName": "Orthographic",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "Orthographic",
"m_StageCapability": 3,
"m_Value": false,
"m_DefaultValue": false
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot",
@@ -3353,6 +3587,66 @@
"m_LiteralMode": false
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.SampleTexture2DNode",
"m_ObjectId": "45427f0cc3994257be048fc580e65bba",
"m_Group": {
"m_Id": ""
},
"m_Name": "Sample Texture 2D",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": 1533.9998779296875,
"y": 325.0,
"width": 208.0,
"height": 432.99993896484377
}
},
"m_Slots": [
{
"m_Id": "08e27e150e004f2f9c3bd1d66fdfa8f4"
},
{
"m_Id": "72e39f090e2a401695cddc208d2b6715"
},
{
"m_Id": "f855c60d63ce493c916822f01cc0aa8c"
},
{
"m_Id": "21d45d62daf74c2aa6143c789698588c"
},
{
"m_Id": "192261403e4c4727b79f19242c8b9ad3"
},
{
"m_Id": "48378a56a612440fa98572181bbef00c"
},
{
"m_Id": "d4d263ad95a64d7bab2b59c02334ca1d"
},
{
"m_Id": "38d8294fee7146508d624ea3b513ab31"
}
],
"synonyms": [
"tex2d"
],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_TextureType": 0,
"m_NormalMapSpace": 0,
"m_EnableGlobalMipBias": true,
"m_MipSamplingMode": 0
}
{
"m_SGVersion": 1,
"m_Type": "UnityEditor.Rendering.Universal.ShaderGraph.UniversalTarget",
@@ -3379,6 +3673,24 @@
"m_SupportVFX": false
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Texture2DInputMaterialSlot",
"m_ObjectId": "48378a56a612440fa98572181bbef00c",
"m_Id": 1,
"m_DisplayName": "Texture",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "Texture",
"m_StageCapability": 3,
"m_BareResource": false,
"m_Texture": {
"m_SerializedTexture": "{\"texture\":{\"fileID\":2800000,\"guid\":\"dffef66376be4fa480fb02b19edbe903\",\"type\":3}}",
"m_Guid": ""
},
"m_DefaultType": 0
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
@@ -3662,6 +3974,31 @@
]
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
"m_ObjectId": "4f2c17ae65834541aed70ada554d5e65",
"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.DynamicValueMaterialSlot",
@@ -4454,8 +4791,8 @@
"m_ObjectId": "64c8b693f8f246429141bf72af10e2ee",
"m_Title": "Billboard",
"m_Position": {
"x": 114.99996948242188,
"y": -690.9999389648438
"x": 115.00003051757813,
"y": -691.0
}
}
@@ -4484,6 +4821,43 @@
"m_LiteralMode": false
}
{
"m_SGVersion": 1,
"m_Type": "UnityEditor.ShaderGraph.PositionNode",
"m_ObjectId": "674cec991594498c8756bf3f89639441",
"m_Group": {
"m_Id": ""
},
"m_Name": "Position",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": 1180.9998779296875,
"y": -153.99998474121095,
"width": 206.0,
"height": 129.99998474121095
}
},
"m_Slots": [
{
"m_Id": "8ca90b9f64714c4aa127830e7a49509e"
}
],
"synonyms": [
"location"
],
"m_Precision": 1,
"m_PreviewExpanded": false,
"m_DismissedVersion": 0,
"m_PreviewMode": 2,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_Space": 0,
"m_PositionSource": 1
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot",
@@ -4543,6 +4917,29 @@
}
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot",
"m_ObjectId": "6962c8bfbbf54b1b8108c2ccda854ecb",
"m_Id": 12,
"m_DisplayName": "Color",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "Color",
"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.DynamicVectorMaterialSlot",
@@ -4779,6 +5176,22 @@
"m_LiteralMode": false
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot",
"m_ObjectId": "72e39f090e2a401695cddc208d2b6715",
"m_Id": 4,
"m_DisplayName": "R",
"m_SlotType": 1,
"m_Hidden": false,
"m_ShaderOutputName": "R",
"m_StageCapability": 2,
"m_Value": 0.0,
"m_DefaultValue": 0.0,
"m_Labels": [],
"m_LiteralMode": false
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.ObjectNode",
@@ -4841,10 +5254,10 @@
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": 685.0,
"y": -81.0,
"x": 564.0000610351563,
"y": -59.00000762939453,
"width": 208.0,
"height": 326.0
"height": 326.0000305175781
}
},
"m_Slots": [
@@ -5715,6 +6128,62 @@
}
}
{
"m_SGVersion": 1,
"m_Type": "UnityEditor.ShaderGraph.CustomFunctionNode",
"m_ObjectId": "8c33db14052d44f58d122f6121da5b71",
"m_Group": {
"m_Id": ""
},
"m_Name": "Ray (Custom Function)",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": 1553.0001220703125,
"y": -81.00000762939453,
"width": 215.0,
"height": 166.0
}
},
"m_Slots": [
{
"m_Id": "6962c8bfbbf54b1b8108c2ccda854ecb"
},
{
"m_Id": "d85f7a35cf404fd2b6d9bd9391c30446"
},
{
"m_Id": "d931b95b4f614bd898b44d12da9c0c74"
},
{
"m_Id": "4087f03500c74575947fac907d28ba80"
},
{
"m_Id": "0ad976f39cdb4bc78db45e87a169cbf8"
},
{
"m_Id": "eda228c55b8e47fab8c2bfb3decc6a23"
}
],
"synonyms": [
"code",
"HLSL"
],
"m_Precision": 0,
"m_PreviewExpanded": false,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_SourceType": 0,
"m_FunctionName": "Ray",
"m_FunctionSource": "194cb86d87bce0942bac30e827885ac1",
"m_FunctionSourceUsePragmas": true,
"m_FunctionBody": "Enter function body here..."
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot",
@@ -5731,6 +6200,29 @@
"m_LiteralMode": false
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot",
"m_ObjectId": "8ca90b9f64714c4aa127830e7a49509e",
"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": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot",
@@ -6561,6 +7053,31 @@
"m_OutputChannel": 0
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
"m_ObjectId": "a4cd5385a9ae42569ee81555e96ef74c",
"m_Id": 0,
"m_DisplayName": "Color",
"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",
@@ -8069,6 +8586,28 @@
}
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.UVMaterialSlot",
"m_ObjectId": "d4d263ad95a64d7bab2b59c02334ca1d",
"m_Id": 2,
"m_DisplayName": "UV",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "UV",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0
},
"m_Labels": [],
"m_Channel": 0
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot",
@@ -8092,7 +8631,7 @@
"m_Title": "Random",
"m_Position": {
"x": -2910.000244140625,
"y": -235.0
"y": -235.00001525878907
}
}
@@ -8176,6 +8715,29 @@
"m_LiteralMode": false
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot",
"m_ObjectId": "d85f7a35cf404fd2b6d9bd9391c30446",
"m_Id": 4,
"m_DisplayName": "PositionOS",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "PositionOS",
"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.Vector1MaterialSlot",
@@ -8192,6 +8754,31 @@
"m_LiteralMode": false
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
"m_ObjectId": "d931b95b4f614bd898b44d12da9c0c74",
"m_Id": 13,
"m_DisplayName": "ScreenPos",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "ScreenPos",
"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.DynamicValueMaterialSlot",
@@ -8856,6 +9443,29 @@
}
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot",
"m_ObjectId": "eda228c55b8e47fab8c2bfb3decc6a23",
"m_Id": 3,
"m_DisplayName": "Output",
"m_SlotType": 1,
"m_Hidden": false,
"m_ShaderOutputName": "Output",
"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.SplitNode",
@@ -9142,6 +9752,22 @@
}
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot",
"m_ObjectId": "f855c60d63ce493c916822f01cc0aa8c",
"m_Id": 5,
"m_DisplayName": "G",
"m_SlotType": 1,
"m_Hidden": false,
"m_ShaderOutputName": "G",
"m_StageCapability": 2,
"m_Value": 0.0,
"m_DefaultValue": 0.0,
"m_Labels": [],
"m_LiteralMode": false
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot",
@@ -1,16 +1,74 @@
void Facing_float(float3 ObjectPos, float3 Origin, float3 InUp, uint Orthographic, out float3 FacingWorldPos, out float3 FacingObjectPos, out float3 Right, out float3 Up, out float3 Forward)
#include "Assets/_Content/Shaders/Include/Noises.hlsl"
float2 WorldToScreenUV(float3 posWS)
{
float3 origin = TransformObjectToWorld(float3(0, 0, 0));
float3 view = lerp(normalize(origin - _WorldSpaceCameraPos.xyz), GetViewForwardDir(), Orthographic);
float4 clip = TransformWorldToHClip(posWS);
float2 ndc = clip.xy / clip.w; // [-1, 1]
return ndc * .5 + .5; // [0, 1]
}
Up = normalize(InUp);
Right = normalize(cross(Up, view));
Forward = cross(Right, Up);
float3 GetBillboardPositionWS(float3 PositionOS, float3 PivotWS, float3 ViewDirWS)
{
float3 upWS = normalize(TransformObjectToWorldDir(float3(0, 1, 0)));
FacingWorldPos = Origin;
FacingWorldPos += ObjectPos.x * length(TransformObjectToWorld(float3(1, 0, 0)) - origin) * Right;
FacingWorldPos += ObjectPos.y * length(TransformObjectToWorld(float3(0, 1, 0)) - origin) * Up;
FacingWorldPos += ObjectPos.z * length(TransformObjectToWorld(float3(0, 0, 1)) - origin) * Forward;
float3 rightWS = cross(upWS, ViewDirWS);
FacingObjectPos = TransformWorldToObject(FacingWorldPos);
if (dot(rightWS, rightWS) < 1e-5)
rightWS = normalize(TransformObjectToWorldDir(float3(1, 0, 0)));
else
rightWS = normalize(rightWS);
float3 forwardWS = normalize(cross(rightWS, upWS));
return PivotWS + PositionOS.x * rightWS + PositionOS.y * upWS + PositionOS.z * forwardWS;
}
float3 ApplayerTaperAndScale(float3 PositionOS, float3 Scale)
{
float taper = lerp(Scale.z, 1, saturate(PositionOS.y));
float3 p = PositionOS;
p.xy *= Scale.xy;
p.x *= taper;
return p;
}
void Ray_float
(
float3 Color,
float3 PositionOS,
float4 ScreenPos,
uint Orthographic,
out float3 OutPosition,
out float3 OutColor
)
{
float3 pivot = TransformObjectToWorld(float3(0, 0, 0));
float3 scale = float3
(
length(TransformObjectToWorld(float3(1, 0, 0)) - pivot),
length(TransformObjectToWorld(float3(0, 1, 0)) - pivot),
length(TransformObjectToWorld(float3(0, 0, 1)) - pivot)
);
float3 viewDir = lerp(normalize(pivot - _WorldSpaceCameraPos.xyz), GetViewForwardDir(), Orthographic);
float3 pOS_0 = ApplayerTaperAndScale(PositionOS, scale);
float3 pOS_1 = ApplayerTaperAndScale(float3( .5, PositionOS.y, 0), scale);
float3 pOS_2 = ApplayerTaperAndScale(float3(-.5, PositionOS.y, 0), scale);
float3 pWS_0 = GetBillboardPositionWS(pOS_0, pivot, viewDir);
float3 pWS_1 = GetBillboardPositionWS(pOS_1, pivot, viewDir);
float3 pWS_2 = GetBillboardPositionWS(pOS_2, pivot, viewDir);
float2 pSC_0 = ScreenPos.xy;
float2 pSC_1 = WorldToScreenUV(pWS_1);
float2 pSC_2 = WorldToScreenUV(pWS_2);
float2 uv = float2(distance(pSC_0.x, pSC_2.x) / distance(pSC_1.x, pSC_2.x), pOS_0.y / scale.y);
OutPosition = TransformWorldToObject(pWS_0);
OutColor = float3(uv, 0);
}
Binary file not shown.