-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
133 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
cont/base/springcontent/shaders/GLSL/Particles/SmokeParticleGenerator.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
return { | ||
EarlyExit = | ||
[[ | ||
int syncedTime = int(frameInfo.x - createFrame); | ||
float currTime = syncedTime + frameInfo.y; | ||
float age = ageRate * syncedTime; | ||
if (age >= 1.0) | ||
return; | ||
]], | ||
MainCode = | ||
[[ | ||
bool doUpdate = (frameInfo.x > frameInfo.w); | ||
if (doUpdate) { | ||
pos += speed; | ||
pos += windVec * age * 0.05; | ||
size += sizeExpansion; | ||
size += ((startSize - size) * 0.2 * float(size < startSize)); | ||
SavePos(pos); | ||
SaveSize(size); | ||
} | ||
float alpha = (1.0 - age); | ||
color *= alpha; | ||
SetCurrentAnimation(animParams, currTime); | ||
vec3 drawPos = pos + speed * frameInfo.y; | ||
float drawSize = size + sizeExpansion * frameInfo.y; | ||
// rotParams do we need it? | ||
AddEffectsQuadCamera( | ||
drawOrder, | ||
animParams, | ||
drawPos, vec2(drawSize), texCoord, | ||
color | ||
); | ||
]] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
rts/Rendering/Env/Particles/Generators/SmokeParticleGenerator.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "SmokeParticleGenerator.h" | ||
|
||
CR_BIND(SmokeParticleData, ) | ||
CR_REG_METADATA(SmokeParticleData, | ||
( | ||
CR_MEMBER(pos), | ||
CR_MEMBER(size), | ||
CR_MEMBER(startSize), | ||
CR_MEMBER(sizeExpansion), | ||
CR_MEMBER(ageRate), | ||
CR_IGNORED(unused), | ||
CR_MEMBER(speed), | ||
CR_MEMBER(createFrame), | ||
CR_MEMBER(animParams), | ||
CR_MEMBER(color), | ||
CR_MEMBER(rotParams), | ||
CR_MEMBER(drawOrder), | ||
CR_MEMBER(texCoord) | ||
)) |
40 changes: 40 additions & 0 deletions
40
rts/Rendering/Env/Particles/Generators/SmokeParticleGenerator.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#pragma once | ||
|
||
#include "ParticleGenerator.h" | ||
|
||
struct SmokeParticleData { | ||
CR_DECLARE_STRUCT(SmokeParticleData) | ||
float3 pos; | ||
float size; | ||
|
||
float startSize; | ||
float sizeExpansion; | ||
float ageRate; | ||
float unused; | ||
|
||
float3 speed; | ||
int32_t createFrame; | ||
|
||
float3 animParams; | ||
SColor color; | ||
|
||
float3 rotParams; | ||
int32_t drawOrder; | ||
|
||
AtlasedTexture texCoord; | ||
|
||
int32_t GetMaxNumQuads() const { return 1 * (texCoord != AtlasedTexture::DefaultAtlasTexture); } | ||
void Invalidate() { | ||
texCoord = AtlasedTexture::DefaultAtlasTexture; | ||
} | ||
}; | ||
static_assert(sizeof(SmokeParticleData) % 16 == 0); | ||
|
||
class SmokeParticleGenerator : public ParticleGenerator<SmokeParticleData, SmokeParticleGenerator> { | ||
friend class ParticleGenerator<SmokeParticleData, SmokeParticleGenerator>; | ||
public: | ||
SmokeParticleGenerator() {} | ||
~SmokeParticleGenerator() {} | ||
protected: | ||
bool GenerateCPUImpl() { return false; } | ||
}; |