From 8867ca41536a97c687afd10050d8bf3f1b73aafc Mon Sep 17 00:00:00 2001 From: Turanszki Janos Date: Fri, 2 Jul 2021 17:32:13 +0200 Subject: [PATCH 1/3] fix stuck anims in tps character controller script --- Content/scripts/character_controller_tps.lua | 56 ++++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/Content/scripts/character_controller_tps.lua b/Content/scripts/character_controller_tps.lua index 16c8b6372..456757bed 100644 --- a/Content/scripts/character_controller_tps.lua +++ b/Content/scripts/character_controller_tps.lua @@ -138,6 +138,34 @@ Character = { if( input.Press(string.byte('J')) or input.Press(KEYBOARD_BUTTON_SPACE) or input.Press(GAMEPAD_BUTTON_2) ) then self:Jump(2000) end + + -- state and animation update + if(self.state == self.states.STAND) then + scene.Component_GetAnimation(self.walk_anim).Stop() + local anim = scene.Component_GetAnimation(self.idle_anim) + anim.Play() + anim.SetAmount(math.lerp(anim.GetAmount(), 1, 0.1)) + if(self.state ~= self.state_prev) then + anim.SetAmount(0) + end + elseif(self.state == self.states.WALK) then + scene.Component_GetAnimation(self.idle_anim).Stop() + local anim = scene.Component_GetAnimation(self.walk_anim) + anim.Play() + anim.SetAmount(math.lerp(anim.GetAmount(), 1, 0.1)) + if(self.state ~= self.state_prev) then + anim.SetAmount(0) + end + elseif(self.state == self.states.JUMP) then + scene.Component_GetAnimation(self.walk_anim).Stop() + local anim = scene.Component_GetAnimation(self.idle_anim) + anim.Play() + anim.SetAmount(math.lerp(anim.GetAmount(), 1, 0.1)) + if(self.state ~= self.state_prev) then + anim.SetAmount(0) + end + end + self.state_prev = self.state -- Camera target control: @@ -168,34 +196,6 @@ Character = { local model_transform = scene.Component_GetTransform(self.model) local target_transform = scene.Component_GetTransform(self.target) - -- state and animation update - if(self.state == self.states.STAND) then - scene.Component_GetAnimation(self.walk_anim).Stop() - local anim = scene.Component_GetAnimation(self.idle_anim) - anim.Play() - anim.SetAmount(math.lerp(anim.GetAmount(), 1, 0.1)) - if(self.state ~= self.state_prev) then - anim.SetAmount(0) - end - elseif(self.state == self.states.WALK) then - scene.Component_GetAnimation(self.idle_anim).Stop() - local anim = scene.Component_GetAnimation(self.walk_anim) - anim.Play() - anim.SetAmount(math.lerp(anim.GetAmount(), 1, 0.1)) - if(self.state ~= self.state_prev) then - anim.SetAmount(0) - end - elseif(self.state == self.states.JUMP) then - scene.Component_GetAnimation(self.walk_anim).Stop() - local anim = scene.Component_GetAnimation(self.idle_anim) - anim.Play() - anim.SetAmount(math.lerp(anim.GetAmount(), 1, 0.1)) - if(self.state ~= self.state_prev) then - anim.SetAmount(0) - end - end - self.state_prev = self.state - -- apply force: self.velocity = vector.Add(self.velocity, vector.Multiply(self.force, 0.016)) self.force = Vector(0,0,0,0) From 4e9cc110d7cf3226861eee7ce563891a99bcfd1a Mon Sep 17 00:00:00 2001 From: Turanszki Janos Date: Sat, 3 Jul 2021 18:09:05 +0200 Subject: [PATCH 2/3] fix: ambient occlusion affects hair particle --- WickedEngine/shaders/hairparticlePS.hlsl | 12 ++++++++++++ WickedEngine/wiVersion.cpp | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/WickedEngine/shaders/hairparticlePS.hlsl b/WickedEngine/shaders/hairparticlePS.hlsl index 55cd6968b..f53b5e445 100644 --- a/WickedEngine/shaders/hairparticlePS.hlsl +++ b/WickedEngine/shaders/hairparticlePS.hlsl @@ -19,12 +19,24 @@ GBuffer main(VertexToPixel input) V /= dist; float emissive = 0; + const uint2 pixel = input.pos.xy; + const float2 ScreenCoord = pixel * g_xFrame_InternalResolution_rcp; + Surface surface; surface.create(g_xMaterial, color, 0); surface.P = input.pos3D; surface.N = input.nor; surface.V = V; surface.pixel = input.pos.xy; + +#ifndef PREPASS +#ifndef ENVMAPRENDERING +#ifndef TRANSPARENT + surface.occlusion *= texture_ao.SampleLevel(sampler_linear_clamp, ScreenCoord, 0).r; +#endif // TRANSPARENT +#endif // ENVMAPRENDERING +#endif // PREPASS + surface.update(); Lighting lighting; diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 117193a87..681d3108d 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wiVersion // minor features, major updates, breaking compatibility changes const int minor = 56; // minor bug fixes, alterations, refactors, updates - const int revision = 58; + const int revision = 59; const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision); From deca61d793f7d8fe624aaf225726ef5fc788b9ee Mon Sep 17 00:00:00 2001 From: Turanszki Janos Date: Sat, 3 Jul 2021 18:53:41 +0200 Subject: [PATCH 3/3] stochastic transparency improvement and disable for alpha blended material --- WickedEngine/shaders/globals.hlsli | 2 +- WickedEngine/shaders/objectHF.hlsli | 30 +++++++++++++++-------------- WickedEngine/wiVersion.cpp | 2 +- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/WickedEngine/shaders/globals.hlsli b/WickedEngine/shaders/globals.hlsli index ac632bbf0..280b116f8 100644 --- a/WickedEngine/shaders/globals.hlsli +++ b/WickedEngine/shaders/globals.hlsli @@ -87,7 +87,7 @@ inline float4 blue_noise(uint2 pixel) } inline float4 blue_noise(uint2 pixel, float depth) { - return frac(texture_bluenoise[pixel % 128].rgba + g_xFrame_BlueNoisePhase * depth); + return frac(texture_bluenoise[pixel % 128].rgba + g_xFrame_BlueNoisePhase + depth); } // Helpers: diff --git a/WickedEngine/shaders/objectHF.hlsli b/WickedEngine/shaders/objectHF.hlsli index 4c4655a11..d6d656417 100644 --- a/WickedEngine/shaders/objectHF.hlsli +++ b/WickedEngine/shaders/objectHF.hlsli @@ -517,20 +517,6 @@ struct VertexSurface tangent.xyz = normalize(mul((float3x3)WORLD, tangent.xyz)); #endif // OBJECTSHADER_INPUT_TAN -#ifdef OBJECTSHADER_USE_WIND - if (material.IsUsingWind()) - { - const float windweight = input.GetWindWeight(); - const float waveoffset = dot(position.xyz, g_xFrame_WindDirection) * g_xFrame_WindWaveSize + (position.x + position.y + position.z) * g_xFrame_WindRandomness; - const float waveoffsetPrev = dot(positionPrev.xyz, g_xFrame_WindDirection) * g_xFrame_WindWaveSize + (positionPrev.x + positionPrev.y + positionPrev.z) * g_xFrame_WindRandomness; - const float3 wavedir = g_xFrame_WindDirection * windweight; - const float3 wind = sin(g_xFrame_Time * g_xFrame_WindSpeed + waveoffset) * wavedir; - const float3 windPrev = sin(g_xFrame_TimePrev * g_xFrame_WindSpeed + waveoffsetPrev) * wavedir; - position.xyz += wind; - positionPrev.xyz += windPrev; - } -#endif // OBJECTSHADER_USE_WIND - #ifdef OBJECTSHADER_INPUT_TEX uvsets = float4(input.GetUV0() * material.texMulAdd.xy + material.texMulAdd.zw, input.GetUV1()); #endif // OBJECTSHADER_INPUT_TEX @@ -547,6 +533,20 @@ struct VertexSurface #else positionPrev = position; #endif // OBJECTSHADER_INPUT_PRE + +#ifdef OBJECTSHADER_USE_WIND + if (material.IsUsingWind()) + { + const float windweight = input.GetWindWeight(); + const float waveoffset = dot(position.xyz, g_xFrame_WindDirection) * g_xFrame_WindWaveSize + (position.x + position.y + position.z) * g_xFrame_WindRandomness; + const float waveoffsetPrev = dot(positionPrev.xyz, g_xFrame_WindDirection) * g_xFrame_WindWaveSize + (positionPrev.x + positionPrev.y + positionPrev.z) * g_xFrame_WindRandomness; + const float3 wavedir = g_xFrame_WindDirection * windweight; + const float3 wind = sin(g_xFrame_Time * g_xFrame_WindSpeed + waveoffset) * wavedir; + const float3 windPrev = sin(g_xFrame_TimePrev * g_xFrame_WindSpeed + waveoffsetPrev) * wavedir; + position.xyz += wind; + positionPrev.xyz += windPrev; + } +#endif // OBJECTSHADER_USE_WIND } }; @@ -1371,10 +1371,12 @@ float4 main(PixelInput input, in bool is_frontface : SV_IsFrontFace) : SV_TARGET #ifndef DISABLE_ALPHATEST float alphatest = GetMaterial().alphaTest; +#ifndef TRANSPARENT if (g_xFrame_Options & OPTION_BIT_TEMPORALAA_ENABLED) { alphatest = clamp(blue_noise(pixel, lineardepth).r, 0, 0.99); } +#endif // TRANSPARENT clip(color.a - alphatest); #endif // DISABLE_ALPHATEST diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 681d3108d..3bc1ed5c9 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wiVersion // minor features, major updates, breaking compatibility changes const int minor = 56; // minor bug fixes, alterations, refactors, updates - const int revision = 59; + const int revision = 60; const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);