-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sprite particle emitter + billboard + instancing --------- Co-authored-by: Sam Joel <30547327+ssamjoel@users.noreply.github.com> Co-authored-by: t-rvw <429601557@qq.com>
- Loading branch information
1 parent
096981e
commit 370d5a6
Showing
39 changed files
with
1,609 additions
and
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
$input v_color0, v_texcoord0 | ||
#include "../common/common.sh" | ||
|
||
SAMPLER2D(s_texColor, 0); | ||
|
||
void main() | ||
{ | ||
vec4 rgba = texture2D(s_texColor, v_texcoord0.xy); | ||
|
||
rgba.xyz = rgba.xyz * v_color0.xyz; | ||
rgba.w = rgba.w * v_color0.w; | ||
gl_FragColor = rgba; | ||
} |
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,6 @@ | ||
#include "../common/common.sh" | ||
|
||
void main() | ||
{ | ||
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); | ||
} |
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,6 @@ | ||
#include "../common/common.sh" | ||
|
||
void main() | ||
{ | ||
gl_FragColor = vec4(0.0, 1.0, 1.0, 1.0); | ||
} |
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,13 @@ | ||
$input v_color0, v_texcoord0 | ||
#include "../common/common.sh" | ||
|
||
SAMPLER2D(s_texColor, 0); | ||
|
||
void main() | ||
{ | ||
vec4 rgba = texture2D(s_texColor, v_texcoord0.xy); | ||
|
||
rgba.xyz = rgba.xyz * v_color0.xyz; | ||
rgba.w = rgba.w * v_color0.w; | ||
gl_FragColor = rgba; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#if defined(PARTICLEINSTANCE) | ||
$input a_position, a_color0, a_texcoord0, i_data0, i_data1 ,i_data2 ,i_data3 ,i_data4 | ||
#else | ||
$input a_position, a_color0, a_texcoord0 | ||
#endif | ||
|
||
$output v_color0, v_texcoord0 | ||
|
||
#if defined(PARTICLEINSTANCE) | ||
#include "../common/common.sh" | ||
#else | ||
#include "../common/common.sh" | ||
uniform vec4 u_particleColor; | ||
#endif | ||
|
||
void main() | ||
{ | ||
#if defined(PARTICLEINSTANCE) | ||
mat4 model = mtxFromCols(i_data0, i_data1, i_data2, i_data3); | ||
vec4 worldPos = mul(model,vec4(a_position,1.0)); | ||
gl_Position = mul(u_viewProj, worldPos); | ||
v_color0 = a_color0*i_data4; | ||
#else | ||
gl_Position = mul(u_modelViewProj, vec4(a_position,1.0)); | ||
v_color0 = a_color0 * u_particleColor; | ||
#endif | ||
|
||
v_texcoord0 = a_texcoord0; | ||
} |
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,10 @@ | ||
$input a_position//, a_color1 | ||
|
||
#include "../common/common.sh" | ||
|
||
uniform vec4 u_shapeRange; | ||
|
||
void main() | ||
{ | ||
gl_Position = mul(u_modelViewProj, vec4(a_position*u_shapeRange.xyz, 1.0)); | ||
} |
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,8 @@ | ||
$input a_position//, a_color1 | ||
|
||
#include "../common/common.sh" | ||
|
||
void main() | ||
{ | ||
gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0)); | ||
} |
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,56 @@ | ||
#if defined(PARTICLEINSTANCE) | ||
$input a_position, a_color0, a_texcoord0, i_data0, i_data1 ,i_data2 ,i_data3 ,i_data4 | ||
#else | ||
$input a_position, a_color0, a_texcoord0 | ||
#endif | ||
$output v_color0, v_texcoord0 | ||
|
||
#include "../common/common.sh" | ||
|
||
#if defined(PARTICLEINSTANCE) | ||
uniform vec4 u_particlePos; | ||
uniform vec4 u_particleScale; | ||
#else | ||
uniform vec4 u_particleColor; | ||
#endif | ||
|
||
void main() | ||
{ | ||
#if defined(PARTICLEINSTANCE) | ||
mat4 model = mtxFromCols(i_data0, i_data1, i_data2, i_data3); | ||
mat4 billboardMatrix; | ||
billboardMatrix[0] = vec4( | ||
u_view[0][0]*u_particleScale.x, | ||
u_view[1][0]*u_particleScale.x, | ||
u_view[2][0]*u_particleScale.x, | ||
0.0 | ||
); | ||
billboardMatrix[1] = vec4( | ||
u_view[0][1]*u_particleScale.y, | ||
u_view[1][1]*u_particleScale.y, | ||
u_view[2][1]*u_particleScale.y, | ||
0.0 | ||
); | ||
billboardMatrix[2] = vec4( | ||
u_view[0][2]*u_particleScale.z, | ||
u_view[1][2]*u_particleScale.z, | ||
u_view[2][2]*u_particleScale.z, | ||
0.0 | ||
); | ||
billboardMatrix[3] = vec4( | ||
u_particlePos.x, | ||
u_particlePos.y, | ||
u_particlePos.z, | ||
1.0 | ||
); | ||
model = mul(model,billboardMatrix); | ||
vec4 worldPos = mul(model,vec4(a_position,1.0)); | ||
gl_Position = mul(u_viewProj, worldPos); | ||
v_color0 = a_color0*i_data4; | ||
#else | ||
gl_Position = mul(u_modelViewProj, vec4(a_position,1.0)); | ||
v_color0 = a_color0 * u_particleColor; | ||
#endif | ||
|
||
v_texcoord0 = a_texcoord0; | ||
} |
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
Oops, something went wrong.