diff --git a/Layouts/Editor/LayoutPathEditor.cs b/Layouts/Editor/LayoutPathEditor.cs index 26a0125..e50c4ea 100644 --- a/Layouts/Editor/LayoutPathEditor.cs +++ b/Layouts/Editor/LayoutPathEditor.cs @@ -251,9 +251,9 @@ public override void OnInspectorGUI() GUILayout.Space(10); GUI.backgroundColor = new Color32(248, 200, 81, 255); GUILayout.Label("Import from Moose Procedural Rally stages", EditorStyles.boldLabel); - if (GUILayout.Button("Import road_data.bin")) + if (GUILayout.Button("Import spline.rsd")) { - var path = EditorUtility.OpenFilePanel("Select the road_data.bin file", "", "bin"); + var path = EditorUtility.OpenFilePanel("Select the spline.rsd file", "", "rsd"); if (path.Length != 0) { if (layoutPath.ImportMooseBin(path)) diff --git a/Layouts/LayoutPath.cs b/Layouts/LayoutPath.cs index 6982ebb..5f7a11c 100644 --- a/Layouts/LayoutPath.cs +++ b/Layouts/LayoutPath.cs @@ -374,6 +374,7 @@ public bool ImportMooseBin(string fileName) { points.Clear(); var b = new BinaryReader(File.Open(fileName, FileMode.Open)); + var version = b.ReadUInt32(); var numPoints = b.ReadUInt32(); for (var i = 0; i < numPoints; i++) { diff --git a/README.md b/README.md index ae6d913..172af0d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +### V1.8.0 - 2018/05/06 +- Moose import path; +- Shader update; + ### V1.7.0 - 2018/04/03 - Added semaphore lights system; diff --git a/Shaders/grs_PhysRoadv2.shader b/Shaders/grs_PhysRoadv2.shader index 3208c73..0dc258d 100644 --- a/Shaders/grs_PhysRoadv2.shader +++ b/Shaders/grs_PhysRoadv2.shader @@ -4,23 +4,23 @@ Shader "gRally/Phys Road v2" { Properties { - _AlbedowithSmoothnessMap("Albedo (with Smoothness Map)", 2D) = "black" {} - _Normalmap("Normal map", 2D) = "bump" {} - _RSpecGTransparencyBAOAWetMap("(R)Spec-(G)Transparency-(B)AO -(A)WetMap", 2D) = "white" {} + [NoScaleOffset]_AlbedowithSmoothnessMap("Albedo (with Smoothness Map)", 2D) = "black" {} + [NoScaleOffset]_Normalmap("Normal map", 2D) = "bump" {} + [NoScaleOffset]_RSpecGTransparencyBAOAWetMap("(R)Spec-(G)Transparency-(B)AO -(A)WetMap", 2D) = "white" {} _TilingMainTextures("Tiling Main Textures", Vector) = (1,1,0,0) _OffsetMainTextures("Offset Main Textures", Vector) = (0,0,0,0) - _Cutoff( "Mask Clip Value", Float ) = 0.5 + _UVMultipliers("Tiling Multipliers for far texture", Vector) = (1,0.2,0,0) + _TransitionDistance("Transition Distance (in meters)", Range( 1 , 150)) = 30 + _TransitionFalloff("Transition Falloff", Float) = 6 + _Cutoff( "Mask Clip Value", Float ) = 0.681 _GR_Displacement("_GR_Displacement", Range( 0 , 1)) = 1 _MaxDisplacementmeters("Max Displacement (meters)", Range( -1 , 0)) = 0 [Toggle]_UseGrooveTex("Use Groove Tex", Float) = 0 - _GrooveMap("GrooveMap", 2D) = "white" {} + [NoScaleOffset]_GrooveMap("GrooveMap", 2D) = "white" {} [Toggle]_UsePuddlesTexture("Use Puddles Texture", Float) = 0 - _PuddlesTexture("Puddles Texture", 2D) = "black" {} + [NoScaleOffset]_PuddlesTexture("Puddles Texture", 2D) = "black" {} _PuddlesSize("Puddles Size", Float) = 0 - _TransitionFalloff("Transition Falloff", Float) = 6 - _TransitionDistance("Transition Distance (in meters)", Range( 1 , 150)) = 30 - _UVMultipliers("Tiling Multipliers for far texture", Vector) = (1,0.2,0,0) - _PhysicalTexture("Physical Texture", 2D) = "white" {} + [NoScaleOffset]_PhysicalTexture("Physical Texture", 2D) = "white" {} [HideInInspector] _texcoord( "", 2D ) = "white" {} [HideInInspector] __dirty( "", Int ) = 1 } @@ -41,6 +41,8 @@ Shader "gRally/Phys Road v2" float4 vertexColor : COLOR; }; + uniform float _MaxDisplacementmeters; + uniform float _GR_Displacement; uniform sampler2D _RSpecGTransparencyBAOAWetMap; uniform float2 _TilingMainTextures; uniform float2 _OffsetMainTextures; @@ -51,18 +53,14 @@ Shader "gRally/Phys Road v2" uniform float _GR_WetSurf; uniform sampler2D _PuddlesTexture; uniform float _PuddlesSize; - uniform float _GR_Displacement; uniform sampler2D _Normalmap; uniform sampler2D _PhysicalTexture; - uniform float4 _PhysicalTexture_ST; uniform sampler2D _AlbedowithSmoothnessMap; uniform float _UseGrooveTex; uniform sampler2D _GrooveMap; - uniform float4 _GrooveMap_ST; uniform float _GR_Groove; uniform float _GR_PhysDebug; - uniform float _MaxDisplacementmeters; - uniform float _Cutoff = 0.5; + uniform float _Cutoff = 0.681; void vertexDataFunc( inout appdata_full v, out Input o ) { @@ -95,28 +93,29 @@ Shader "gRally/Phys Road v2" float smoothstepResult223 = smoothstep( clampResult227 , 1.01 , ( tex2DNode178.b * ( temp_output_177_0 * temp_output_173_0 ) )); float smoothstepResult224 = smoothstep( clampResult227 , 1.01 , ( tex2DNode178.a * ( temp_output_177_0 * temp_output_176_0 ) )); float4 appendResult237 = (float4(smoothstepResult221 , smoothstepResult222 , smoothstepResult223 , smoothstepResult224)); + float4 break240 = lerp(float4(0,0,0,0),appendResult237,_UsePuddlesTexture); float temp_output_234_0 = ( i.vertexColor.b * _GR_Displacement ); - float clampResult201 = clamp( ( lerpResult150 + lerp(float4(0,0,0,0),appendResult237,_UsePuddlesTexture).x + lerp(float4(0,0,0,0),appendResult237,_UsePuddlesTexture).y + lerp(float4(0,0,0,0),appendResult237,_UsePuddlesTexture).z + lerp(float4(0,0,0,0),appendResult237,_UsePuddlesTexture).w + temp_output_234_0 ) , 0 , 1 ); + float clampResult201 = clamp( ( lerpResult150 + break240.x + break240.y + break240.z + break240.w + temp_output_234_0 ) , 0 , 1 ); float temp_output_206_0 = ( clampResult201 * _GR_WetSurf ); float temp_output_81_0 = ( 1.0 - temp_output_206_0 ); float lerpResult208 = lerp( temp_output_81_0 , 0 , Transition210); float lerpResult209 = lerp( 0 , temp_output_81_0 , Transition210); o.Normal = BlendNormals( UnpackScaleNormal( tex2D( _Normalmap, UV_Texture212 ) ,lerpResult208 ) , UnpackScaleNormal( tex2D( _Normalmap, UV_Texture_Tiling_Mult215 ) ,lerpResult209 ) ); - float2 uv_PhysicalTexture = i.uv_texcoord * _PhysicalTexture_ST.xy + _PhysicalTexture_ST.zw; + float2 uv_PhysicalTexture71 = i.uv_texcoord; float4 tex2DNode1 = tex2D( _AlbedowithSmoothnessMap, UV_Texture212 ); float4 tex2DNode144 = tex2D( _AlbedowithSmoothnessMap, UV_Texture_Tiling_Mult215 ); float4 lerpResult145 = lerp( tex2DNode1 , tex2DNode144 , Transition210); float4 _Color0 = float4(0,0,0,0); - float2 uv_GrooveMap = i.uv_texcoord * _GrooveMap_ST.xy + _GrooveMap_ST.zw; + float2 uv_GrooveMap55 = i.uv_texcoord; float lerpResult64 = lerp( _Color0.g , i.vertexColor.g , _GR_Groove); - float4 lerpResult56 = lerp( lerpResult145 , ( lerp(_Color0,tex2D( _GrooveMap, uv_GrooveMap ),_UseGrooveTex) * lerpResult145 ) , lerpResult64); + float4 lerpResult56 = lerp( lerpResult145 , ( lerp(_Color0,tex2D( _GrooveMap, uv_GrooveMap55 ),_UseGrooveTex) * lerpResult145 ) , lerpResult64); float clampResult90 = clamp( ( 1.0 - _GR_WetSurf ) , 0.68 , 1 ); - float4 lerpResult83 = lerp( tex2D( _PhysicalTexture, uv_PhysicalTexture ) , ( lerpResult56 * clampResult90 ) , ( 1.0 - _GR_PhysDebug )); + float4 lerpResult83 = lerp( tex2D( _PhysicalTexture, uv_PhysicalTexture71 ) , ( lerpResult56 * clampResult90 ) , ( 1.0 - _GR_PhysDebug )); o.Albedo = lerpResult83.rgb; float lerpResult147 = lerp( tex2DNode3.r , tex2DNode146.r , Transition210); float clampResult47 = clamp( ( lerpResult147 + temp_output_206_0 ) , 0 , 1 ); - float3 temp_cast_5 = (clampResult47).xxx; - o.Specular = temp_cast_5; + float3 temp_cast_2 = (clampResult47).xxx; + o.Specular = temp_cast_2; float lerpResult143 = lerp( tex2DNode1.a , tex2DNode144.a , Transition210); float clampResult33 = clamp( ( ( lerpResult143 + temp_output_206_0 ) + ( _GR_WetSurf / 2 ) ) , 0 , 1 ); o.Smoothness = clampResult33; @@ -133,186 +132,186 @@ Shader "gRally/Phys Road v2" CustomEditor "ASEMaterialInspector" } /*ASEBEGIN -Version=14501 -1957;75;1762;925;4627.332;1882.862;1.865;True;True -Node;AmplifyShaderEditor.RangedFloatNode;165;-6992.537,613.2579;Float;False;Property;_PuddlesSize;Puddles Size;12;0;Create;True;0;0;0;0;0;0;1;FLOAT;0 +Version=15205 +2025;179;1732;729;2815.736;-1110.474;1;True;False Node;AmplifyShaderEditor.WorldPosInputsNode;164;-7008.547,202.1764;Float;False;0;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3 -Node;AmplifyShaderEditor.SimpleDivideOpNode;166;-6607.854,834.4611;Float;False;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 +Node;AmplifyShaderEditor.RangedFloatNode;165;-6992.537,613.2579;Float;False;Property;_PuddlesSize;Puddles Size;15;0;Create;True;0;0;False;0;0;2.62;0;0;0;1;FLOAT;0 Node;AmplifyShaderEditor.SimpleDivideOpNode;167;-6609.307,568.5803;Float;False;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 -Node;AmplifyShaderEditor.SimpleMultiplyOpNode;169;-6386.69,799.6981;Float;True;2;2;0;FLOAT;0.5;False;1;FLOAT;0.5;False;1;FLOAT;0 +Node;AmplifyShaderEditor.SimpleDivideOpNode;166;-6607.854,834.4611;Float;False;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.SimpleMultiplyOpNode;168;-6395.148,524.3087;Float;True;2;2;0;FLOAT;0;False;1;FLOAT;0.5;False;1;FLOAT;0 -Node;AmplifyShaderEditor.FractNode;171;-6172.316,525.9478;Float;True;1;0;FLOAT;0;False;1;FLOAT;0 +Node;AmplifyShaderEditor.SimpleMultiplyOpNode;169;-6386.69,799.6981;Float;True;2;2;0;FLOAT;0.5;False;1;FLOAT;0.5;False;1;FLOAT;0 +Node;AmplifyShaderEditor.RangedFloatNode;5;-2302.857,649.7941;Float;False;Global;_GR_WetSurf;_GR_WetSurf;6;0;Create;True;0;0;False;0;1;0;0;1;0;1;FLOAT;0 Node;AmplifyShaderEditor.FractNode;170;-6154.066,801.5233;Float;True;1;0;FLOAT;0;False;1;FLOAT;0 -Node;AmplifyShaderEditor.RangedFloatNode;5;-2302.857,649.7941;Float;False;Global;_GR_WetSurf;_GR_WetSurf;6;0;Create;True;0;1;0;0;1;0;1;FLOAT;0 -Node;AmplifyShaderEditor.StepOpNode;174;-5949.85,514.9988;Float;True;2;0;FLOAT;0.5;False;1;FLOAT;0.5;False;1;FLOAT;0 -Node;AmplifyShaderEditor.StepOpNode;173;-5937.076,798.848;Float;True;2;0;FLOAT;0.5;False;1;FLOAT;0.5;False;1;FLOAT;0 -Node;AmplifyShaderEditor.DynamicAppendNode;172;-6611.878,222.2662;Float;False;FLOAT2;4;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;0;False;1;FLOAT2;0 +Node;AmplifyShaderEditor.FractNode;171;-6172.316,525.9478;Float;True;1;0;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.RegisterLocalVarNode;219;-2012.595,829.7492;Float;False;WetSurf;-1;True;1;0;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.GetLocalVarNode;220;-4204.614,629.6141;Float;False;219;0;1;FLOAT;0 -Node;AmplifyShaderEditor.OneMinusNode;177;-5704.586,628.149;Float;False;1;0;FLOAT;0;False;1;FLOAT;0 -Node;AmplifyShaderEditor.OneMinusNode;176;-5690.516,923.798;Float;False;1;0;FLOAT;0;False;1;FLOAT;0 -Node;AmplifyShaderEditor.WorldPosInputsNode;133;-5790.179,-1434.743;Float;False;0;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3 +Node;AmplifyShaderEditor.DynamicAppendNode;172;-6611.878,222.2662;Float;False;FLOAT2;4;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;0;False;1;FLOAT2;0 +Node;AmplifyShaderEditor.StepOpNode;174;-5949.85,514.9988;Float;True;2;0;FLOAT;0.5;False;1;FLOAT;0.5;False;1;FLOAT;0 +Node;AmplifyShaderEditor.StepOpNode;173;-5937.076,798.848;Float;True;2;0;FLOAT;0.5;False;1;FLOAT;0.5;False;1;FLOAT;0 Node;AmplifyShaderEditor.WorldSpaceCameraPos;132;-5832.527,-1669.023;Float;False;0;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3 Node;AmplifyShaderEditor.OneMinusNode;231;-3997.205,632.2744;Float;False;1;0;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.SimpleDivideOpNode;175;-6041.869,284.7727;Float;False;2;0;FLOAT2;0,0;False;1;FLOAT;0;False;1;FLOAT2;0 -Node;AmplifyShaderEditor.SimpleMultiplyOpNode;184;-5150.248,585.4493;Float;True;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 -Node;AmplifyShaderEditor.SimpleMultiplyOpNode;179;-5137.473,1080.024;Float;True;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 -Node;AmplifyShaderEditor.RangedFloatNode;134;-5372.6,-1392.323;Float;False;Property;_TransitionDistance;Transition Distance (in meters);14;0;Create;False;0;30;30;1;150;0;1;FLOAT;0 -Node;AmplifyShaderEditor.SamplerNode;178;-5174.985,47.71904;Float;True;Property;_PuddlesTexture;Puddles Texture;11;0;Create;True;0;None;None;True;0;False;black;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 -Node;AmplifyShaderEditor.Vector2Node;153;-5283.106,-1899.414;Float;False;Property;_TilingMainTextures;Tiling Main Textures;3;0;Create;True;0;1,1;1,1;0;3;FLOAT2;0;FLOAT;1;FLOAT;2 -Node;AmplifyShaderEditor.DistanceOpNode;135;-5317.926,-1565.678;Float;False;2;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;1;FLOAT;0 -Node;AmplifyShaderEditor.Vector2Node;163;-5286.705,-1755.028;Float;False;Property;_OffsetMainTextures;Offset Main Textures;4;0;Create;True;0;0,0;0,0;0;3;FLOAT2;0;FLOAT;1;FLOAT;2 +Node;AmplifyShaderEditor.OneMinusNode;177;-5704.586,628.149;Float;False;1;0;FLOAT;0;False;1;FLOAT;0 +Node;AmplifyShaderEditor.OneMinusNode;176;-5690.516,923.798;Float;False;1;0;FLOAT;0;False;1;FLOAT;0 +Node;AmplifyShaderEditor.WorldPosInputsNode;133;-5790.179,-1434.743;Float;False;0;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3 Node;AmplifyShaderEditor.SimpleMultiplyOpNode;186;-5146.598,833.6492;Float;True;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 +Node;AmplifyShaderEditor.Vector2Node;163;-5286.705,-1755.028;Float;False;Property;_OffsetMainTextures;Offset Main Textures;4;0;Create;True;0;0;False;0;0,0;0,0;0;3;FLOAT2;0;FLOAT;1;FLOAT;2 Node;AmplifyShaderEditor.SimpleAddOpNode;226;-3816.756,618.5948;Float;False;2;2;0;FLOAT;0;False;1;FLOAT;0.2;False;1;FLOAT;0 +Node;AmplifyShaderEditor.SamplerNode;178;-5178.165,47.71904;Float;True;Property;_PuddlesTexture;Puddles Texture;14;1;[NoScaleOffset];Create;True;0;0;False;0;None;8483e227f8901524981c77e7d51489ca;True;0;False;black;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 Node;AmplifyShaderEditor.SimpleMultiplyOpNode;181;-5155.723,344.5507;Float;True;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 -Node;AmplifyShaderEditor.SimpleMultiplyOpNode;187;-4518.624,1098.315;Float;True;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 +Node;AmplifyShaderEditor.SimpleMultiplyOpNode;179;-5137.473,1080.024;Float;True;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 +Node;AmplifyShaderEditor.SimpleMultiplyOpNode;184;-5150.248,585.4493;Float;True;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 +Node;AmplifyShaderEditor.RangedFloatNode;134;-5372.6,-1392.323;Float;False;Property;_TransitionDistance;Transition Distance (in meters);6;0;Create;False;0;0;False;0;30;21.7;1;150;0;1;FLOAT;0 +Node;AmplifyShaderEditor.DistanceOpNode;135;-5317.926,-1565.678;Float;False;2;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;1;FLOAT;0 +Node;AmplifyShaderEditor.Vector2Node;153;-5283.106,-1899.414;Float;False;Property;_TilingMainTextures;Tiling Main Textures;3;0;Create;True;0;0;False;0;1,1;1,1;0;3;FLOAT2;0;FLOAT;1;FLOAT;2 +Node;AmplifyShaderEditor.SimpleDivideOpNode;137;-5046.72,-1562.203;Float;False;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 +Node;AmplifyShaderEditor.Vector2Node;139;-5040.537,-1222.318;Float;False;Property;_UVMultipliers;Tiling Multipliers for far texture;5;0;Create;False;0;0;False;0;1,0.2;1,0.2;0;3;FLOAT2;0;FLOAT;1;FLOAT;2 +Node;AmplifyShaderEditor.RangedFloatNode;136;-5037.748,-1379.923;Float;False;Property;_TransitionFalloff;Transition Falloff;7;0;Create;True;0;0;False;0;6;5.56;0;0;0;1;FLOAT;0 +Node;AmplifyShaderEditor.SimpleMultiplyOpNode;190;-4526.284,294.0146;Float;True;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.SimpleMultiplyOpNode;189;-4528.199,849.3636;Float;True;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 +Node;AmplifyShaderEditor.SimpleMultiplyOpNode;187;-4518.624,1098.315;Float;True;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.ClampOpNode;227;-3643.97,643.0301;Float;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;1;False;1;FLOAT;0 -Node;AmplifyShaderEditor.SimpleMultiplyOpNode;188;-4514.793,575.5182;Float;True;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.TextureCoordinatesNode;138;-4923.495,-1778.348;Float;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 -Node;AmplifyShaderEditor.Vector2Node;139;-5040.537,-1222.318;Float;False;Property;_UVMultipliers;Tiling Multipliers for far texture;15;0;Create;False;0;1,0.2;1,1;0;3;FLOAT2;0;FLOAT;1;FLOAT;2 -Node;AmplifyShaderEditor.SimpleDivideOpNode;137;-5046.72,-1562.203;Float;False;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 -Node;AmplifyShaderEditor.SimpleMultiplyOpNode;190;-4526.284,294.0146;Float;True;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 -Node;AmplifyShaderEditor.RangedFloatNode;136;-5037.748,-1379.923;Float;False;Property;_TransitionFalloff;Transition Falloff;13;0;Create;True;0;6;6;0;0;0;1;FLOAT;0 +Node;AmplifyShaderEditor.SimpleMultiplyOpNode;188;-4514.793,575.5182;Float;True;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 +Node;AmplifyShaderEditor.PowerNode;140;-4803.047,-1569.423;Float;False;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 +Node;AmplifyShaderEditor.SimpleMultiplyOpNode;141;-4500.752,-1386.244;Float;False;2;2;0;FLOAT2;0,0;False;1;FLOAT2;0,0;False;1;FLOAT2;0 +Node;AmplifyShaderEditor.SmoothstepOpNode;222;-3311.154,570.0542;Float;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;1.01;False;1;FLOAT;0 Node;AmplifyShaderEditor.SmoothstepOpNode;224;-3326.005,1152.129;Float;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;1.01;False;1;FLOAT;0 Node;AmplifyShaderEditor.SmoothstepOpNode;223;-3320.514,855.6691;Float;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;1.01;False;1;FLOAT;0 Node;AmplifyShaderEditor.SmoothstepOpNode;221;-3315.205,277.3891;Float;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;1.01;False;1;FLOAT;0 -Node;AmplifyShaderEditor.SmoothstepOpNode;222;-3311.154,570.0542;Float;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;1.01;False;1;FLOAT;0 -Node;AmplifyShaderEditor.PowerNode;140;-4803.047,-1569.423;Float;False;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 -Node;AmplifyShaderEditor.SimpleMultiplyOpNode;141;-4500.752,-1386.244;Float;False;2;2;0;FLOAT2;0,0;False;1;FLOAT2;0,0;False;1;FLOAT2;0 -Node;AmplifyShaderEditor.GetLocalVarNode;213;-3669.257,-1895.792;Float;False;212;0;1;FLOAT2;0 -Node;AmplifyShaderEditor.ClampOpNode;142;-4507.264,-1576.183;Float;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;1;False;1;FLOAT;0 -Node;AmplifyShaderEditor.DynamicAppendNode;237;-3101.623,153.8496;Float;False;FLOAT4;4;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;0;False;1;FLOAT4;0 -Node;AmplifyShaderEditor.RegisterLocalVarNode;215;-4289.954,-1240.724;Float;False;UV_Texture_Tiling_Mult;-1;True;1;0;FLOAT2;0,0;False;1;FLOAT2;0 Node;AmplifyShaderEditor.RegisterLocalVarNode;212;-4457.607,-1905.7;Float;False;UV_Texture;-1;True;1;0;FLOAT2;0,0;False;1;FLOAT2;0 -Node;AmplifyShaderEditor.ColorNode;235;-3332.974,18.22424;Float;False;Constant;_Color1;Color 1;7;0;Create;True;0;0,0,0,0;0,0,0,0;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 +Node;AmplifyShaderEditor.ColorNode;235;-3332.974,18.22424;Float;False;Constant;_Color1;Color 1;7;0;Create;True;0;0;False;0;0,0,0,0;0,0,0,0;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 Node;AmplifyShaderEditor.GetLocalVarNode;216;-3796.402,-1353.894;Float;False;215;0;1;FLOAT2;0 -Node;AmplifyShaderEditor.ToggleSwitchNode;236;-2954.214,88.86333;Float;False;Property;_UsePuddlesTexture;Use Puddles Texture;10;0;Create;True;0;0;2;0;FLOAT4;0,0,0,0;False;1;FLOAT4;0,0,0,0;False;1;FLOAT4;0 -Node;AmplifyShaderEditor.SamplerNode;146;-3420.286,-562.7644;Float;True;Property;_TextureSample1;Texture Sample 1;2;0;Create;True;0;None;None;True;0;False;white;Auto;False;Instance;3;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 -Node;AmplifyShaderEditor.RegisterLocalVarNode;210;-4240.485,-1584.492;Float;False;Transition;-1;True;1;0;FLOAT;0;False;1;FLOAT;0 -Node;AmplifyShaderEditor.RangedFloatNode;85;-2164.926,1609.144;Float;False;Property;_GR_Displacement;_GR_Displacement;6;0;Create;True;0;1;1;0;1;0;1;FLOAT;0 +Node;AmplifyShaderEditor.ClampOpNode;142;-4507.264,-1576.183;Float;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;1;False;1;FLOAT;0 +Node;AmplifyShaderEditor.GetLocalVarNode;213;-3669.257,-1895.792;Float;False;212;0;1;FLOAT2;0 +Node;AmplifyShaderEditor.RegisterLocalVarNode;215;-4289.954,-1240.724;Float;False;UV_Texture_Tiling_Mult;-1;True;1;0;FLOAT2;0,0;False;1;FLOAT2;0 +Node;AmplifyShaderEditor.DynamicAppendNode;237;-3101.623,153.8496;Float;False;FLOAT4;4;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;0;False;1;FLOAT4;0 Node;AmplifyShaderEditor.VertexColorNode;54;-2953.16,1022.339;Float;False;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 Node;AmplifyShaderEditor.GetLocalVarNode;211;-3642.492,-1018.123;Float;False;210;0;1;FLOAT;0 -Node;AmplifyShaderEditor.SamplerNode;3;-3185.404,-1176.127;Float;True;Property;_RSpecGTransparencyBAOAWetMap;(R)Spec-(G)Transparency-(B)AO -(A)WetMap;2;0;Create;True;0;None;15a93fc58d1cbe542baf37f04d88639a;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 -Node;AmplifyShaderEditor.SimpleMultiplyOpNode;234;-2523.104,787.9199;Float;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 +Node;AmplifyShaderEditor.RangedFloatNode;85;-2164.926,1609.144;Float;False;Property;_GR_Displacement;_GR_Displacement;9;0;Create;True;0;0;False;0;1;0;0;1;0;1;FLOAT;0 +Node;AmplifyShaderEditor.RegisterLocalVarNode;210;-4240.485,-1584.492;Float;False;Transition;-1;True;1;0;FLOAT;0;False;1;FLOAT;0 +Node;AmplifyShaderEditor.SamplerNode;146;-3420.286,-562.7644;Float;True;Property;_TextureSample1;Texture Sample 1;2;0;Create;True;0;0;False;0;None;None;True;0;False;white;Auto;False;Instance;3;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 +Node;AmplifyShaderEditor.ToggleSwitchNode;236;-2954.214,88.86333;Float;False;Property;_UsePuddlesTexture;Use Puddles Texture;13;0;Create;True;0;0;False;0;0;2;0;FLOAT4;0,0,0,0;False;1;FLOAT4;0,0,0,0;False;1;FLOAT4;0 +Node;AmplifyShaderEditor.SamplerNode;3;-3183.159,-1176.127;Float;True;Property;_RSpecGTransparencyBAOAWetMap;(R)Spec-(G)Transparency-(B)AO -(A)WetMap;2;1;[NoScaleOffset];Create;True;0;0;False;0;None;7e34e8ef173c161468fe09b5a26c9f01;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 Node;AmplifyShaderEditor.BreakToComponentsNode;240;-2677.082,106.4245;Float;False;FLOAT4;1;0;FLOAT4;0,0,0,0;False;16;FLOAT;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4;FLOAT;5;FLOAT;6;FLOAT;7;FLOAT;8;FLOAT;9;FLOAT;10;FLOAT;11;FLOAT;12;FLOAT;13;FLOAT;14;FLOAT;15 +Node;AmplifyShaderEditor.SimpleMultiplyOpNode;234;-2523.104,787.9199;Float;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.LerpOp;150;-2787.433,-188.9251;Float;True;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.SimpleAddOpNode;241;-2340.764,78.62479;Float;False;6;6;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;0;False;4;FLOAT;0;False;5;FLOAT;0;False;1;FLOAT;0 -Node;AmplifyShaderEditor.SamplerNode;55;-2418.818,-2344.473;Float;True;Property;_GrooveMap;GrooveMap;9;0;Create;True;0;None;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 +Node;AmplifyShaderEditor.SamplerNode;55;-2418.818,-2344.473;Float;True;Property;_GrooveMap;GrooveMap;12;1;[NoScaleOffset];Create;True;0;0;False;0;None;572078f7efe28924a996e6e0d35f816e;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 +Node;AmplifyShaderEditor.SamplerNode;1;-3182.482,-1968.898;Float;True;Property;_AlbedowithSmoothnessMap;Albedo (with Smoothness Map);0;1;[NoScaleOffset];Create;True;0;0;False;0;None;dd85de7f5163c2c4191e22573039696a;True;0;False;black;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 +Node;AmplifyShaderEditor.ColorNode;61;-2390.219,-2131.737;Float;False;Constant;_Color0;Color 0;7;0;Create;True;0;0;False;0;0,0,0,0;0,0,0,0;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 +Node;AmplifyShaderEditor.SamplerNode;144;-3227.768,-1657.504;Float;True;Property;_TextureSample0;Texture Sample 0;0;0;Create;True;0;0;False;0;None;None;True;0;False;white;Auto;False;Instance;1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 Node;AmplifyShaderEditor.ClampOpNode;201;-2095.796,155.2407;Float;True;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;1;False;1;FLOAT;0 -Node;AmplifyShaderEditor.ColorNode;61;-2390.219,-2131.737;Float;False;Constant;_Color0;Color 0;7;0;Create;True;0;0,0,0,0;0,0,0,0;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 -Node;AmplifyShaderEditor.SamplerNode;144;-3227.768,-1657.504;Float;True;Property;_TextureSample0;Texture Sample 0;0;0;Create;True;0;None;None;True;0;False;white;Auto;False;Instance;1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 -Node;AmplifyShaderEditor.SamplerNode;1;-3201.277,-1968.898;Float;True;Property;_AlbedowithSmoothnessMap;Albedo (with Smoothness Map);0;0;Create;True;0;None;17ed22243f1ca1740adf6980e3acc2b1;True;0;False;black;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 -Node;AmplifyShaderEditor.RangedFloatNode;62;-2414.646,-1935.935;Float;False;Global;_GR_Groove;_GR_Groove;8;0;Create;True;0;0;0;0;1;0;1;FLOAT;0 -Node;AmplifyShaderEditor.SimpleMultiplyOpNode;206;-1538.174,161.7106;Float;True;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 -Node;AmplifyShaderEditor.ToggleSwitchNode;70;-1891.137,-2222.358;Float;False;Property;_UseGrooveTex;Use Groove Tex;8;0;Create;True;0;0;2;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;1;COLOR;0 Node;AmplifyShaderEditor.LerpOp;145;-2744.86,-1821.597;Float;True;3;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;2;FLOAT;0;False;1;COLOR;0 -Node;AmplifyShaderEditor.GetLocalVarNode;217;-1281.975,-230.1949;Float;False;210;0;1;FLOAT;0 -Node;AmplifyShaderEditor.OneMinusNode;89;315.2041,-390.497;Float;False;1;0;FLOAT;0;False;1;FLOAT;0 +Node;AmplifyShaderEditor.RangedFloatNode;62;-2414.646,-1935.935;Float;False;Global;_GR_Groove;_GR_Groove;8;0;Create;True;0;0;False;0;0;0;0;1;0;1;FLOAT;0 +Node;AmplifyShaderEditor.ToggleSwitchNode;70;-1891.137,-2222.358;Float;False;Property;_UseGrooveTex;Use Groove Tex;11;0;Create;True;0;0;False;0;0;2;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;1;COLOR;0 +Node;AmplifyShaderEditor.SimpleMultiplyOpNode;206;-1538.174,161.7106;Float;True;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 +Node;AmplifyShaderEditor.LerpOp;64;-1677.147,-2042.375;Float;True;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.SimpleMultiplyOpNode;66;-1603.039,-2204.064;Float;False;2;2;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;1;COLOR;0 +Node;AmplifyShaderEditor.GetLocalVarNode;217;-1281.975,-230.1949;Float;False;210;0;1;FLOAT;0 Node;AmplifyShaderEditor.OneMinusNode;81;-1244.742,-65.67212;Float;False;1;0;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.LerpOp;143;-2752.141,-1532.748;Float;True;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;1;FLOAT;0 -Node;AmplifyShaderEditor.LerpOp;64;-1677.147,-2042.375;Float;True;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;1;FLOAT;0 -Node;AmplifyShaderEditor.LerpOp;208;-919.4467,-395.8791;Float;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;1;FLOAT;0 +Node;AmplifyShaderEditor.OneMinusNode;89;315.2041,-390.497;Float;False;1;0;FLOAT;0;False;1;FLOAT;0 +Node;AmplifyShaderEditor.GetLocalVarNode;218;-921.1132,-190.3044;Float;False;215;0;1;FLOAT2;0 +Node;AmplifyShaderEditor.SimpleDivideOpNode;48;-1167.691,731.4235;Float;False;2;0;FLOAT;0;False;1;FLOAT;2;False;1;FLOAT;0 Node;AmplifyShaderEditor.LerpOp;209;-856.5331,-68.24269;Float;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;1;FLOAT;0 -Node;AmplifyShaderEditor.LerpOp;147;-2608.805,-1142.354;Float;True;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.GetLocalVarNode;214;-928.8777,-526.6465;Float;False;212;0;1;FLOAT2;0 -Node;AmplifyShaderEditor.ClampOpNode;90;562.4168,-419.9025;Float;False;3;0;FLOAT;0;False;1;FLOAT;0.68;False;2;FLOAT;1;False;1;FLOAT;0 Node;AmplifyShaderEditor.SimpleAddOpNode;7;-794.4315,631.7591;Float;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 -Node;AmplifyShaderEditor.RangedFloatNode;82;776.6593,-708.5289;Float;False;Global;_GR_PhysDebug;_GR_PhysDebug;6;0;Create;True;0;1;0;0;1;0;1;FLOAT;0 +Node;AmplifyShaderEditor.LerpOp;208;-919.4467,-395.8791;Float;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;1;FLOAT;0 +Node;AmplifyShaderEditor.RangedFloatNode;82;776.6593,-708.5289;Float;False;Global;_GR_PhysDebug;_GR_PhysDebug;6;0;Create;True;0;0;False;0;1;0;0;1;0;1;FLOAT;0 +Node;AmplifyShaderEditor.ClampOpNode;90;562.4168,-419.9025;Float;False;3;0;FLOAT;0;False;1;FLOAT;0.68;False;2;FLOAT;1;False;1;FLOAT;0 +Node;AmplifyShaderEditor.LerpOp;147;-2608.805,-1142.354;Float;True;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.LerpOp;56;-1165.73,-1875.159;Float;False;3;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;2;FLOAT;0;False;1;COLOR;0 -Node;AmplifyShaderEditor.SimpleDivideOpNode;48;-1167.691,731.4235;Float;False;2;0;FLOAT;0;False;1;FLOAT;2;False;1;FLOAT;0 -Node;AmplifyShaderEditor.GetLocalVarNode;218;-921.1132,-190.3044;Float;False;215;0;1;FLOAT2;0 -Node;AmplifyShaderEditor.SamplerNode;151;-561.0124,-220.53;Float;True;Property;_TextureSample2;Texture Sample 2;1;0;Create;True;0;None;None;True;0;True;bump;Auto;True;Instance;2;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 -Node;AmplifyShaderEditor.RangedFloatNode;52;-2219.487,1436.445;Float;False;Property;_MaxDisplacementmeters;Max Displacement (meters);7;0;Create;True;0;0;0;-1;0;0;1;FLOAT;0 +Node;AmplifyShaderEditor.SimpleMultiplyOpNode;88;762.0712,-464.5163;Float;False;2;2;0;COLOR;0,0,0,0;False;1;FLOAT;0;False;1;COLOR;0 +Node;AmplifyShaderEditor.RangedFloatNode;52;-2219.487,1436.445;Float;False;Property;_MaxDisplacementmeters;Max Displacement (meters);10;0;Create;True;0;0;False;0;0;-0.924;-1;0;0;1;FLOAT;0 Node;AmplifyShaderEditor.SimpleAddOpNode;25;-479.8809,181.0737;Float;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 -Node;AmplifyShaderEditor.SamplerNode;71;269.7823,-763.9866;Float;True;Property;_PhysicalTexture;Physical Texture;16;0;Create;True;0;None;0740c06b11e06e84a987525be2de5b90;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 -Node;AmplifyShaderEditor.SamplerNode;2;-560.7631,-493.5752;Float;True;Property;_Normalmap;Normal map;1;0;Create;True;0;None;d11c354bc9269ce4db49bab60df8c2d2;True;0;True;bump;Auto;True;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 +Node;AmplifyShaderEditor.SamplerNode;151;-561.0124,-220.53;Float;True;Property;_TextureSample2;Texture Sample 2;1;0;Create;True;0;0;False;0;None;None;True;0;True;bump;Auto;True;Instance;2;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 +Node;AmplifyShaderEditor.NormalVertexDataNode;50;-1423.484,1271.131;Float;False;0;5;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 +Node;AmplifyShaderEditor.SimpleAddOpNode;34;-504.8837,608.61;Float;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.OneMinusNode;84;1074.568,-612.0295;Float;False;1;0;FLOAT;0;False;1;FLOAT;0 +Node;AmplifyShaderEditor.SamplerNode;71;261.6223,-763.9866;Float;True;Property;_PhysicalTexture;Physical Texture;16;1;[NoScaleOffset];Create;True;0;0;False;0;None;81f56c8c35fbe5947ae76e975e98b7d9;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 +Node;AmplifyShaderEditor.SamplerNode;2;-560.7631,-493.5752;Float;True;Property;_Normalmap;Normal map;1;1;[NoScaleOffset];Create;True;0;0;False;0;None;8e3229242cae297439c5d810b71cb074;True;0;True;bump;Auto;True;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 Node;AmplifyShaderEditor.LerpOp;149;-2583.204,-517.7145;Float;True;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;1;FLOAT;0 -Node;AmplifyShaderEditor.SimpleAddOpNode;34;-504.8837,608.61;Float;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 -Node;AmplifyShaderEditor.NormalVertexDataNode;50;-1423.484,1271.131;Float;False;0;5;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 -Node;AmplifyShaderEditor.SimpleMultiplyOpNode;88;762.0712,-464.5163;Float;False;2;2;0;COLOR;0,0,0,0;False;1;FLOAT;0;False;1;COLOR;0 -Node;AmplifyShaderEditor.LerpOp;83;1182.659,-517.5289;Float;False;3;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;2;FLOAT;0;False;1;COLOR;0 +Node;AmplifyShaderEditor.ClampOpNode;33;-170.5482,374.7318;Float;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;1;False;1;FLOAT;0 Node;AmplifyShaderEditor.SimpleAddOpNode;77;-1335.746,575.8272;Float;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0 -Node;AmplifyShaderEditor.BlendNormalsNode;207;-108.9855,-364.1339;Float;True;2;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;1;FLOAT3;0 -Node;AmplifyShaderEditor.LerpOp;148;-2601.124,-850.5142;Float;True;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;1;FLOAT;0 -Node;AmplifyShaderEditor.SimpleMultiplyOpNode;195;-6090.462,160.4864;Float;False;2;2;0;FLOAT2;0,0;False;1;FLOAT;0;False;1;FLOAT2;0 +Node;AmplifyShaderEditor.LerpOp;83;1182.659,-517.5289;Float;False;3;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;2;FLOAT;0;False;1;COLOR;0 +Node;AmplifyShaderEditor.BlendNormalsNode;207;-108.9855,-364.1339;Float;True;0;3;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;1;FLOAT3;0 +Node;AmplifyShaderEditor.ClampOpNode;47;-176.1671,111.7834;Float;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;1;False;1;FLOAT;0 Node;AmplifyShaderEditor.SimpleAddOpNode;200;-2342.544,371.1309;Float;False;6;6;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;0;False;4;FLOAT;0;False;5;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.SimpleMultiplyOpNode;51;-854.2187,1285.561;Float;True;4;4;0;FLOAT;0;False;1;FLOAT3;0,0,0;False;2;FLOAT;0;False;3;FLOAT;0;False;1;FLOAT3;0 -Node;AmplifyShaderEditor.ClampOpNode;33;-170.5482,374.7318;Float;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;1;False;1;FLOAT;0 -Node;AmplifyShaderEditor.ClampOpNode;47;-176.1671,111.7834;Float;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;1;False;1;FLOAT;0 -Node;AmplifyShaderEditor.StandardSurfaceOutputNode;0;1609.576,58.40502;Float;False;True;6;Float;ASEMaterialInspector;0;0;StandardSpecular;gRally/Phys Road v2;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;Back;0;0;False;0;0;False;0;Custom;0.5;True;True;0;True;Transparent;;Geometry;All;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;False;0;255;255;0;0;0;0;0;0;0;0;False;0;20;3;10;False;0.5;True;0;Zero;Zero;0;Zero;Zero;Add;Add;0;False;0;0,0,0,0;VertexOffset;True;False;Cylindrical;False;Relative;0;;5;-1;-1;-1;0;0;0;False;0;0;16;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;3;FLOAT3;0,0,0;False;4;FLOAT;0;False;5;FLOAT;0;False;6;FLOAT3;0,0,0;False;7;FLOAT3;0,0,0;False;8;FLOAT;0;False;9;FLOAT;0;False;10;FLOAT;0;False;13;FLOAT3;0,0,0;False;11;FLOAT3;0,0,0;False;12;FLOAT3;0,0,0;False;14;FLOAT4;0,0,0,0;False;15;FLOAT3;0,0,0;False;0 -WireConnection;166;0;164;3 -WireConnection;166;1;165;0 +Node;AmplifyShaderEditor.SimpleMultiplyOpNode;195;-6090.462,160.4864;Float;False;2;2;0;FLOAT2;0,0;False;1;FLOAT;0;False;1;FLOAT2;0 +Node;AmplifyShaderEditor.LerpOp;148;-2601.124,-850.5142;Float;True;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;1;FLOAT;0 +Node;AmplifyShaderEditor.StandardSurfaceOutputNode;0;1631.336,61.58502;Float;False;True;6;Float;ASEMaterialInspector;0;0;StandardSpecular;gRally/Phys Road v2;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;Back;0;False;-1;0;False;-1;False;0;0;False;0;Custom;0.681;True;True;0;True;Transparent;;Geometry;All;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;0;False;-1;False;0;False;-1;255;False;-1;255;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;False;0;20;3;10;False;0.5;True;0;0;False;-1;0;False;-1;0;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;0;0,0,0,0;VertexOffset;True;False;Cylindrical;False;Relative;0;;8;-1;-1;-1;0;0;0;False;0;0;0;False;-1;-1;0;False;-1;16;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;3;FLOAT3;0,0,0;False;4;FLOAT;0;False;5;FLOAT;0;False;6;FLOAT3;0,0,0;False;7;FLOAT3;0,0,0;False;8;FLOAT;0;False;9;FLOAT;0;False;10;FLOAT;0;False;13;FLOAT3;0,0,0;False;11;FLOAT3;0,0,0;False;12;FLOAT3;0,0,0;False;14;FLOAT4;0,0,0,0;False;15;FLOAT3;0,0,0;False;0 WireConnection;167;0;164;1 WireConnection;167;1;165;0 -WireConnection;169;0;166;0 +WireConnection;166;0;164;3 +WireConnection;166;1;165;0 WireConnection;168;0;167;0 -WireConnection;171;0;168;0 +WireConnection;169;0;166;0 WireConnection;170;0;169;0 -WireConnection;174;0;171;0 -WireConnection;173;0;170;0 +WireConnection;171;0;168;0 +WireConnection;219;0;5;0 WireConnection;172;0;164;1 WireConnection;172;1;164;3 -WireConnection;219;0;5;0 -WireConnection;177;0;174;0 -WireConnection;176;0;173;0 +WireConnection;174;0;171;0 +WireConnection;173;0;170;0 WireConnection;231;0;220;0 WireConnection;175;0;172;0 WireConnection;175;1;165;0 -WireConnection;184;0;174;0 -WireConnection;184;1;176;0 -WireConnection;179;0;177;0 -WireConnection;179;1;176;0 -WireConnection;178;1;175;0 -WireConnection;135;0;132;0 -WireConnection;135;1;133;0 +WireConnection;177;0;174;0 +WireConnection;176;0;173;0 WireConnection;186;0;177;0 WireConnection;186;1;173;0 WireConnection;226;0;231;0 +WireConnection;178;1;175;0 WireConnection;181;0;174;0 WireConnection;181;1;173;0 -WireConnection;187;0;178;4 -WireConnection;187;1;179;0 +WireConnection;179;0;177;0 +WireConnection;179;1;176;0 +WireConnection;184;0;174;0 +WireConnection;184;1;176;0 +WireConnection;135;0;132;0 +WireConnection;135;1;133;0 +WireConnection;137;0;135;0 +WireConnection;137;1;134;0 +WireConnection;190;0;178;1 +WireConnection;190;1;181;0 WireConnection;189;0;178;3 WireConnection;189;1;186;0 +WireConnection;187;0;178;4 +WireConnection;187;1;179;0 WireConnection;227;0;226;0 -WireConnection;188;0;178;2 -WireConnection;188;1;184;0 WireConnection;138;0;153;0 WireConnection;138;1;163;0 -WireConnection;137;0;135;0 -WireConnection;137;1;134;0 -WireConnection;190;0;178;1 -WireConnection;190;1;181;0 +WireConnection;188;0;178;2 +WireConnection;188;1;184;0 +WireConnection;140;0;137;0 +WireConnection;140;1;136;0 +WireConnection;141;0;138;0 +WireConnection;141;1;139;0 +WireConnection;222;0;188;0 +WireConnection;222;1;227;0 WireConnection;224;0;187;0 WireConnection;224;1;227;0 WireConnection;223;0;189;0 WireConnection;223;1;227;0 WireConnection;221;0;190;0 WireConnection;221;1;227;0 -WireConnection;222;0;188;0 -WireConnection;222;1;227;0 -WireConnection;140;0;137;0 -WireConnection;140;1;136;0 -WireConnection;141;0;138;0 -WireConnection;141;1;139;0 +WireConnection;212;0;138;0 WireConnection;142;0;140;0 +WireConnection;215;0;141;0 WireConnection;237;0;221;0 WireConnection;237;1;222;0 WireConnection;237;2;223;0 WireConnection;237;3;224;0 -WireConnection;215;0;141;0 -WireConnection;212;0;138;0 +WireConnection;210;0;142;0 +WireConnection;146;1;216;0 WireConnection;236;0;235;0 WireConnection;236;1;237;0 -WireConnection;146;1;216;0 -WireConnection;210;0;142;0 WireConnection;3;1;213;0 +WireConnection;240;0;236;0 WireConnection;234;0;54;3 WireConnection;234;1;85;0 -WireConnection;240;0;236;0 WireConnection;150;0;3;4 WireConnection;150;1;146;4 WireConnection;150;2;211;0 @@ -322,66 +321,63 @@ WireConnection;241;2;240;1 WireConnection;241;3;240;2 WireConnection;241;4;240;3 WireConnection;241;5;234;0 -WireConnection;201;0;241;0 -WireConnection;144;1;216;0 WireConnection;1;1;213;0 -WireConnection;206;0;201;0 -WireConnection;206;1;5;0 -WireConnection;70;0;61;0 -WireConnection;70;1;55;0 +WireConnection;144;1;216;0 +WireConnection;201;0;241;0 WireConnection;145;0;1;0 WireConnection;145;1;144;0 WireConnection;145;2;211;0 -WireConnection;89;0;5;0 +WireConnection;70;0;61;0 +WireConnection;70;1;55;0 +WireConnection;206;0;201;0 +WireConnection;206;1;5;0 +WireConnection;64;0;61;2 +WireConnection;64;1;54;2 +WireConnection;64;2;62;0 WireConnection;66;0;70;0 WireConnection;66;1;145;0 WireConnection;81;0;206;0 WireConnection;143;0;1;4 WireConnection;143;1;144;4 WireConnection;143;2;211;0 -WireConnection;64;0;61;2 -WireConnection;64;1;54;2 -WireConnection;64;2;62;0 -WireConnection;208;0;81;0 -WireConnection;208;2;217;0 +WireConnection;89;0;5;0 +WireConnection;48;0;5;0 WireConnection;209;1;81;0 WireConnection;209;2;217;0 +WireConnection;7;0;143;0 +WireConnection;7;1;206;0 +WireConnection;208;0;81;0 +WireConnection;208;2;217;0 +WireConnection;90;0;89;0 WireConnection;147;0;3;1 WireConnection;147;1;146;1 WireConnection;147;2;211;0 -WireConnection;90;0;89;0 -WireConnection;7;0;143;0 -WireConnection;7;1;206;0 WireConnection;56;0;145;0 WireConnection;56;1;66;0 WireConnection;56;2;64;0 -WireConnection;48;0;5;0 -WireConnection;151;1;218;0 -WireConnection;151;5;209;0 +WireConnection;88;0;56;0 +WireConnection;88;1;90;0 WireConnection;25;0;147;0 WireConnection;25;1;206;0 +WireConnection;151;1;218;0 +WireConnection;151;5;209;0 +WireConnection;34;0;7;0 +WireConnection;34;1;48;0 +WireConnection;84;0;82;0 WireConnection;2;1;214;0 WireConnection;2;5;208;0 -WireConnection;84;0;82;0 WireConnection;149;0;3;3 WireConnection;149;1;146;3 WireConnection;149;2;211;0 -WireConnection;34;0;7;0 -WireConnection;34;1;48;0 -WireConnection;88;0;56;0 -WireConnection;88;1;90;0 +WireConnection;33;0;34;0 +WireConnection;77;0;149;0 +WireConnection;77;1;5;0 WireConnection;83;0;71;0 WireConnection;83;1;88;0 WireConnection;83;2;84;0 -WireConnection;77;0;149;0 -WireConnection;77;1;5;0 WireConnection;207;0;2;0 WireConnection;207;1;151;0 -WireConnection;148;0;3;2 -WireConnection;148;1;146;2 -WireConnection;148;2;211;0 -WireConnection;195;0;172;0 -WireConnection;195;1;165;0 +WireConnection;47;0;25;0 WireConnection;200;0;150;0 WireConnection;200;1;221;0 WireConnection;200;2;222;0 @@ -392,8 +388,11 @@ WireConnection;51;0;54;3 WireConnection;51;1;50;0 WireConnection;51;2;52;0 WireConnection;51;3;85;0 -WireConnection;33;0;34;0 -WireConnection;47;0;25;0 +WireConnection;195;0;172;0 +WireConnection;195;1;165;0 +WireConnection;148;0;3;2 +WireConnection;148;1;146;2 +WireConnection;148;2;211;0 WireConnection;0;0;83;0 WireConnection;0;1;207;0 WireConnection;0;3;47;0 @@ -402,4 +401,4 @@ WireConnection;0;5;77;0 WireConnection;0;10;148;0 WireConnection;0;11;51;0 ASEEND*/ -//CHKSM=58E797A9753CCB96CA4D8D350EBF78B4E4A2BDF4 \ No newline at end of file +//CHKSM=5ECCCB2CFAF61CBE3CAFA978F872296A66FA62E7 \ No newline at end of file diff --git a/VertexPaint.meta b/VertexPaint.meta deleted file mode 100644 index d7ec687..0000000 --- a/VertexPaint.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 8fdf5e28f5329454c947fc543b44438b -folderAsset: yes -timeCreated: 1470478091 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/VertexPaint/Editor.meta b/VertexPaint/Editor.meta deleted file mode 100644 index d11e1b8..0000000 --- a/VertexPaint/Editor.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 6f1e25360b608544698662a2f19ab579 -folderAsset: yes -timeCreated: 1470478091 -licenseType: Free -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/VertexPaint/Editor/ColorSwatches.cs b/VertexPaint/Editor/ColorSwatches.cs deleted file mode 100644 index 456fae5..0000000 --- a/VertexPaint/Editor/ColorSwatches.cs +++ /dev/null @@ -1,13 +0,0 @@ -using UnityEngine; -using System.Collections; - -namespace JBooth.VertexPainterPro -{ - [System.Serializable] - class ColorSwatches : ScriptableObject - { - public Color[] colors = new Color[] { Color.white, Color.black, Color.red, Color.green, Color.blue, Color.cyan, - Color.magenta, Color.yellow, Color.gray, Color.gray, Color.gray, Color.gray, Color.gray, Color.gray, Color.gray, Color.gray - }; - } -} \ No newline at end of file diff --git a/VertexPaint/Editor/ColorSwatches.cs.meta b/VertexPaint/Editor/ColorSwatches.cs.meta deleted file mode 100644 index 4cf7f28..0000000 --- a/VertexPaint/Editor/ColorSwatches.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: ee0d406915771418b89411f7e359a7cd -timeCreated: 1459565652 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VertexPaint/Editor/RxLookingGlass.cs b/VertexPaint/Editor/RxLookingGlass.cs deleted file mode 100644 index d902bf0..0000000 --- a/VertexPaint/Editor/RxLookingGlass.cs +++ /dev/null @@ -1,38 +0,0 @@ -using UnityEngine; -using UnityEditor; -using System.Collections; -using System; -using System.Linq; -using System.Reflection; - -// https://gist.github.com/MattRix/9205bc62d558fef98045 -namespace JBooth.VertexPainterPro -{ - [InitializeOnLoad] - public class RXLookingGlass - { - public static Type type_HandleUtility; - protected static MethodInfo meth_IntersectRayMesh; - - static RXLookingGlass() - { - var editorTypes = typeof(Editor).Assembly.GetTypes(); - - type_HandleUtility = editorTypes.FirstOrDefault(t => t.Name == "HandleUtility"); - meth_IntersectRayMesh = type_HandleUtility.GetMethod("IntersectRayMesh",(BindingFlags.Static | BindingFlags.NonPublic)); - } - - public static bool IntersectRayMesh(Ray ray, MeshFilter meshFilter, out RaycastHit hit) - { - return IntersectRayMesh(ray,meshFilter.sharedMesh,meshFilter.transform.localToWorldMatrix,out hit); - } - - public static bool IntersectRayMesh(Ray ray, Mesh mesh, Matrix4x4 matrix, out RaycastHit hit) - { - var parameters = new object[]{ray,mesh,matrix,null}; - bool result = (bool)meth_IntersectRayMesh.Invoke(null,parameters); - hit = (RaycastHit)parameters[3]; - return result; - } - } -} \ No newline at end of file diff --git a/VertexPaint/Editor/RxLookingGlass.cs.meta b/VertexPaint/Editor/RxLookingGlass.cs.meta deleted file mode 100644 index f340536..0000000 --- a/VertexPaint/Editor/RxLookingGlass.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 1ab295d8392724b1db773ecc02bf98bf -timeCreated: 1447602956 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VertexPaint/Editor/VertexPainterWindow.cs b/VertexPaint/Editor/VertexPainterWindow.cs deleted file mode 100644 index 659d92f..0000000 --- a/VertexPaint/Editor/VertexPainterWindow.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System.Collections; -using UnityEditor; -using System.Collections.Generic; - -/* VertexPainterWindow - * - Jason Booth - * - * Uses Unity 5.0+ MeshRenderer.additionalVertexStream so that you can paint per-instance vertex colors on your meshes. - * A component is added to your mesh to serialize this data and set it at load time. This is more effecient than making - * duplicate meshes, and certainly less painful than saving them as separate asset files on disk. However, if you only have - * one copy of the vertex information in your game and want to burn it into the original mesh, you can use the save feature - * to save a new version of your mesh with the data burned into the verticies, avoiding the need for the runtime component. - * - * In other words, bake it if you need to instance the paint job - however, if you want tons of the same instances painted - * uniquely in your scene, keep the component version and skip the baking.. - * - * One possible optimization is to have the component free the array after updating the mesh when in play mode.. - * - * Also supports burning data into the UV channels, in case you want some additional channels to work with, which also - * happen to be full 32bit floats. You can set a viewable range; so if your floats go from 0-120, it will remap it to - * 0-1 for display in the shader. That way you can always see your values, even when they go out of color ranges. - * - * Note that as of this writing Unity has a bug in the additionalVertexStream function. The docs claim the data applied here - * will supply or overwrite the data in the mesh, however, this is not true. Rather, it will only replace the data that's - * there - if your mesh has no color information, it will not upload the color data in additionalVertexStream, which is sad - * because the original mesh doesn't need this data. As a workaround, if your mesh does not have color channels on the verts, - * they will be created for you. - * - * There is another bug in additionalVertexStream, in that the mesh keeps disapearing in edit mode. So the component - * which holds the data caches the mesh and keeps assigning it in the Update call, but only when running in the editor - * and not in play mode. - * - * Really, the additionalVertexStream mesh should be owned by the MeshRenderer and saved as part of the objects instance - * data. That's essentially what the VertexInstaceStream component does, but it's annoying and wasteful of memory to do - * it this way since it doesn't need to be on the CPU at all. Enlighten somehow does this with the UVs it generates - * this way, but appears to be handled specially. Oh, Unity.. -*/ - - - -namespace JBooth.VertexPainterPro -{ - public partial class VertexPainterWindow : EditorWindow - { - [MenuItem("Window/Vertex Painter Pro")] - public static void ShowWindow() - { - var window = GetWindow(); - window.InitMeshes(); - window.Show(); - } - } -} diff --git a/VertexPaint/Editor/VertexPainterWindow.cs.meta b/VertexPaint/Editor/VertexPainterWindow.cs.meta deleted file mode 100644 index 463af22..0000000 --- a/VertexPaint/Editor/VertexPainterWindow.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 9b7e87c0d1c384ebcbd51b505e55a724 -timeCreated: 1452445638 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VertexPaint/Editor/VertexPainterWindow_AO.cs b/VertexPaint/Editor/VertexPainterWindow_AO.cs deleted file mode 100644 index 12d8885..0000000 --- a/VertexPaint/Editor/VertexPainterWindow_AO.cs +++ /dev/null @@ -1,229 +0,0 @@ - -using UnityEditor; -using UnityEngine; -using System.Collections; -using System.Collections.Generic; - -namespace JBooth.VertexPainterPro -{ - public partial class VertexPainterWindow : EditorWindow - { - public int aoSamples = 512; - public Vector2 aoRange = new Vector2(0.0001f, 1.5f); - public float aoIntensity = 2.0f; - public bool bakeLighting; - public Color aoLightAmbient = new Color(0.05f, 0.05f, 0.05f, 1); - - public enum AOBakeMode - { - Replace = 0, - Multiply - } - public AOBakeMode aoBakeMode = AOBakeMode.Replace; - - - RaycastHit hit = new RaycastHit(); - - void ApplyAOLight(ref Color c, Light l, Vector3 pos, Vector3 n) - { - if (!l.isActiveAndEnabled) - return; - Vector3 dir; - float intensity = l.intensity; - if (l.type == LightType.Directional) - { - dir = -l.transform.forward; - } - else if (l.type == LightType.Point) - { - dir = (l.transform.position - pos).normalized; - intensity *= Mathf.Clamp01((l.range - Vector3.Distance(l.transform.position, pos)) / l.range); - } - else - { - return; - } - - intensity *= Mathf.Clamp01(Vector3.Dot(n, dir)); - - c.r += l.color.r * intensity; - c.g += l.color.g * intensity; - c.b += l.color.b * intensity; - } - - void BakeAO() - { - Light[] aoLights = null; - if (bakeLighting) - { - aoLights = GameObject.FindObjectsOfType(); - } - int sample = 0; - int numVerts = 0; - for (int i = 0; i < jobs.Length; ++i) - { - numVerts += jobs[i].verts.Length; - } - int numSamples = numVerts * aoSamples; - - float oldFloat = floatBrushValue; - Color oldColor = brushColor; - int oldVal = brushValue; - - // add temp colliders if needed - bool[] tempCollider = new bool[jobs.Length]; - for (int jIdx = 0; jIdx < jobs.Length; ++jIdx) - { - PaintJob job = jobs[jIdx]; - - if (job.meshFilter.GetComponent() == null) - { - job.meshFilter.gameObject.AddComponent(); - tempCollider[jIdx] = true; - } - } - - // do AO - for (int jIdx = 0; jIdx < jobs.Length; ++jIdx) - { - PaintJob job = jobs[jIdx]; - - PrepBrushMode(job); - // bake down the mesh so we take instance positions into account.. - Mesh mesh = BakeDownMesh(job.meshFilter.sharedMesh, job.stream); - Vector3[] verts = mesh.vertices; - if (mesh.normals == null || mesh.normals.Length == 0) - { - mesh.RecalculateNormals(); - } - Vector3[] normals = mesh.normals; - - brushValue = 255; - floatBrushValue = 1.0f; - brushColor = Color.white; - var val = GetBrushValue(); - Setter setter = null; - Multiplier mult = null; - - if (aoBakeMode == AOBakeMode.Replace) - { - setter = GetSetter(job.stream); - for (int i = 0; i < job.verts.Length; ++i) - { - setter.Invoke(i, ref val); - } - } - else - { - mult = GetMultiplier(job.stream); - } - - for (int i = 0; i aoRange.x ) - { - totalOcclusion += Mathf.Clamp01( 1 - ( hit.distance / aoRange.y ) ); - } - } - - sample++; - if (sample % 500 == 0) - { - EditorUtility.DisplayProgressBar("Baking AO...", "Baking...", (float)sample / (float)numSamples); - } - } - - totalOcclusion = Mathf.Clamp01( 1 - ((totalOcclusion*aoIntensity)/aoSamples) ); - - if (aoLights != null && aoLights.Length > 0) - { - Color c = aoLightAmbient; - for (int l = 0; l < aoLights.Length; ++l) - { - Light light = aoLights[l]; - ApplyAOLight(ref c, light, v, n); - } - c.r *= totalOcclusion; - c.g *= totalOcclusion; - c.b *= totalOcclusion; - c.a = totalOcclusion; - brushColor = c; - - // if we're lit and targeting a channel other than color, bake max intensity.. - floatBrushValue = Mathf.Max(Mathf.Max(c.r, c.g), c.b) * totalOcclusion; - brushValue = (int)(floatBrushValue * 255); - } - else - { - brushColor.r = totalOcclusion; - brushColor.g = totalOcclusion; - brushColor.b = totalOcclusion; - brushColor.a = totalOcclusion; - - floatBrushValue = totalOcclusion; - brushValue = (int)(totalOcclusion * 255); - } - val = GetBrushValue(); - if (aoBakeMode == AOBakeMode.Replace) - { - setter.Invoke(i, ref val); - } - else - { - mult.Invoke(i, ref val); - } - } - job.stream.Apply(); - DestroyImmediate(mesh); - - brushValue = oldVal; - floatBrushValue = oldFloat; - brushColor = oldColor; - } - // remove temp colliders - for (int jIdx = 0; jIdx < jobs.Length; ++jIdx) - { - if (tempCollider[jIdx] == true) - { - Collider c = jobs[jIdx].meshFilter.GetComponent(); - if (c != null) - { - DestroyImmediate(c); - } - } - } - - EditorUtility.ClearProgressBar(); - SceneView.RepaintAll(); - - } - } - -} diff --git a/VertexPaint/Editor/VertexPainterWindow_AO.cs.meta b/VertexPaint/Editor/VertexPainterWindow_AO.cs.meta deleted file mode 100644 index 73925f7..0000000 --- a/VertexPaint/Editor/VertexPainterWindow_AO.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 5193227ca7fab46e9a838229f6bd41a3 -timeCreated: 1449121155 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VertexPaint/Editor/VertexPainterWindow_BakePivot.cs b/VertexPaint/Editor/VertexPainterWindow_BakePivot.cs deleted file mode 100644 index c1add47..0000000 --- a/VertexPaint/Editor/VertexPainterWindow_BakePivot.cs +++ /dev/null @@ -1,73 +0,0 @@ -using UnityEngine; -using System.Collections; -using UnityEditor; -using System.Collections.Generic; - -// bake pivots into mesh verticies. This can be very useful for things like tree billboards, object shattering, etc, -// as it allows you to rotate each polygon individually. To use, build your geometry as a bunch of separate meshes, -// bake the data using this tool, and combine the meshes into one mesh. Another useful thing is to bake a random number -// into the spare channel; for instance, if your shattering an object you can use this to make each shard rotate -// in a different direction, etc.. - -namespace JBooth.VertexPainterPro -{ - public partial class VertexPainterWindow : EditorWindow - { - enum PivotTarget - { - UV0, - UV1, - UV2, - UV3 - } - - PivotTarget pivotTarget = PivotTarget.UV2; - - void BakePivot() - { - switch (pivotTarget) - { - case PivotTarget.UV0: - { - InitBakeChannel(BakeChannel.UV0); - foreach (PaintJob job in jobs) - { - Vector3 lp = job.meshFilter.transform.localPosition; - job.stream.SetUV0(new Vector4(lp.x, lp.y, lp.z, UnityEngine.Random.Range(0.0f, 1.0f)), job.verts.Length); - } - break; - } - case PivotTarget.UV1: - { - InitBakeChannel(BakeChannel.UV1); - foreach (PaintJob job in jobs) - { - Vector3 lp = job.meshFilter.transform.localPosition; - job.stream.SetUV1(new Vector4(lp.x, lp.y, lp.z, UnityEngine.Random.Range(0.0f, 1.0f)), job.verts.Length); - } - break; - } - case PivotTarget.UV2: - { - InitBakeChannel(BakeChannel.UV2); - foreach (PaintJob job in jobs) - { - Vector3 lp = job.meshFilter.transform.localPosition; - job.stream.SetUV2(new Vector4(lp.x, lp.y, lp.z, UnityEngine.Random.Range(0.0f, 1.0f)), job.verts.Length); - } - break; - } - case PivotTarget.UV3: - { - InitBakeChannel(BakeChannel.UV3); - foreach (PaintJob job in jobs) - { - Vector3 lp = job.meshFilter.transform.localPosition; - job.stream.SetUV3(new Vector4(lp.x, lp.y, lp.z, UnityEngine.Random.Range(0.0f, 1.0f)), job.verts.Length); - } - break; - } - } - } - } -} diff --git a/VertexPaint/Editor/VertexPainterWindow_BakePivot.cs.meta b/VertexPaint/Editor/VertexPainterWindow_BakePivot.cs.meta deleted file mode 100644 index 00c3c23..0000000 --- a/VertexPaint/Editor/VertexPainterWindow_BakePivot.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 97bcdee99cf0141c7b961d194c199f28 -timeCreated: 1449637058 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VertexPaint/Editor/VertexPainterWindow_BakeTexture.cs b/VertexPaint/Editor/VertexPainterWindow_BakeTexture.cs deleted file mode 100644 index 5594f7f..0000000 --- a/VertexPaint/Editor/VertexPainterWindow_BakeTexture.cs +++ /dev/null @@ -1,181 +0,0 @@ -using UnityEngine; -using System.Collections; -using UnityEditor; -using System.Collections.Generic; - -// bake texture data into vertex data - -namespace JBooth.VertexPainterPro -{ - public partial class VertexPainterWindow : EditorWindow - { - - public enum BakeChannel - { - None, - Color, - UV0, - UV1, - UV2, - UV3 - } - - public enum BakeSourceUV - { - UV0, - UV1, - UV2, - UV3 - } - - Texture2D bakingTex = null; - BakeSourceUV bakeSourceUV = BakeSourceUV.UV0; - BakeChannel bakeChannel = BakeChannel.Color; - - - void InitBakeChannel(BakeChannel bc) - { - foreach (PaintJob job in jobs) - { - if (bc == BakeChannel.Color) - { - if (job.stream.colors == null || job.stream.colors.Length != job.verts.Length) - { - job.stream.SetColor(Color.black, job.verts.Length); - } - } - else if (bc == BakeChannel.UV0) - { - if (job.stream.uv0 == null || job.stream.uv0.Count!= job.verts.Length) - { - job.stream.SetUV0(Vector4.zero, job.verts.Length); - } - } - else if (bc == BakeChannel.UV1) - { - if (job.stream.uv1 == null || job.stream.uv1.Count != job.verts.Length) - { - job.stream.SetUV1(Vector4.zero, job.verts.Length); - } - } - else if (bc == BakeChannel.UV2) - { - if (job.stream.uv2 == null || job.stream.uv2.Count != job.verts.Length) - { - job.stream.SetUV2(Vector4.zero, job.verts.Length); - } - } - else if (bc == BakeChannel.UV3) - { - if (job.stream.uv3 == null || job.stream.uv3.Count != job.verts.Length) - { - job.stream.SetUV3(Vector4.zero, job.verts.Length); - } - } - } - } - - void BakeColor(PaintJob job, BakeChannel bc, Vector4 val, int i) - { - switch (bc) - { - case BakeChannel.Color: - { - job.stream.colors[i] = new Color(val.x, val.y, val.z, val.w); break; - } - case BakeChannel.UV0: - { - job.stream.uv0[i] = val; - break; - } - case BakeChannel.UV1: - { - job.stream.uv1[i] = val; - break; - } - case BakeChannel.UV2: - { - job.stream.uv2[i] = val; - break; - } - case BakeChannel.UV3: - { - job.stream.uv3[i] = val; - break; - } - } - } - - void BakeFromTexture() - { - // make sure we have the channels we're baking to.. - InitBakeChannel(bakeChannel); - // lets avoid the whole read/write texture thing, because it's lame to require that.. - int w = bakingTex.width; - int h = bakingTex.height; - RenderTexture rt = RenderTexture.GetTemporary(w, h, 0, RenderTextureFormat.ARGB32); - Graphics.Blit(bakingTex, rt); - Texture2D tex = new Texture2D(w, h, TextureFormat.ARGB32, false); - RenderTexture.active = rt; - tex.ReadPixels(new Rect(0,0,w,h), 0, 0); - foreach (PaintJob job in jobs) - { - List srcUV0 = new List(); - List srcUV1 = new List(); - List srcUV2 = new List(); - List srcUV3 = new List(); - job.meshFilter.sharedMesh.GetUVs(0, srcUV0); - job.meshFilter.sharedMesh.GetUVs(1, srcUV1); - job.meshFilter.sharedMesh.GetUVs(2, srcUV2); - job.meshFilter.sharedMesh.GetUVs(3, srcUV3); - for (int i = 0; i < job.verts.Length; ++i) - { - Vector4 uv = Vector4.zero; - - switch (bakeSourceUV) - { - case BakeSourceUV.UV0: - { - if (job.stream.uv0 != null && job.stream.uv0.Count == job.verts.Length) - uv = job.stream.uv0[i]; - else if (srcUV0 != null && srcUV0.Count == job.verts.Length) - uv = srcUV0[i]; - break; - } - case BakeSourceUV.UV1: - { - if (job.stream.uv1 != null && job.stream.uv1.Count == job.verts.Length) - uv = job.stream.uv1[i]; - else if (srcUV1 != null && srcUV1.Count == job.verts.Length) - uv = srcUV1[i]; - break; - } - case BakeSourceUV.UV2: - { - if (job.stream.uv2 != null && job.stream.uv2.Count == job.verts.Length) - uv = job.stream.uv2[i]; - else if (srcUV2 != null && srcUV2.Count == job.verts.Length) - uv = srcUV2[i]; - break; - } - case BakeSourceUV.UV3: - { - if (job.stream.uv3 != null && job.stream.uv3.Count == job.verts.Length) - uv = job.stream.uv3[i]; - else if (srcUV3 != null && srcUV3.Count == job.verts.Length) - uv = srcUV3[i]; - break; - } - } - Color c = tex.GetPixel((int)(uv.x*w), (int)(uv.y*w)); - - BakeColor(job, bakeChannel, new Vector4(c.r, c.g, c.b, c.a), i); - - } - job.stream.Apply(); - } - } - } -} - - diff --git a/VertexPaint/Editor/VertexPainterWindow_BakeTexture.cs.meta b/VertexPaint/Editor/VertexPainterWindow_BakeTexture.cs.meta deleted file mode 100644 index 9a507cc..0000000 --- a/VertexPaint/Editor/VertexPainterWindow_BakeTexture.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: a061a2d4c78324f7980c83424c9ad60c -timeCreated: 1449629032 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VertexPaint/Editor/VertexPainterWindow_GUI.cs b/VertexPaint/Editor/VertexPainterWindow_GUI.cs deleted file mode 100644 index 7dbe2ba..0000000 --- a/VertexPaint/Editor/VertexPainterWindow_GUI.cs +++ /dev/null @@ -1,691 +0,0 @@ -using UnityEngine; -using System.Collections; -using UnityEditor; -using System.Collections.Generic; - -/* VertexPainterWindow - * - Jason Booth - * - * Uses Unity 5.0+ MeshRenderer.additionalVertexStream so that you can paint per-instance vertex colors on your meshes. - * A component is added to your mesh to serialize this data and set it at load time. This is more effecient than making - * duplicate meshes, and certainly less painful than saving them as separate asset files on disk. However, if you only have - * one copy of the vertex information in your game and want to burn it into the original mesh, you can use the save feature - * to save a new version of your mesh with the data burned into the verticies, avoiding the need for the runtime component. - * - * In other words, bake it if you need to instance the paint job - however, if you want tons of the same instances painted - * uniquely in your scene, keep the component version and skip the baking.. - * - * One possible optimization is to have the component free the array after updating the mesh when in play mode.. - * - * Also supports burning data into the UV channels, in case you want some additional channels to work with, which also - * happen to be full 32bit floats. You can set a viewable range; so if your floats go from 0-120, it will remap it to - * 0-1 for display in the shader. That way you can always see your values, even when they go out of color ranges. - * - * Note that as of this writing Unity has a bug in the additionalVertexStream function. The docs claim the data applied here - * will supply or overwrite the data in the mesh, however, this is not true. Rather, it will only replace the data that's - * there - if your mesh has no color information, it will not upload the color data in additionalVertexStream, which is sad - * because the original mesh doesn't need this data. As a workaround, if your mesh does not have color channels on the verts, - * they will be created for you. - * - * There is another bug in additionalVertexStream, in that the mesh keeps disapearing in edit mode. So the component - * which holds the data caches the mesh and keeps assigning it in the Update call, but only when running in the editor - * and not in play mode. - * - * Really, the additionalVertexStream mesh should be owned by the MeshRenderer and saved as part of the objects instance - * data. That's essentially what the VertexInstaceStream component does, but it's annoying and wasteful of memory to do - * it this way since it doesn't need to be on the CPU at all. Enlighten somehow does this with the UVs it generates - * this way, but appears to be handled specially. Oh, Unity.. -*/ - - - -namespace JBooth.VertexPainterPro -{ - public partial class VertexPainterWindow : EditorWindow - { - enum Tab - { - Paint = 0, - Deform, - Flow, - Bake, - } - - string[] tabNames = - { - "Paint", - "Deform", - "Flow", - "Bake" - }; - - - static string sSwatchKey = "VertexPainter_Swatches"; - - ColorSwatches swatches = null; - - - Tab tab = Tab.Paint; - - bool hideMeshWireframe = false; - - bool DrawClearButton(string label) - { - if (GUILayout.Button(label, GUILayout.Width(46))) - { - return (EditorUtility.DisplayDialog("Confirm", "Clear " + label + " data?", "ok", "cancel")); - } - return false; - } - - - Vector2 scroll; - void OnGUI() - { - - if (Selection.activeGameObject == null) - { - EditorGUILayout.LabelField("No objects selected. Please select an object with a MeshFilter and Renderer"); - return; - } - - if (swatches == null) - { - swatches = ColorSwatches.CreateInstance(); - if (EditorPrefs.HasKey(sSwatchKey)) - { - JsonUtility.FromJsonOverwrite(EditorPrefs.GetString(sSwatchKey), swatches); - } - if (swatches == null) - { - swatches = ColorSwatches.CreateInstance(); - EditorPrefs.SetString(sSwatchKey, JsonUtility.ToJson(swatches, false)); - } - } - - DrawChannelGUI(); - - var ot = tab; - tab = (Tab)GUILayout.Toolbar((int)tab, tabNames); - if (ot != tab) - { - UpdateDisplayMode(); - } - scroll = EditorGUILayout.BeginScrollView(scroll); - if (tab == Tab.Paint) - { - DrawPaintGUI(); - } - else if (tab == Tab.Deform) - { - DrawDeformGUI(); - } - else if (tab == Tab.Flow) - { - DrawFlowGUI(); - } - else if (tab == Tab.Bake) - { - DrawBakeGUI(); - } - EditorGUILayout.EndScrollView(); - } - - - void DrawChannelGUI() - { - EditorGUILayout.Separator(); - GUI.skin.box.normal.textColor = Color.white; - GUILayout.Box("Vertex Painter", new GUILayoutOption[]{GUILayout.ExpandWidth(true), GUILayout.Height(18)}); - EditorGUILayout.Separator(); - bool oldEnabled = enabled; - if (Event.current.isKey && Event.current.keyCode == KeyCode.Escape && Event.current.type == EventType.KeyUp) - { - enabled = !enabled; - } - enabled = GUILayout.Toggle(enabled, "Active (ESC)"); - if (enabled != oldEnabled) - { - InitMeshes(); - } - var oldShow = showVertexShader; - showVertexShader = GUILayout.Toggle(showVertexShader, "Show Vertex Data (ctrl-V)"); - if (oldShow != showVertexShader) - { - UpdateDisplayMode(); - } - - brushVisualization = (BrushVisualization)EditorGUILayout.EnumPopup("Brush Visualization", brushVisualization); - - showVertexPoints = GUILayout.Toggle(showVertexPoints, "Show Brush Influence"); - - bool oldHideMeshWireframe = hideMeshWireframe; - hideMeshWireframe = !GUILayout.Toggle(!hideMeshWireframe, "Show Wireframe (ctrl-W)"); - - if (hideMeshWireframe != oldHideMeshWireframe) - { - for (int i = 0; i < jobs.Length; ++i) - { - EditorUtility.SetSelectedWireframeHidden(jobs[i].renderer, hideMeshWireframe); - } - } - - - bool hasColors = false; - bool hasUV0 = false; - bool hasUV1 = false; - bool hasUV2 = false; - bool hasUV3 = false; - bool hasPositions = false; - bool hasNormals = false; - - for (int i = 0; i < jobs.Length; ++i) - { - if (jobs[i]._stream != null) - { - int vertexCount = jobs[i].verts.Length; - - hasColors = (jobs[i].stream.colors != null && jobs[i].stream.colors.Length == vertexCount); - hasUV0 = (jobs[i].stream.uv0 != null && jobs[i].stream.uv0.Count == vertexCount); - hasUV1 = (jobs[i].stream.uv1 != null && jobs[i].stream.uv1.Count == vertexCount); - hasUV2 = (jobs[i].stream.uv2 != null && jobs[i].stream.uv2.Count == vertexCount); - hasUV3 = (jobs[i].stream.uv3 != null && jobs[i].stream.uv3.Count == vertexCount); - hasPositions = (jobs[i].stream.positions != null && jobs[i].stream.positions.Length == vertexCount); - hasNormals = (jobs[i].stream.normals != null && jobs[i].stream.normals.Length == vertexCount); - } - } - - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.PrefixLabel("Clear Channel:"); - if (hasColors && DrawClearButton("Colors")) - { - for (int i = 0; i < jobs.Length; ++i) - { - Undo.RecordObject(jobs[i].stream, "Vertex Painter Clear"); - jobs[i].stream.colors = null; - jobs[i].stream.Apply(); - } - Undo.CollapseUndoOperations(Undo.GetCurrentGroup()); - } - if (hasUV0 && DrawClearButton("UV0")) - { - for (int i = 0; i < jobs.Length; ++i) - { - Undo.RecordObject(jobs[i].stream, "Vertex Painter Clear"); - jobs[i].stream.uv0 = null; - jobs[i].stream.Apply(); - } - Undo.CollapseUndoOperations(Undo.GetCurrentGroup()); - } - if (hasUV1 && DrawClearButton("UV1")) - { - for (int i = 0; i < jobs.Length; ++i) - { - Undo.RecordObject(jobs[i].stream, "Vertex Painter Clear"); - jobs[i].stream.uv1 = null; - jobs[i].stream.Apply(); - } - Undo.CollapseUndoOperations(Undo.GetCurrentGroup()); - } - if (hasUV2 && DrawClearButton("UV2")) - { - for (int i = 0; i < jobs.Length; ++i) - { - Undo.RecordObject(jobs[i].stream, "Vertex Painter Clear"); - jobs[i].stream.uv2 = null; - jobs[i].stream.Apply(); - } - Undo.CollapseUndoOperations(Undo.GetCurrentGroup()); - } - if (hasUV3 && DrawClearButton("UV3")) - { - for (int i = 0; i < jobs.Length; ++i) - { - Undo.RecordObject(jobs[i].stream, "Vertex Painter Clear"); - jobs[i].stream.uv3 = null; - jobs[i].stream.Apply(); - } - Undo.CollapseUndoOperations(Undo.GetCurrentGroup()); - } - if (hasPositions && DrawClearButton("Pos")) - { - for (int i = 0; i < jobs.Length; ++i) - { - Undo.RecordObject(jobs[i].stream, "Vertex Painter Clear"); - jobs[i].stream.positions = null; - Mesh m = jobs[i].stream.GetModifierMesh(); - if (m != null) - m.vertices = jobs[i].meshFilter.sharedMesh.vertices; - jobs[i].stream.Apply(); - } - Undo.CollapseUndoOperations(Undo.GetCurrentGroup()); - } - if (hasNormals && DrawClearButton("Norm")) - { - for (int i = 0; i < jobs.Length; ++i) - { - Undo.RecordObject(jobs[i].stream, "Vertex Painter Clear"); - jobs[i].stream.normals = null; - jobs[i].stream.tangents = null; - jobs[i].stream.Apply(); - } - Undo.CollapseUndoOperations(Undo.GetCurrentGroup()); - } - - EditorGUILayout.EndHorizontal(); - - EditorGUILayout.Separator(); - GUILayout.Box("", new GUILayoutOption[]{GUILayout.ExpandWidth(true), GUILayout.Height(1)}); - EditorGUILayout.Separator(); - - } - - void DrawBrushSettingsGUI() - { - brushSize = EditorGUILayout.Slider("Brush Size", brushSize, 0.01f, 30.0f); - brushFlow = EditorGUILayout.Slider("Brush Flow", brushFlow, 0.1f, 128.0f); - brushFalloff = EditorGUILayout.Slider("Brush Falloff", brushFalloff, 0.1f, 4.0f); - if (tab == Tab.Paint && flowTarget != FlowTarget.ColorBA && flowTarget != FlowTarget.ColorRG) - { - flowRemap01 = EditorGUILayout.Toggle("use 0->1 mapping", flowRemap01); - } - EditorGUILayout.Separator(); - GUILayout.Box("", new GUILayoutOption[]{GUILayout.ExpandWidth(true), GUILayout.Height(1)}); - EditorGUILayout.Separator(); - - } - - void DrawPaintGUI() - { - - GUILayout.Box("Brush Settings", new GUILayoutOption[]{GUILayout.ExpandWidth(true), GUILayout.Height(20)}); - var oldBM = brushMode; - brushMode = (BrushTarget)EditorGUILayout.EnumPopup("Target Channel", brushMode); - if (oldBM != brushMode) - { - UpdateDisplayMode(); - } - if (brushMode == BrushTarget.Color) - { - brushColor = EditorGUILayout.ColorField("Brush Color", brushColor); - - if (GUILayout.Button("Reset Palette", EditorStyles.miniButton, GUILayout.Width(80), GUILayout.Height(16))) - { - if (swatches != null) - { - DestroyImmediate(swatches); - } - swatches = ColorSwatches.CreateInstance(); - EditorPrefs.SetString(sSwatchKey, JsonUtility.ToJson(swatches,false)); - } - - GUILayout.BeginHorizontal(); - - for (int i = 0; i < swatches.colors.Length; ++i) - { - if (GUILayout.Button("", EditorStyles.textField, GUILayout.Width(16), GUILayout.Height(16))) - { - brushColor = swatches.colors[i]; - } - EditorGUI.DrawRect(new Rect(GUILayoutUtility.GetLastRect().x + 1, GUILayoutUtility.GetLastRect().y + 1, 14, 14), swatches.colors[i]); - } - GUILayout.EndHorizontal(); - GUILayout.BeginHorizontal(); - for (int i = 0; i < swatches.colors.Length; i++) - { - if (GUILayout.Button("+", EditorStyles.miniButton, GUILayout.Width(16), GUILayout.Height(12))) - { - swatches.colors[i] = brushColor; - EditorPrefs.SetString(sSwatchKey, JsonUtility.ToJson(swatches, false)); - } - } - GUILayout.EndHorizontal(); - - } - else if (brushMode == BrushTarget.ValueR || brushMode == BrushTarget.ValueG || brushMode == BrushTarget.ValueB || brushMode == BrushTarget.ValueA) - { - brushValue = (int)EditorGUILayout.Slider("Brush Value", (float)brushValue, 0.0f, 256.0f); - } - else - { - floatBrushValue = EditorGUILayout.FloatField("Brush Value", floatBrushValue); - var oldUVRange = uvVisualizationRange; - uvVisualizationRange = EditorGUILayout.Vector2Field("Visualize Range", uvVisualizationRange); - if (oldUVRange != uvVisualizationRange) - { - UpdateDisplayMode(); - } - } - - DrawBrushSettingsGUI(); - - //GUILayout.Box("", new GUILayoutOption[]{GUILayout.ExpandWidth(true), GUILayout.Height(1)}); - EditorGUILayout.BeginHorizontal(); - if (GUILayout.Button("Fill")) - { - for (int i = 0; i < jobs.Length; ++i) - { - Undo.RecordObject(jobs[i].stream, "Vertex Painter Fill"); - FillMesh(jobs[i]); - } - Undo.CollapseUndoOperations(Undo.GetCurrentGroup()); - } - if (GUILayout.Button("Random")) - { - for (int i = 0; i < jobs.Length; ++i) - { - Undo.RecordObject(jobs[i].stream, "Vertex Painter Fill"); - RandomMesh(jobs[i]); - } - } - EditorGUILayout.EndHorizontal(); - - } - - void DrawDeformGUI() - { - GUILayout.Box("Brush Settings", new GUILayoutOption[]{GUILayout.ExpandWidth(true), GUILayout.Height(20)}); - pull = (Event.current.shift); - - vertexMode = (VertexMode)EditorGUILayout.EnumPopup("Vertex Mode", vertexMode); - vertexContraint = (VertexContraint)EditorGUILayout.EnumPopup("Vertex Constraint", vertexContraint); - - DrawBrushSettingsGUI(); - - EditorGUILayout.LabelField(pull ? "Pull (shift)" : "Push (shift)"); - - } - - void DrawFlowGUI() - { - GUILayout.Box("Brush Settings", new GUILayoutOption[]{GUILayout.ExpandWidth(true), GUILayout.Height(20)}); - var oldV = flowVisualization; - flowVisualization = (FlowVisualization)EditorGUILayout.EnumPopup("Visualize", flowVisualization); - if (flowVisualization != oldV) - { - UpdateDisplayMode(); - } - var ft = flowTarget; - flowTarget = (FlowTarget)EditorGUILayout.EnumPopup("Target", flowTarget); - if (flowTarget != ft) - { - UpdateDisplayMode(); - } - flowBrushType = (FlowBrushType)EditorGUILayout.EnumPopup("Mode", flowBrushType); - - DrawBrushSettingsGUI(); - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.Space(); - - - - if (GUILayout.Button("Reset")) - { - Vector2 norm = new Vector2(0.5f, 0.5f); - - foreach (PaintJob job in jobs) - { - PrepBrushMode(job); - switch (flowTarget) - { - case FlowTarget.ColorRG: - job.stream.SetColorRG(norm, job.verts.Length); break; - case FlowTarget.ColorBA: - job.stream.SetColorBA(norm, job.verts.Length); break; - case FlowTarget.UV0_XY: - job.stream.SetUV0_XY(norm, job.verts.Length); break; - case FlowTarget.UV0_ZW: - job.stream.SetUV0_ZW(norm, job.verts.Length); break; - case FlowTarget.UV1_XY: - job.stream.SetUV1_XY(norm, job.verts.Length); break; - case FlowTarget.UV1_ZW: - job.stream.SetUV1_ZW(norm, job.verts.Length); break; - case FlowTarget.UV2_XY: - job.stream.SetUV2_XY(norm, job.verts.Length); break; - case FlowTarget.UV2_ZW: - job.stream.SetUV2_ZW(norm, job.verts.Length); break; - case FlowTarget.UV3_XY: - job.stream.SetUV3_XY(norm, job.verts.Length); break; - case FlowTarget.UV3_ZW: - job.stream.SetUV3_ZW(norm, job.verts.Length); break; - } - } - } - EditorGUILayout.Space(); - EditorGUILayout.EndHorizontal(); - - } - - - void DrawBakeGUI() - { - GUILayout.Box("Ambient Occlusion", new GUILayoutOption[]{GUILayout.ExpandWidth(true), GUILayout.Height(20)}); - brushMode = (BrushTarget)EditorGUILayout.EnumPopup("Target Channel", brushMode); - aoSamples = EditorGUILayout.IntSlider("Samples", aoSamples, 64, 1024); - EditorGUILayout.BeginHorizontal(); - aoRange = EditorGUILayout.Vector2Field("Range", aoRange); - aoRange.x = Mathf.Max(aoRange.x, 0.0001f); - EditorGUILayout.EndHorizontal(); - aoIntensity = EditorGUILayout.Slider("Intensity", aoIntensity, 0.25f, 4.0f); - bakeLighting = EditorGUILayout.Toggle("Bake Lighting", bakeLighting); - if (bakeLighting) - { - aoLightAmbient = EditorGUILayout.ColorField("Light Ambient", aoLightAmbient); - } - aoBakeMode = (AOBakeMode)EditorGUILayout.EnumPopup("Mode", aoBakeMode); - - - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.Space(); - if (GUILayout.Button("Bake")) - { - BakeAO(); - } - EditorGUILayout.Space(); - EditorGUILayout.EndHorizontal(); - - GUILayout.Space(10); - GUILayout.Box("Bake From Texture", new GUILayoutOption[]{GUILayout.ExpandWidth(true), GUILayout.Height(20)}); - bakingTex = EditorGUILayout.ObjectField("Texture", bakingTex, typeof(Texture2D), false) as Texture2D; - - bakeSourceUV = (BakeSourceUV)EditorGUILayout.EnumPopup("Source UVs", bakeSourceUV); - bakeChannel = (BakeChannel)EditorGUILayout.EnumPopup("Bake To", bakeChannel); - - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.Space(); - if (GUILayout.Button("Bake")) - { - if (bakingTex != null) - { - BakeFromTexture(); - } - else - { - EditorUtility.DisplayDialog("Error", "Baking texture is not set", "ok"); - } - } - EditorGUILayout.Space(); - EditorGUILayout.EndHorizontal(); - - GUILayout.Space(10); - GUILayout.Box("Bake Pivot", new GUILayoutOption[]{GUILayout.ExpandWidth(true), GUILayout.Height(20)}); - pivotTarget = (PivotTarget)EditorGUILayout.EnumPopup("Store in", pivotTarget); - - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.Space(); - if (GUILayout.Button("Bake")) - { - BakePivot(); - } - EditorGUILayout.Space(); - EditorGUILayout.EndHorizontal(); - - GUILayout.Space(10); - GUILayout.Box("Mesh Combiner", new GUILayoutOption[]{GUILayout.ExpandWidth(true), GUILayout.Height(20)}); - EditorGUILayout.BeginHorizontal(); - if (GUILayout.Button("Combine Meshes")) - { - MergeMeshes(); - } - if (GUILayout.Button("Combine and Save")) - { - if (jobs.Length != 0) - { - string path = EditorUtility.SaveFilePanel("Save Asset", Application.dataPath, "models", "asset"); - if (!string.IsNullOrEmpty(path)) - { - path = FileUtil.GetProjectRelativePath(path); - GameObject go = MergeMeshes(); - Mesh m = go.GetComponent().sharedMesh; - AssetDatabase.CreateAsset(m, path); - AssetDatabase.SaveAssets(); - AssetDatabase.ImportAsset(path); - DestroyImmediate(go); - } - } - } - EditorGUILayout.EndHorizontal(); - GUILayout.Space(10); - GUILayout.Box("Mesh Save", new GUILayoutOption[]{GUILayout.ExpandWidth(true), GUILayout.Height(20)}); - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.Space(); - if (GUILayout.Button("Save Mesh")) - { - SaveMesh(); - } - - EditorGUILayout.Space(); - EditorGUILayout.EndHorizontal(); - } - - void SaveMesh() - { - if (jobs.Length != 0) - { - string path = EditorUtility.SaveFilePanel("Save Asset", Application.dataPath, "models", "asset"); - if (!string.IsNullOrEmpty(path)) - { - path = FileUtil.GetProjectRelativePath(path); - Mesh firstMesh = BakeDownMesh(jobs[0].meshFilter.sharedMesh, jobs[0].stream); - - AssetDatabase.CreateAsset(firstMesh, path); - - for (int i = 1; i < jobs.Length; ++i) - { - Mesh m = BakeDownMesh(jobs[i].meshFilter.sharedMesh, jobs[i].stream); - AssetDatabase.AddObjectToAsset(m, firstMesh); - } - AssetDatabase.SaveAssets(); - AssetDatabase.ImportAsset(path); - } - } - } - - // copy a mesh, and bake it's vertex stream into the mesh data. - Mesh BakeDownMesh(Mesh mesh, VertexInstanceStream stream) - { - var copy = new Mesh(); - foreach(var property in typeof(Mesh).GetProperties()) - { - if(property.GetSetMethod() != null && property.GetGetMethod() != null) - { - property.SetValue(copy, property.GetValue(mesh, null), null); - } - } - copy.hideFlags = 0; - - copy.colors = stream.colors; - if (stream.uv0 != null) { copy.SetUVs(0, stream.uv0); } - if (stream.uv1 != null) { copy.SetUVs(1, stream.uv1); } - if (stream.uv2 != null) { copy.SetUVs(2, stream.uv2); } - if (stream.uv3 != null) { copy.SetUVs(3, stream.uv3); } - - if (stream.positions != null && stream.positions.Length == copy.vertexCount) - { - copy.vertices = stream.positions; - } - if (stream.normals != null && stream.normals.Length == copy.vertexCount) - { - copy.normals = stream.normals; - } - if (stream.tangents != null && stream.tangents.Length == copy.vertexCount) - { - copy.tangents = stream.tangents; - } - ; - copy.RecalculateBounds(); - copy.UploadMeshData(false); - - return copy; - } - - GameObject MergeMeshes() - { - if (jobs.Length == 0) - return null; - List meshes = new List(); - for (int i = 0; i < jobs.Length; ++i) - { - Mesh m = BakeDownMesh(jobs[i].meshFilter.sharedMesh, jobs[i].stream); - CombineInstance ci = new CombineInstance(); - ci.mesh = m; - ci.transform = jobs[i].meshFilter.transform.localToWorldMatrix; - meshes.Add(ci); - } - - Mesh mesh = new Mesh(); - mesh.CombineMeshes(meshes.ToArray()); - GameObject go = new GameObject("Combined Mesh"); - go.AddComponent(); - var mf = go.AddComponent(); - ; - mesh.RecalculateBounds(); - mesh.UploadMeshData(false); - mf.sharedMesh = mesh; - for (int i = 0; i < meshes.Count; ++i) - { - DestroyImmediate(meshes[i].mesh); - } - return go; - } - - void OnFocus() - { - if (painting) - { - EndStroke(); - } - - SceneView.onSceneGUIDelegate -= this.OnSceneGUI; - SceneView.onSceneGUIDelegate += this.OnSceneGUI; - - Undo.undoRedoPerformed -= this.OnUndo; - Undo.undoRedoPerformed += this.OnUndo; - this.titleContent = new GUIContent("Vertex Paint"); - Repaint(); - - } - - void OnInspectorUpdate() - { - // unfortunate... - Repaint (); - } - - void OnSelectionChange() - { - InitMeshes(); - this.Repaint(); - } - - void OnDestroy() - { - bool show = showVertexShader; - showVertexShader = false; - UpdateDisplayMode(); - showVertexShader = show; - DestroyImmediate(VertexInstanceStream.vertexShaderMat); - SceneView.onSceneGUIDelegate -= this.OnSceneGUI; - } - } -} \ No newline at end of file diff --git a/VertexPaint/Editor/VertexPainterWindow_GUI.cs.meta b/VertexPaint/Editor/VertexPainterWindow_GUI.cs.meta deleted file mode 100644 index 26b1b60..0000000 --- a/VertexPaint/Editor/VertexPainterWindow_GUI.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: ae410e13fcd2a4249980c7bef9494a95 -timeCreated: 1447732490 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VertexPaint/Editor/VertexPainterWindow_Painting.cs b/VertexPaint/Editor/VertexPainterWindow_Painting.cs deleted file mode 100644 index 19c13d4..0000000 --- a/VertexPaint/Editor/VertexPainterWindow_Painting.cs +++ /dev/null @@ -1,1930 +0,0 @@ -using UnityEngine; -using System.Collections; -using UnityEditor; -using System.Collections.Generic; - -namespace JBooth.VertexPainterPro -{ - public partial class VertexPainterWindow : EditorWindow - { - - // C# doesn't have *& or **, so it's not easy to pass a reference to a value for changing. - // instead, we wrap the setter into a templated lambda which allows us to pass a changable - // reference around via a function which sets it. Pretty tricky sis, but I'd rather just - // be able to pass the freaking reference already.. - // Note the ref object, which is there just to prevent boxing of Vector/Color structs. Also - // note the complete lack of type safety, etc.. ugh.. - - // whats worse- this could also be condensed down to a macro, which would actually be MORE - // safe in terms of potential bugs than all this; and it would be like a dozen lines to boot. - delegate void Setter(int idx, ref object x); - - Setter GetSetter(VertexInstanceStream s) - { - if (tab == Tab.Flow) - { - switch (flowTarget) - { - case FlowTarget.ColorRG: - return delegate(int idx, ref object v) - { - Vector2 vv = (Vector2)v; - s.colors[idx].r = vv.x; - s.colors[idx].g = vv.y; - }; - case FlowTarget.ColorBA: - return delegate(int idx, ref object v) - { - Vector2 vv = (Vector2)v; - s.colors[idx].b = vv.x; - s.colors[idx].a = vv.y; - }; - case FlowTarget.UV0_XY: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv0[idx]; - Vector2 iv = (Vector2)v; - vec.x = iv.x; - vec.y = iv.y; - s.uv0[idx] = vec; - }; - case FlowTarget.UV0_ZW: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv0[idx]; - Vector2 iv = (Vector2)v; - vec.z = iv.x; - vec.w = iv.y; - s.uv0[idx] = vec; - }; - case FlowTarget.UV1_XY: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv1[idx]; - Vector2 iv = (Vector2)v; - vec.x = iv.x; - vec.y = iv.y; - s.uv1[idx] = vec; - }; - case FlowTarget.UV1_ZW: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv1[idx]; - Vector2 iv = (Vector2)v; - vec.z = iv.x; - vec.w = iv.y; - s.uv1[idx] = vec; - }; - case FlowTarget.UV2_XY: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv2[idx]; - Vector2 iv = (Vector2)v; - vec.x = iv.x; - vec.y = iv.y; - s.uv2[idx] = vec; - }; - case FlowTarget.UV2_ZW: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv2[idx]; - Vector2 iv = (Vector2)v; - vec.z = iv.x; - vec.w = iv.y; - s.uv2[idx] = vec; - }; - case FlowTarget.UV3_XY: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv3[idx]; - Vector2 iv = (Vector2)v; - vec.x = iv.x; - vec.y = iv.y; - s.uv3[idx] = vec; - }; - case FlowTarget.UV3_ZW: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv3[idx]; - Vector2 iv = (Vector2)v; - vec.z = iv.x; - vec.w = iv.y; - s.uv3[idx] = vec; - }; - } - return null; - } - switch (brushMode) - { - case BrushTarget.Color: - return delegate(int idx, ref object v) - { - s.colors[idx] = (Color)v; - }; - case BrushTarget.ValueR: - return delegate(int idx, ref object v) - { - s.colors[idx].r = (float)v; - }; - case BrushTarget.ValueG: - return delegate(int idx, ref object v) - { - s.colors[idx].g = (float)v; - }; - case BrushTarget.ValueB: - return delegate(int idx, ref object v) - { - s.colors[idx].b = (float)v; - }; - case BrushTarget.ValueA: - return delegate(int idx, ref object v) - { - s.colors[idx].a = (float)v; - }; - case BrushTarget.UV0_X: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv0[idx]; - vec.x = (float)v; - s.uv0[idx] = vec; - }; - case BrushTarget.UV0_Y: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv0[idx]; - vec.y = (float)v; - s.uv0[idx] = vec; - }; - case BrushTarget.UV0_Z: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv0[idx]; - vec.z = (float)v; - s.uv0[idx] = vec; - }; - case BrushTarget.UV0_W: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv0[idx]; - vec.w = (float)v; - s.uv0[idx] = vec; - }; - case BrushTarget.UV1_X: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv1[idx]; - vec.x = (float)v; - s.uv1[idx] = vec; - }; - case BrushTarget.UV1_Y: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv1[idx]; - vec.y = (float)v; - s.uv1[idx] = vec; - }; - case BrushTarget.UV1_Z: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv1[idx]; - vec.z = (float)v; - s.uv1[idx] = vec; - }; - case BrushTarget.UV1_W: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv1[idx]; - vec.w = (float)v; - s.uv1[idx] = vec; - }; - case BrushTarget.UV2_X: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv2[idx]; - vec.x = (float)v; - s.uv2[idx] = vec; - }; - case BrushTarget.UV2_Y: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv2[idx]; - vec.y = (float)v; - s.uv2[idx] = vec; - }; - case BrushTarget.UV2_Z: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv2[idx]; - vec.z = (float)v; - s.uv2[idx] = vec; - }; - case BrushTarget.UV2_W: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv2[idx]; - vec.w = (float)v; - s.uv2[idx] = vec; - }; - case BrushTarget.UV3_X: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv3[idx]; - vec.x = (float)v; - s.uv3[idx] = vec; - }; - case BrushTarget.UV3_Y: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv3[idx]; - vec.y = (float)v; - s.uv3[idx] = vec; - }; - case BrushTarget.UV3_Z: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv3[idx]; - vec.z = (float)v; - s.uv3[idx] = vec; - }; - case BrushTarget.UV3_W: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv3[idx]; - vec.w = (float)v; - s.uv3[idx] = vec; - }; - - } - return null; - } - - delegate void Multiplier(int idx, ref object x); - - Multiplier GetMultiplier(VertexInstanceStream s) - { - if (tab == Tab.Flow) - { - switch (flowTarget) - { - case FlowTarget.ColorRG: - return delegate(int idx, ref object v) - { - Vector2 vv = (Vector2)v; - s.colors[idx].r *= vv.x; - s.colors[idx].g *= vv.y; - }; - case FlowTarget.ColorBA: - return delegate(int idx, ref object v) - { - Vector2 vv = (Vector2)v; - s.colors[idx].b *= vv.x; - s.colors[idx].a *= vv.y; - }; - case FlowTarget.UV0_XY: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv0[idx]; - Vector2 iv = (Vector2)v; - vec.x *= iv.x; - vec.y *= iv.y; - s.uv0[idx] = vec; - }; - case FlowTarget.UV0_ZW: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv0[idx]; - Vector2 iv = (Vector2)v; - vec.z *= iv.x; - vec.w *= iv.y; - s.uv0[idx] = vec; - }; - case FlowTarget.UV1_XY: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv1[idx]; - Vector2 iv = (Vector2)v; - vec.x *= iv.x; - vec.y *= iv.y; - s.uv1[idx] = vec; - }; - case FlowTarget.UV1_ZW: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv1[idx]; - Vector2 iv = (Vector2)v; - vec.z *= iv.x; - vec.w *= iv.y; - s.uv1[idx] = vec; - }; - case FlowTarget.UV2_XY: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv2[idx]; - Vector2 iv = (Vector2)v; - vec.x *= iv.x; - vec.y *= iv.y; - s.uv2[idx] = vec; - }; - case FlowTarget.UV2_ZW: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv2[idx]; - Vector2 iv = (Vector2)v; - vec.z *= iv.x; - vec.w *= iv.y; - s.uv2[idx] = vec; - }; - case FlowTarget.UV3_XY: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv3[idx]; - Vector2 iv = (Vector2)v; - vec.x *= iv.x; - vec.y *= iv.y; - s.uv3[idx] = vec; - }; - case FlowTarget.UV3_ZW: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv3[idx]; - Vector2 iv = (Vector2)v; - vec.z *= iv.x; - vec.w *= iv.y; - s.uv3[idx] = vec; - }; - } - return null; - } - switch (brushMode) - { - case BrushTarget.Color: - return delegate(int idx, ref object v) - { - s.colors[idx] *= (Color)v; - }; - case BrushTarget.ValueR: - return delegate(int idx, ref object v) - { - s.colors[idx].r *= (float)v; - }; - case BrushTarget.ValueG: - return delegate(int idx, ref object v) - { - s.colors[idx].g *= (float)v; - }; - case BrushTarget.ValueB: - return delegate(int idx, ref object v) - { - s.colors[idx].b *= (float)v; - }; - case BrushTarget.ValueA: - return delegate(int idx, ref object v) - { - s.colors[idx].a *= (float)v; - }; - case BrushTarget.UV0_X: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv0[idx]; - vec.x *= (float)v; - s.uv0[idx] = vec; - }; - case BrushTarget.UV0_Y: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv0[idx]; - vec.y *= (float)v; - s.uv0[idx] = vec; - }; - case BrushTarget.UV0_Z: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv0[idx]; - vec.z *= (float)v; - s.uv0[idx] = vec; - }; - case BrushTarget.UV0_W: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv0[idx]; - vec.w *= (float)v; - s.uv0[idx] = vec; - }; - case BrushTarget.UV1_X: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv1[idx]; - vec.x *= (float)v; - s.uv1[idx] = vec; - }; - case BrushTarget.UV1_Y: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv1[idx]; - vec.y *= (float)v; - s.uv1[idx] = vec; - }; - case BrushTarget.UV1_Z: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv1[idx]; - vec.z *= (float)v; - s.uv1[idx] = vec; - }; - case BrushTarget.UV1_W: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv1[idx]; - vec.w *= (float)v; - s.uv1[idx] = vec; - }; - case BrushTarget.UV2_X: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv2[idx]; - vec.x *= (float)v; - s.uv2[idx] = vec; - }; - case BrushTarget.UV2_Y: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv2[idx]; - vec.y *= (float)v; - s.uv2[idx] = vec; - }; - case BrushTarget.UV2_Z: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv2[idx]; - vec.z *= (float)v; - s.uv2[idx] = vec; - }; - case BrushTarget.UV2_W: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv2[idx]; - vec.w *= (float)v; - s.uv2[idx] = vec; - }; - case BrushTarget.UV3_X: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv3[idx]; - vec.x *= (float)v; - s.uv3[idx] = vec; - }; - case BrushTarget.UV3_Y: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv3[idx]; - vec.y *= (float)v; - s.uv3[idx] = vec; - }; - case BrushTarget.UV3_Z: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv3[idx]; - vec.z *= (float)v; - s.uv3[idx] = vec; - }; - case BrushTarget.UV3_W: - return delegate(int idx, ref object v) - { - Vector4 vec = s.uv3[idx]; - vec.w *= (float)v; - s.uv3[idx] = vec; - }; - - } - return null; - } - - delegate void Lerper(int idx,ref object x,float strength); - - Lerper GetLerper(VertexInstanceStream s) - { - if (tab == Tab.Flow) - { - switch (flowTarget) - { - case FlowTarget.ColorRG: - return delegate(int idx, ref object v, float r) - { - Vector2 vv = (Vector2)v; - Color c = s.colors[idx]; - s.colors[idx].r = Mathf.Lerp(c.r, vv.x, r); - s.colors[idx].g = Mathf.Lerp(c.g, vv.y, r); - }; - case FlowTarget.ColorBA: - return delegate(int idx, ref object v, float r) - { - Vector2 vv = (Vector2)v; - Color c = s.colors[idx]; - s.colors[idx].b = Mathf.Lerp(c.r, vv.x, r); - s.colors[idx].a = Mathf.Lerp(c.g, vv.y, r); - }; - case FlowTarget.UV0_XY: - return delegate(int idx, ref object v, float r) - { - Vector4 o = s.uv0[idx]; - Vector2 t = (Vector2)v; - o.x = Mathf.Lerp(o.x, t.x, r); - o.y = Mathf.Lerp(o.y, t.y, r); - s.uv0[idx] = o; - }; - case FlowTarget.UV0_ZW: - return delegate(int idx, ref object v, float r) - { - Vector4 o = s.uv0[idx]; - Vector2 t = (Vector2)v; - o.z = Mathf.Lerp(o.z, t.x, r); - o.w = Mathf.Lerp(o.w, t.y, r); - s.uv0[idx] = o; - }; - case FlowTarget.UV1_XY: - return delegate(int idx, ref object v, float r) - { - Vector4 o = s.uv1[idx]; - Vector2 t = (Vector2)v; - o.x = Mathf.Lerp(o.x, t.x, r); - o.y = Mathf.Lerp(o.y, t.y, r); - s.uv1[idx] = o; - }; - case FlowTarget.UV1_ZW: - return delegate(int idx, ref object v, float r) - { - Vector4 o = s.uv1[idx]; - Vector2 t = (Vector2)v; - o.z = Mathf.Lerp(o.z, t.x, r); - o.w = Mathf.Lerp(o.w, t.y, r); - s.uv1[idx] = o; - }; - case FlowTarget.UV2_XY: - return delegate(int idx, ref object v, float r) - { - Vector4 o = s.uv2[idx]; - Vector2 t = (Vector2)v; - o.x = Mathf.Lerp(o.x, t.x, r); - o.y = Mathf.Lerp(o.y, t.y, r); - s.uv2[idx] = o; - }; - case FlowTarget.UV2_ZW: - return delegate(int idx, ref object v, float r) - { - Vector4 o = s.uv2[idx]; - Vector2 t = (Vector2)v; - o.z = Mathf.Lerp(o.z, t.x, r); - o.w = Mathf.Lerp(o.w, t.y, r); - s.uv2[idx] = o; - }; - case FlowTarget.UV3_XY: - return delegate(int idx, ref object v, float r) - { - Vector4 o = s.uv3[idx]; - Vector2 t = (Vector2)v; - o.x = Mathf.Lerp(o.x, t.x, r); - o.y = Mathf.Lerp(o.y, t.y, r); - s.uv3[idx] = o; - }; - case FlowTarget.UV3_ZW: - return delegate(int idx, ref object v, float r) - { - Vector4 o = s.uv3[idx]; - Vector2 t = (Vector2)v; - o.z = Mathf.Lerp(o.z, t.x, r); - o.w = Mathf.Lerp(o.w, t.y, r); - s.uv3[idx] = o; - }; - } - return null; - } - switch (brushMode) - { - case BrushTarget.Color: - return delegate(int idx, ref object v, float r) - { - s.colors[idx] = Color.Lerp(s.colors[idx], (Color)v, r); - }; - case BrushTarget.ValueR: - return delegate(int idx, ref object v, float r) - { - s.colors[idx].r = Mathf.Lerp(s.colors[idx].r, (float)v, r); - }; - case BrushTarget.ValueG: - return delegate(int idx, ref object v, float r) - { - s.colors[idx].g = Mathf.Lerp(s.colors[idx].g, (float)v, r); - }; - case BrushTarget.ValueB: - return delegate(int idx, ref object v, float r) - { - s.colors[idx].b = Mathf.Lerp(s.colors[idx].b, (float)v, r); - }; - case BrushTarget.ValueA: - return delegate(int idx, ref object v, float r) - { - s.colors[idx].a = Mathf.Lerp(s.colors[idx].a, (float)v, r); - }; - case BrushTarget.UV0_X: - return delegate(int idx, ref object v, float r) - { - Vector4 vec = s.uv0[idx]; - vec.x = Mathf.Lerp(vec.x, (float)v, r); - s.uv0[idx] = vec; - }; - case BrushTarget.UV0_Y: - return delegate(int idx, ref object v, float r) - { - Vector4 vec = s.uv0[idx]; - vec.y = Mathf.Lerp(vec.y, (float)v, r); - s.uv0[idx] = vec; - }; - case BrushTarget.UV0_Z: - return delegate(int idx, ref object v, float r) - { - Vector4 vec = s.uv0[idx]; - vec.z = Mathf.Lerp(vec.z, (float)v, r); - s.uv0[idx] = vec; - }; - case BrushTarget.UV0_W: - return delegate(int idx, ref object v, float r) - { - Vector4 vec = s.uv0[idx]; - vec.w = Mathf.Lerp(vec.w, (float)v, r); - s.uv0[idx] = vec; - }; - case BrushTarget.UV1_X: - return delegate(int idx, ref object v, float r) - { - Vector4 vec = s.uv1[idx]; - vec.x = Mathf.Lerp(vec.x, (float)v, r); - s.uv1[idx] = vec; - }; - case BrushTarget.UV1_Y: - return delegate(int idx, ref object v, float r) - { - Vector4 vec = s.uv1[idx]; - vec.y = Mathf.Lerp(vec.y, (float)v, r); - s.uv1[idx] = vec; - }; - case BrushTarget.UV1_Z: - return delegate(int idx, ref object v, float r) - { - Vector4 vec = s.uv1[idx]; - vec.z = Mathf.Lerp(vec.z, (float)v, r); - s.uv1[idx] = vec; - }; - case BrushTarget.UV1_W: - return delegate(int idx, ref object v, float r) - { - Vector4 vec = s.uv1[idx]; - vec.w = Mathf.Lerp(vec.w, (float)v, r); - s.uv1[idx] = vec; - }; - case BrushTarget.UV2_X: - return delegate(int idx, ref object v, float r) - { - Vector4 vec = s.uv2[idx]; - vec.x = Mathf.Lerp(vec.x, (float)v, r); - s.uv2[idx] = vec; - }; - case BrushTarget.UV2_Y: - return delegate(int idx, ref object v, float r) - { - Vector4 vec = s.uv2[idx]; - vec.y = Mathf.Lerp(vec.y, (float)v, r); - s.uv2[idx] = vec; - }; - case BrushTarget.UV2_Z: - return delegate(int idx, ref object v, float r) - { - Vector4 vec = s.uv2[idx]; - vec.z = Mathf.Lerp(vec.z, (float)v, r); - s.uv2[idx] = vec; - }; - case BrushTarget.UV2_W: - return delegate(int idx, ref object v, float r) - { - Vector4 vec = s.uv2[idx]; - vec.w = Mathf.Lerp(vec.w, (float)v, r); - s.uv2[idx] = vec; - }; - case BrushTarget.UV3_X: - return delegate(int idx, ref object v, float r) - { - Vector4 vec = s.uv3[idx]; - vec.x = Mathf.Lerp(vec.x, (float)v, r); - s.uv3[idx] = vec; - }; - case BrushTarget.UV3_Y: - return delegate(int idx, ref object v, float r) - { - Vector4 vec = s.uv3[idx]; - vec.y = Mathf.Lerp(vec.y, (float)v, r); - s.uv3[idx] = vec; - }; - case BrushTarget.UV3_Z: - return delegate(int idx, ref object v, float r) - { - Vector4 vec = s.uv3[idx]; - vec.z = Mathf.Lerp(vec.z, (float)v, r); - s.uv3[idx] = vec; - }; - case BrushTarget.UV3_W: - return delegate(int idx, ref object v, float r) - { - Vector4 vec = s.uv3[idx]; - vec.w = Mathf.Lerp(vec.w, (float)v, r); - s.uv3[idx] = vec; - }; - - } - return null; - } - - object GetBrushValue() - { - if (tab == Tab.Flow) - { - return strokeDir; - } - switch (brushMode) - { - case BrushTarget.Color: - return brushColor; - case BrushTarget.ValueR: - return brushValue / 255.0f; - case BrushTarget.ValueG: - return brushValue / 255.0f; - case BrushTarget.ValueB: - return brushValue / 255.0f; - case BrushTarget.ValueA: - return brushValue / 255.0f; - default: - return floatBrushValue; - } - } - - - public enum FlowTarget - { - ColorRG = 0, - ColorBA, - UV0_XY, - UV0_ZW, - UV1_XY, - UV1_ZW, - UV2_XY, - UV2_ZW, - UV3_XY, - UV3_ZW - } - - public enum FlowBrushType - { - Direction = 0, - Soften - } - - public enum FlowVisualization - { - Arrows = 0, - Water, - } - - public enum BrushTarget - { - Color = 0, - ValueR, - ValueG, - ValueB, - ValueA, - UV0_X, - UV0_Y, - UV0_Z, - UV0_W, - UV1_X, - UV1_Y, - UV1_Z, - UV1_W, - UV2_X, - UV2_Y, - UV2_Z, - UV2_W, - UV3_X, - UV3_Y, - UV3_Z, - UV3_W, - } - - public enum VertexMode - { - Adjust, - Smear, - Smooth, - HistoryEraser, - } - - public enum VertexContraint - { - Camera, - Normal, - X, - Y, - Z, - } - - public bool enabled; - public Vector3 oldpos = Vector3.zero; - public float brushSize = 1; - public float brushFlow = 8; - public float brushFalloff = 1; // linear - public Color brushColor = Color.red; - public int brushValue = 255; - public float floatBrushValue = 1.0f; - public Vector2 uvVisualizationRange = new Vector2(0, 1); - public BrushTarget brushMode = BrushTarget.Color; - public VertexMode vertexMode = VertexMode.Adjust; - public FlowTarget flowTarget = FlowTarget.ColorRG; - public FlowBrushType flowBrushType = FlowBrushType.Direction; - public FlowVisualization flowVisualization = FlowVisualization.Water; - public bool flowRemap01 = true; - public bool pull = false; - public VertexContraint vertexContraint = VertexContraint.Normal; - public bool showVertexShader = false; - public bool showVertexPoints = false; - - public enum BrushVisualization - { - Sphere, - Disk - } - public BrushVisualization brushVisualization = BrushVisualization.Sphere; - public PaintJob[] jobs = new PaintJob[0]; - - - public class PaintJob - { - public MeshFilter meshFilter; - public Renderer renderer; - public VertexInstanceStream _stream; - // cache of data we often need so we don't have to cross the c#->cpp bridge often - public Vector3[] verts; - public Vector3[] normals; - public Vector4[] tangents; - - - public bool HasStream() { return _stream != null; } - public VertexInstanceStream stream - { - get - { - if (_stream == null) - { - if (meshFilter == null) - { // object has been deleted - return null; - } - _stream = meshFilter.gameObject.GetComponent(); - if (_stream == null) - { - _stream = meshFilter.gameObject.AddComponent(); - } - else - { - _stream.Apply(); - } - } - return _stream; - } - - } - - public void InitMeshConnections() - { - UnityEngine.Profiling.Profiler.BeginSample("Generate Mesh Connections"); - // a half edge representation would be nice, but really just care about adjacentcy for now.. - vertexConnections = new List[meshFilter.sharedMesh.vertexCount]; - for (int i = 0; i < vertexConnections.Length; ++i) - { - vertexConnections[i] = new List(); - } - int[] tris = meshFilter.sharedMesh.triangles; - for (int i = 0; i < tris.Length; i=i+3) - { - int c0 = tris[i]; - int c1 = tris[i + 1]; - int c2 = tris[i + 2]; - - List l = vertexConnections[c0]; - if (!l.Contains(c1)) - { - l.Add(c1); - } - if (!l.Contains(c2)) - { - l.Add(c2); - } - - l = vertexConnections[c1]; - if (!l.Contains(c2)) - { - l.Add(c2); - } - if (!l.Contains(c0)) - { - l.Add(c0); - } - - l = vertexConnections[c2]; - if (!l.Contains(c1)) - { - l.Add(c1); - } - if (!l.Contains(c0)) - { - l.Add(c0); - } - } - UnityEngine.Profiling.Profiler.EndSample(); - } - - public List[] vertexConnections; - - public PaintJob(MeshFilter mf, Renderer r) - { - meshFilter = mf; - renderer = r; - if (r.sharedMaterials != null && r.sharedMaterials.Length > 1) - { - stream.originalMaterial = new Material[r.sharedMaterials.Length]; - for (int i = 0; i < r.sharedMaterials.Length; ++i) - { - stream.originalMaterial[i] = r.sharedMaterials[i]; - } - } - else - { - stream.originalMaterial = new Material[1]; - stream.originalMaterial[0] = r.sharedMaterial; - } - verts = mf.sharedMesh.vertices; - normals = mf.sharedMesh.normals; - tangents = mf.sharedMesh.tangents; - // optionally defer this unless the brush is set to position.. - InitMeshConnections(); - } - } - - public void RevertMat() - { - // revert old materials - for (int i = 0; i < jobs.Length; ++i) - { - if (jobs[i].renderer != null) - { - var j = jobs[i]; - if (j.renderer.sharedMaterials != null && j.stream.originalMaterial != null && - j.renderer.sharedMaterials.Length == j.stream.originalMaterial.Length && - j.stream.originalMaterial.Length > 1) - { - Material[] mats = new Material[j.stream.originalMaterial.Length]; - for (int x = 0; x < jobs[i].renderer.sharedMaterials.Length; ++x) - { - mats[x] = j.stream.originalMaterial[x]; - } - j.renderer.sharedMaterials = mats; - } - else - { - jobs[i].renderer.sharedMaterial = jobs[i].stream.originalMaterial[0]; - } - } - EditorUtility.SetSelectedWireframeHidden(jobs[i].renderer, true); - } - } - - void InitMeshes() - { - RevertMat(); - - List pjs = new List(); - Object[] objs = Selection.GetFiltered(typeof(GameObject), SelectionMode.Editable | SelectionMode.OnlyUserModifiable | SelectionMode.Deep); - for (int i = 0; i < objs.Length; ++i) - { - GameObject go = objs[i] as GameObject; - if (go != null) - { - MeshFilter mf = go.GetComponent(); - Renderer r = go.GetComponent(); - if (mf != null && r != null && mf.sharedMesh.isReadable) - { - pjs.Add(new PaintJob(mf, r)); - } - } - } - - jobs = pjs.ToArray(); - UpdateDisplayMode(); - } - - void UpdateDisplayMode() - { - if (painting) - { - EndStroke(); - } - if (VertexInstanceStream.vertexShaderMat == null) - { - VertexInstanceStream.vertexShaderMat = new Material(Shader.Find("Hidden/VertexPainterPro_Preview")); - VertexInstanceStream.vertexShaderMat.hideFlags = HideFlags.HideAndDontSave; - } - for (int i = 0; i < jobs.Length; ++i) - { - var job = jobs[i]; - EditorUtility.SetSelectedWireframeHidden(job.renderer, hideMeshWireframe); - - if (!showVertexShader) - { - if (job.renderer) - { - if (job.renderer.sharedMaterials != null && job.renderer.sharedMaterials.Length > 1 && - job.renderer.sharedMaterials.Length == job.stream.originalMaterial.Length) - { - Material[] mats = new Material[jobs[i].renderer.sharedMaterials.Length]; - - for (int x = 0; x < job.renderer.sharedMaterials.Length; ++x) - { - mats[x] = job.stream.originalMaterial[x]; - } - job.renderer.sharedMaterials = mats; - } - else - { - job.renderer.sharedMaterial = job.stream.originalMaterial[0]; - } - } - } - else - { - if (job.renderer != null) - { - if (job.renderer.sharedMaterials != null && job.renderer.sharedMaterials.Length > 1) - { - Material[] mats = new Material[job.renderer.sharedMaterials.Length]; - for (int x = 0; x < job.renderer.sharedMaterials.Length; ++x) - { - mats[x] = VertexInstanceStream.vertexShaderMat; - } - job.renderer.sharedMaterials = mats; - } - else - { - job.renderer.sharedMaterial = VertexInstanceStream.vertexShaderMat; - } - VertexInstanceStream.vertexShaderMat.SetInt("_flowVisualization", (int)flowVisualization); - VertexInstanceStream.vertexShaderMat.SetInt("_tab", (int)tab); - VertexInstanceStream.vertexShaderMat.SetInt("_flowTarget", (int)flowTarget); - VertexInstanceStream.vertexShaderMat.SetInt("_channel", (int)brushMode); - VertexInstanceStream.vertexShaderMat.SetVector("_uvRange", uvVisualizationRange); - - } - } - } - } - - void OnUndo() - { - for (int i = 0; i < jobs.Length; ++i) - { - if (jobs[i].stream != null) - { - jobs[i].stream.Apply(false); - } - } - } - - void FillMesh(PaintJob job) - { - PrepBrushMode(job); - var setter = GetSetter(job.stream); - var val = GetBrushValue(); - for (int i = 0; i < job.verts.Length; ++i) - { - setter.Invoke(i, ref val); - } - job.stream.Apply(); - } - - void RandomMesh(PaintJob job) - { - Color oldColor = brushColor; - int oldVal = brushValue; - float oldFloat = floatBrushValue; - PrepBrushMode(job); - var setter = GetSetter(job.stream); - for (int i = 0; i < job.verts.Length; ++i) - { - brushColor = new Color(UnityEngine.Random.Range(0.0f, 1.0f), - UnityEngine.Random.Range(0.0f, 1.0f), - UnityEngine.Random.Range(0.0f, 1.0f), - UnityEngine.Random.Range(0.0f, 1.0f)); - brushValue = UnityEngine.Random.Range(0, 255); - floatBrushValue = UnityEngine.Random.Range(uvVisualizationRange.x, uvVisualizationRange.y); - object v = GetBrushValue(); - setter(i, ref v); - } - job.stream.Apply(); - brushColor = oldColor; - brushValue = oldVal; - floatBrushValue = oldFloat; - } - - void InitColors(PaintJob j) - { - Color[] colors = j.stream.colors; - if (colors == null || colors.Length != j.verts.Length) - { - Color[] orig = j.meshFilter.sharedMesh.colors; - if (j.meshFilter.sharedMesh.colors != null && j.meshFilter.sharedMesh.colors.Length > 0) - { - j.stream.colors = orig; - } - else - { - j.stream.SetColor(Color.white, j.verts.Length); - } - } - } - - void InitUV0(PaintJob j) - { - List uvs = j.stream.uv0; - if (uvs == null || uvs.Count != j.verts.Length) - { - if (j.meshFilter.sharedMesh.uv != null && j.meshFilter.sharedMesh.uv.Length == j.verts.Length) - { - List nuv = new List(j.meshFilter.sharedMesh.vertices.Length); - j.meshFilter.sharedMesh.GetUVs(0, nuv); - j.stream.uv0 = nuv; - } - else - { - j.stream.SetUV0(Vector4.zero, j.verts.Length); - } - } - } - - void InitUV1(PaintJob j) - { - var uvs = j.stream.uv1; - if (uvs == null || uvs.Count != j.verts.Length) - { - if (j.meshFilter.sharedMesh.uv2 != null && j.meshFilter.sharedMesh.uv2.Length == j.verts.Length) - { - List nuv = new List(j.meshFilter.sharedMesh.vertices.Length); - j.meshFilter.sharedMesh.GetUVs(1, nuv); - j.stream.uv1 = nuv; - } - else - { - j.stream.SetUV1(Vector2.zero, j.verts.Length); - } - } - } - - void InitUV2(PaintJob j) - { - var uvs = j.stream.uv2; - if (uvs == null || uvs.Count != j.verts.Length) - { - if (j.meshFilter.sharedMesh.uv3 != null && j.meshFilter.sharedMesh.uv3.Length == j.verts.Length) - { - List nuv = new List(j.meshFilter.sharedMesh.vertices.Length); - j.meshFilter.sharedMesh.GetUVs(2, nuv); - j.stream.uv2 = nuv; - } - else - { - j.stream.SetUV2(Vector2.zero, j.verts.Length); - } - } - } - - void InitUV3(PaintJob j) - { - var uvs = j.stream.uv3; - if (uvs == null || uvs.Count != j.verts.Length) - { - if (j.meshFilter.sharedMesh.uv4 != null && j.meshFilter.sharedMesh.uv4.Length == j.verts.Length) - { - List nuv = new List(j.meshFilter.sharedMesh.vertices.Length); - j.meshFilter.sharedMesh.GetUVs(3, nuv); - j.stream.uv3 = nuv; - } - else - { - j.stream.SetUV3(Vector2.zero, j.verts.Length); - } - } - } - - void PrepBrushMode(PaintJob j) - { - if (tab == Tab.Deform) - { - Vector3[] pos = j.stream.positions; - if (pos == null || pos.Length != j.verts.Length) - { - int vc = j.meshFilter.sharedMesh.vertexCount; - if (j.stream.positions == null || j.stream.positions.Length != vc) - { - j.stream.positions = new Vector3[j.meshFilter.sharedMesh.vertices.Length]; - j.meshFilter.sharedMesh.vertices.CopyTo(j.stream.positions, 0); - } - if (j.stream.normals == null || j.stream.normals.Length != vc) - { - j.stream.normals = new Vector3[j.meshFilter.sharedMesh.vertices.Length]; - j.meshFilter.sharedMesh.normals.CopyTo(j.stream.normals, 0); - } - if (j.stream.tangents == null || j.stream.tangents.Length != vc) - { - j.stream.tangents = new Vector4[j.meshFilter.sharedMesh.vertices.Length]; - j.meshFilter.sharedMesh.tangents.CopyTo(j.stream.tangents, 0); - } - } - return; - } - if (tab == Tab.Flow) - { - switch (flowTarget) - { - case FlowTarget.ColorRG: - goto case FlowTarget.ColorBA; - case FlowTarget.ColorBA: - { - InitColors(j); - break; - } - case FlowTarget.UV0_XY: - { - InitUV0(j); - break; - } - case FlowTarget.UV1_XY: - { - InitUV1(j); - break; - } - case FlowTarget.UV2_XY: - { - InitUV2(j); - break; - } - case FlowTarget.UV3_XY: - { - InitUV3(j); - break; - } - } - return; - } - - // make sure the instance data is initialized - switch (brushMode) - { - case BrushTarget.Color: - goto case BrushTarget.ValueA; - case BrushTarget.ValueR: - goto case BrushTarget.ValueA; - case BrushTarget.ValueG: - goto case BrushTarget.ValueA; - case BrushTarget.ValueB: - goto case BrushTarget.ValueA; - case BrushTarget.ValueA: - { - InitColors(j); - break; - } - case BrushTarget.UV0_X: - goto case BrushTarget.UV0_Y; - case BrushTarget.UV0_Y: - { - InitUV0(j); - break; - } - case BrushTarget.UV1_X: - goto case BrushTarget.UV1_Y; - case BrushTarget.UV1_Y: - { - InitUV1(j); - break; - } - case BrushTarget.UV2_X: - goto case BrushTarget.UV2_Y; - case BrushTarget.UV2_Y: - { - InitUV2(j); - break; - } - case BrushTarget.UV3_X: - goto case BrushTarget.UV3_Y; - case BrushTarget.UV3_Y: - { - InitUV3(j); - break; - } - - } - - } - - - void DrawVertexPoints(PaintJob j, Vector3 point) - { - UnityEngine.Profiling.Profiler.BeginSample("Draw Vertex Points"); - PrepBrushMode(j); - // convert point into local space, so we don't have to convert every point - point = j.renderer.transform.worldToLocalMatrix.MultiplyPoint3x4(point); - // for some reason this doesn't handle scale, seems like it should - // we handle it poorly until I can find a better solution - float scale = 1.0f / Mathf.Abs(j.renderer.transform.lossyScale.x); - - float bz = scale * brushSize; - - for (int i = 0; i < j.verts.Length; ++i) - { - float d = Vector3.Distance(point, j.verts[i]); - if (d < bz) - { - Handles.color = Color.white; - Vector3 wp = j.meshFilter.transform.localToWorldMatrix.MultiplyPoint(j.verts[i]); - Handles.SphereCap(0, wp, Quaternion.identity, HandleUtility.GetHandleSize(wp) * 0.02f); - } - } - UnityEngine.Profiling.Profiler.EndSample(); - } - - - void PaintMesh(PaintJob j, Vector3 point) - { - UnityEngine.Profiling.Profiler.BeginSample("Paint Mesh"); - PrepBrushMode(j); - // convert point into local space, so we don't have to convert every point - point = j.renderer.transform.worldToLocalMatrix.MultiplyPoint3x4(point); - // for some reason this doesn't handle scale, seems like it should - // we handle it poorly until I can find a better solution - float scale = 1.0f / Mathf.Abs(j.renderer.transform.lossyScale.x); - - float bz = scale * brushSize; - var lerper = GetLerper(j.stream); - var value = GetBrushValue(); - float pressure = Event.current.pressure > 0 ? Event.current.pressure : 1.0f; - - bool modPos = !(j.stream.positions == null || j.stream.positions.Length == 0); - if (tab == Tab.Flow) - { - float strength = strokeDir.magnitude; - Vector3 sd = strokeDir.normalized; - Vector2 target = new Vector2(0.5f, 0.5f); - for (int i = 0; i < j.verts.Length; ++i) - { - float d = Vector3.Distance(point, modPos ? j.stream.positions[i] : j.verts[i]); - if (d < bz) - { - Vector3 n = j.normals[i]; - Vector4 t = j.tangents[i]; - - if (j.stream.normals != null && j.stream.normals.Length == j.verts.Length) - { - n = j.stream.normals[i]; - } - if (j.stream.tangents != null && j.stream.tangents.Length == j.verts.Length) - { - t = j.stream.tangents[i]; - } - - var mtx = j.meshFilter.transform.localToWorldMatrix; - n = mtx.MultiplyVector(n); - Vector3 tg = new Vector3(t.x, t.y, t.z); - tg = mtx.MultiplyVector(tg); - t.x = tg.x; - t.y = tg.y; - t.z = tg.z; - - target.x = 0.5f; - target.y = 0.5f; - if (flowBrushType == FlowBrushType.Direction) - { - Vector3 b = Vector3.Cross(n, new Vector3(t.x, t.y, t.z) * t.w); - - - float dx = Vector3.Dot(t, sd); - float dy = Vector3.Dot(b, sd); - - target = new Vector2(dx, dy); - target.Normalize(); - - if (flowTarget == FlowTarget.ColorBA || flowTarget == FlowTarget.ColorRG || flowRemap01) - { - target.x = target.x * 0.5f + 0.5f; - target.y = target.y * 0.5f + 0.5f; - } - } - - float str = 1.0f - d / bz; - str *= strength; // take brush speed into account.. - str = Mathf.Pow(str, brushFalloff); - - object obj = target; - float finalStr = str * (float)deltaTime * brushFlow * pressure; - if (finalStr > 0) - { - lerper.Invoke(i, ref obj, finalStr); - } - } - } - } - else if (tab == Tab.Deform) - { - for (int i = 0; i < j.verts.Length; ++i) - { - float d = Vector3.Distance(point, j.verts[i]); - if (d < bz) - { - float str = 1.0f - d / bz; - str = Mathf.Pow(str, brushFalloff); - PaintVertPosition(j, i, str * (float)deltaTime * brushFlow * pressure); - } - } - } - else - { - UnityEngine.Profiling.Profiler.BeginSample("Paint Color"); - for (int i = 0; i < j.verts.Length; ++i) - { - float d = Vector3.Distance(point, j.verts[i]); - if (d < bz) - { - float str = 1.0f - d / bz; - str = Mathf.Pow(str, brushFalloff); - float finalStr = str * (float)deltaTime * brushFlow * pressure; - if (finalStr > 0) - { - lerper.Invoke(i, ref value, finalStr); - } - } - } - UnityEngine.Profiling.Profiler.EndSample(); - } - - j.stream.Apply(); - UnityEngine.Profiling.Profiler.EndSample(); - } - - void EndStroke() - { - painting = false; - - // could possibly make this faster by avoiding the double apply.. - if (tab == Tab.Deform) - { - UnityEngine.Profiling.Profiler.BeginSample("Recalculate Normals and Tangents"); - for (int i = 0; i < jobs.Length; ++i) - { - PaintJob j = jobs[i]; - if (j.stream.positions != null && j.stream.normals != null && j.stream.tangents != null) - { - Mesh m = j.stream.Apply(false); - m.triangles = j.meshFilter.sharedMesh.triangles; - - m.RecalculateNormals(); - if (j.stream.normals == null) - { - j.stream.normals = new Vector3[m.vertexCount]; - } - m.normals.CopyTo(j.stream.normals, 0); - - m.uv = j.meshFilter.sharedMesh.uv; - CalculateMeshTangents(m); - if (j.stream.tangents == null) - { - j.stream.tangents = new Vector4[m.vertexCount]; - } - m.tangents.CopyTo(j.stream.tangents, 0); - - m.RecalculateBounds(); - j.stream.Apply(); - } - } - UnityEngine.Profiling.Profiler.EndSample(); - } - //Undo.CollapseUndoOperations(Undo.GetCurrentGroup()); - } - - void CalculateMeshTangents(Mesh mesh) - { - //speed up math by copying the mesh arrays - int[] triangles = mesh.triangles; - Vector3[] vertices = mesh.vertices; - Vector2[] uv = mesh.uv; - Vector3[] normals = mesh.normals; - - //variable definitions - int triangleCount = triangles.Length; - int vertexCount = vertices.Length; - - Vector3[] tan1 = new Vector3[vertexCount]; - Vector3[] tan2 = new Vector3[vertexCount]; - - Vector4[] tangents = new Vector4[vertexCount]; - - for (long a = 0; a < triangleCount; a += 3) - { - long i1 = triangles[a + 0]; - long i2 = triangles[a + 1]; - long i3 = triangles[a + 2]; - - Vector3 v1 = vertices[i1]; - Vector3 v2 = vertices[i2]; - Vector3 v3 = vertices[i3]; - - Vector2 w1 = uv[i1]; - Vector2 w2 = uv[i2]; - Vector2 w3 = uv[i3]; - - float x1 = v2.x - v1.x; - float x2 = v3.x - v1.x; - float y1 = v2.y - v1.y; - float y2 = v3.y - v1.y; - float z1 = v2.z - v1.z; - float z2 = v3.z - v1.z; - - float s1 = w2.x - w1.x; - float s2 = w3.x - w1.x; - float t1 = w2.y - w1.y; - float t2 = w3.y - w1.y; - - float div = s1 * t2 - s2 * t1; - float r = div == 0.0f ? 0.0f : 1.0f / div; - - Vector3 sdir = new Vector3((t2 * x1 - t1 * x2) * r, (t2 * y1 - t1 * y2) * r, (t2 * z1 - t1 * z2) * r); - Vector3 tdir = new Vector3((s1 * x2 - s2 * x1) * r, (s1 * y2 - s2 * y1) * r, (s1 * z2 - s2 * z1) * r); - - tan1[i1] += sdir; - tan1[i2] += sdir; - tan1[i3] += sdir; - - tan2[i1] += tdir; - tan2[i2] += tdir; - tan2[i3] += tdir; - } - - - for (long a = 0; a < vertexCount; ++a) - { - Vector3 n = normals[a]; - Vector3 t = tan1[a]; - - //Vector3 tmp = (t - n * Vector3.Dot(n, t)).normalized; - //tangents[a] = new Vector4(tmp.x, tmp.y, tmp.z); - Vector3.OrthoNormalize(ref n, ref t); - tangents[a].x = t.x; - tangents[a].y = t.y; - tangents[a].z = t.z; - - tangents[a].w = (Vector3.Dot(Vector3.Cross(n, t), tan2[a]) < 0.0f) ? -1.0f : 1.0f; - } - - mesh.tangents = tangents; - } - - void ConstrainAxis(ref Vector3 cur, Vector3 orig) - { - if (vertexContraint == VertexContraint.X) - { - cur.y = orig.y; - cur.z = orig.z; - } - else if (vertexContraint == VertexContraint.Y) - { - cur.x = orig.x; - cur.z = orig.z; - } - else if (vertexContraint == VertexContraint.Z) - { - cur.x = orig.x; - cur.y = orig.y; - } - } - - void PaintVertPosition(PaintJob j, int i, float strength) - { - switch (vertexMode) - { - case VertexMode.Adjust: - { - switch (vertexContraint) - { - case VertexContraint.Normal: - { - Vector3 cur = j.stream.positions[i]; - Vector3 dir = j.stream.normals[i].normalized; - dir *= strength; - cur += pull ? dir : -dir; - j.stream.positions[i] = cur; - break; - } - case VertexContraint.Camera: - { - Vector3 cur = j.stream.positions[i]; - Vector3 dir = strokeDir; - dir *= strength; - cur += pull ? dir : -dir; - j.stream.positions[i] = cur; - break; - } - case VertexContraint.X: - { - Vector3 cur = j.stream.positions[i]; - Vector3 dir = new Vector3(1, 0, 0); - dir *= strength; - cur += pull ? dir : -dir; - j.stream.positions[i] = cur; - break; - } - case VertexContraint.Y: - { - Vector3 cur = j.stream.positions[i]; - Vector3 dir = new Vector3(0, 1, 0); - dir *= strength; - cur += pull ? dir : -dir; - j.stream.positions[i] = cur; - break; - } - case VertexContraint.Z: - { - Vector3 cur = j.stream.positions[i]; - Vector3 dir = new Vector3(0, 0, 1); - dir *= strength; - cur += pull ? dir : -dir; - j.stream.positions[i] = cur; - break; - } - } - break; - } - case VertexMode.Smooth: - { - Vector3 cur = j.stream.positions[i]; - var con = j.vertexConnections[i]; - for (int x = 0; x < con.Count; ++x) - { - cur += j.stream.positions[con[x]]; - } - cur /= (con.Count + 1); - ConstrainAxis(ref cur, j.stream.positions[i]); - - j.stream.positions[i] = Vector3.Lerp(j.stream.positions[i], cur, Mathf.Clamp01(strength)); - break; - } - case VertexMode.Smear: - { - Vector3 cur = j.stream.positions[i]; - Vector3 dir = strokeDir; - dir *= strength; - cur += pull ? dir : -dir; - j.stream.positions[i] = cur; - break; - } - case VertexMode.HistoryEraser: - { - Vector3 cur = j.stream.positions[i]; - Vector3 orig = j.verts[i]; - ConstrainAxis(ref orig, cur); - j.stream.positions[i] = Vector3.Lerp(cur, orig, Mathf.Clamp01(strength)); - break; - } - } - } - - double deltaTime = 0; - double lastTime = 0; - bool painting = false; - Vector3 oldMousePosition; - Vector3 strokeDir = Vector3.zero; - - void OnSceneGUI(SceneView sceneView) - { - deltaTime = EditorApplication.timeSinceStartup - lastTime; - lastTime = EditorApplication.timeSinceStartup; - - if (jobs.Length == 0 && Selection.activeGameObject != null) - { - InitMeshes(); - } - - if (!enabled || jobs.Length == 0 || Selection.activeGameObject == null) - { - return; - } - - if (tab == Tab.Bake) - { - return; - } - - if (VertexInstanceStream.vertexShaderMat != null) - { - VertexInstanceStream.vertexShaderMat.SetFloat("_time", (float)EditorApplication.timeSinceStartup); - } - - RaycastHit hit; - float distance = float.MaxValue; - Vector3 mousePosition = Event.current.mousePosition; - mousePosition.y = sceneView.camera.pixelHeight - mousePosition.y; - - Vector3 fakeMP = mousePosition; - fakeMP.z = 20; - Vector3 point = sceneView.camera.ScreenToWorldPoint(fakeMP); - Vector3 normal = Vector3.forward; - Ray ray = sceneView.camera.ScreenPointToRay(mousePosition); - for (int i = 0; i < jobs.Length; ++i) - { - if (jobs[i] == null || jobs[i].meshFilter == null) - continue; - Matrix4x4 mtx = jobs[i].meshFilter.transform.localToWorldMatrix; - Mesh msh = jobs[i].meshFilter.sharedMesh; - if (jobs[i].HasStream()) - { - msh = jobs[i].stream.GetModifierMesh(); - if (msh == null) - { - msh = jobs[i].meshFilter.sharedMesh; - } - } - - if (RXLookingGlass.IntersectRayMesh(ray, msh, mtx, out hit)) - { - if (Event.current.shift == false) - { - if (hit.distance < distance) - { - distance = hit.distance; - point = hit.point; - oldpos = hit.point; - normal = hit.normal; - // if we don't have normal overrides, we have to recast against the shared mesh to get it's normal - // This could get a little strange if you modify the mesh, then delete the normal data, but in that - // case there's no real correct answer anyway without knowing the index of the vertex we're hitting. - if (normal.magnitude < 0.1f) - { - RXLookingGlass.IntersectRayMesh(ray, jobs[i].meshFilter.sharedMesh, mtx, out hit); - normal = hit.normal; - } - } - } - else - { - point = oldpos; - } - } - else - { - if (Event.current.shift == true) - { - point = oldpos; - } - } - } - strokeDir = Vector3.zero; - if (tab == Tab.Flow || vertexMode == VertexMode.Smear) - { - if (Event.current.isMouse) - { - strokeDir = (point - oldMousePosition); - strokeDir.x *= Event.current.delta.magnitude; - strokeDir.y *= Event.current.delta.magnitude; - strokeDir.z *= Event.current.delta.magnitude; - oldMousePosition = point; - } - } - else if (vertexMode == VertexMode.Adjust) - { - strokeDir = -sceneView.camera.transform.forward; - } - - if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.alt == false) - { - painting = true; - for (int i = 0; i < jobs.Length; ++i) - { - Undo.RegisterCompleteObjectUndo(jobs[i].stream, "Vertex Painter Stroke"); - } - - } - - if (Event.current.type == EventType.KeyUp && Event.current.control) - { - if (Event.current.keyCode == KeyCode.W) - { - hideMeshWireframe = !hideMeshWireframe; - for (int i = 0; i < jobs.Length; ++i) - { - EditorUtility.SetSelectedWireframeHidden(jobs[i].renderer, hideMeshWireframe); - } - } - if (Event.current.keyCode == KeyCode.V) - { - showVertexShader = !showVertexShader; - UpdateDisplayMode(); - } - } - - - - if (Event.current.type == EventType.MouseMove && Event.current.shift) { - brushSize += Event.current.delta.x * (float)deltaTime * (float)6; - brushFalloff -= Event.current.delta.y * (float)deltaTime * (float)48; - } - - if (Event.current.rawType == EventType.MouseUp) - { - EndStroke(); - } - if (Event.current.type == EventType.MouseMove && Event.current.alt) - { - brushSize += Event.current.delta.y * (float)deltaTime; - } - - // set brush color - if (brushMode == BrushTarget.Color) - { - Handles.color = new Color(brushColor.r, brushColor.g, brushColor.b, 0.4f); - } - else if (brushMode == BrushTarget.ValueR || brushMode == BrushTarget.ValueG || - brushMode == BrushTarget.ValueB || brushMode == BrushTarget.ValueA) - { - float v = (float)brushValue / 255.0f; - Handles.color = new Color(v, v, v, 0.4f); - } - else - { - float v = (floatBrushValue - uvVisualizationRange.x) / Mathf.Max(0.00001f, uvVisualizationRange.y); - Handles.color = new Color(v, v, v, 0.4f); - } - - if (brushVisualization == BrushVisualization.Sphere) - { - Handles.SphereCap(0, point, Quaternion.identity, brushSize * 2); - } - else - { - Handles.color = new Color(0.8f, 0, 0, 1.0f); - float r = Mathf.Pow(0.5f, brushFalloff); - Handles.DrawWireDisc(point, normal, brushSize * r); - Handles.color = new Color(0.9f, 0, 0, 0.8f); - Handles.DrawWireDisc(point, normal, brushSize); - } - // eat current event if mouse event and we're painting - if (Event.current.isMouse && painting) - { - Event.current.Use(); - } - - if (Event.current.type == EventType.Layout) - { - HandleUtility.AddDefaultControl(GUIUtility.GetControlID(GetHashCode(), FocusType.Passive)); - } - - // only paint once per frame - if (tab != Tab.Flow && Event.current.type != EventType.Repaint) - { - return; - } - - - if (jobs.Length > 0 && painting) - { - for (int i = 0; i < jobs.Length; ++i) - { - PaintMesh(jobs[i], point); - Undo.RecordObject(jobs[i].stream, "Vertex Painter Stroke"); - - } - } - - if (jobs.Length > 0 && showVertexPoints) - { - for (int i = 0; i < jobs.Length; ++i) - { - DrawVertexPoints(jobs[i], point); - } - } - - // update views - sceneView.Repaint(); - HandleUtility.Repaint(); - } - } -} diff --git a/VertexPaint/Editor/VertexPainterWindow_Painting.cs.meta b/VertexPaint/Editor/VertexPainterWindow_Painting.cs.meta deleted file mode 100644 index 99b356e..0000000 --- a/VertexPaint/Editor/VertexPainterWindow_Painting.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: fbee0de5b71e84e9989cb94b2521e6bc -timeCreated: 1447602377 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VertexPaint/VertexInstanceStream.cs b/VertexPaint/VertexInstanceStream.cs deleted file mode 100644 index a636a9c..0000000 --- a/VertexPaint/VertexInstanceStream.cs +++ /dev/null @@ -1,435 +0,0 @@ -using UnityEngine; -using System.Collections; -using System; -using System.Collections.Generic; -using UnityEngine.Profiling; - -/* Holds streams of data to override the colors or UVs on a mesh without making the mesh unique. This is more - * memory efficient than burning the color data into many copies of a mesh, and much easier to manage. - * -*/ -namespace JBooth.VertexPainterPro -{ - [ExecuteInEditMode] - public class VertexInstanceStream : MonoBehaviour - { - [HideInInspector] - [SerializeField] - private Color[] _colors; - - [HideInInspector] - [SerializeField] - private List _uv0; - - [HideInInspector] - [SerializeField] - private List _uv1; - - [HideInInspector] - [SerializeField] - private List _uv2; - - [HideInInspector] - [SerializeField] - private List _uv3; - - [HideInInspector] - [SerializeField] - private Vector3[] _positions; - - [HideInInspector] - [SerializeField] - private Vector3[] _normals; - - [HideInInspector] - [SerializeField] - private Vector4[] _tangents; - - public Color[] colors - { - get - { - return _colors; - } - set - { - enforcedColorChannels = (! (_colors == null || (value != null && _colors.Length != value.Length))); - _colors = value; - Apply(); - } - } - - public List uv0 { get { return _uv0; } set { _uv0 = value; Apply(); } } - public List uv1 { get { return _uv1; } set { _uv1 = value; Apply(); } } - public List uv2 { get { return _uv2; } set { _uv2 = value; Apply(); } } - public List uv3 { get { return _uv3; } set { _uv3 = value; Apply(); } } - public Vector3[] positions { get { return _positions; } set { _positions = value; Apply(); } } - public Vector3[] normals { get { return _normals; } set { _normals = value; Apply(); } } - public Vector4[] tangents { get { return _tangents; } set { _tangents = value; Apply(); } } - - #if UNITY_EDITOR - // Stored here to make copy/save behaviour work better - basically, if you copy a mesh around, you want to also - // clone the original material otherwise it may have the preview material stuck on it forever. - [HideInInspector] - public Material[] originalMaterial; - public static Material vertexShaderMat; - - #endif - void Start() - { - // restore original material if we got saved with the preview material. - // I tried to do this in a number of ways; using the pre/post serialization callbacks seemed - // like the best, but is actually not possible because they don't always both get called. In editor, - // sometimes only the pre-serialization callback gets called. WTF.. - - #if UNITY_EDITOR - MeshRenderer mr = GetComponent(); - if (mr != null) - { - if (mr.sharedMaterials != null && mr.sharedMaterial == vertexShaderMat && originalMaterial != null - && originalMaterial.Length == mr.sharedMaterials.Length && originalMaterial.Length > 1) - { - Material[] mats = new Material[mr.sharedMaterials.Length]; - for (int i = 0; i < mr.sharedMaterials.Length; ++i) - { - mats[i] = originalMaterial[i]; - } - mr.sharedMaterials = mats; - } - else if (originalMaterial.Length > 0) - { - mr.sharedMaterial = originalMaterial[0]; - } - } - #endif - Apply(true); - } - - void OnDestroy() - { - if (!Application.isPlaying) - { - MeshRenderer mr = GetComponent (); - if ( mr != null ) - mr.additionalVertexStreams = null; - } - } - - bool enforcedColorChannels = false; - void EnforceOriginalMeshHasColors(Mesh stream) - { - if (enforcedColorChannels == true) - return; - enforcedColorChannels = false; - MeshFilter mf = GetComponent(); - Color[] origColors = mf.sharedMesh.colors; - if (stream != null && stream.colors.Length > 0 && (origColors == null || origColors.Length == 0)) - { - Profiler.BeginSample("Set mesh colors"); - // workaround for unity bug; dispite docs claim, color channels must exist on the original mesh - // for the additionalVertexStream to work. Which is, sad... - mf.sharedMesh.colors = stream.colors; - Profiler.EndSample(); - } - } - - #if UNITY_EDITOR - public void SetColor(Color c, int count) { _colors = new Color[count]; for (int i = 0; i < count; ++i) { _colors[i] = c; } Apply(); } - public void SetUV0(Vector4 uv, int count) { _uv0 = new List(count); for (int i = 0; i < count; ++i) { _uv0.Add(uv); } Apply(); } - public void SetUV1(Vector4 uv, int count) { _uv1 = new List(count); for (int i = 0; i < count; ++i) { _uv1.Add(uv); } Apply(); } - public void SetUV2(Vector4 uv, int count) { _uv2 = new List(count); for (int i = 0; i < count; ++i) { _uv2.Add(uv); } Apply(); } - public void SetUV3(Vector4 uv, int count) { _uv3 = new List(count); for (int i = 0; i < count; ++i) { _uv3.Add(uv); } Apply(); } - - public void SetUV0_XY(Vector2 uv, int count) - { - if (_uv0 == null || _uv0.Count != count) - { - _uv0 = new List(count); - for (int i = 0; i < count; ++i) - { - _uv0[i] = Vector4.zero; - } - } - - for (int i = 0; i < count; ++i) - { - Vector4 v = _uv0[i]; - v.x = uv.x; - v.y = uv.y; - _uv0[i] = v; - } - Apply(); - } - - public void SetUV0_ZW(Vector2 uv, int count) - { - if (_uv0 == null || _uv0.Count != count) - { - _uv0 = new List(count); - for (int i = 0; i < count; ++i) - { - _uv0[i] = Vector4.zero; - } - } - - for (int i = 0; i < count; ++i) - { - Vector4 v = _uv0[i]; - v.z = uv.x; - v.w = uv.y; - _uv0[i] = v; - } - Apply(); - } - - public void SetUV1_XY(Vector2 uv, int count) - { - if (_uv1 == null || _uv1.Count != count) - { - _uv1 = new List(count); - for (int i = 0; i < count; ++i) - { - _uv1[i] = Vector4.zero; - } - } - - for (int i = 0; i < count; ++i) - { - Vector4 v = _uv1[i]; - v.x = uv.x; - v.y = uv.y; - _uv1[i] = v; - } - Apply(); - } - - public void SetUV1_ZW(Vector2 uv, int count) - { - if (_uv1 == null || _uv1.Count != count) - { - _uv1 = new List(count); - for (int i = 0; i < count; ++i) - { - _uv1[i] = Vector4.zero; - } - } - - for (int i = 0; i < count; ++i) - { - Vector4 v = _uv1[i]; - v.z = uv.x; - v.w = uv.y; - _uv1[i] = v; - } - Apply(); - } - - public void SetUV2_XY(Vector2 uv, int count) - { - if (_uv2 == null || _uv2.Count != count) - { - _uv2 = new List(count); - for (int i = 0; i < count; ++i) - { - _uv2[i] = Vector4.zero; - } - } - - for (int i = 0; i < count; ++i) - { - Vector4 v = _uv2[i]; - v.x = uv.x; - v.y = uv.y; - _uv2[i] = v; - } - Apply(); - } - - public void SetUV2_ZW(Vector2 uv, int count) - { - if (_uv2 == null || _uv2.Count != count) - { - _uv2 = new List(count); - for (int i = 0; i < count; ++i) - { - _uv2[i] = Vector4.zero; - } - } - - for (int i = 0; i < count; ++i) - { - Vector4 v = _uv2[i]; - v.z = uv.x; - v.w = uv.y; - _uv2[i] = v; - } - Apply(); - } - - public void SetUV3_XY(Vector2 uv, int count) - { - if (_uv3 == null || _uv3.Count != count) - { - _uv3 = new List(count); - for (int i = 0; i < count; ++i) - { - _uv3[i] = Vector4.zero; - } - } - - for (int i = 0; i < count; ++i) - { - Vector4 v = _uv3[i]; - v.x = uv.x; - v.y = uv.y; - _uv3[i] = v; - } - Apply(); - } - - public void SetUV3_ZW(Vector2 uv, int count) - { - if (_uv3 == null || _uv3.Count != count) - { - _uv3 = new List(count); - for (int i = 0; i < count; ++i) - { - _uv3[i] = Vector4.zero; - } - } - - for (int i = 0; i < count; ++i) - { - Vector4 v = _uv3[i]; - v.z = uv.x; - v.w = uv.y; - _uv3[i] = v; - } - Apply(); - } - - public void SetColorRG(Vector2 rg, int count) - { - if (_colors == null || _colors.Length != count) - { - _colors = new Color[count]; - enforcedColorChannels = false; - } - for (int i = 0; i < count; ++i) - { - _colors[i].r = rg.x; - _colors[i].g = rg.y; - } - Apply(); - } - - public void SetColorBA(Vector2 ba, int count) - { - if (_colors == null || _colors.Length != count) - { - _colors = new Color[count]; - enforcedColorChannels = false; - } - for (int i = 0; i < count; ++i) - { - _colors[i].r = ba.x; - _colors[i].g = ba.y; - } - Apply(); - } - #endif - - public Mesh Apply(bool markNoLongerReadable = true) - { - MeshRenderer mr = GetComponent(); - MeshFilter mf = GetComponent(); - - if (mr != null && mf != null) - { - Profiler.BeginSample("Creating additionalVertexStream Data"); - int vertexCount = mf.sharedMesh.vertexCount; - Mesh stream = null; - #if UNITY_EDITOR - stream = meshStream; - #endif - if (stream == null || vertexCount != stream.vertexCount) - { - Profiler.BeginSample("Create Mesh stream"); - if (stream != null) - { - DestroyImmediate(stream); - } - stream = new Mesh(); - - // even though the docs say you don't need to set the positions on your avs, you do.. - stream.vertices = new Vector3[mf.sharedMesh.vertexCount]; - - // wtf, copy won't work? - // so, originally I did a copyTo here, but with a unity patch release the behavior changed and - // the verticies would all become 0. This seems a funny thing to change in a patch release, but - // since getting the data from the C++ side creates a new array anyway, we don't really need - // to copy them anyway since they are a unique copy already. - stream.vertices = mf.sharedMesh.vertices; - // another Unity bug, when in editor, the paint job will just disapear sometimes. So we have to re-assign - // it every update (even though this doesn't get called each frame, it appears to loose the data during - // the editor update call, which only happens occationaly. - stream.MarkDynamic(); - stream.triangles = mf.sharedMesh.triangles; - #if UNITY_EDITOR - meshStream = stream; - #endif - - stream.hideFlags = HideFlags.HideAndDontSave; - Profiler.EndSample(); - } - - Profiler.BeginSample("Generating Mesh"); - - if (_positions != null && _positions.Length == vertexCount) { stream.vertices = _positions; } - if (_normals != null && _normals.Length == vertexCount) { stream.normals = _normals; } else { stream.normals = null; } - if (_tangents != null && _tangents.Length == vertexCount) { stream.tangents = _tangents; } else { stream.tangents = null; } - if (_colors != null && _colors.Length == vertexCount) { stream.colors = _colors; } else { stream.colors = null; } - if (_uv0 != null && _uv0.Count == vertexCount) { stream.SetUVs(0, _uv0); } else { stream.uv = null; } - if (_uv1 != null && _uv1.Count == vertexCount) { stream.SetUVs(1, _uv1); } else { stream.uv2 = null; } - if (_uv2 != null && _uv2.Count == vertexCount) { stream.SetUVs(2, _uv2); } else { stream.uv3 = null; } - if (_uv3 != null && _uv3.Count == vertexCount) { stream.SetUVs(3, _uv3); } else { stream.uv4 = null; } - - - EnforceOriginalMeshHasColors(stream); - - Profiler.EndSample(); - - Profiler.BeginSample("Uploading mesh data"); - - if (!Application.isPlaying || Application.isEditor) - { - // only mark no longer readable in game.. - markNoLongerReadable = false; - } - - stream.UploadMeshData(markNoLongerReadable); - mr.additionalVertexStreams = stream; - - Profiler.EndSample(); // uploading mesh data - - Profiler.EndSample(); // creating additional vertex stream data - return stream; - } - return null; - } - - // hack around unity bugs in the editor.. - #if UNITY_EDITOR - private Mesh meshStream; - public Mesh GetModifierMesh() { return meshStream; } - void Update() - { - if (!Application.isPlaying) - { - MeshRenderer r = GetComponent(); - r.additionalVertexStreams = meshStream; - } - } - #endif - } -} diff --git a/VertexPaint/VertexInstanceStream.cs.meta b/VertexPaint/VertexInstanceStream.cs.meta deleted file mode 100644 index 3212358..0000000 --- a/VertexPaint/VertexInstanceStream.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 3e8f0905b39c2bd499a8c0becda2d173 -timeCreated: 1470478091 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/VertexPaint/VertexPainterPro_Preview.shader b/VertexPaint/VertexPainterPro_Preview.shader deleted file mode 100644 index ae73fb7..0000000 --- a/VertexPaint/VertexPainterPro_Preview.shader +++ /dev/null @@ -1,351 +0,0 @@ -// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' - -// I highly recomend you look in the example shaders rather than this one if your wondering how to best use -// these tools. This shader is designed to not use textures and show visual information, which makes it rather -// expensive since it has lots of procedural functions and a ton of display options in a single shader. - - -Shader "Hidden/VertexPainterPro_Preview" -{ - Properties - { - - } - SubShader - { - Tags { "RenderType"="Opaque" } - - - Pass - { - CGPROGRAM - #pragma vertex vert - #pragma fragment frag - - #include "UnityCG.cginc" - - struct appdata - { - float4 vertex : POSITION; - float4 color : COLOR; - float4 uv0 : TEXCOORD0; - float4 uv1 : TEXCOORD1; - float4 uv2 : TEXCOORD2; - float4 uv3 : TEXCOORD3; - }; - - struct v2f - { - float4 vertex : SV_POSITION; - float4 color : COLOR0; - float2 uv : TexCoord0; - float2 flow : TexCoord1; - }; - - int _channel; - float2 _uvRange; - int _flowVisualization; - int _flowTarget; - int _tab; - float _time; // because _Time won't work in edit mode.. - - float Range(float f) - { - f -= _uvRange.x; - f /= max(0.0001f, _uvRange.y); - return f; - } - - - // 2d noise - float Hash( float2 p ) - { - float h = dot(p, float2(127.1,311.7)); - return frac(sin(h)*43758.5453123); - } - - float Noise2D(float2 p ) - { - float2 i = floor( p ); - float2 f = frac( p ); - - float2 u = f*f*(3.0-2.0*f); - - float cLowerLeft = Hash( i + float2(0.0,0.0)); - float cLowerRight = Hash( i + float2(1.0,0.0)); - float cUpperLeft = Hash( i + float2(0.0,1.0)); - float cUpperRight = Hash( i + float2(1.0,1.0)); - - - float nLower = lerp(cLowerLeft, cLowerRight, u.x); - float nUpper = lerp(cUpperLeft, cUpperRight, u.x); - float noise = lerp(nLower, nUpper, u.y); - return noise; - } - - // 3d noise for water - float mod289(float x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } - float4 mod289(float4 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; } - float4 perm(float4 x) { return mod289(((x * 34.0) + 1.0) * x); } - - float Noise3d(float3 p) - { - float3 a = floor(p); - float3 d = p - a; - d = d * d * (3.0 - 2.0 * d); - - float4 b = a.xxyy + float4(0.0, 1.0, 0.0, 1.0); - float4 k1 = perm(b.xyxy); - float4 k2 = perm(k1.xyxy + b.zzww); - - float4 c = k2 + a.zzzz; - float4 k3 = perm(c); - float4 k4 = perm(c + 1.0); - - float4 o1 = frac(k3 * (1.0 / 41.0)); - float4 o2 = frac(k4 * (1.0 / 41.0)); - - float4 o3 = o2 * d.z + o1 * (1.0 - d.z); - float2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x); - - return o4.y * d.y + o4.x * (1.0 - d.y); - } - - float4 Water(float2 uv) - { - float3x3 r = float3x3(0.36, 0.48, -0.8, -0.8, 0.60, 0.0, 0.48, 0.64, 0.60); - float3 pos = mul(r, float3(uv * float2(16.0, 9.0), 0.0)); - float3 time = mul(r, float3(0.0, 0.0, _time)); - - float4 n = float4(Noise3d(pos + time), Noise3d(pos/2.02 + time), Noise3d(pos/4.01 + time), Noise3d(pos/8.12 + time)); - float p = dot(abs(2.0 * n - 1.0), float4(0.5, 0.25, 0.125, 0.125)); - float q = sqrt(p); - - return float4(1.0 - q, 1.0 - 0.5 * q, 1.0, 1.0); - } - - // flowmap water - float4 FlowWater(float2 uv, float2 flow) - { - float scale = 5; - - float n = Noise2D(uv*9); - - float2 flowVector = (flow * 2.0 - 1.0); - - float timeScale = _time * 0.05 * scale + n; - float2 phase; - - phase.x = frac(timeScale); - phase.y = frac(timeScale + 0.5); - - fixed4 color0; - fixed4 color1; - - color0 = Water(uv * scale - flowVector * half2(phase.x, phase.x)); - color1 = Water(uv * scale - flowVector * half2(phase.y, phase.y)); - - - fixed flowInterp = abs(0.5 - phase.x) / 0.5; - return lerp(color0, color1, flowInterp); - } - - v2f vert (appdata v) - { - v2f o; - o.uv = v.uv0.xy; - o.vertex = UnityObjectToClipPos(v.vertex); - if (_tab > 1.9 && _tab < 2.1) - { - if (_flowTarget < 1) - { - o.flow = v.color.rg; - } - else if (_flowTarget < 2) - { - o.flow = v.color.ba; - } - else if (_flowTarget < 3) - { - o.flow = v.uv0.xy; - } - else if (_flowTarget < 4) - { - o.flow = v.uv0.zw; - } - else if (_flowTarget < 5) - { - o.flow = v.uv1.xy; - } - else if (_flowTarget < 6) - { - o.flow = v.uv1.zw; - } - else if (_flowTarget < 7) - { - o.flow = v.uv2.xy; - } - else if (_flowTarget < 8) - { - o.flow = v.uv2.zw; - } - else if (_flowTarget < 9) - { - o.flow = v.uv3.xy; - } - else if (_flowTarget < 10) - { - o.flow = v.uv3.zw; - } - return o; - } - else if (_channel < 1) - { - o.color = v.color; - } - else if (_channel < 2) - { - o.color = v.color.rrrr; - } - else if (_channel < 3) - { - o.color = v.color.gggg; - } - else if (_channel < 4) - { - o.color = v.color.bbbb; - } - else if (_channel < 5) - { - o.color = v.color.aaaa; - } - else if (_channel < 6) - { - float f = Range(v.uv0.x); o.color = fixed4(f,f,f,1); - } - else if (_channel < 7) - { - float f = Range(v.uv0.y); o.color = fixed4(f,f,f,1); - } - else if (_channel < 8) - { - float f = Range(v.uv0.z); o.color = fixed4(f,f,f,1); - } - else if (_channel < 9) - { - float f = Range(v.uv0.w); o.color = fixed4(f,f,f,1); - } - else if (_channel < 10) - { - float f = Range(v.uv1.x); o.color = fixed4(f,f,f,1); - } - else if (_channel < 11) - { - float f = Range(v.uv1.y); o.color = fixed4(f,f,f,1); - } - else if (_channel < 12) - { - float f = Range(v.uv1.z); o.color = fixed4(f,f,f,1); - } - else if (_channel < 13) - { - float f = Range(v.uv1.w); o.color = fixed4(f,f,f,1); - } - else if (_channel < 14) - { - float f = Range(v.uv2.x); o.color = fixed4(f,f,f,1); - } - else if (_channel < 15) - { - float f = Range(v.uv2.y); o.color = fixed4(f,f,f,1); - } - else if (_channel < 16) - { - float f = Range(v.uv2.z); o.color = fixed4(f,f,f,1); - } - else if (_channel < 17) - { - float f = Range(v.uv2.w); o.color = fixed4(f,f,f,1); - } - else if (_channel < 18) - { - float f = Range(v.uv3.x); o.color = fixed4(f,f,f,1); - } - else if (_channel < 19) - { - float f = Range(v.uv3.y); o.color = fixed4(f,f,f,1); - } - else if (_channel < 20) - { - float f = Range(v.uv3.z); o.color = fixed4(f,f,f,1); - } - else if (_channel < 21) - { - float f = Range(v.uv3.w); o.color = fixed4(f,f,f,1); - } - - return o; - } - - - // Line SDF - float Line(float2 p, float2 p1, float2 p2) - { - float2 center = (p1 + p2) * 0.5; - float len = length(p2 - p1); - float2 dir = (p2 - p1) / len; - float2 rel_p = p - center; - float dist1 = abs(dot(rel_p, float2(dir.y, -dir.x))); - float dist2 = abs(dot(rel_p, dir)) - 0.5 * len; - return max(dist1, dist2); - } - - float Arrow(float2 p, float2 v) - { - float arrow_scale = 40; - v *= arrow_scale; - p -= (floor(p / arrow_scale) + 0.5) * arrow_scale; - - float mv = length(v); - float mp = length(p); - - if (mv > 0.0) - { - float2 dir_v = v / mv; - - mv = clamp(mv, 5.0, arrow_scale * 0.5); - v = dir_v * mv; - float shaft = Line(p, v, -v); - float head = min(Line(p, v, 0.4 * v + 0.2 * float2(-v.y, v.x)), Line(p, v, 0.4 * v + 0.2 * float2(v.y, -v.x))); - - return min(shaft, head); - } - else - { - return mp; - } - } - - - fixed4 frag (v2f i) : SV_Target - { - if (_tab > 1.9 && _tab < 2.1) // flow - { - if (_flowVisualization < 0.1) - { - float2 flow = i.flow * 2 - 1; - float arrow_dist = Arrow(i.uv*500, flow * 0.4); - return lerp(fixed4(0,0,0,1), fixed4(i.uv, 0, 1), saturate(arrow_dist)); - } - else - { - return FlowWater(i.uv, i.flow); - } - } - - return i.color; - } - ENDCG - } - } -} diff --git a/VertexPaint/VertexPainterPro_Preview.shader.meta b/VertexPaint/VertexPainterPro_Preview.shader.meta deleted file mode 100644 index bfa6858..0000000 --- a/VertexPaint/VertexPainterPro_Preview.shader.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: f2e6ccea338663248b9d9052bedc4b32 -timeCreated: 1470478094 -licenseType: Free -ShaderImporter: - defaultTextures: [] - userData: - assetBundleName: - assetBundleVariant: