diff --git a/Content/Documentation/ScriptingAPI-Documentation.md b/Content/Documentation/ScriptingAPI-Documentation.md index 4e5aa981b..5d55edc0a 100644 --- a/Content/Documentation/ScriptingAPI-Documentation.md +++ b/Content/Documentation/ScriptingAPI-Documentation.md @@ -659,6 +659,8 @@ A four component floating point vector. Provides efficient calculations with SIM - QuaternionToRollPitchYaw(Vector quaternion) : Vector resultQuaternion - QuaternionSlerp(Vector quaternion1,quaternion2, float t) : Vector resultQuaternion - Slerp(Vector quaternion1,quaternion2, float t) : Vector resultQuaternion -- same as QuaternionSlerp +- PlaneFromPointNormal(Vector point, normal) : constructs a plane from a point and a normal +- PlaneFromPoints(Vector a,b,c) : constructs a plane from three points - GetAngle(Vector a,b,axis, opt float max_angle = math.pi * 2) : float result -- computes the signed angle between two 3D vectors around specified axis ### Matrix @@ -1348,6 +1350,19 @@ Describes a Weather - SetVolumetricClouds(bool value) -- Sets if weather is rendering volumetric clouds or not - SetHeightFog(bool value) -- Sets if weather is rendering height fog visual effect or not +##### OceanParameters +- dmap_dim : int +- patch_length : float +- time_scale : float +- wave_amplitude : float +- wind_dir : Vector +- wind_speed : float +- wind dependency : float +- choppy_scale : float +- waterColor : Vector +- waterHeight : float +- surfaceDisplacementTolerance : float + #### SoundComponent Describes a Sound object. - Filename : string @@ -1775,6 +1790,7 @@ A ray is defined by an origin Vector and a normalized direction Vector. It can b - Intersects(AABB aabb) : bool result - Intersects(Sphere sphere) : bool result - Intersects(Capsule capsule) : bool result +- Intersects(Vector plane) : Vector result : intersects with a plane and returns intersection position or nans. Use `vector.PlaneFromPointNormal(Vector point, normal)` or `vector.PlaneFromPoints(Vector a,b,c)` to construct a plane. - GetOrigin() : Vector result - GetDirection() : Vector result - SetOrigin(Vector vector) diff --git a/Content/models/emitter_spritesheet_test.wiscene b/Content/models/emitter_spritesheet_test.wiscene new file mode 100644 index 000000000..cc1b6defc Binary files /dev/null and b/Content/models/emitter_spritesheet_test.wiscene differ diff --git a/Content/models/spritesheet_anim_test.wiscene b/Content/models/spritesheet_anim_test.wiscene new file mode 100644 index 000000000..2e11d35f6 Binary files /dev/null and b/Content/models/spritesheet_anim_test.wiscene differ diff --git a/Editor/EmitterWindow.cpp b/Editor/EmitterWindow.cpp index c696b69d9..d2a723665 100644 --- a/Editor/EmitterWindow.cpp +++ b/Editor/EmitterWindow.cpp @@ -61,7 +61,7 @@ void EmitterWindow::Create(EditorComponent* _editor) AddWidget(&burstButton); burstCountInput.Create(""); - burstCountInput.SetValue(100); + burstCountInput.SetValue(10); burstCountInput.SetSize(XMFLOAT2(itemheight * 4, itemheight)); burstCountInput.SetCancelInputEnabled(false); burstCountInput.SetTooltip("Specify burst count (number of particles to burst)."); @@ -282,7 +282,7 @@ void EmitterWindow::Create(EditorComponent* _editor) frameRateInput.SetPos(XMFLOAT2(x, y)); frameRateInput.SetSize(XMFLOAT2(38, 18)); frameRateInput.SetText(""); - frameRateInput.SetTooltip("Enter a value to enable looping sprite sheet animation (frames per second). Set 0 for animation along paritcle lifetime."); + frameRateInput.SetTooltip("Enter a value to enable looping sprite sheet animation (frames per second). Set 0 for exactly one complete animation along particle lifetime."); frameRateInput.SetDescription("Frame Rate: "); frameRateInput.OnInputAccepted([this](wi::gui::EventArgs args) { wi::scene::Scene& scene = editor->GetCurrentScene(); @@ -335,7 +335,7 @@ void EmitterWindow::Create(EditorComponent* _editor) frameCountInput.SetPos(XMFLOAT2(x, y += step)); frameCountInput.SetSize(XMFLOAT2(38, 18)); frameCountInput.SetText(""); - frameCountInput.SetTooltip("Enter a value to enable the random sprite sheet frame selection's max frame number."); + frameCountInput.SetTooltip("The total number of frames in the sprite sheet animation."); frameCountInput.SetDescription("Frame Count: "); frameCountInput.OnInputAccepted([this](wi::gui::EventArgs args) { wi::scene::Scene& scene = editor->GetCurrentScene(); diff --git a/WickedEngine/shaders/emittedparticleVS.hlsl b/WickedEngine/shaders/emittedparticleVS.hlsl index a930614d1..1df5e482d 100644 --- a/WickedEngine/shaders/emittedparticleVS.hlsl +++ b/WickedEngine/shaders/emittedparticleVS.hlsl @@ -35,7 +35,7 @@ VertextoPixel main(uint vid : SV_VertexID, uint instanceID : SV_InstanceID) // Sprite sheet UV transform: const float spriteframe = xEmitterFrameRate == 0 ? lerp(xEmitterFrameStart, xEmitterFrameCount, lifeLerp) : - ((xEmitterFrameStart + particle.life * xEmitterFrameRate) % xEmitterFrameCount); + ((xEmitterFrameStart + (particle.maxLife - particle.life) * xEmitterFrameRate) % xEmitterFrameCount); const float frameBlend = frac(spriteframe); VertextoPixel Out; diff --git a/WickedEngine/shaders/emittedparticle_simulateCS.hlsl b/WickedEngine/shaders/emittedparticle_simulateCS.hlsl index 9b35073c8..7f63d9738 100644 --- a/WickedEngine/shaders/emittedparticle_simulateCS.hlsl +++ b/WickedEngine/shaders/emittedparticle_simulateCS.hlsl @@ -43,6 +43,8 @@ void main(uint3 DTid : SV_DispatchThreadID, uint Gid : SV_GroupIndex) Particle particle = particleBuffer[particleIndex]; uint v0 = particleIndex * 4; + particle.life -= dt; + const float lifeLerp = 1 - particle.life / particle.maxLife; const float particleSize = lerp(particle.sizeBeginEnd.x, particle.sizeBeginEnd.y, lifeLerp); const float lifeOpa = opacityCurveTex.SampleLevel(sampler_linear_clamp, float2(lifeLerp, 0), 0); @@ -261,8 +263,6 @@ void main(uint3 DTid : SV_DispatchThreadID, uint Gid : SV_GroupIndex) } - particle.life -= dt; - float2 rotation_rotationVel = unpack_half2(particle.rotation_rotationVelocity); rotation_rotationVel.x += rotation_rotationVel.y * dt; particle.rotation_rotationVelocity = pack_half2(rotation_rotationVel); @@ -289,12 +289,12 @@ void main(uint3 DTid : SV_DispatchThreadID, uint Gid : SV_GroupIndex) ); // Sprite sheet frame: - const float spriteframe = xEmitterFrameRate == 0 ? + const bool anim_over_lifetime = xEmitterFrameRate == 0; + const float spriteframe = anim_over_lifetime ? lerp(xEmitterFrameStart, xEmitterFrameCount, lifeLerp) : - ((xEmitterFrameStart + particle.life * xEmitterFrameRate) % xEmitterFrameCount); + ((xEmitterFrameStart + (particle.maxLife - particle.life) * xEmitterFrameRate) % xEmitterFrameCount); const uint currentFrame = floor(spriteframe); - const uint nextFrame = ceil(spriteframe); - const float frameBlend = frac(spriteframe); + const uint nextFrame = anim_over_lifetime ? min(ceil(spriteframe), xEmitterFrameCount - 1) : (uint(ceil(spriteframe)) % xEmitterFrameCount); // anim_over_lifetime doesn't wrap around uint2 offset = uint2(currentFrame % xEmitterFramesXY.x, currentFrame / xEmitterFramesXY.x); uint2 offset2 = uint2(nextFrame % xEmitterFramesXY.x, nextFrame / xEmitterFramesXY.x); diff --git a/WickedEngine/shaders/oceanSurfacePS.hlsl b/WickedEngine/shaders/oceanSurfacePS.hlsl index 3ef1d7eee..139a7bc1d 100644 --- a/WickedEngine/shaders/oceanSurfacePS.hlsl +++ b/WickedEngine/shaders/oceanSurfacePS.hlsl @@ -32,7 +32,7 @@ float4 main(PSIn input) : SV_TARGET [branch] if (GetCamera().texture_waterriples_index >= 0) { - gradient.rg += bindless_textures_float2[GetCamera().texture_waterriples_index].SampleLevel(sampler_linear_clamp, ScreenCoord, 0).rg * 0.01; + gradient.rg += bindless_textures_float2[GetCamera().texture_waterriples_index].SampleLevel(sampler_linear_clamp, ScreenCoord, 0).rg * 0.025; } Surface surface; diff --git a/WickedEngine/wiMath_BindLua.cpp b/WickedEngine/wiMath_BindLua.cpp index 1ed60e4e3..ef9414d14 100644 --- a/WickedEngine/wiMath_BindLua.cpp +++ b/WickedEngine/wiMath_BindLua.cpp @@ -36,6 +36,8 @@ namespace wi::lua lunamethod(Vector_BindLua, QuaternionMultiply), lunamethod(Vector_BindLua, QuaternionFromRollPitchYaw), lunamethod(Vector_BindLua, QuaternionToRollPitchYaw), + lunamethod(Vector_BindLua, PlaneFromPointNormal), + lunamethod(Vector_BindLua, PlaneFromPoints), lunamethod(Vector_BindLua, GetAngle), { NULL, NULL } }; @@ -594,6 +596,40 @@ namespace wi::lua return 0; } + int Vector_BindLua::PlaneFromPointNormal(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc > 1) + { + Vector_BindLua* v1 = Luna::lightcheck(L, 1); + Vector_BindLua* v2 = Luna::lightcheck(L, 2); + if (v1 && v2) + { + Luna::push(L, XMPlaneFromPointNormal(XMLoadFloat4(&v1->data), XMLoadFloat4(&v2->data))); + return 1; + } + } + wi::lua::SError(L, "PlaneFromPointNormal(Vector a,b,c) not enough arguments!"); + return 0; + } + int Vector_BindLua::PlaneFromPoints(lua_State* L) + { + int argc = wi::lua::SGetArgCount(L); + if (argc > 2) + { + Vector_BindLua* v1 = Luna::lightcheck(L, 1); + Vector_BindLua* v2 = Luna::lightcheck(L, 2); + Vector_BindLua* v3 = Luna::lightcheck(L, 3); + if (v1 && v2 && v3) + { + Luna::push(L, XMPlaneFromPoints(XMLoadFloat4(&v1->data), XMLoadFloat4(&v2->data), XMLoadFloat4(&v3->data))); + return 1; + } + } + wi::lua::SError(L, "PlaneFromPoints(Vector a,b,c) not enough arguments!"); + return 0; + } + int Vector_BindLua::GetAngle(lua_State* L) { int argc = wi::lua::SGetArgCount(L); diff --git a/WickedEngine/wiMath_BindLua.h b/WickedEngine/wiMath_BindLua.h index 0e0d181da..85fab39e6 100644 --- a/WickedEngine/wiMath_BindLua.h +++ b/WickedEngine/wiMath_BindLua.h @@ -62,6 +62,9 @@ namespace wi::lua int QuaternionSlerp(lua_State* L); int Slerp(lua_State* L); + int PlaneFromPointNormal(lua_State* L); + int PlaneFromPoints(lua_State* L); + int GetAngle(lua_State* L); static void Bind(); diff --git a/WickedEngine/wiPrimitive_BindLua.cpp b/WickedEngine/wiPrimitive_BindLua.cpp index f436d3786..024edc1fa 100644 --- a/WickedEngine/wiPrimitive_BindLua.cpp +++ b/WickedEngine/wiPrimitive_BindLua.cpp @@ -99,8 +99,19 @@ namespace wi::lua::primitive return 1; } + Vector_BindLua* vec = Luna::lightcheck(L, 1); + if (vec) + { + XMVECTOR P = XMLoadFloat4(&vec->data); + XMVECTOR O = XMLoadFloat3(&ray.origin); + XMVECTOR D = XMLoadFloat3(&ray.direction); + XMVECTOR I = XMPlaneIntersectLine(P, O + D * ray.TMin, O + D * ray.TMax); + Luna::push(L, I); + return 1; + } + } - wi::lua::SError(L, "[Intersects(AABB), Intersects(Sphere), Intersects(Capsule)] no matching arguments! "); + wi::lua::SError(L, "[Intersects(AABB), Intersects(Sphere), Intersects(Capsule), Intersects(Vector)] no matching arguments! "); return 0; } int Ray_BindLua::GetOrigin(lua_State* L) diff --git a/WickedEngine/wiScene_BindLua.cpp b/WickedEngine/wiScene_BindLua.cpp index 1642cc5ec..7286749e9 100644 --- a/WickedEngine/wiScene_BindLua.cpp +++ b/WickedEngine/wiScene_BindLua.cpp @@ -6274,7 +6274,7 @@ Luna::PropertyType Weather_OceanParams_BindLua::pro lunaproperty(Weather_OceanParams_BindLua, waterColor), lunaproperty(Weather_OceanParams_BindLua, waterHeight), lunaproperty(Weather_OceanParams_BindLua, surfaceDetail), - lunaproperty(Weather_OceanParams_BindLua, surfaceDisplacement), + lunaproperty(Weather_OceanParams_BindLua, surfaceDisplacementTolerance), { NULL, NULL } }; diff --git a/WickedEngine/wiScene_BindLua.h b/WickedEngine/wiScene_BindLua.h index c07a4d081..b42042364 100644 --- a/WickedEngine/wiScene_BindLua.h +++ b/WickedEngine/wiScene_BindLua.h @@ -1100,6 +1100,10 @@ namespace wi::lua::scene wind_speed = FloatProperty(¶meter->wind_speed); wind_dependency = FloatProperty(¶meter->wind_dependency); choppy_scale = FloatProperty(¶meter->choppy_scale); + waterColor = VectorProperty(¶meter->waterColor); + waterHeight = FloatProperty(¶meter->waterHeight); + //surfaceDetail = IntProperty(¶meter->surfaceDetail); + surfaceDisplacementTolerance = FloatProperty(¶meter->surfaceDisplacementTolerance); } Weather_OceanParams_BindLua(wi::Ocean::OceanParameters* parameter) :parameter(parameter) @@ -1121,8 +1125,8 @@ namespace wi::lua::scene FloatProperty choppy_scale; VectorProperty waterColor; FloatProperty waterHeight; - LongLongProperty surfaceDetail; - FloatProperty surfaceDisplacement; + IntProperty surfaceDetail; + FloatProperty surfaceDisplacementTolerance; PropertyFunction(dmap_dim) PropertyFunction(patch_length) @@ -1135,7 +1139,7 @@ namespace wi::lua::scene PropertyFunction(waterColor) PropertyFunction(waterHeight) PropertyFunction(surfaceDetail) - PropertyFunction(surfaceDisplacement) + PropertyFunction(surfaceDisplacementTolerance) }; struct Weather_OceanParams_Property { diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index f7211ffcb..7cac94b4f 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wi::version // minor features, major updates, breaking compatibility changes const int minor = 71; // minor bug fixes, alterations, refactors, updates - const int revision = 609; + const int revision = 610; const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);