From 484451d948fca1d84f0aaa841e5a1c29c0d8a163 Mon Sep 17 00:00:00 2001 From: ueshita Date: Sun, 15 Mar 2020 12:09:51 +0900 Subject: [PATCH 1/3] Remove a gain process of bloom blend pass. --- .../Shader/efk.GraphicsDX11.PostFX_Blend_PS.h | 91 ++++++++----------- .../Platform/DX11/Shader/postfx_blend_PS.fx | 9 +- .../Platform/GL/efk.PostEffectsGL.cpp | 9 +- 3 files changed, 46 insertions(+), 63 deletions(-) diff --git a/Dev/Cpp/Viewer/Graphics/Platform/DX11/Shader/efk.GraphicsDX11.PostFX_Blend_PS.h b/Dev/Cpp/Viewer/Graphics/Platform/DX11/Shader/efk.GraphicsDX11.PostFX_Blend_PS.h index 09a5978e15..b18073b0c8 100644 --- a/Dev/Cpp/Viewer/Graphics/Platform/DX11/Shader/efk.GraphicsDX11.PostFX_Blend_PS.h +++ b/Dev/Cpp/Viewer/Graphics/Platform/DX11/Shader/efk.GraphicsDX11.PostFX_Blend_PS.h @@ -43,30 +43,29 @@ dcl_resource_texture2d (float,float,float,float) t3 dcl_input_ps linear v1.xy dcl_output o0.xyzw dcl_temps 2 -sample r0.xyz, v1.xyxx, t1.xyzw, s0 -mul r0.xyz, r0.xyzx, l(0.500000, 0.500000, 0.500000, 0.000000) -sample r1.xyz, v1.xyxx, t0.xyzw, s0 -mad r0.xyz, r1.xyzx, l(0.250000, 0.250000, 0.250000, 0.000000), r0.xyzx +sample r0.xyz, v1.xyxx, t0.xyzw, s0 +sample r1.xyz, v1.xyxx, t1.xyzw, s0 +add r0.xyz, r0.xyzx, r1.xyzx sample r1.xyz, v1.xyxx, t2.xyzw, s0 add r0.xyz, r0.xyzx, r1.xyzx sample r1.xyz, v1.xyxx, t3.xyzw, s0 -mad o0.xyz, r1.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), r0.xyzx +add o0.xyz, r0.xyzx, r1.xyzx mov o0.w, l(1.000000) ret -// Approximately 10 instruction slots used +// Approximately 9 instruction slots used #endif const BYTE g_PS[] = { - 68, 88, 66, 67, 130, 142, - 8, 212, 33, 142, 21, 7, - 153, 211, 128, 225, 79, 8, - 117, 224, 1, 0, 0, 0, - 52, 4, 0, 0, 5, 0, + 68, 88, 66, 67, 25, 39, + 231, 154, 37, 213, 54, 0, + 117, 245, 139, 140, 54, 73, + 182, 235, 1, 0, 0, 0, + 228, 3, 0, 0, 5, 0, 0, 0, 52, 0, 0, 0, 96, 1, 0, 0, 184, 1, 0, 0, 236, 1, 0, 0, - 184, 3, 0, 0, 82, 68, + 104, 3, 0, 0, 82, 68, 69, 70, 36, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, @@ -140,9 +139,9 @@ const BYTE g_PS[] = 0, 0, 15, 0, 0, 0, 83, 86, 95, 84, 97, 114, 103, 101, 116, 0, 171, 171, - 83, 72, 68, 82, 196, 1, + 83, 72, 68, 82, 116, 1, 0, 0, 65, 0, 0, 0, - 113, 0, 0, 0, 106, 8, + 93, 0, 0, 0, 106, 8, 0, 1, 90, 0, 0, 3, 0, 96, 16, 0, 0, 0, 0, 0, 88, 24, 0, 4, @@ -165,29 +164,19 @@ const BYTE g_PS[] = 114, 0, 16, 0, 0, 0, 0, 0, 70, 16, 16, 0, 1, 0, 0, 0, 70, 126, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 69, 0, 0, 9, + 114, 0, 16, 0, 1, 0, + 0, 0, 70, 16, 16, 0, + 1, 0, 0, 0, 70, 126, 16, 0, 1, 0, 0, 0, 0, 96, 16, 0, 0, 0, - 0, 0, 56, 0, 0, 10, + 0, 0, 0, 0, 0, 7, 114, 0, 16, 0, 0, 0, 0, 0, 70, 2, 16, 0, - 0, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 63, - 0, 0, 0, 63, 0, 0, - 0, 63, 0, 0, 0, 0, - 69, 0, 0, 9, 114, 0, - 16, 0, 1, 0, 0, 0, - 70, 16, 16, 0, 1, 0, - 0, 0, 70, 126, 16, 0, - 0, 0, 0, 0, 0, 96, - 16, 0, 0, 0, 0, 0, - 50, 0, 0, 12, 114, 0, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 0, 1, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 128, 62, 0, 0, - 128, 62, 0, 0, 128, 62, 0, 0, 0, 0, 70, 2, - 16, 0, 0, 0, 0, 0, + 16, 0, 1, 0, 0, 0, 69, 0, 0, 9, 114, 0, 16, 0, 1, 0, 0, 0, 70, 16, 16, 0, 1, 0, @@ -204,38 +193,34 @@ const BYTE g_PS[] = 16, 0, 1, 0, 0, 0, 70, 126, 16, 0, 3, 0, 0, 0, 0, 96, 16, 0, - 0, 0, 0, 0, 50, 0, - 0, 12, 114, 32, 16, 0, - 0, 0, 0, 0, 70, 2, - 16, 0, 1, 0, 0, 0, - 2, 64, 0, 0, 0, 0, - 0, 64, 0, 0, 0, 64, - 0, 0, 0, 64, 0, 0, - 0, 0, 70, 2, 16, 0, - 0, 0, 0, 0, 54, 0, - 0, 5, 130, 32, 16, 0, - 0, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 128, 63, - 62, 0, 0, 1, 83, 84, - 65, 84, 116, 0, 0, 0, - 10, 0, 0, 0, 2, 0, - 0, 0, 0, 0, 0, 0, - 2, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, + 0, 7, 114, 32, 16, 0, + 0, 0, 0, 0, 70, 2, + 16, 0, 0, 0, 0, 0, + 70, 2, 16, 0, 1, 0, + 0, 0, 54, 0, 0, 5, + 130, 32, 16, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 62, 0, + 0, 1, 83, 84, 65, 84, + 116, 0, 0, 0, 9, 0, + 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0 + 0, 0, 0, 0, 0, 0 }; diff --git a/Dev/Cpp/Viewer/Graphics/Platform/DX11/Shader/postfx_blend_PS.fx b/Dev/Cpp/Viewer/Graphics/Platform/DX11/Shader/postfx_blend_PS.fx index 5ba13a7431..9f911c649d 100644 --- a/Dev/Cpp/Viewer/Graphics/Platform/DX11/Shader/postfx_blend_PS.fx +++ b/Dev/Cpp/Viewer/Graphics/Platform/DX11/Shader/postfx_blend_PS.fx @@ -13,10 +13,9 @@ struct PS_Input float4 PS( const PS_Input Input ) : SV_Target { - const float4 gain = float4(0.25, 0.5, 1.0, 2.0); - float3 c0 = g_texture0.Sample(g_sampler, Input.UV).rgb * gain.x; - float3 c1 = g_texture1.Sample(g_sampler, Input.UV).rgb * gain.y; - float3 c2 = g_texture2.Sample(g_sampler, Input.UV).rgb * gain.z; - float3 c3 = g_texture3.Sample(g_sampler, Input.UV).rgb * gain.w; + float3 c0 = g_texture0.Sample(g_sampler, Input.UV).rgb; + float3 c1 = g_texture1.Sample(g_sampler, Input.UV).rgb; + float3 c2 = g_texture2.Sample(g_sampler, Input.UV).rgb; + float3 c3 = g_texture3.Sample(g_sampler, Input.UV).rgb; return float4(c0 + c1 + c2 + c3, 1.0); } diff --git a/Dev/Cpp/Viewer/Graphics/Platform/GL/efk.PostEffectsGL.cpp b/Dev/Cpp/Viewer/Graphics/Platform/GL/efk.PostEffectsGL.cpp index 6c852c1df9..0b9ca55c51 100644 --- a/Dev/Cpp/Viewer/Graphics/Platform/GL/efk.PostEffectsGL.cpp +++ b/Dev/Cpp/Viewer/Graphics/Platform/GL/efk.PostEffectsGL.cpp @@ -74,12 +74,11 @@ uniform sampler2D u_Texture0; uniform sampler2D u_Texture1; uniform sampler2D u_Texture2; uniform sampler2D u_Texture3; -const vec4 gain = vec4(0.25, 0.5, 1.0, 2.0); void main() { - vec3 c0 = TEX2D(u_Texture0, v_TexCoord).rgb * gain.x; - vec3 c1 = TEX2D(u_Texture1, v_TexCoord).rgb * gain.y; - vec3 c2 = TEX2D(u_Texture2, v_TexCoord).rgb * gain.z; - vec3 c3 = TEX2D(u_Texture3, v_TexCoord).rgb * gain.w; + vec3 c0 = TEX2D(u_Texture0, v_TexCoord).rgb; + vec3 c1 = TEX2D(u_Texture1, v_TexCoord).rgb; + vec3 c2 = TEX2D(u_Texture2, v_TexCoord).rgb; + vec3 c3 = TEX2D(u_Texture3, v_TexCoord).rgb; FRAGCOLOR = vec4(c0 + c1 + c2 + c3, 1.0); } )"; From 496746ad1096b7c3935dd73c21a15e7d3695fa4a Mon Sep 17 00:00:00 2001 From: ueshita Date: Sun, 15 Mar 2020 12:12:25 +0900 Subject: [PATCH 2/3] Add 2 turbulence samples. --- Release/Sample/00_Basic/Emissive.efkmat | Bin 0 -> 1218 bytes Release/Sample/00_Basic/Material/Emissive.efkmat | Bin 0 -> 2557 bytes .../00_Basic/Simple_Turbulence_Fireworks.efkefc | Bin 0 -> 4036 bytes .../00_Basic/Simple_Turbulence_Particles.efkefc | Bin 0 -> 2822 bytes 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 Release/Sample/00_Basic/Emissive.efkmat create mode 100644 Release/Sample/00_Basic/Material/Emissive.efkmat create mode 100644 Release/Sample/00_Basic/Simple_Turbulence_Fireworks.efkefc create mode 100644 Release/Sample/00_Basic/Simple_Turbulence_Particles.efkefc diff --git a/Release/Sample/00_Basic/Emissive.efkmat b/Release/Sample/00_Basic/Emissive.efkmat new file mode 100644 index 0000000000000000000000000000000000000000..97ff9f7e720e3821f906c7225189b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diff --git a/Release/Sample/00_Basic/Simple_Turbulence_Particles.efkefc b/Release/Sample/00_Basic/Simple_Turbulence_Particles.efkefc new file mode 100644 index 0000000000000000000000000000000000000000..e326f7a64472ffeb4a81f2b763bfd0fdbe62278c GIT binary patch literal 2822 zcmZ>D^LAwb0#83T|9L?A4l4r#Bal`B;t+;Zh6;ufhEj$iAWNSifFTjcDq+ZENM^_Z ziWo4MFvK$?G2}C317(UCGJrDiKoX=Xg+Y&@fFX||9cT_Z0GTfd#J)h4B|vkEfcg@F zCh9Y|GUNi;#Xy+JPzIFI1L8EG>A7H)3=FO=o*{nB3=9=>-Ui3|3kM3wa&6hN^a4}U z{0KYN)=jq;eH6{k?nshap|Q{8dRf-`H}BT&j%NOU?`HM((n(T>n>%Oi;IBSEcdlh| zT2)k|&6QoTdw2x?wyocnV9he4DR}82POJM|;=%^ZSLc;j*;P#r^eHXiN?W)pCcN_b zA;|;-UP}wX@bwp*<6D9%J+-X9?YcBsaajUiT}`H!c)9{-=ohCimklIE(-t{bMV_iz ze9P**!172UC9c4mUQ#^4 zOFS{E{-~-(k42vytJ+sFT_rB7(x=-u>Ro(!n zkENC$C;t^bk1V=3wvFB3~dw^rZ4<( zc$fdSjTz@=UB7svuZksq%B$&_%a6rPJUi5j1mIcjzX* z$N7##i~8dHpC^>wa8_?;3og2;V*WfaIp%2M>&d%B z9R0Ud9eVFF>C=%k(Tvctmn%!7boDRrOijP0)OuEU?#drxdxa-R)G~X?9b3%HTR5q1 zzWmRVg7Z3N`uyct?R$LZ#mR{lr$6XCK6AA6qVe%ZpVx%f_0&)L=xmdKmF)9?RTT*nL&c_{{TI$)n3p`d^%RZKAbQy2-xNzwTX54|9KK ze2(4c|0=t)ZStFL*}RUvVzK<=tYc}PU+;f1r{7XJXWOoY8*hG7TYXpR;mRHPjbC*) z>|@I}&Jkfc5dZwpBZ>cKV4Ns=}m#+vuDoO zf-p!71VCyMfEbsV3=9qSKxrsIu#wFGviHJN;G#i(0oes{Q-cFYKeGFf^$7quAon1P zf%HoNasQ!GTdwPiZIIT!H}1FF3|v|O#Uf?t0hSg(CJ{;xqiF$qS^xk|e+It* literal 0 HcmV?d00001 From 31873d701db5669905dd0c4447ec55e4d1a8a061 Mon Sep 17 00:00:00 2001 From: ueshita Date: Sun, 15 Mar 2020 15:28:19 +0900 Subject: [PATCH 3/3] Improve UI of Dynamic parameter. (and fix crash bug when a dynamic parameter is default value.) --- Dev/Editor/Effekseer/GUI/Dock/Dynamic.cs | 40 +++++++++++++++--------- Dev/Editor/EffekseerCore/Data/Dynamic.cs | 23 ++++++++++---- Dev/Editor/EffekseerCore/Data/IO.cs | 10 ++++-- 3 files changed, 49 insertions(+), 24 deletions(-) diff --git a/Dev/Editor/Effekseer/GUI/Dock/Dynamic.cs b/Dev/Editor/Effekseer/GUI/Dock/Dynamic.cs index e5b5a84357..a0a4871863 100644 --- a/Dev/Editor/Effekseer/GUI/Dock/Dynamic.cs +++ b/Dev/Editor/Effekseer/GUI/Dock/Dynamic.cs @@ -81,6 +81,10 @@ protected override void UpdateInternal() Manager.NativeManager.Text(Resources.GetString("DynamicEquation")); + float width = Manager.NativeManager.GetContentRegionAvail().X; + + Manager.NativeManager.PushItemWidth(width - Manager.NativeManager.GetTextLineHeight() * 5.5f); + var nextParam = Component.DynamicSelector.Select("", "", Core.Dynamic.Equations.Selected, false, true); if (Core.Dynamic.Equations.Selected != nextParam) @@ -88,7 +92,11 @@ protected override void UpdateInternal() Core.Dynamic.Equations.Selected = nextParam; } - if(Manager.NativeManager.Button(Resources.GetString("DynamicAdd") + "###DynamicAdd")) + Manager.NativeManager.PopItemWidth(); + + Manager.NativeManager.SameLine(); + + if (Manager.NativeManager.Button(Resources.GetString("DynamicAdd") + "###DynamicAdd")) { Core.Dynamic.Equations.Add(); } @@ -98,27 +106,29 @@ protected override void UpdateInternal() if (Manager.NativeManager.Button(Resources.GetString("DynamicDelete") + "###DynamicDelete")) { Core.Dynamic.Equations.Delete(Core.Dynamic.Equations.Selected); - Core.Dynamic.Equations.Selected = null; } paramerterList.Update(); - // TODO make good GUI - if (Manager.NativeManager.Button(Resources.GetString("Compile") + "###DynamicCompile")) + if (Core.Dynamic.Equations.Selected != null) { - var selected = Core.Dynamic.Equations.Selected; - if(selected != null) + // TODO make good GUI + if (Manager.NativeManager.Button(Resources.GetString("Compile") + "###DynamicCompile")) { - var compiler = new InternalScript.Compiler(); - var result = compiler.Compile(selected.Code.Value); - - if(result.Error != null) - { - compileResult = Utils.CompileErrorGenerator.Generate(selected.Code.Value, result.Error); - } - else + var selected = Core.Dynamic.Equations.Selected; + if (selected != null) { - compileResult = "OK"; + var compiler = new InternalScript.Compiler(); + var result = compiler.Compile(selected.Code.Value); + + if (result.Error != null) + { + compileResult = Utils.CompileErrorGenerator.Generate(selected.Code.Value, result.Error); + } + else + { + compileResult = "OK"; + } } } } diff --git a/Dev/Editor/EffekseerCore/Data/Dynamic.cs b/Dev/Editor/EffekseerCore/Data/Dynamic.cs index 6887a7d345..111fad2893 100644 --- a/Dev/Editor/EffekseerCore/Data/Dynamic.cs +++ b/Dev/Editor/EffekseerCore/Data/Dynamic.cs @@ -18,18 +18,16 @@ public DynamicInput() public class DynamicEquation { - public const string DefaultName = "Eq"; - public Value.String Name { get; private set; } public Value.String Code { get; private set; } DynamicEquationCollection parent = null; - public DynamicEquation(string name, DynamicEquationCollection parent) + public DynamicEquation(DynamicEquationCollection parent) { - Name = new Value.String(name); - Code = new Value.String(); + Name = new Value.String(""); + Code = new Value.String(""); Code.IsMultiLine = true; this.parent = parent; } @@ -147,15 +145,20 @@ public bool Add() { if (values.Count >= 16) return false; + var old_selected = selected; var old_value = values; var new_value = new List(values); - new_value.Add(new DynamicEquation(DynamicEquation.DefaultName, this)); + var value = new DynamicEquation(this); + value.Name.SetValue("New Expression"); + value.Code.SetValue("@O.x = @1"); + new_value.Add(value); var cmd = new Command.DelegateCommand( () => { values = new_value; + selected = new_value[new_value.Count - 1]; if (OnChanged != null) { OnChanged(this, null); @@ -164,6 +167,7 @@ public bool Add() () => { values = old_value; + selected = old_selected; if (OnChanged != null) { OnChanged(this, null); @@ -180,6 +184,7 @@ public bool Delete(DynamicEquation o) if (o == null) return false; + var old_index = values.IndexOf(o); var old_value = values; var new_value = new List(values); new_value.Remove(o); @@ -188,6 +193,11 @@ public bool Delete(DynamicEquation o) () => { values = new_value; + + if (old_index < values.Count) selected = new_value[old_index]; + else if (old_index > 0 && values.Count > 0) selected = new_value[old_index - 1]; + else selected = null; + if (OnChanged != null) { OnChanged(this, null); @@ -196,6 +206,7 @@ public bool Delete(DynamicEquation o) () => { values = old_value; + selected = o; if (OnChanged != null) { OnChanged(this, null); diff --git a/Dev/Editor/EffekseerCore/Data/IO.cs b/Dev/Editor/EffekseerCore/Data/IO.cs index 4b99c5cc39..c2cb7e16c5 100644 --- a/Dev/Editor/EffekseerCore/Data/IO.cs +++ b/Dev/Editor/EffekseerCore/Data/IO.cs @@ -304,8 +304,12 @@ public static XmlElement SaveToElement(XmlDocument doc, string element_name, Dat var e = doc.CreateElement(element_name); for (int i = 0; i < collection.Values.Count; i++) { - var e_node = SaveToElement(doc, collection.Values[i].GetType().Name, collection.Values[i], isClip); - e.AppendChild(e_node); + var name = collection.Values[i].GetType().Name; + var e_node = SaveToElement(doc, name, collection.Values[i], isClip); + if (e_node != null) + { + e.AppendChild(e_node); + } } return e; @@ -1045,7 +1049,7 @@ public static void LoadFromElement(XmlElement e, Data.DynamicEquationCollection for (var i = 0; i < e.ChildNodes.Count; i++) { var e_child = e.ChildNodes[i] as XmlElement; - var element = new DynamicEquation(DynamicEquation.DefaultName, collection); + var element = new DynamicEquation(collection); LoadFromElement(e_child, element, isClip); collection.Values.Add(element); }