Skip to content
Snippets Groups Projects
Unverified Commit 3cfdb94e authored by TheJackiMonster's avatar TheJackiMonster
Browse files

Added sampling smoke and blending with alpha values

parent 8bd7dd46
No related branches found
No related tags found
1 merge request!106Created initial firework project
...@@ -12,18 +12,35 @@ layout(location = 0) out vec4 outColor; ...@@ -12,18 +12,35 @@ layout(location = 0) out vec4 outColor;
layout(set=1, binding=0) uniform sampler smokeSampler; layout(set=1, binding=0) uniform sampler smokeSampler;
layout(set=1, binding=1) uniform texture3D smokeTextures []; layout(set=1, binding=1) uniform texture3D smokeTextures [];
#define NUM_SMOKE_SAMPLES 8
void main() { void main() {
if (passSize <= 0.0f) { if (passSize <= 0.0f) {
discard; discard;
} }
vec4 data = texture( vec3 start = (vec3(1.0f) + passPos) * 0.5f;
sampler3D( vec3 end = (vec3(1.0f) - passPos) * 0.5f;
smokeTextures[nonuniformEXT(passTextureIndex)],
smokeSampler vec4 result = vec4(0);
),
vec3(0.0f) for (uint i = 0; i < NUM_SMOKE_SAMPLES; i++) {
); #if NUM_SMOKE_SAMPLES > 1
vec3 position = mix(end, start, vec3(i) / (NUM_SMOKE_SAMPLES - 1));
#else
vec3 position = end;
#endif
vec4 data = texture(
sampler3D(
smokeTextures[nonuniformEXT(passTextureIndex)],
smokeSampler
),
position
);
result = vec4(mix(result.rgb, data.rgb, data.a), min(result.a + data.a, 1.0f));
}
outColor = vec4(passColor + data.rgb, 0.1f + data.a); outColor = vec4(passColor * result.rgb, 0.1f * result.a);
} }
\ No newline at end of file
...@@ -50,7 +50,7 @@ struct draw_particles_t { ...@@ -50,7 +50,7 @@ struct draw_particles_t {
#define PARTICLE_COUNT 1024 #define PARTICLE_COUNT 1024
#define SMOKE_COUNT 256 #define SMOKE_COUNT 256
#define SMOKE_RESOLUTION 4 #define SMOKE_RESOLUTION 16
#define RANDOM_DATA_LENGTH 1024 #define RANDOM_DATA_LENGTH 1024
int main(int argc, const char **argv) { int main(int argc, const char **argv) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment