add mixbox for unity

This commit is contained in:
Ondrej Jamriska
2022-09-21 05:08:56 +02:00
parent fb1cd48e08
commit 4d1ef91f61
57 changed files with 6401 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 94751c8e8a8eee8418810170ed6644ac
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,103 @@
#ifndef MIXBOX_FUNCTIONS_INCLUDED
#define MIXBOX_FUNCTIONS_INCLUDED
#ifndef UNITY_COLORSPACE_GAMMA
#define MIXBOX_COLORSPACE_LINEAR
#endif
#define MIXBOX_LUT(UV) SAMPLE_TEXTURE2D_LOD(MixboxLUT.tex, MixboxLUT.samplerstate, UV, 0)
typedef float3x3 MixboxLatent;
float3 MixboxEvalPolynomial(float3 c)
{
float c0 = c[0];
float c1 = c[1];
float c2 = c[2];
float c3 = 1.0 - (c0 + c1 + c2);
float c00 = c0 * c0;
float c11 = c1 * c1;
float c22 = c2 * c2;
float c01 = c0 * c1;
float c02 = c0 * c2;
float c12 = c1 * c2;
float c33 = c3 * c3;
return (c0*c00) * float3(+0.07717053, +0.02826978, +0.24832992) +
(c1*c11) * float3(+0.95912302, +0.80256528, +0.03561839) +
(c2*c22) * float3(+0.74683774, +0.04868586, +0.00000000) +
(c3*c33) * float3(+0.99518138, +0.99978149, +0.99704802) +
(c00*c1) * float3(+0.04819146, +0.83363781, +0.32515377) +
(c01*c1) * float3(-0.68146950, +1.46107803, +1.06980936) +
(c00*c2) * float3(+0.27058419, -0.15324870, +1.98735057) +
(c02*c2) * float3(+0.80478189, +0.67093710, +0.18424500) +
(c00*c3) * float3(-0.35031003, +1.37855826, +3.68865000) +
(c0*c33) * float3(+1.05128046, +1.97815239, +2.82989073) +
(c11*c2) * float3(+3.21607125, +0.81270228, +1.03384539) +
(c1*c22) * float3(+2.78893374, +0.41565549, -0.04487295) +
(c11*c3) * float3(+3.02162577, +2.55374103, +0.32766114) +
(c1*c33) * float3(+2.95124691, +2.81201112, +1.17578442) +
(c22*c3) * float3(+2.82677043, +0.79933038, +1.81715262) +
(c2*c33) * float3(+2.99691099, +1.22593053, +1.80653661) +
(c01*c2) * float3(+1.87394106, +2.05027182, -0.29835996) +
(c01*c3) * float3(+2.56609566, +7.03428198, +0.62575374) +
(c02*c3) * float3(+4.08329484, -1.40408358, +2.14995522) +
(c12*c3) * float3(+6.00078678, +2.55552042, +1.90739502);
}
float3 MixboxSRGBToLinear(float3 rgb)
{
return (rgb >= 0.04045) ? pow((abs(rgb) + 0.055) / 1.055, 2.4) : rgb/12.92;
}
float3 MixboxLinearToSRGB(float3 rgb)
{
return (rgb >= 0.0031308) ? 1.055*pow(abs(rgb), 1.0/2.4) - 0.055 : 12.92*rgb;
}
MixboxLatent MixboxRGBToLatent(UnityTexture2D MixboxLUT,float3 rgb)
{
#ifdef MIXBOX_COLORSPACE_LINEAR
rgb = MixboxLinearToSRGB(saturate(rgb));
#else
rgb = saturate(rgb);
#endif
float x = rgb.r * 63.0;
float y = rgb.g * 63.0;
float z = rgb.b * 63.0;
float iz = floor(z);
float x0 = fmod(iz, 8.0) * 64.0;
float y0 = floor(iz / 8.0) * 64.0;
float x1 = fmod(iz + 1.0, 8.0) * 64.0;
float y1 = floor((iz + 1.0) / 8.0) * 64.0;
float2 uv0 = float2(x0 + x + 0.5, 512.0 - (y0 + y + 0.5)) / 512.0;
float2 uv1 = float2(x1 + x + 0.5, 512.0 - (y1 + y + 0.5)) / 512.0;
float3 c = lerp(MIXBOX_LUT(uv0).rgb, MIXBOX_LUT(uv1).rgb, z - iz);
return MixboxLatent(c, rgb - MixboxEvalPolynomial(c), 0.0, 0.0, 0.0);
}
float3 MixboxLatentToRGB(MixboxLatent latent)
{
float3 rgb = saturate(MixboxEvalPolynomial(latent[0]) + latent[1]);
#ifdef MIXBOX_COLORSPACE_LINEAR
return MixboxSRGBToLinear(rgb);
#else
return rgb;
#endif
}
void MixboxLerp_float(float4 A, float4 B, float T, UnityTexture2D MixboxLUT, out float4 Out)
{
Out = float4(MixboxLatentToRGB((1.0-T)*MixboxRGBToLatent(MixboxLUT, A.rgb) + T*MixboxRGBToLatent(MixboxLUT, B.rgb)), lerp(A.a, B.a, T));
}
#endif

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: cb159fec42c279547ac0aeb6aa800e61
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,619 @@
{
"m_SGVersion": 3,
"m_Type": "UnityEditor.ShaderGraph.GraphData",
"m_ObjectId": "cdf7407d587a4ca4bdb3b1c9c0514e3f",
"m_Properties": [
{
"m_Id": "11199b40178e4bfdabfc8980462cc32d"
},
{
"m_Id": "2bd2b8f5e97c4449a49bbb010dc38099"
},
{
"m_Id": "1fdb427e9c3c426586e388436306794c"
}
],
"m_Keywords": [],
"m_Dropdowns": [],
"m_CategoryData": [
{
"m_Id": "aa0270e37e694c84850e872cb02bb05b"
}
],
"m_Nodes": [
{
"m_Id": "d6c44a7d970e4bbb89d057e0287c7229"
},
{
"m_Id": "6d215c5b13de4fa59f8aa951085a2436"
},
{
"m_Id": "8e721ef9cdf14ca38f24ddc0f1cb3ec9"
},
{
"m_Id": "77e69188df04432f993c71f41c8e9d80"
},
{
"m_Id": "b23fbc667c274c1c8d8a7aab35f86159"
}
],
"m_GroupDatas": [],
"m_StickyNoteDatas": [],
"m_Edges": [
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "6d215c5b13de4fa59f8aa951085a2436"
},
"m_SlotId": 3
},
"m_InputSlot": {
"m_Node": {
"m_Id": "d6c44a7d970e4bbb89d057e0287c7229"
},
"m_SlotId": 1
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "77e69188df04432f993c71f41c8e9d80"
},
"m_SlotId": 0
},
"m_InputSlot": {
"m_Node": {
"m_Id": "6d215c5b13de4fa59f8aa951085a2436"
},
"m_SlotId": 1
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "8e721ef9cdf14ca38f24ddc0f1cb3ec9"
},
"m_SlotId": 0
},
"m_InputSlot": {
"m_Node": {
"m_Id": "6d215c5b13de4fa59f8aa951085a2436"
},
"m_SlotId": 0
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "b23fbc667c274c1c8d8a7aab35f86159"
},
"m_SlotId": 0
},
"m_InputSlot": {
"m_Node": {
"m_Id": "6d215c5b13de4fa59f8aa951085a2436"
},
"m_SlotId": 2
}
}
],
"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": "Sub Graphs",
"m_GraphPrecision": 1,
"m_PreviewMode": 0,
"m_OutputNode": {
"m_Id": "d6c44a7d970e4bbb89d057e0287c7229"
},
"m_ActiveTargets": []
}
{
"m_SGVersion": 3,
"m_Type": "UnityEditor.ShaderGraph.Internal.ColorShaderProperty",
"m_ObjectId": "11199b40178e4bfdabfc8980462cc32d",
"m_Guid": {
"m_GuidSerialized": "09cf5334-d845-42f8-9b26-ab94581aceb8"
},
"m_Name": "A",
"m_DefaultRefNameVersion": 1,
"m_RefNameGeneratedByDisplayName": "A",
"m_DefaultReferenceName": "_A",
"m_OverrideReferenceName": "",
"m_GeneratePropertyBlock": true,
"m_UseCustomSlotLabel": false,
"m_CustomSlotLabel": "",
"m_Precision": 0,
"overrideHLSLDeclaration": false,
"hlslDeclarationOverride": 0,
"m_Hidden": false,
"m_Value": {
"r": 0.0,
"g": 0.0,
"b": 0.0,
"a": 0.0
},
"isMainColor": false,
"m_ColorMode": 0
}
{
"m_SGVersion": 1,
"m_Type": "UnityEditor.ShaderGraph.Internal.Vector1ShaderProperty",
"m_ObjectId": "1fdb427e9c3c426586e388436306794c",
"m_Guid": {
"m_GuidSerialized": "e58bd6d6-6b39-41a9-8ea5-1cfff536735d"
},
"m_Name": "T",
"m_DefaultRefNameVersion": 1,
"m_RefNameGeneratedByDisplayName": "T",
"m_DefaultReferenceName": "_T",
"m_OverrideReferenceName": "",
"m_GeneratePropertyBlock": true,
"m_UseCustomSlotLabel": false,
"m_CustomSlotLabel": "",
"m_Precision": 0,
"overrideHLSLDeclaration": false,
"hlslDeclarationOverride": 0,
"m_Hidden": false,
"m_Value": 0.0,
"m_FloatType": 0,
"m_RangeValues": {
"x": 0.0,
"y": 1.0
}
}
{
"m_SGVersion": 3,
"m_Type": "UnityEditor.ShaderGraph.Internal.ColorShaderProperty",
"m_ObjectId": "2bd2b8f5e97c4449a49bbb010dc38099",
"m_Guid": {
"m_GuidSerialized": "393f5f87-e1b5-4bdf-bbd4-cefca1cbe5f3"
},
"m_Name": "B",
"m_DefaultRefNameVersion": 1,
"m_RefNameGeneratedByDisplayName": "B",
"m_DefaultReferenceName": "_B",
"m_OverrideReferenceName": "",
"m_GeneratePropertyBlock": true,
"m_UseCustomSlotLabel": false,
"m_CustomSlotLabel": "",
"m_Precision": 0,
"overrideHLSLDeclaration": false,
"hlslDeclarationOverride": 0,
"m_Hidden": false,
"m_Value": {
"r": 0.0,
"g": 0.0,
"b": 0.0,
"a": 0.0
},
"isMainColor": false,
"m_ColorMode": 0
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot",
"m_ObjectId": "2e8d66bc6e25463a939be8960a3f6820",
"m_Id": 0,
"m_DisplayName": "T",
"m_SlotType": 1,
"m_Hidden": false,
"m_ShaderOutputName": "Out",
"m_StageCapability": 3,
"m_Value": 0.0,
"m_DefaultValue": 0.0,
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Texture2DInputMaterialSlot",
"m_ObjectId": "36787d100abd4e0096a646873dfb91b9",
"m_Id": 4,
"m_DisplayName": "MixboxLUT",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "MixboxLUT",
"m_StageCapability": 3,
"m_BareResource": false,
"m_Texture": {
"m_SerializedTexture": "{\"texture\":{\"fileID\":2800000,\"guid\":\"9bb177930f1b0624ebcd9bdad8029652\",\"type\":3}}",
"m_Guid": ""
},
"m_DefaultType": 0
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
"m_ObjectId": "54cd54f3e62b424284755f0eb6cf13e1",
"m_Id": 0,
"m_DisplayName": "B",
"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.Vector4MaterialSlot",
"m_ObjectId": "56cb7828d34d4f35b6c36c350d3699ab",
"m_Id": 0,
"m_DisplayName": "A",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "A",
"m_StageCapability": 3,
"m_Value": {
"x": 1.0,
"y": 1.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.Vector1MaterialSlot",
"m_ObjectId": "5b18ca5037a64ba8b19e4c4e090d28b8",
"m_Id": 2,
"m_DisplayName": "T",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "T",
"m_StageCapability": 3,
"m_Value": 0.5,
"m_DefaultValue": 0.0,
"m_Labels": []
}
{
"m_SGVersion": 1,
"m_Type": "UnityEditor.ShaderGraph.CustomFunctionNode",
"m_ObjectId": "6d215c5b13de4fa59f8aa951085a2436",
"m_Group": {
"m_Id": ""
},
"m_Name": "MixboxLerp (Custom Function)",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": -219.0,
"y": -227.0,
"width": 222.0,
"height": 326.0
}
},
"m_Slots": [
{
"m_Id": "56cb7828d34d4f35b6c36c350d3699ab"
},
{
"m_Id": "87b7d4b5a2144d7780c5745a0352e150"
},
{
"m_Id": "5b18ca5037a64ba8b19e4c4e090d28b8"
},
{
"m_Id": "36787d100abd4e0096a646873dfb91b9"
},
{
"m_Id": "85828eb8f8c2448caabb64ad42ae0df1"
}
],
"synonyms": [
"code",
"HLSL"
],
"m_Precision": 1,
"m_PreviewExpanded": true,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_SourceType": 0,
"m_FunctionName": "MixboxLerp",
"m_FunctionSource": "cb159fec42c279547ac0aeb6aa800e61",
"m_FunctionBody": "Enter function body here..."
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.PropertyNode",
"m_ObjectId": "77e69188df04432f993c71f41c8e9d80",
"m_Group": {
"m_Id": ""
},
"m_Name": "Property",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": -358.0,
"y": -197.0,
"width": 85.0,
"height": 34.0
}
},
"m_Slots": [
{
"m_Id": "54cd54f3e62b424284755f0eb6cf13e1"
}
],
"synonyms": [],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_Property": {
"m_Id": "2bd2b8f5e97c4449a49bbb010dc38099"
}
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
"m_ObjectId": "83d97e9a8d9b4ceca1a3836ee0ca4b05",
"m_Id": 1,
"m_DisplayName": "Out",
"m_SlotType": 0,
"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.Vector4MaterialSlot",
"m_ObjectId": "85828eb8f8c2448caabb64ad42ae0df1",
"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_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
"m_ObjectId": "87b7d4b5a2144d7780c5745a0352e150",
"m_Id": 1,
"m_DisplayName": "B",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "B",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 1.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": "8e721ef9cdf14ca38f24ddc0f1cb3ec9",
"m_Group": {
"m_Id": ""
},
"m_Name": "Property",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": -358.0,
"y": -241.0,
"width": 85.0,
"height": 34.0
}
},
"m_Slots": [
{
"m_Id": "d51dfa18bb40402097f248c3f5741f61"
}
],
"synonyms": [],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_Property": {
"m_Id": "11199b40178e4bfdabfc8980462cc32d"
}
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.CategoryData",
"m_ObjectId": "aa0270e37e694c84850e872cb02bb05b",
"m_Name": "",
"m_ChildObjectList": [
{
"m_Id": "11199b40178e4bfdabfc8980462cc32d"
},
{
"m_Id": "2bd2b8f5e97c4449a49bbb010dc38099"
},
{
"m_Id": "1fdb427e9c3c426586e388436306794c"
}
]
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.PropertyNode",
"m_ObjectId": "b23fbc667c274c1c8d8a7aab35f86159",
"m_Group": {
"m_Id": ""
},
"m_Name": "Property",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": -357.0,
"y": -152.0,
"width": 83.0,
"height": 34.0
}
},
"m_Slots": [
{
"m_Id": "2e8d66bc6e25463a939be8960a3f6820"
}
],
"synonyms": [],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_Property": {
"m_Id": "1fdb427e9c3c426586e388436306794c"
}
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
"m_ObjectId": "d51dfa18bb40402097f248c3f5741f61",
"m_Id": 0,
"m_DisplayName": "A",
"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": "d6c44a7d970e4bbb89d057e0287c7229",
"m_Group": {
"m_Id": ""
},
"m_Name": "Output",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": 10.0,
"y": -227.0,
"width": 121.0,
"height": 77.0
}
},
"m_Slots": [
{
"m_Id": "83d97e9a8d9b4ceca1a3836ee0ca4b05"
}
],
"synonyms": [],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"IsFirstSlotValid": true
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: cea2d6a55fe1f64458be5f69a8bff761
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3}