add color to sprite ssbo
This commit is contained in:
parent
0d5ce8f62c
commit
e3029994f9
|
@ -35,6 +35,7 @@ var sprite = {
|
||||||
rect: fullrect,
|
rect: fullrect,
|
||||||
anim:{},
|
anim:{},
|
||||||
playing: 0,
|
playing: 0,
|
||||||
|
anim_speed: 1,
|
||||||
play(str = 0, fn, loop = true, reverse = false) {
|
play(str = 0, fn, loop = true, reverse = false) {
|
||||||
this.del_anim?.();
|
this.del_anim?.();
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -76,7 +77,7 @@ var sprite = {
|
||||||
// if (!self.loop) { self.stop(); return; }
|
// if (!self.loop) { self.stop(); return; }
|
||||||
}
|
}
|
||||||
if (self)
|
if (self)
|
||||||
stop = self.gameobject.delay(advance, playing.frames[f].time);
|
stop = self.gameobject.delay(advance, playing.frames[f].time/self.anim_speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
advance();
|
advance();
|
||||||
|
|
|
@ -7,12 +7,14 @@
|
||||||
in vec3 a_pos;
|
in vec3 a_pos;
|
||||||
in vec2 a_uv;
|
in vec2 a_uv;
|
||||||
out vec2 uv;
|
out vec2 uv;
|
||||||
|
out vec4 shade;
|
||||||
|
|
||||||
vec3 pos;
|
vec3 pos;
|
||||||
|
|
||||||
struct sprite {
|
struct sprite {
|
||||||
mat4 model;
|
mat4 model;
|
||||||
vec4 rect;
|
vec4 rect;
|
||||||
|
vec4 shade;
|
||||||
};
|
};
|
||||||
|
|
||||||
readonly buffer ssbo {
|
readonly buffer ssbo {
|
||||||
|
@ -32,19 +34,20 @@ void main()
|
||||||
pos *= vec3(diffuse_size * s.rect.zw,1);
|
pos *= vec3(diffuse_size * s.rect.zw,1);
|
||||||
uv = (uv*s.rect.zw)+s.rect.xy;
|
uv = (uv*s.rect.zw)+s.rect.xy;
|
||||||
gl_Position = vp * s.model * vec4(pos, 1.0);
|
gl_Position = vp * s.model * vec4(pos, 1.0);
|
||||||
|
shade = s.shade;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@fs fs
|
@fs fs
|
||||||
|
|
||||||
in vec2 uv;
|
in vec2 uv;
|
||||||
|
in vec4 shade;
|
||||||
|
|
||||||
out vec4 color;
|
out vec4 color;
|
||||||
|
|
||||||
texture2D diffuse;
|
texture2D diffuse;
|
||||||
sampler smp;
|
sampler smp;
|
||||||
|
|
||||||
uniform vec4 shade;
|
|
||||||
void frag()
|
void frag()
|
||||||
{
|
{
|
||||||
color = texture(sampler2D(diffuse,smp), uv);
|
color = texture(sampler2D(diffuse,smp), uv);
|
||||||
|
|
|
@ -1075,6 +1075,7 @@ JSC_CCALL(render_make_particle_ssbo,
|
||||||
typedef struct sprite_ss {
|
typedef struct sprite_ss {
|
||||||
HMM_Mat4 model;
|
HMM_Mat4 model;
|
||||||
HMM_Vec4 rect;
|
HMM_Vec4 rect;
|
||||||
|
HMM_Vec4 shade;
|
||||||
} sprite_ss;
|
} sprite_ss;
|
||||||
|
|
||||||
JSC_CCALL(render_make_sprite_ssbo,
|
JSC_CCALL(render_make_sprite_ssbo,
|
||||||
|
@ -1099,6 +1100,7 @@ JSC_CCALL(render_make_sprite_ssbo,
|
||||||
JSValue sub = js_getpropidx(array,i);
|
JSValue sub = js_getpropidx(array,i);
|
||||||
ms[i].model = transform2mat(js2transform(js_getpropstr(sub, "transform")));
|
ms[i].model = transform2mat(js2transform(js_getpropstr(sub, "transform")));
|
||||||
ms[i].rect = js2vec4(js_getpropstr(sub,"rect"));
|
ms[i].rect = js2vec4(js_getpropstr(sub,"rect"));
|
||||||
|
ms[i].shade = js2vec4(js_getpropstr(sub,"shade"));
|
||||||
}
|
}
|
||||||
|
|
||||||
sg_append_buffer(*b, (&(sg_range){
|
sg_append_buffer(*b, (&(sg_range){
|
||||||
|
|
Loading…
Reference in a new issue