-
-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Materials for paged atlas support (#7581)
* Added sprite and particlefx paged materials + shaders * Use lowp instead
- Loading branch information
Showing
6 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
engine/engine/content/builtins/materials/particlefx_paged_atlas.fp
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,14 @@ | ||
varying mediump vec2 var_texcoord0; | ||
varying lowp vec4 var_color; | ||
varying lowp float var_page_index; | ||
|
||
uniform lowp sampler2DArray texture_sampler; | ||
uniform lowp vec4 tint; | ||
|
||
void main() | ||
{ | ||
// Pre-multiply alpha since all runtime textures already are | ||
lowp vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w); | ||
// var_color is vertex color from the particle system, pre-multiplied in vertex program | ||
gl_FragColor = texture2DArray(texture_sampler, vec3(var_texcoord0.xy, var_page_index)) * var_color * tint_pm; | ||
} |
14 changes: 14 additions & 0 deletions
14
engine/engine/content/builtins/materials/particlefx_paged_atlas.material
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,14 @@ | ||
name: "particle_paged_atlas" | ||
vertex_program: "/builtins/materials/particlefx_paged_atlas.vp" | ||
fragment_program: "/builtins/materials/particlefx_paged_atlas.fp" | ||
tags: "particle" | ||
vertex_constants { | ||
name: "view_proj" | ||
type: CONSTANT_TYPE_VIEWPROJ | ||
} | ||
fragment_constants { | ||
name: "tint" | ||
type: CONSTANT_TYPE_USER | ||
value: {x: 1 y: 1 z: 1 w: 1} | ||
} | ||
max_page_count: 4 |
19 changes: 19 additions & 0 deletions
19
engine/engine/content/builtins/materials/particlefx_paged_atlas.vp
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 @@ | ||
uniform highp mat4 view_proj; | ||
|
||
// positions are in world space | ||
attribute highp vec4 position; | ||
attribute mediump vec2 texcoord0; | ||
attribute lowp vec4 color; | ||
attribute lowp float page_index; | ||
|
||
varying mediump vec2 var_texcoord0; | ||
varying lowp vec4 var_color; | ||
varying lowp float var_page_index; | ||
|
||
void main() | ||
{ | ||
gl_Position = view_proj * vec4(position.xyz, 1.0); | ||
var_texcoord0 = texcoord0; | ||
var_color = vec4(color.rgb * color.a, color.a); | ||
var_page_index = page_index; | ||
} |
12 changes: 12 additions & 0 deletions
12
engine/engine/content/builtins/materials/sprite_paged_atlas.fp
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,12 @@ | ||
varying mediump vec2 var_texcoord0; | ||
varying lowp float var_page_index; | ||
|
||
uniform lowp sampler2DArray texture_sampler; | ||
uniform lowp vec4 tint; | ||
|
||
void main() | ||
{ | ||
// Pre-multiply alpha since all runtime textures already are | ||
lowp vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w); | ||
gl_FragColor = texture2DArray(texture_sampler, vec3(var_texcoord0.xy, var_page_index)) * tint_pm; | ||
} |
14 changes: 14 additions & 0 deletions
14
engine/engine/content/builtins/materials/sprite_paged_atlas.material
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,14 @@ | ||
name: "sprite_paged_atlas" | ||
vertex_program: "/builtins/materials/sprite_paged_atlas.vp" | ||
fragment_program: "/builtins/materials/sprite_paged_atlas.fp" | ||
tags: "tile" | ||
vertex_constants { | ||
name: "view_proj" | ||
type: CONSTANT_TYPE_VIEWPROJ | ||
} | ||
fragment_constants { | ||
name: "tint" | ||
type: CONSTANT_TYPE_USER | ||
value: {x: 1 y: 1 z: 1 w: 1} | ||
} | ||
max_page_count: 4 |
16 changes: 16 additions & 0 deletions
16
engine/engine/content/builtins/materials/sprite_paged_atlas.vp
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,16 @@ | ||
uniform highp mat4 view_proj; | ||
|
||
// positions are in world space | ||
attribute highp vec4 position; | ||
attribute mediump vec2 texcoord0; | ||
attribute lowp float page_index; | ||
|
||
varying mediump vec2 var_texcoord0; | ||
varying lowp float var_page_index; | ||
|
||
void main() | ||
{ | ||
gl_Position = view_proj * vec4(position.xyz, 1.0); | ||
var_texcoord0 = texcoord0; | ||
var_page_index = page_index; | ||
} |