added some lua bindings and emitter spritesheet fix

This commit is contained in:
Turánszki János
2024-10-31 18:01:31 +01:00
parent 54af7bb2fa
commit b1b2cb8513
13 changed files with 87 additions and 17 deletions
@@ -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)
Binary file not shown.
Binary file not shown.
+3 -3
View File
@@ -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();
+1 -1
View File
@@ -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;
@@ -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);
+1 -1
View File
@@ -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;
+36
View File
@@ -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<Vector_BindLua>::lightcheck(L, 1);
Vector_BindLua* v2 = Luna<Vector_BindLua>::lightcheck(L, 2);
if (v1 && v2)
{
Luna<Vector_BindLua>::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<Vector_BindLua>::lightcheck(L, 1);
Vector_BindLua* v2 = Luna<Vector_BindLua>::lightcheck(L, 2);
Vector_BindLua* v3 = Luna<Vector_BindLua>::lightcheck(L, 3);
if (v1 && v2 && v3)
{
Luna<Vector_BindLua>::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);
+3
View File
@@ -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();
+12 -1
View File
@@ -99,8 +99,19 @@ namespace wi::lua::primitive
return 1;
}
Vector_BindLua* vec = Luna<Vector_BindLua>::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<Vector_BindLua>::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)
+1 -1
View File
@@ -6274,7 +6274,7 @@ Luna<Weather_OceanParams_BindLua>::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 }
};
+7 -3
View File
@@ -1100,6 +1100,10 @@ namespace wi::lua::scene
wind_speed = FloatProperty(&parameter->wind_speed);
wind_dependency = FloatProperty(&parameter->wind_dependency);
choppy_scale = FloatProperty(&parameter->choppy_scale);
waterColor = VectorProperty(&parameter->waterColor);
waterHeight = FloatProperty(&parameter->waterHeight);
//surfaceDetail = IntProperty(&parameter->surfaceDetail);
surfaceDisplacementTolerance = FloatProperty(&parameter->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
{
+1 -1
View File
@@ -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);