mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-15 00:11:55 +07:00
add custom blendings and custom materials to sprite and spine
This commit is contained in:
@@ -15,6 +15,9 @@
|
||||
}, {
|
||||
"prototype" : "ship_prefab.json",
|
||||
"components" : {
|
||||
"sprite_renderer" : {
|
||||
"blending" : "additive"
|
||||
},
|
||||
"actor" : {
|
||||
"translation" : [-50,-50,0]
|
||||
}
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
{
|
||||
"prototype" : "sprite_prefab.json",
|
||||
"components" : {
|
||||
"renderer" : {
|
||||
"materials" : [
|
||||
"sprite_material.json"
|
||||
]
|
||||
},
|
||||
"sprite_renderer" : {
|
||||
"sprite" : "ship_sprite.json"
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
{
|
||||
"prototype" : "spine_prefab.json",
|
||||
"components" : {
|
||||
"renderer" : {
|
||||
"materials" : ["spine_material.json"]
|
||||
},
|
||||
"spine_player" : {
|
||||
"model" : "spine_coin.json"
|
||||
},
|
||||
|
||||
14
samples/bin/library/spine_material_additive.json
Normal file
14
samples/bin/library/spine_material_additive.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"passes" : [{
|
||||
"shader" : "spine_shader.json",
|
||||
"state_block" : {
|
||||
"blending_state" : {
|
||||
"src_factor" : "one",
|
||||
"dst_factor" : "one"
|
||||
},
|
||||
"capabilities_state" : {
|
||||
"blending" : true
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
"shader" : "spine_shader.json",
|
||||
"state_block" : {
|
||||
"blending_state" : {
|
||||
"src_factor" : "src_alpha",
|
||||
"src_factor" : "dst_color",
|
||||
"dst_factor" : "one_minus_src_alpha"
|
||||
},
|
||||
"capabilities_state" : {
|
||||
14
samples/bin/library/spine_material_normal.json
Normal file
14
samples/bin/library/spine_material_normal.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"passes" : [{
|
||||
"shader" : "spine_shader.json",
|
||||
"state_block" : {
|
||||
"blending_state" : {
|
||||
"src_factor" : "one",
|
||||
"dst_factor" : "one_minus_src_alpha"
|
||||
},
|
||||
"capabilities_state" : {
|
||||
"blending" : true
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
14
samples/bin/library/spine_material_screen.json
Normal file
14
samples/bin/library/spine_material_screen.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"passes" : [{
|
||||
"shader" : "spine_shader.json",
|
||||
"state_block" : {
|
||||
"blending_state" : {
|
||||
"src_factor" : "one",
|
||||
"dst_factor" : "one_minus_src_color"
|
||||
},
|
||||
"capabilities_state" : {
|
||||
"blending" : true
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
15
samples/bin/library/spine_prefab.json
Normal file
15
samples/bin/library/spine_prefab.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"components" : {
|
||||
"renderer" : {},
|
||||
"spine_player" : {
|
||||
"materials" : {
|
||||
"additive" : "spine_material_additive.json",
|
||||
"multiply" : "spine_material_multiply.json",
|
||||
"normal" : "spine_material_normal.json",
|
||||
"screen" : "spine_material_screen.json"
|
||||
}
|
||||
},
|
||||
"spine_player_cmd" : {},
|
||||
"spine_player_evt" : {}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
{
|
||||
"prototype" : "spine_prefab.json",
|
||||
"components" : {
|
||||
"renderer" : {
|
||||
"materials" : ["spine_material.json"]
|
||||
},
|
||||
"spine_player" : {
|
||||
"model" : "spine_raptor.json"
|
||||
},
|
||||
|
||||
@@ -4,5 +4,7 @@ varying vec2 v_st0;
|
||||
varying vec4 v_color0;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = texture2D(u_texture, v_st0) * v_color0;
|
||||
vec4 c = texture2D(u_texture, v_st0) * v_color0;
|
||||
c.rgb *= c.a;
|
||||
gl_FragColor = c;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
uniform vec2 u_screen_s;
|
||||
uniform mat4 u_matrix_vp;
|
||||
|
||||
attribute vec3 a_vertex;
|
||||
@@ -7,6 +8,19 @@ attribute vec4 a_color0;
|
||||
varying vec2 v_st0;
|
||||
varying vec4 v_color0;
|
||||
|
||||
vec2 round(vec2 v) {
|
||||
return vec2(
|
||||
floor(v.x + 0.5),
|
||||
floor(v.y + 0.5));
|
||||
}
|
||||
|
||||
vec4 pixel_snap(vec4 pos) {
|
||||
vec2 hpc = u_screen_s * 0.5;
|
||||
vec2 pixel_pos = round((pos.xy / pos.w) * hpc);
|
||||
pos.xy = pixel_pos / hpc * pos.w;
|
||||
return pos;
|
||||
}
|
||||
|
||||
vec4 vertex_to_homo(vec3 pos) {
|
||||
return vec4(pos, 1.0) * u_matrix_vp;
|
||||
}
|
||||
@@ -14,5 +28,9 @@ vec4 vertex_to_homo(vec3 pos) {
|
||||
void main() {
|
||||
v_st0 = a_st0;
|
||||
v_color0 = a_color0;
|
||||
#ifndef VERTEX_SNAPPING_ON
|
||||
gl_Position = vertex_to_homo(a_vertex);
|
||||
#else
|
||||
gl_Position = pixel_snap(vertex_to_homo(a_vertex));
|
||||
#endif
|
||||
}
|
||||
|
||||
14
samples/bin/library/sprite_material_additive.json
Normal file
14
samples/bin/library/sprite_material_additive.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"passes" : [{
|
||||
"shader" : "sprite_shader.json",
|
||||
"state_block" : {
|
||||
"blending_state" : {
|
||||
"src_factor" : "one",
|
||||
"dst_factor" : "one"
|
||||
},
|
||||
"capabilities_state" : {
|
||||
"blending" : true
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
14
samples/bin/library/sprite_material_multiply.json
Normal file
14
samples/bin/library/sprite_material_multiply.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"passes" : [{
|
||||
"shader" : "sprite_shader.json",
|
||||
"state_block" : {
|
||||
"blending_state" : {
|
||||
"src_factor" : "dst_color",
|
||||
"dst_factor" : "one_minus_src_alpha"
|
||||
},
|
||||
"capabilities_state" : {
|
||||
"blending" : true
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
14
samples/bin/library/sprite_material_screen.json
Normal file
14
samples/bin/library/sprite_material_screen.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"passes" : [{
|
||||
"shader" : "sprite_shader.json",
|
||||
"state_block" : {
|
||||
"blending_state" : {
|
||||
"src_factor" : "one",
|
||||
"dst_factor" : "one_minus_src_color"
|
||||
},
|
||||
"capabilities_state" : {
|
||||
"blending" : true
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
@@ -1,6 +1,13 @@
|
||||
{
|
||||
"components" : {
|
||||
"renderer" : {},
|
||||
"sprite_renderer" : {}
|
||||
"sprite_renderer" : {
|
||||
"materials" : {
|
||||
"additive" : "sprite_material_additive.json",
|
||||
"multiply" : "sprite_material_multiply.json",
|
||||
"normal" : "sprite_material_normal.json",
|
||||
"screen" : "sprite_material_screen.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user