Skip to content

Commit

Permalink
Update for API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ravbug committed Jun 22, 2024
1 parent aa6d389 commit 7cad458
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 84 deletions.
2 changes: 1 addition & 1 deletion RavEngine
5 changes: 4 additions & 1 deletion Samples/Rendering/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,14 @@ struct Level : public RavEngine::World {
};

auto asteroidUpdateMat = New<ParticleUpdateMaterialInstance>(New<AsteroidUpdateMaterial>());
auto asteroidRenderMat = New<PBRMeshParticleRenderMaterialInstance>(New<PBRMeshParticleRenderMaterial>());
auto asteroidRenderMat = New<PBRMeshParticleRenderMaterialInstance>(New<PBRMeshParticleRenderMaterial>(),asteroidMeshCol, sizeof(AsteroidParticleData), offsetof(AsteroidParticleData,pos));

auto asteroidEmitterEntity = Instantiate<GameObject>();
auto& emitter = asteroidEmitterEntity.EmplaceComponent<ParticleEmitter>(1024, sizeof(AsteroidParticleData), asteroidUpdateMat, asteroidRenderMat);

emitter.Play();
emitter.SetEmissionRate(500);

SetupInputs();

constexpr auto MoveParticleSystem = [](const ParticleEmitter& emitter, Transform& t) {
Expand Down
5 changes: 5 additions & 0 deletions Samples/Rendering/shaders/AsteroidUpdate.csh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ layout(push_constant, std430) uniform UniformBufferObject{
float fpsScale;
} ubo;

const float kGraivty = 0.5 / 60;

void update(inout ParticleData data, inout float newLife, uint particleID)
{
newLife += ubo.fpsScale;

data.velocity.y -= kGraivty * ubo.fpsScale;

data.pos += data.velocity;

if (newLife > 300)
{
// destroy the particle
Expand Down
22 changes: 2 additions & 20 deletions Samples/Rendering/shaders/FireParticleInit.csh
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
struct ParticleData{
vec3 pos;
vec2 scale;
uint animationFrame;
};

float rand(in vec2 ip) {
const float seed = 12345678;
uvec2 p = uvec2(floatBitsToUint(ip.x), floatBitsToUint(ip.y));
uint s = floatBitsToUint(seed);
s ^= (s ^ ((~p.x << s) + (~p.y << s)));

p ^= (p << 17U);
p ^= ((p ^ s) >> 13U);
p ^= (p << 5U);
p ^= ((s + (s&(p.x^p.y))) >> 3U);
uint n = (p.x*s+p.y)+((p.x ^ p.y) << ~p.x ^ s) + ((p.x ^ p.y) << ~p.y ^ s);
return float(n*50323U) / float(0xFFFFFFFFU);
}
#include "sprite_particle_layout.glsl"

#include "utility.glsl"

ParticleData init(ParticleInitData initData)
{
Expand Down
24 changes: 3 additions & 21 deletions Samples/Rendering/shaders/FireParticleUpdate.csh
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,9 @@ layout(push_constant, std430) uniform UniformBufferObject{
} ubo;


struct ParticleData{
vec3 pos;
vec2 scale;
uint animationFrame;
};


float rand(in vec2 ip) {
const float seed = 12345678;
uvec2 p = uvec2(floatBitsToUint(ip.x), floatBitsToUint(ip.y));
uint s = floatBitsToUint(seed);
s ^= (s ^ ((~p.x << s) + (~p.y << s)));

p ^= (p << 17U);
p ^= ((p ^ s) >> 13U);
p ^= (p << 5U);
p ^= ((s + (s&(p.x^p.y))) >> 3U);
uint n = (p.x*s+p.y)+((p.x ^ p.y) << ~p.x ^ s) + ((p.x ^ p.y) << ~p.y ^ s);
return float(n*50323U) / float(0xFFFFFFFFU);
}
#include "sprite_particle_layout.glsl"

#include "utility.glsl"

const float maxLife = 20;

Expand Down
22 changes: 2 additions & 20 deletions Samples/Rendering/shaders/SmokeParticleInitialize.csh
Original file line number Diff line number Diff line change
@@ -1,25 +1,7 @@

struct ParticleData{
vec3 pos;
vec2 scale;
uint animationFrame;
};

float rand(in vec2 ip) {
const float seed = 12345678;
uvec2 p = uvec2(floatBitsToUint(ip.x), floatBitsToUint(ip.y));
uint s = floatBitsToUint(seed);
s ^= (s ^ ((~p.x << s) + (~p.y << s)));

p ^= (p << 17U);
p ^= ((p ^ s) >> 13U);
p ^= (p << 5U);
p ^= ((s + (s&(p.x^p.y))) >> 3U);
uint n = (p.x*s+p.y)+((p.x ^ p.y) << ~p.x ^ s) + ((p.x ^ p.y) << ~p.y ^ s);
return float(n*50323U) / float(0xFFFFFFFFU);
}
#include "sprite_particle_layout.glsl"

#include "utility.glsl"

ParticleData init(ParticleInitData initData)
{
Expand Down
24 changes: 3 additions & 21 deletions Samples/Rendering/shaders/SmokeParticleUpdate.csh
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,9 @@ layout(push_constant, std430) uniform UniformBufferObject{
} ubo;


struct ParticleData{
vec3 pos;
vec2 scale;
uint animationFrame;
};


float rand(in vec2 ip) {
const float seed = 12345678;
uvec2 p = uvec2(floatBitsToUint(ip.x), floatBitsToUint(ip.y));
uint s = floatBitsToUint(seed);
s ^= (s ^ ((~p.x << s) + (~p.y << s)));

p ^= (p << 17U);
p ^= ((p ^ s) >> 13U);
p ^= (p << 5U);
p ^= ((s + (s&(p.x^p.y))) >> 3U);
uint n = (p.x*s+p.y)+((p.x ^ p.y) << ~p.x ^ s) + ((p.x ^ p.y) << ~p.y ^ s);
return float(n*50323U) / float(0xFFFFFFFFU);
}
#include "sprite_particle_layout.glsl"

#include "utility.glsl"

const float maxLife = 200;

Expand Down
5 changes: 5 additions & 0 deletions Samples/Rendering/shaders/sprite_particle_layout.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
struct ParticleData{
vec3 pos;
vec2 scale;
uint animationFrame;
};

0 comments on commit 7cad458

Please sign in to comment.