Add render system
This commit is contained in:
parent
af76df6a81
commit
29e7b5e499
8 changed files with 395 additions and 330 deletions
42
shaders/src/shader.glsl
Normal file
42
shaders/src/shader.glsl
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
@header package shader
|
||||
@header import sg "../../sokol/gfx"
|
||||
@header import ecs "../../types"
|
||||
|
||||
@ctype mat4 ecs.Mat4
|
||||
|
||||
@vs vs
|
||||
in vec3 pos;
|
||||
in vec2 uv;
|
||||
|
||||
layout(binding = 0) uniform VsParams {
|
||||
mat4 mvp;
|
||||
vec4 col;
|
||||
};
|
||||
|
||||
out vec4 color;
|
||||
out vec2 tex_coord;
|
||||
|
||||
void main() {
|
||||
gl_Position = mvp * vec4(pos, 1);
|
||||
color = col;
|
||||
tex_coord = uv;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@fs fs
|
||||
in vec4 color;
|
||||
in vec2 tex_coord;
|
||||
|
||||
layout(binding=0) uniform texture2D tex;
|
||||
layout(binding=0) uniform sampler smp;
|
||||
|
||||
out vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
frag_color = texture(sampler2D(tex, smp), tex_coord) * color;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@program main vs fs
|
||||
Loading…
Add table
Add a link
Reference in a new issue