3D: névoa e transparência nos 3 renderizadores

- Tb3dFrame ganha fog_color/fog_start/fog_end e opaque_count; versão 8.
- Os draws saem com os opacos na frente e os transparentes (color[3] < 1)
  depois, do mais longe ao mais perto.
- Software mistura por alfa e não grava o z; OpenGL e Vulkan usam um
  pipeline de blend separado (o alfa mistura a cor, sem gravar o z).
- Blocos novos: "mude a opacidade de %1 para %2" (3D.Opacity) e
  "névoa de %1 até %2" (3D.Fog).
- d3_test compara névoa e transparência nos três renderizadores.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
mguinhosandClaude Opus 5 committed 2026-10-30 00:55:03 -03:00
1 parent cea7cb5ba4
commit 7b3cf8ce9b
11 files changed
+829 -647

No files matched your search

+11 -2
View File
@@ -29,7 +29,7 @@
#include <tinyblocks/tinyblocks.h>
#define TB_3D_LIB "tinyblocks-3d"
#define TB_3D_RENDERER_VERSION 7
#define TB_3D_RENDERER_VERSION 8
/* Malha: triangulos com posicao, normal e uv (8 floats por vertice). Alem
das malhas fixas (cubo, esfera, plano e cilindro de tamanho 1), o usuario
@@ -100,7 +100,7 @@ typedef struct Tb3dDraw {
float mvp[16]; /* viewproj * model (ja calculada: os
renderizadores nao precisam de matematica) */
float normal[9]; /* matriz das normais (3x3, colunas) */
float color[4]; /* RGBA 0..1 */
float color[4]; /* RGB 0..1; A = opacidade (< 1: transparente) */
const Tb3dShader* shader; /* NULL = a luz padrao (lambert por vertice) */
const Tb3dTexture* albedo; /* NULL = sem textura (branco) */
const Tb3dTexture* normaltex; /* NULL = sem normal map (usado depois) */
@@ -116,8 +116,17 @@ typedef struct Tb3dFrame {
float light_dir[3]; /* direcao PARA a luz, normalizada */
float ambient; /* 0..1 */
float time; /* segundos desde a "nova cena 3D" */
/* Nevoa: a cor do pixel vai para fog_color conforme a profundidade na
camera (o w do clip), de fog_start (nada) a fog_end (so nevoa).
fog_end <= fog_start = sem nevoa. */
float fog_color[3];
float fog_start, fog_end;
/* Os draws vem com os opacos primeiro e, depois de opaque_count, os
transparentes (color[3] < 1) do mais longe para o mais perto: o
renderizador mistura esses com o fundo e nao grava a profundidade. */
const Tb3dDraw* draws;
int draw_count;
int opaque_count;
} Tb3dFrame;
/* Renderizador. render escreve width*height*4 bytes RGBA, linha 0 no ALTO. */
+64 -6
View File
@@ -343,6 +343,7 @@ static struct {
int n, cap;
float eye[3], at[3], fov;
float light[3], ambient, sky[4];
float fog_start, fog_end; /* nevoa (fim <= inicio = sem) */
char want[16]; /* "" = automatico */
char used[64], err[160];
double t0; /* "nova cena 3D" (o "tempo" dos shaders) */
@@ -359,6 +360,7 @@ static void scene_reset(void) {
v3_norm(S.light);
S.ambient = 0.35f;
S.sky[0] = 0.53f; S.sky[1] = 0.78f; S.sky[2] = 0.98f; S.sky[3] = 1;
S.fog_start = S.fog_end = 0;
S.t0 = now_s();
}
@@ -435,6 +437,13 @@ static void obj_aabb(const Obj* o, float lo[3], float hi[3]) {
static Tb3dDraw* s_draws;
static int s_draws_cap;
/* Distancia (ao quadrado) do centro do objeto ao olho: ordem dos transparentes */
static float draw_depth(const Tb3dDraw* d, const float eye[3]) {
float c[3];
for (int k = 0; k < 3; k++) c[k] = d->model[12 + k] - eye[k];
return c[0] * c[0] + c[1] * c[1] + c[2] * c[2];
}
static bool frame_build(Tb3dFrame* f, int w, int h) {
meshes_build();
memset(f, 0, sizeof(*f));
@@ -447,6 +456,9 @@ static bool frame_build(Tb3dFrame* f, int w, int h) {
memcpy(f->light_dir, S.light, sizeof(f->light_dir));
f->ambient = S.ambient;
f->time = (float)(now_s() - S.t0);
memcpy(f->fog_color, S.sky, sizeof(f->fog_color)); /* a nevoa some no ceu */
f->fog_start = S.fog_start;
f->fog_end = S.fog_end;
if (S.n > s_draws_cap) {
Tb3dDraw* d = realloc(s_draws, (size_t)S.n * sizeof(*d));
if (!d) return false;
@@ -472,8 +484,23 @@ static bool frame_build(Tb3dFrame* f, int w, int h) {
if (o->material)
for (int k = 0; k < 3; k++) d->color[k] = o->color[k] * o->material->tint[k];
}
/* opacos primeiro; os transparentes no fim, do mais longe ao mais perto */
int no = 0;
for (int i = 0; i < n; i++)
if (s_draws[i].color[3] >= 0.999f) {
Tb3dDraw t = s_draws[i]; s_draws[i] = s_draws[no]; s_draws[no] = t;
no++;
}
for (int i = no + 1; i < n; i++) { /* insercao: poucos transparentes */
Tb3dDraw t = s_draws[i];
float dt = draw_depth(&t, S.eye);
int j = i - 1;
while (j >= no && draw_depth(&s_draws[j], S.eye) < dt) { s_draws[j + 1] = s_draws[j]; j--; }
s_draws[j + 1] = t;
}
f->draws = s_draws;
f->draw_count = n;
f->opaque_count = no;
return true;
}
@@ -492,6 +519,8 @@ static const Tb3dFrame* s_frame;
static float s_base[3];
static float s_nmat[9]; /* matriz das normais (objeto -> mundo) */
static float s_alpha = 1.f; /* opacidade do objeto (< 1: mistura, sem z) */
static float* s_zbuf;
static size_t s_zcap;
@@ -561,7 +590,7 @@ static void raster_tri(const CV* a, const CV* b, const CV* c, int W, int H, uint
if (z < -1.f || z > 1.f) continue;
float* zb = &s_zbuf[(size_t)y * W + x];
if (z >= *zb) continue;
*zb = z;
if (s_alpha >= 0.999f) *zb = z;
uint8_t* p = px + ((size_t)y * W + x) * 4;
float r, g, bl;
float q0 = w0 / a->w, q1 = w1 / b->w, q2 = w2 / c->w, qs = 1.f / (q0 + q1 + q2);
@@ -609,9 +638,23 @@ static void raster_tri(const CV* a, const CV* b, const CV* c, int W, int H, uint
g = (w0 * a->g + w1 * b->g + w2 * c->g) * I * tex[1];
bl = (w0 * a->b + w1 * b->b + w2 * c->b) * I * tex[2];
}
p[0] = (uint8_t)(fminf(r, 1.f) * 255.f + .5f);
p[1] = (uint8_t)(fminf(g, 1.f) * 255.f + .5f);
p[2] = (uint8_t)(fminf(bl, 1.f) * 255.f + .5f);
r = fminf(r, 1.f); g = fminf(g, 1.f); bl = fminf(bl, 1.f);
if (s_frame->fog_end > s_frame->fog_start) { /* nevoa pela profundidade (w do clip) */
float t = (qs - s_frame->fog_start) / (s_frame->fog_end - s_frame->fog_start);
t = t < 0 ? 0 : t > 1 ? 1 : t;
r += (s_frame->fog_color[0] - r) * t;
g += (s_frame->fog_color[1] - g) * t;
bl += (s_frame->fog_color[2] - bl) * t;
}
if (s_alpha < 0.999f) {
float a = s_alpha < 0 ? 0 : s_alpha;
r = r * a + p[0] / 255.f * (1 - a);
g = g * a + p[1] / 255.f * (1 - a);
bl = bl * a + p[2] / 255.f * (1 - a);
}
p[0] = (uint8_t)(r * 255.f + .5f);
p[1] = (uint8_t)(g * 255.f + .5f);
p[2] = (uint8_t)(bl * 255.f + .5f);
p[3] = 255;
}
}
@@ -705,6 +748,7 @@ static bool sw_render(const Tb3dFrame* f, uint8_t* px) {
s_normal = d->normaltex;
memcpy(s_nmat, d->normal, sizeof(s_nmat));
s_frame = f;
s_alpha = d->color[3];
memcpy(s_base, d->color, sizeof(s_base));
for (int i = 0; i < m->vcount; i++) shade(f, d, m->verts + (size_t)i * 8, &cv[i]);
for (int t = 0; t + 2 < m->icount; t += 3) {
@@ -716,6 +760,7 @@ static bool sw_render(const Tb3dFrame* f, uint8_t* px) {
free(cv);
s_prog = s_vprog = NULL;
s_albedo = s_normal = NULL;
s_alpha = 1.f;
return true;
}
@@ -938,8 +983,12 @@ OBJ_CMD(eval_rot_by, vec_in(self, rt, 1, v); for (int k = 0; k < 3; k++) o->r
OBJ_CMD(eval_scale, vec_in(self, rt, 1, v); memcpy(o->scale, v, sizeof(v));)
OBJ_CMD(eval_show, o->visible = true;)
OBJ_CMD(eval_hide, o->visible = false;)
OBJ_CMD(eval_color, if (!d3_color_of(name_in(self, rt, 1), o->color))
tinyblocks_set_error(rt, "cor desconhecida '%s' (use um nome ou #rrggbb)", name_in(self, rt, 1));)
OBJ_CMD(eval_color, float a = o->color[3];
if (!d3_color_of(name_in(self, rt, 1), o->color))
tinyblocks_set_error(rt, "cor desconhecida '%s' (use um nome ou #rrggbb)", name_in(self, rt, 1));
o->color[3] = a;)
OBJ_CMD(eval_opacity, double a = tb_block_input_number(self, rt, 1, 1.0);
o->color[3] = a < 0 ? 0.f : a > 1 ? 1.f : (float)a;)
static void eval_delete(TinyBlocks_Block* self, TinyBlocks* rt) {
self->dirty = false;
@@ -1021,6 +1070,13 @@ static void eval_sky(TinyBlocks_Block* self, TinyBlocks* rt) {
if (!d3_color_of(name_in(self, rt, 0), S.sky)) tinyblocks_set_error(rt, "cor desconhecida '%s'", name_in(self, rt, 0));
}
static void eval_fog(TinyBlocks_Block* self, TinyBlocks* rt) {
self->dirty = false;
double a = tb_block_input_number(self, rt, 0, 20), b = tb_block_input_number(self, rt, 1, 60);
S.fog_start = a < 0 ? 0.f : (float)a;
S.fog_end = (float)b;
}
static void eval_use(TinyBlocks_Block* self, TinyBlocks* rt) {
self->dirty = false;
const char* w = name_in(self, rt, 0);
@@ -1298,6 +1354,7 @@ static const Spec s_specs[] = {
{ "3D.RotateBy", "gire %1 por x %2 y %3 z %4 graus", "jogador|0|5|0", 4, {T,R,R,R}, O_NONE, -1, S_(eval_rot_by), "Soma à rotação do objeto" },
{ "3D.Scale", "mude o tamanho de %1 para x %2 y %3 z %4", "chão|20|1|20", 4, {T,R,R,R}, O_NONE, -1, S_(eval_scale), "Escala do objeto em cada eixo" },
{ "3D.Color", "mude a cor de %1 para %2", "jogador|vermelho", 2, {T,T}, O_NONE, -1, S_(eval_color), "Cor por nome (vermelho, azul, dourado...) ou #rrggbb" },
{ "3D.Opacity", "mude a opacidade de %1 para %2", "água|0.6", 2, {T,R}, O_NONE, -1, S_(eval_opacity), "0 = invisível, 1 = sólido (água, vidro, fantasmas)" },
{ "3D.Show", "mostre o objeto %1", "jogador", 1, {T}, O_NONE, -1, S_(eval_show), "Volta a desenhar o objeto" },
{ "3D.Hide", "esconda o objeto %1", "jogador", 1, {T}, O_NONE, -1, S_(eval_hide), "Deixa de desenhar o objeto (e ele não encosta)" },
{ "3D.Delete", "apague o objeto %1", "jogador", 1, {T}, O_NONE, -1, S_(eval_delete), "Tira o objeto da cena" },
@@ -1312,6 +1369,7 @@ static const Spec s_specs[] = {
{ "3D.Light", "luz vindo de x %1 y %2 z %3", "0.4|1|0.6", 3, {R,R,R}, O_NONE, -1, S_(eval_light), "Direção de onde vem a luz do sol" },
{ "3D.Ambient", "luz ambiente %1", "0.35", 1, {R}, O_NONE, -1, S_(eval_ambient), "Claridade das partes na sombra (0 a 1)" },
{ "3D.Sky", "cor do céu %1", "#87c7fa", 1, {T}, O_NONE, -1, S_(eval_sky), "Cor do fundo" },
{ "3D.Fog", "névoa de %1 até %2", "20|60", 2, {R,R}, O_NONE, -1, S_(eval_fog), "Longe da câmera tudo some na cor do céu: começa na 1a distância e cobre tudo na 2a (0 e 0 = sem névoa)" },
{ "3D.Image", "imagem da cena de %1 por %2", "480|360", 2, {I,I}, O_IMAGE, -1, S_(eval_image), "Desenha a cena numa imagem (use com \"desenhe\")" },
{ "3D.Use", "use o renderizador %1", "automático", 1, {T}, O_NONE, -1, S_(eval_use), "vulkan, opengl, software ou automático" },
{ "3D.Renderer", "renderizador da cena", "", 0, {T}, O_TEXT, -1, S_(eval_renderer), "Quem desenhou o último quadro (e em qual placa)" },
+34 -4
View File
@@ -38,7 +38,7 @@ static struct {
static EGLDisplay s_dpy = EGL_NO_DISPLAY;
static EGLContext s_ctx = EGL_NO_CONTEXT;
static GLuint s_prog, s_fbo, s_color, s_depth;
static GLint u_mvp, u_nrm, u_color, u_light, u_ambient;
static GLint u_mvp, u_nrm, u_color, u_light, u_ambient, u_fog, u_fog_end;
static int s_w, s_h;
static uint8_t* s_rows; /* leitura (de baixo para cima) */
static size_t s_rows_cap;
@@ -53,7 +53,7 @@ static GLuint s_white;
static GLuint s_flat; /* normal map neutro (0,0,1) */
/* Programas dos shaders feitos com blocos: cache pelo id (id % 64) */
typedef struct { GLuint prog; int id; GLint mvp, model, nrm, color, light, ambient, time, albedo, normalmap; } GpuShader;
typedef struct { GLuint prog; int id; GLint mvp, model, nrm, color, light, ambient, time, albedo, normalmap, fog, fog_end; } GpuShader;
static GpuShader s_shd[64];
static void fail(const char* fmt, const char* a) { snprintf(G.err, sizeof(G.err), fmt, a); }
@@ -84,6 +84,13 @@ static const char* FS =
"uniform float u_ambient;\n"
"uniform sampler2D u_albedo;\n"
"uniform sampler2D u_normalmap;\n"
"uniform vec4 u_fog;\n" /* rgb = cor da nevoa, a = inicio */
"uniform float u_fog_end;\n"
"vec3 tb_fog(vec3 c) {\n"
" if (u_fog_end <= u_fog.w) return c;\n"
" float t = clamp((1.0 / gl_FragCoord.w - u_fog.w) / (u_fog_end - u_fog.w), 0.0, 1.0);\n"
" return mix(c, u_fog.rgb, t);\n"
"}\n"
"out vec4 o_color;\n"
"void main() {\n"
" vec3 No = normalize(v_nobj);\n"
@@ -94,7 +101,7 @@ static const char* FS =
" vec3 nm = texture(u_normalmap, v_uv).xyz * 2.0 - 1.0;\n"
" vec3 N = normalize(u_nrm * normalize(mat3(T, B, No) * nm));\n"
" float I = u_ambient + (1.0 - u_ambient) * max(dot(N, u_light), 0.0);\n"
" o_color = vec4(min(u_color.rgb * I * texture(u_albedo, v_uv).rgb, vec3(1.0)), 1.0);\n"
" o_color = vec4(tb_fog(min(u_color.rgb * I * texture(u_albedo, v_uv).rgb, vec3(1.0))), u_color.a);\n"
"}\n";
static const char* VS_VERT_HEAD =
@@ -144,6 +151,13 @@ static const char* FS_HEAD =
"uniform float u_time;\n"
"uniform sampler2D u_albedo;\n"
"uniform sampler2D u_normalmap;\n"
"uniform vec4 u_fog;\n" /* rgb = cor da nevoa, a = inicio */
"uniform float u_fog_end;\n"
"vec3 tb_fog(vec3 c) {\n"
" if (u_fog_end <= u_fog.w) return c;\n"
" float t = clamp((1.0 / gl_FragCoord.w - u_fog.w) / (u_fog_end - u_fog.w), 0.0, 1.0);\n"
" return mix(c, u_fog.rgb, t);\n"
"}\n"
"out vec4 o_color;\n";
static const char* FS_MAIN =
"void main() {\n"
@@ -156,7 +170,7 @@ static const char* FS_MAIN =
" vec3 N = normalize(u_nrm * normalize(mat3(T, B, No) * nm));\n"
" float light = u_ambient + (1.0 - u_ambient) * max(dot(N, u_light), 0.0);\n"
" vec3 tex = texture(u_albedo, v_uv).rgb;\n"
" o_color = vec4(tb_shade(v_pos, N, v_local, v_uv, u_color.rgb, tex, light, u_time), 1.0);\n"
" o_color = vec4(tb_fog(min(tb_shade(v_pos, N, v_local, v_uv, u_color.rgb, tex, light, u_time), vec3(1.0))), u_color.a);\n"
"}\n";
static GLuint shader(GLenum kind, const char* src) {
@@ -266,6 +280,8 @@ static GpuShader* gpu_shader(const Tb3dShader* sh) {
g->time = glGetUniformLocation(g->prog, "u_time");
g->albedo = glGetUniformLocation(g->prog, "u_albedo");
g->normalmap = glGetUniformLocation(g->prog, "u_normalmap");
g->fog = glGetUniformLocation(g->prog, "u_fog");
g->fog_end = glGetUniformLocation(g->prog, "u_fog_end");
return g;
}
@@ -306,6 +322,8 @@ static bool gl_setup(void) {
u_color = glGetUniformLocation(s_prog, "u_color");
u_light = glGetUniformLocation(s_prog, "u_light");
u_ambient = glGetUniformLocation(s_prog, "u_ambient");
u_fog = glGetUniformLocation(s_prog, "u_fog");
u_fog_end = glGetUniformLocation(s_prog, "u_fog_end");
glGenTextures(1, &s_white);
glBindTexture(GL_TEXTURE_2D, s_white);
static const uint8_t branco[4] = { 255, 255, 255, 255 };
@@ -392,10 +410,17 @@ static bool draw(const Tb3dFrame* f, uint8_t* out) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glDisable(GL_BLEND); /* um quadro que parou no meio */
glDepthMask(GL_TRUE);
glDisable(GL_CULL_FACE);
glUseProgram(s_prog);
glUniform3fv(u_light, 1, f->light_dir);
glUniform1f(u_ambient, f->ambient);
float fog[4] = { f->fog_color[0], f->fog_color[1], f->fog_color[2], f->fog_start };
glUniform4fv(u_fog, 1, fog);
glUniform1f(u_fog_end, f->fog_end);
/* transparentes: misturam a cor (o alfa da imagem fica 1) sem gravar o z */
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE);
glActiveTexture(GL_TEXTURE0);
glUniform1i(glGetUniformLocation(s_prog, "u_albedo"), 0);
glUniform1i(glGetUniformLocation(s_prog, "u_normalmap"), 1);
@@ -403,6 +428,7 @@ static bool draw(const Tb3dFrame* f, uint8_t* out) {
const Tb3dDraw* d = &f->draws[i];
GpuMesh* g = gpu_mesh(d->mesh);
if (!g) continue;
if (i == f->opaque_count) { glEnable(GL_BLEND); glDepthMask(GL_FALSE); }
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, gpu_tex(d->albedo));
glActiveTexture(GL_TEXTURE1);
@@ -420,6 +446,8 @@ static bool draw(const Tb3dFrame* f, uint8_t* out) {
glUniform1f(sh->time, f->time);
glUniform1i(sh->albedo, 0);
glUniform1i(sh->normalmap, 1);
glUniform4fv(sh->fog, 1, fog);
glUniform1f(sh->fog_end, f->fog_end);
glBindVertexArray(g->vao);
glDrawElements(GL_TRIANGLES, g->icount, GL_UNSIGNED_INT, (void*)0);
glUseProgram(s_prog);
@@ -431,6 +459,8 @@ static bool draw(const Tb3dFrame* f, uint8_t* out) {
glBindVertexArray(g->vao);
glDrawElements(GL_TRIANGLES, g->icount, GL_UNSIGNED_INT, (void*)0);
}
glDisable(GL_BLEND);
glDepthMask(GL_TRUE);
size_t row = (size_t)f->width * 4, n = row * (size_t)f->height;
if (n > s_rows_cap) {
uint8_t* p = realloc(s_rows, n);
+11 -2
View File
@@ -4,9 +4,18 @@ layout(location = 1) in vec3 v_nobj;
layout(location = 2) in vec2 v_uv;
layout(set = 0, binding = 0) uniform sampler2D u_albedo;
layout(set = 0, binding = 1) uniform sampler2D u_normalmap;
// Do quadro: fog.rgb = cor da nevoa, fog.w = inicio; p.x = fim, p.y = luz ambiente
layout(set = 0, binding = 2) uniform Frame { vec4 fog; vec4 p; } fr;
// color.rgb = cor do objeto, color.a = opacidade
layout(push_constant) uniform PC { mat4 mvp; vec4 n0; vec4 n1; vec4 n2; vec4 color; } pc;
layout(location = 0) out vec4 o_color;
vec3 tb_fog(vec3 c) {
if (fr.p.x <= fr.fog.w) return c;
float t = clamp((1.0 / gl_FragCoord.w - fr.fog.w) / (fr.p.x - fr.fog.w), 0.0, 1.0);
return mix(c, fr.fog.rgb, t);
}
void main() {
mat3 Nmat = mat3(pc.n0.xyz, pc.n1.xyz, pc.n2.xyz);
vec3 No = normalize(v_nobj);
@@ -19,6 +28,6 @@ void main() {
vec3 nm = texture(u_normalmap, v_uv).xyz * 2.0 - 1.0;
vec3 N = normalize(Nmat * normalize(mat3(T, B, No) * nm));
vec3 L = vec3(pc.n0.w, pc.n1.w, pc.n2.w);
float I = pc.color.a + (1.0 - pc.color.a) * max(dot(N, L), 0.0);
o_color = vec4(min(pc.color.rgb * I * texture(u_albedo, v_uv).rgb, vec3(1.0)), 1.0);
float I = fr.p.y + (1.0 - fr.p.y) * max(dot(N, L), 0.0);
o_color = vec4(tb_fog(min(pc.color.rgb * I * texture(u_albedo, v_uv).rgb, vec3(1.0))), pc.color.a);
}
+2 -1
View File
@@ -2,7 +2,8 @@
// Vertice da tinyblocks-vk: passa posicao local, normal de objeto e uv para o
// fragment, que faz a luz (e o relevo) por pixel. Push constants (128 bytes):
// mvp; n0..n2 = colunas da matriz das normais, com a direcao da luz nos .w;
// color.rgb = cor do objeto, color.a = luz ambiente.
// color.rgb = cor do objeto, color.a = opacidade (a luz ambiente vem do
// uniform do quadro, binding 2).
layout(location = 0) in vec3 a_pos;
layout(location = 1) in vec3 a_nrm;
layout(location = 2) in vec2 a_uv;
@@ -1,7 +1,7 @@
#version 450
// Vertice dos objetos com shader feito com blocos: passa o ponto e a normal
// no mundo para o fragment (que chama tb_shade). Push constants (160 bytes):
// mvp; model; color.rgb = cor do objeto, color.a = luz ambiente;
// mvp; model; color.rgb = cor do objeto, color.a = opacidade;
// light.xyz = direcao da luz, light.w = tempo.
layout(location = 0) in vec3 a_pos;
layout(location = 1) in vec3 a_nrm;
+43 -17
View File
@@ -69,8 +69,14 @@ static const char* FS_HEAD =
"layout(location = 4) in vec3 v_nobj;\n"
"layout(set = 0, binding = 0) uniform sampler2D u_albedo;\n"
"layout(set = 0, binding = 1) uniform sampler2D u_normalmap;\n"
"layout(set = 0, binding = 2) uniform Frame { vec4 fog; vec4 p; } fr;\n"
"layout(push_constant) uniform PC { mat4 mvp; mat4 model; vec4 color; vec4 light; } pc;\n"
"layout(location = 0) out vec4 o_color;\n";
"layout(location = 0) out vec4 o_color;\n"
"vec3 tb_fog(vec3 c) {\n"
" if (fr.p.x <= fr.fog.w) return c;\n"
" float t = clamp((1.0 / gl_FragCoord.w - fr.fog.w) / (fr.p.x - fr.fog.w), 0.0, 1.0);\n"
" return mix(c, fr.fog.rgb, t);\n"
"}\n";
static const char* FS_MAIN =
"void main() {\n"
" mat3 Nmat = transpose(inverse(mat3(pc.model)));\n"
@@ -81,9 +87,9 @@ static const char* FS_MAIN =
" vec3 B = -normalize(dp2 * duv1.x - dp1 * duv2.x);\n"
" vec3 nm = texture(u_normalmap, v_uv).xyz * 2.0 - 1.0;\n"
" vec3 N = normalize(Nmat * normalize(mat3(T, B, No) * nm));\n"
" float light = pc.color.a + (1.0 - pc.color.a) * max(dot(N, pc.light.xyz), 0.0);\n"
" float light = fr.p.y + (1.0 - fr.p.y) * max(dot(N, pc.light.xyz), 0.0);\n"
" vec3 tex = texture(u_albedo, v_uv).rgb;\n"
" o_color = vec4(tb_shade(v_pos, N, v_local, v_uv, pc.color.rgb, tex, light, pc.light.w), 1.0);\n"
" o_color = vec4(tb_fog(min(tb_shade(v_pos, N, v_local, v_uv, pc.color.rgb, tex, light, pc.light.w), vec3(1.0))), pc.color.a);\n"
"}\n";
/* Estagio de VERTICE: o VS chama tb_vert e sai a interface que o fragmento
@@ -94,6 +100,7 @@ static const char* VS_VERT_HEAD =
"layout(location = 1) in vec3 a_nrm;\n"
"layout(location = 2) in vec2 a_uv;\n"
"layout(push_constant) uniform PC { mat4 mvp; mat4 model; vec4 color; vec4 light; } pc;\n"
"layout(set = 0, binding = 2) uniform Frame { vec4 fog; vec4 p; } fr;\n"
"layout(location = 0) out vec3 v_pos;\n"
"layout(location = 1) out vec3 v_nrm;\n"
"layout(location = 2) out vec3 v_local;\n"
@@ -102,7 +109,7 @@ static const char* VS_VERT_HEAD =
static const char* VS_VERT_MAIN =
"void main() {\n"
" vec3 n = normalize(transpose(inverse(mat3(pc.model))) * a_nrm);\n"
" float light = pc.color.a + (1.0 - pc.color.a) * max(dot(n, pc.light.xyz), 0.0);\n"
" float light = fr.p.y + (1.0 - fr.p.y) * max(dot(n, pc.light.xyz), 0.0);\n"
" vec3 P = tb_vert(a_pos, a_nrm, a_pos, a_uv, pc.color.rgb, vec3(1.0), light, pc.light.w);\n"
" vec4 p = pc.mvp * vec4(P, 1.0);\n"
" p.z = (p.z + p.w) * 0.5;\n"
@@ -185,6 +192,8 @@ static struct {
VkRenderPass pass;
VkPipelineLayout layout;
VkPipeline pipe;
VkPipeline pipe_blend; /* o mesmo, para transparentes */
Buf frame_ubo; /* nevoa e luz ambiente do quadro */
VkPipelineLayout shd_layout; /* 160 bytes de push constants */
VkShaderModule shd_vert;
bool shd_ok; /* da para usar shaders feitos com blocos */
@@ -295,7 +304,8 @@ static bool pick_device(void) {
/* Pipeline com os estados fixos da vk (vertice pos+normal, profundidade,
viewport/scissor dinamicos) e os dois modulos dados */
static VkResult build_pipe(VkShaderModule vs, VkShaderModule fs, VkPipelineLayout layout, VkPipeline* out) {
/* blend: transparente (mistura a cor, mantem o alfa da imagem e nao grava o z) */
static VkResult build_pipe(VkShaderModule vs, VkShaderModule fs, VkPipelineLayout layout, bool blend, VkPipeline* out) {
VkPipelineShaderStageCreateInfo st[2] = {
{ VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, NULL, 0, VK_SHADER_STAGE_VERTEX_BIT, vs, "main", NULL },
{ VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, NULL, 0, VK_SHADER_STAGE_FRAGMENT_BIT, fs, "main", NULL },
@@ -313,8 +323,11 @@ static VkResult build_pipe(VkShaderModule vs, VkShaderModule fs, VkPipelineLayou
VkPipelineMultisampleStateCreateInfo ms = { VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, NULL, 0,
VK_SAMPLE_COUNT_1_BIT, VK_FALSE, 0, NULL, VK_FALSE, VK_FALSE };
VkPipelineDepthStencilStateCreateInfo ds = { VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, NULL, 0,
VK_TRUE, VK_TRUE, VK_COMPARE_OP_LESS, VK_FALSE, VK_FALSE, {0}, {0}, 0, 1 };
VK_TRUE, blend ? VK_FALSE : VK_TRUE, VK_COMPARE_OP_LESS, VK_FALSE, VK_FALSE, {0}, {0}, 0, 1 };
VkPipelineColorBlendAttachmentState cba = { VK_FALSE, 0, 0, 0, 0, 0, 0, 0xf };
if (blend) cba = (VkPipelineColorBlendAttachmentState){ VK_TRUE,
VK_BLEND_FACTOR_SRC_ALPHA, VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, VK_BLEND_OP_ADD,
VK_BLEND_FACTOR_ZERO, VK_BLEND_FACTOR_ONE, VK_BLEND_OP_ADD, 0xf };
VkPipelineColorBlendStateCreateInfo cb = { VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, NULL, 0,
VK_FALSE, 0, 1, &cba, {0} };
VkDynamicState dyn_s[2] = { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR };
@@ -411,16 +424,22 @@ static bool make_pipeline(void) {
VkRenderPassCreateInfo rp = { VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, NULL, 0, 2, att, 1, &sub, 1, &dep };
CK(vkCreateRenderPass(V.dev, &rp, NULL, &V.pass), "vkCreateRenderPass");
VkDescriptorSetLayoutBinding b[2] = {
VkDescriptorSetLayoutBinding b[3] = {
{ 0, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, NULL },
{ 1, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, NULL } };
VkDescriptorSetLayoutCreateInfo dl = { VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, NULL, 0, 2, b };
{ 1, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, NULL },
{ 2, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, NULL } };
VkDescriptorSetLayoutCreateInfo dl = { VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, NULL, 0, 3, b };
CK(vkCreateDescriptorSetLayout(V.dev, &dl, NULL, &V.desc_layout), "vkCreateDescriptorSetLayout");
VkDescriptorPoolSize ps = { VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 2 };
VkDescriptorPoolCreateInfo dp = { VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO, NULL, 0, 1, 1, &ps };
VkDescriptorPoolSize ps[2] = { { VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 2 }, { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1 } };
VkDescriptorPoolCreateInfo dp = { VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO, NULL, 0, 1, 2, ps };
CK(vkCreateDescriptorPool(V.dev, &dp, NULL, &V.desc_pool), "vkCreateDescriptorPool");
VkDescriptorSetAllocateInfo da = { VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, NULL, V.desc_pool, 1, &V.desc_layout };
CK(vkAllocateDescriptorSets(V.dev, &da, &V.desc_set), "vkAllocateDescriptorSets");
if (!buf_new(&V.frame_ubo, 32, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT)) return false;
VkDescriptorBufferInfo ubi = { V.frame_ubo.buf, 0, 32 };
VkWriteDescriptorSet uw = { VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, NULL, V.desc_set, 2, 0, 1,
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, NULL, &ubi, NULL };
vkUpdateDescriptorSets(V.dev, 1, &uw, 0, NULL);
VkSamplerCreateInfo sc = { VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, NULL, 0,
VK_FILTER_LINEAR, VK_FILTER_LINEAR, VK_SAMPLER_MIPMAP_MODE_NEAREST,
VK_SAMPLER_ADDRESS_MODE_REPEAT, VK_SAMPLER_ADDRESS_MODE_REPEAT, VK_SAMPLER_ADDRESS_MODE_REPEAT,
@@ -435,7 +454,8 @@ static bool make_pipeline(void) {
CK(vkCreateShaderModule(V.dev, &sm, NULL, &vs), "shader de vértice");
sm.codeSize = sizeof(s_frag_spv); sm.pCode = s_frag_spv;
CK(vkCreateShaderModule(V.dev, &sm, NULL, &fs), "shader de fragmento");
VkResult r = build_pipe(vs, fs, V.layout, &V.pipe);
VkResult r = build_pipe(vs, fs, V.layout, false, &V.pipe);
if (r == VK_SUCCESS) r = build_pipe(vs, fs, V.layout, true, &V.pipe_blend);
vkDestroyShaderModule(V.dev, vs, NULL);
vkDestroyShaderModule(V.dev, fs, NULL);
CK(r, "vkCreateGraphicsPipelines");
@@ -594,7 +614,7 @@ static GpuShader* gpu_shader(const Tb3dShader* sh) {
vkDeviceWaitIdle(V.dev);
if (g->pipe) vkDestroyPipeline(V.dev, g->pipe, NULL);
g->pipe = VK_NULL_HANDLE;
r = build_pipe(vs, fs, V.shd_layout, &g->pipe);
r = build_pipe(vs, fs, V.shd_layout, false, &g->pipe);
if (vert) vkDestroyShaderModule(V.dev, fs, NULL);
vkDestroyShaderModule(V.dev, mod, NULL);
if (r != VK_SUCCESS) { snprintf(V.err, sizeof(V.err), "pipeline do shader recusado (%d)", (int)r); return NULL; }
@@ -624,6 +644,9 @@ static bool vk_draw(const Tb3dFrame* f, uint8_t* out) {
gpu_tex(f->draws[i].albedo);
if (f->draws[i].normaltex) gpu_tex(f->draws[i].normaltex);
}
float fu[8] = { f->fog_color[0], f->fog_color[1], f->fog_color[2], f->fog_start,
f->fog_end, f->ambient, 0, 0 };
memcpy(V.frame_ubo.map, fu, sizeof(fu)); /* a fila esta parada: pode escrever */
CK(vkResetCommandBuffer(V.cmd, 0), "vkResetCommandBuffer");
VkCommandBufferBeginInfo bi = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, NULL, VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, NULL };
CK(vkBeginCommandBuffer(V.cmd, &bi), "vkBeginCommandBuffer");
@@ -642,11 +665,12 @@ static bool vk_draw(const Tb3dFrame* f, uint8_t* out) {
for (int i = 0; i < f->draw_count; i++) {
const Tb3dDraw* d = &f->draws[i];
GpuMesh* g = gpu_mesh(d->mesh);
if (i == f->opaque_count) vkCmdBindPipeline(V.cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, V.pipe_blend);
if (d->shader) { /* shader feito com blocos */
float pc[40];
memcpy(pc, d->mvp, sizeof(d->mvp));
memcpy(pc + 16, d->model, sizeof(d->model));
pc[32] = d->color[0]; pc[33] = d->color[1]; pc[34] = d->color[2]; pc[35] = f->ambient;
pc[32] = d->color[0]; pc[33] = d->color[1]; pc[34] = d->color[2]; pc[35] = d->color[3];
pc[36] = f->light_dir[0]; pc[37] = f->light_dir[1]; pc[38] = f->light_dir[2]; pc[39] = f->time;
vkCmdBindPipeline(V.cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, V.shd[(unsigned)d->shader->id % 64u].pipe);
bind_tex(V.cmd, V.shd_layout, d->albedo, d->normaltex);
@@ -656,7 +680,7 @@ static bool vk_draw(const Tb3dFrame* f, uint8_t* out) {
vkCmdBindVertexBuffers(V.cmd, 0, 1, &g->vb.buf, &off);
vkCmdBindIndexBuffer(V.cmd, g->ib.buf, 0, VK_INDEX_TYPE_UINT32);
vkCmdDrawIndexed(V.cmd, (uint32_t)g->icount, 1, 0, 0, 0);
vkCmdBindPipeline(V.cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, V.pipe);
vkCmdBindPipeline(V.cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, i >= f->opaque_count ? V.pipe_blend : V.pipe);
continue;
}
float pc[32];
@@ -667,9 +691,9 @@ static bool vk_draw(const Tb3dFrame* f, uint8_t* out) {
pc[16 + c * 4 + 2] = d->normal[c * 3 + 2];
pc[16 + c * 4 + 3] = f->light_dir[c];
}
pc[28] = d->color[0]; pc[29] = d->color[1]; pc[30] = d->color[2]; pc[31] = f->ambient;
pc[28] = d->color[0]; pc[29] = d->color[1]; pc[30] = d->color[2]; pc[31] = d->color[3];
bind_tex(V.cmd, V.layout, d->albedo, d->normaltex);
vkCmdPushConstants(V.cmd, V.layout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(pc), pc);
vkCmdPushConstants(V.cmd, V.layout, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(pc), pc);
VkDeviceSize off = 0;
vkCmdBindVertexBuffers(V.cmd, 0, 1, &g->vb.buf, &off);
vkCmdBindIndexBuffer(V.cmd, g->ib.buf, 0, VK_INDEX_TYPE_UINT32);
@@ -707,6 +731,8 @@ static void vk_cleanup(void) {
if (V.shd_vert) vkDestroyShaderModule(V.dev, V.shd_vert, NULL);
if (V.shd_layout) vkDestroyPipelineLayout(V.dev, V.shd_layout, NULL);
if (V.pipe) vkDestroyPipeline(V.dev, V.pipe, NULL);
if (V.pipe_blend) vkDestroyPipeline(V.dev, V.pipe_blend, NULL);
buf_free(&V.frame_ubo);
if (V.layout) vkDestroyPipelineLayout(V.dev, V.layout, NULL);
if (V.pass) vkDestroyRenderPass(V.dev, V.pass, NULL);
if (V.fence) vkDestroyFence(V.dev, V.fence, NULL);
+108 -83
View File
@@ -49,90 +49,115 @@ static const uint32_t s_vert_spv[341] = {
0x0003003e, 0x00000039, 0x0000003c, 0x000100fd, 0x00010038,
};
static const uint32_t s_frag_spv[657] = {
0x07230203, 0x00010000, 0x000d000b, 0x000000ae, 0x00000000, 0x00020011, 0x00000001, 0x0006000b,
static const uint32_t s_frag_spv[864] = {
0x07230203, 0x00010000, 0x000d000b, 0x00000111, 0x00000000, 0x00020011, 0x00000001, 0x0006000b,
0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 0x00000000, 0x00000001,
0x0009000f, 0x00000004, 0x00000004, 0x6e69616d, 0x00000000, 0x00000030, 0x00000034, 0x0000003e,
0x0000009c, 0x00030010, 0x00000004, 0x00000007, 0x00040048, 0x0000000d, 0x00000000, 0x00000005,
0x00050048, 0x0000000d, 0x00000000, 0x00000023, 0x00000000, 0x00050048, 0x0000000d, 0x00000000,
0x00000007, 0x00000010, 0x00050048, 0x0000000d, 0x00000001, 0x00000023, 0x00000040, 0x00050048,
0x0000000d, 0x00000002, 0x00000023, 0x00000050, 0x00050048, 0x0000000d, 0x00000003, 0x00000023,
0x00000060, 0x00050048, 0x0000000d, 0x00000004, 0x00000023, 0x00000070, 0x00030047, 0x0000000d,
0x00000002, 0x00040047, 0x00000030, 0x0000001e, 0x00000001, 0x00040047, 0x00000034, 0x0000001e,
0x00000000, 0x00040047, 0x0000003e, 0x0000001e, 0x00000002, 0x00040047, 0x00000064, 0x00000022,
0x00000000, 0x00040047, 0x00000064, 0x00000021, 0x00000001, 0x00040047, 0x0000009c, 0x0000001e,
0x00000000, 0x00040047, 0x000000a2, 0x00000022, 0x00000000, 0x00040047, 0x000000a2, 0x00000021,
0x00000000, 0x00020013, 0x00000002, 0x00030021, 0x00000003, 0x00000002, 0x00030016, 0x00000006,
0x00000020, 0x00040017, 0x00000007, 0x00000006, 0x00000003, 0x00040018, 0x00000008, 0x00000007,
0x00000003, 0x00040017, 0x0000000b, 0x00000006, 0x00000004, 0x00040018, 0x0000000c, 0x0000000b,
0x00000004, 0x0007001e, 0x0000000d, 0x0000000c, 0x0000000b, 0x0000000b, 0x0000000b, 0x0000000b,
0x00040020, 0x0000000e, 0x00000009, 0x0000000d, 0x0004003b, 0x0000000e, 0x0000000f, 0x00000009,
0x00040015, 0x00000010, 0x00000020, 0x00000001, 0x0004002b, 0x00000010, 0x00000011, 0x00000001,
0x00040020, 0x00000012, 0x00000009, 0x0000000b, 0x0004002b, 0x00000010, 0x00000016, 0x00000002,
0x0004002b, 0x00000010, 0x0000001a, 0x00000003, 0x0004002b, 0x00000006, 0x0000001e, 0x3f800000,
0x0004002b, 0x00000006, 0x0000001f, 0x00000000, 0x00040020, 0x0000002f, 0x00000001, 0x00000007,
0x0004003b, 0x0000002f, 0x00000030, 0x00000001, 0x0004003b, 0x0000002f, 0x00000034, 0x00000001,
0x00040017, 0x0000003a, 0x00000006, 0x00000002, 0x00040020, 0x0000003d, 0x00000001, 0x0000003a,
0x0004003b, 0x0000003d, 0x0000003e, 0x00000001, 0x00040015, 0x00000046, 0x00000020, 0x00000000,
0x00090019, 0x00000061, 0x00000006, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000001,
0x00000000, 0x0003001b, 0x00000062, 0x00000061, 0x00040020, 0x00000063, 0x00000000, 0x00000062,
0x0004003b, 0x00000063, 0x00000064, 0x00000000, 0x0004002b, 0x00000006, 0x00000069, 0x40000000,
0x0004002b, 0x00000046, 0x00000085, 0x00000003, 0x00040020, 0x00000086, 0x00000009, 0x00000006,
0x0004002b, 0x00000010, 0x0000008f, 0x00000004, 0x00040020, 0x0000009b, 0x00000003, 0x0000000b,
0x0004003b, 0x0000009b, 0x0000009c, 0x00000003, 0x0004003b, 0x00000063, 0x000000a2, 0x00000000,
0x0006002c, 0x00000007, 0x000000a8, 0x0000001e, 0x0000001e, 0x0000001e, 0x00050036, 0x00000002,
0x00000004, 0x00000000, 0x00000003, 0x000200f8, 0x00000005, 0x00050041, 0x00000012, 0x00000013,
0x0000000f, 0x00000011, 0x0004003d, 0x0000000b, 0x00000014, 0x00000013, 0x00050041, 0x00000012,
0x00000017, 0x0000000f, 0x00000016, 0x0004003d, 0x0000000b, 0x00000018, 0x00000017, 0x00050041,
0x00000012, 0x0000001b, 0x0000000f, 0x0000001a, 0x0004003d, 0x0000000b, 0x0000001c, 0x0000001b,
0x00050051, 0x00000006, 0x00000020, 0x00000014, 0x00000000, 0x00050051, 0x00000006, 0x00000021,
0x00000014, 0x00000001, 0x00050051, 0x00000006, 0x00000022, 0x00000014, 0x00000002, 0x00050051,
0x00000006, 0x00000023, 0x00000018, 0x00000000, 0x00050051, 0x00000006, 0x00000024, 0x00000018,
0x00000001, 0x00050051, 0x00000006, 0x00000025, 0x00000018, 0x00000002, 0x00050051, 0x00000006,
0x00000026, 0x0000001c, 0x00000000, 0x00050051, 0x00000006, 0x00000027, 0x0000001c, 0x00000001,
0x00050051, 0x00000006, 0x00000028, 0x0000001c, 0x00000002, 0x00060050, 0x00000007, 0x00000029,
0x00000020, 0x00000021, 0x00000022, 0x00060050, 0x00000007, 0x0000002a, 0x00000023, 0x00000024,
0x00000025, 0x00060050, 0x00000007, 0x0000002b, 0x00000026, 0x00000027, 0x00000028, 0x00060050,
0x00000008, 0x0000002c, 0x00000029, 0x0000002a, 0x0000002b, 0x0004003d, 0x00000007, 0x00000031,
0x00000030, 0x0006000c, 0x00000007, 0x00000032, 0x00000001, 0x00000045, 0x00000031, 0x0004003d,
0x00000007, 0x00000035, 0x00000034, 0x000400cf, 0x00000007, 0x00000036, 0x00000035, 0x000400d0,
0x00000007, 0x00000039, 0x00000035, 0x0004003d, 0x0000003a, 0x0000003f, 0x0000003e, 0x000400cf,
0x0000003a, 0x00000040, 0x0000003f, 0x000400d0, 0x0000003a, 0x00000043, 0x0000003f, 0x00050051,
0x00000006, 0x0000004a, 0x00000043, 0x00000001, 0x0005008e, 0x00000007, 0x0000004b, 0x00000036,
0x0000004a, 0x00050051, 0x00000006, 0x0000004e, 0x00000040, 0x00000001, 0x0005008e, 0x00000007,
0x0000004f, 0x00000039, 0x0000004e, 0x00050083, 0x00000007, 0x00000050, 0x0000004b, 0x0000004f,
0x0006000c, 0x00000007, 0x00000051, 0x00000001, 0x00000045, 0x00000050, 0x0004007f, 0x00000007,
0x00000052, 0x00000051, 0x00050051, 0x00000006, 0x00000057, 0x00000040, 0x00000000, 0x0005008e,
0x00000007, 0x00000058, 0x00000039, 0x00000057, 0x00050051, 0x00000006, 0x0000005b, 0x00000043,
0x00000000, 0x0005008e, 0x00000007, 0x0000005c, 0x00000036, 0x0000005b, 0x00050083, 0x00000007,
0x0000005d, 0x00000058, 0x0000005c, 0x0006000c, 0x00000007, 0x0000005e, 0x00000001, 0x00000045,
0x0000005d, 0x0004007f, 0x00000007, 0x0000005f, 0x0000005e, 0x0004003d, 0x00000062, 0x00000065,
0x00000064, 0x00050057, 0x0000000b, 0x00000067, 0x00000065, 0x0000003f, 0x0008004f, 0x00000007,
0x00000068, 0x00000067, 0x00000067, 0x00000000, 0x00000001, 0x00000002, 0x0005008e, 0x00000007,
0x0000006a, 0x00000068, 0x00000069, 0x00050083, 0x00000007, 0x0000006c, 0x0000006a, 0x000000a8,
0x00060050, 0x00000008, 0x0000007e, 0x00000052, 0x0000005f, 0x00000032, 0x00050091, 0x00000007,
0x00000080, 0x0000007e, 0x0000006c, 0x0006000c, 0x00000007, 0x00000081, 0x00000001, 0x00000045,
0x00000080, 0x00050091, 0x00000007, 0x00000082, 0x0000002c, 0x00000081, 0x0006000c, 0x00000007,
0x00000083, 0x00000001, 0x00000045, 0x00000082, 0x00060041, 0x00000086, 0x00000087, 0x0000000f,
0x00000011, 0x00000085, 0x0004003d, 0x00000006, 0x00000088, 0x00000087, 0x00060041, 0x00000086,
0x00000089, 0x0000000f, 0x00000016, 0x00000085, 0x0004003d, 0x00000006, 0x0000008a, 0x00000089,
0x00060041, 0x00000086, 0x0000008b, 0x0000000f, 0x0000001a, 0x00000085, 0x0004003d, 0x00000006,
0x0000008c, 0x0000008b, 0x00060050, 0x00000007, 0x0000008d, 0x00000088, 0x0000008a, 0x0000008c,
0x00060041, 0x00000086, 0x00000090, 0x0000000f, 0x0000008f, 0x00000085, 0x0004003d, 0x00000006,
0x00000091, 0x00000090, 0x00050083, 0x00000006, 0x00000094, 0x0000001e, 0x00000091, 0x00050094,
0x00000006, 0x00000097, 0x00000083, 0x0000008d, 0x0007000c, 0x00000006, 0x00000098, 0x00000001,
0x00000028, 0x00000097, 0x0000001f, 0x0008000c, 0x00000006, 0x0000009a, 0x00000001, 0x00000032,
0x00000094, 0x00000098, 0x00000091, 0x00050041, 0x00000012, 0x0000009d, 0x0000000f, 0x0000008f,
0x0004003d, 0x0000000b, 0x0000009e, 0x0000009d, 0x0008004f, 0x00000007, 0x0000009f, 0x0000009e,
0x0000009e, 0x00000000, 0x00000001, 0x00000002, 0x0005008e, 0x00000007, 0x000000a1, 0x0000009f,
0x0000009a, 0x0004003d, 0x00000062, 0x000000a3, 0x000000a2, 0x00050057, 0x0000000b, 0x000000a5,
0x000000a3, 0x0000003f, 0x0008004f, 0x00000007, 0x000000a6, 0x000000a5, 0x000000a5, 0x00000000,
0x00000001, 0x00000002, 0x00050085, 0x00000007, 0x000000a7, 0x000000a1, 0x000000a6, 0x0007000c,
0x00000007, 0x000000a9, 0x00000001, 0x00000025, 0x000000a7, 0x000000a8, 0x00050051, 0x00000006,
0x000000aa, 0x000000a9, 0x00000000, 0x00050051, 0x00000006, 0x000000ab, 0x000000a9, 0x00000001,
0x00050051, 0x00000006, 0x000000ac, 0x000000a9, 0x00000002, 0x00070050, 0x0000000b, 0x000000ad,
0x000000aa, 0x000000ab, 0x000000ac, 0x0000001e, 0x0003003e, 0x0000009c, 0x000000ad, 0x000100fd,
0x00010038,
0x000a000f, 0x00000004, 0x00000004, 0x6e69616d, 0x00000000, 0x00000026, 0x00000062, 0x00000066,
0x00000070, 0x000000c9, 0x00030010, 0x00000004, 0x00000007, 0x00050048, 0x0000000e, 0x00000000,
0x00000023, 0x00000000, 0x00050048, 0x0000000e, 0x00000001, 0x00000023, 0x00000010, 0x00030047,
0x0000000e, 0x00000002, 0x00040047, 0x00000010, 0x00000022, 0x00000000, 0x00040047, 0x00000010,
0x00000021, 0x00000002, 0x00040047, 0x00000026, 0x0000000b, 0x0000000f, 0x00040048, 0x00000044,
0x00000000, 0x00000005, 0x00050048, 0x00000044, 0x00000000, 0x00000023, 0x00000000, 0x00050048,
0x00000044, 0x00000000, 0x00000007, 0x00000010, 0x00050048, 0x00000044, 0x00000001, 0x00000023,
0x00000040, 0x00050048, 0x00000044, 0x00000002, 0x00000023, 0x00000050, 0x00050048, 0x00000044,
0x00000003, 0x00000023, 0x00000060, 0x00050048, 0x00000044, 0x00000004, 0x00000023, 0x00000070,
0x00030047, 0x00000044, 0x00000002, 0x00040047, 0x00000062, 0x0000001e, 0x00000001, 0x00040047,
0x00000066, 0x0000001e, 0x00000000, 0x00040047, 0x00000070, 0x0000001e, 0x00000002, 0x00040047,
0x00000093, 0x00000022, 0x00000000, 0x00040047, 0x00000093, 0x00000021, 0x00000001, 0x00040047,
0x000000c9, 0x0000001e, 0x00000000, 0x00040047, 0x000000d0, 0x00000022, 0x00000000, 0x00040047,
0x000000d0, 0x00000021, 0x00000000, 0x00020013, 0x00000002, 0x00030021, 0x00000003, 0x00000002,
0x00030016, 0x00000006, 0x00000020, 0x00040017, 0x00000007, 0x00000006, 0x00000003, 0x00040017,
0x0000000d, 0x00000006, 0x00000004, 0x0004001e, 0x0000000e, 0x0000000d, 0x0000000d, 0x00040020,
0x0000000f, 0x00000002, 0x0000000e, 0x0004003b, 0x0000000f, 0x00000010, 0x00000002, 0x00040015,
0x00000011, 0x00000020, 0x00000001, 0x0004002b, 0x00000011, 0x00000012, 0x00000001, 0x00040015,
0x00000013, 0x00000020, 0x00000000, 0x0004002b, 0x00000013, 0x00000014, 0x00000000, 0x00040020,
0x00000015, 0x00000002, 0x00000006, 0x0004002b, 0x00000011, 0x00000018, 0x00000000, 0x0004002b,
0x00000013, 0x00000019, 0x00000003, 0x00020014, 0x0000001c, 0x0004002b, 0x00000006, 0x00000024,
0x3f800000, 0x00040020, 0x00000025, 0x00000001, 0x0000000d, 0x0004003b, 0x00000025, 0x00000026,
0x00000001, 0x00040020, 0x00000027, 0x00000001, 0x00000006, 0x0004002b, 0x00000006, 0x00000034,
0x00000000, 0x00040020, 0x00000037, 0x00000002, 0x0000000d, 0x00040018, 0x00000040, 0x00000007,
0x00000003, 0x00040018, 0x00000043, 0x0000000d, 0x00000004, 0x0007001e, 0x00000044, 0x00000043,
0x0000000d, 0x0000000d, 0x0000000d, 0x0000000d, 0x00040020, 0x00000045, 0x00000009, 0x00000044,
0x0004003b, 0x00000045, 0x00000046, 0x00000009, 0x00040020, 0x00000047, 0x00000009, 0x0000000d,
0x0004002b, 0x00000011, 0x0000004b, 0x00000002, 0x0004002b, 0x00000011, 0x0000004f, 0x00000003,
0x00040020, 0x00000061, 0x00000001, 0x00000007, 0x0004003b, 0x00000061, 0x00000062, 0x00000001,
0x0004003b, 0x00000061, 0x00000066, 0x00000001, 0x00040017, 0x0000006c, 0x00000006, 0x00000002,
0x00040020, 0x0000006f, 0x00000001, 0x0000006c, 0x0004003b, 0x0000006f, 0x00000070, 0x00000001,
0x0004002b, 0x00000013, 0x00000078, 0x00000001, 0x00090019, 0x00000090, 0x00000006, 0x00000001,
0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x0003001b, 0x00000091, 0x00000090,
0x00040020, 0x00000092, 0x00000000, 0x00000091, 0x0004003b, 0x00000092, 0x00000093, 0x00000000,
0x0004002b, 0x00000006, 0x00000098, 0x40000000, 0x00040020, 0x000000b4, 0x00000009, 0x00000006,
0x00040020, 0x000000c8, 0x00000003, 0x0000000d, 0x0004003b, 0x000000c8, 0x000000c9, 0x00000003,
0x0004002b, 0x00000011, 0x000000ca, 0x00000004, 0x0004003b, 0x00000092, 0x000000d0, 0x00000000,
0x0006002c, 0x00000007, 0x000000d6, 0x00000024, 0x00000024, 0x00000024, 0x00050036, 0x00000002,
0x00000004, 0x00000000, 0x00000003, 0x000200f8, 0x00000005, 0x00050041, 0x00000047, 0x00000048,
0x00000046, 0x00000012, 0x0004003d, 0x0000000d, 0x00000049, 0x00000048, 0x00050041, 0x00000047,
0x0000004c, 0x00000046, 0x0000004b, 0x0004003d, 0x0000000d, 0x0000004d, 0x0000004c, 0x00050041,
0x00000047, 0x00000050, 0x00000046, 0x0000004f, 0x0004003d, 0x0000000d, 0x00000051, 0x00000050,
0x00050051, 0x00000006, 0x00000053, 0x00000049, 0x00000000, 0x00050051, 0x00000006, 0x00000054,
0x00000049, 0x00000001, 0x00050051, 0x00000006, 0x00000055, 0x00000049, 0x00000002, 0x00050051,
0x00000006, 0x00000056, 0x0000004d, 0x00000000, 0x00050051, 0x00000006, 0x00000057, 0x0000004d,
0x00000001, 0x00050051, 0x00000006, 0x00000058, 0x0000004d, 0x00000002, 0x00050051, 0x00000006,
0x00000059, 0x00000051, 0x00000000, 0x00050051, 0x00000006, 0x0000005a, 0x00000051, 0x00000001,
0x00050051, 0x00000006, 0x0000005b, 0x00000051, 0x00000002, 0x00060050, 0x00000007, 0x0000005c,
0x00000053, 0x00000054, 0x00000055, 0x00060050, 0x00000007, 0x0000005d, 0x00000056, 0x00000057,
0x00000058, 0x00060050, 0x00000007, 0x0000005e, 0x00000059, 0x0000005a, 0x0000005b, 0x00060050,
0x00000040, 0x0000005f, 0x0000005c, 0x0000005d, 0x0000005e, 0x0004003d, 0x00000007, 0x00000063,
0x00000062, 0x0006000c, 0x00000007, 0x00000064, 0x00000001, 0x00000045, 0x00000063, 0x0004003d,
0x00000007, 0x00000067, 0x00000066, 0x000400cf, 0x00000007, 0x00000068, 0x00000067, 0x000400d0,
0x00000007, 0x0000006b, 0x00000067, 0x0004003d, 0x0000006c, 0x00000071, 0x00000070, 0x000400cf,
0x0000006c, 0x00000072, 0x00000071, 0x000400d0, 0x0000006c, 0x00000075, 0x00000071, 0x00050051,
0x00000006, 0x0000007a, 0x00000075, 0x00000001, 0x0005008e, 0x00000007, 0x0000007b, 0x00000068,
0x0000007a, 0x00050051, 0x00000006, 0x0000007e, 0x00000072, 0x00000001, 0x0005008e, 0x00000007,
0x0000007f, 0x0000006b, 0x0000007e, 0x00050083, 0x00000007, 0x00000080, 0x0000007b, 0x0000007f,
0x0006000c, 0x00000007, 0x00000081, 0x00000001, 0x00000045, 0x00000080, 0x0004007f, 0x00000007,
0x00000082, 0x00000081, 0x00050051, 0x00000006, 0x00000086, 0x00000072, 0x00000000, 0x0005008e,
0x00000007, 0x00000087, 0x0000006b, 0x00000086, 0x00050051, 0x00000006, 0x0000008a, 0x00000075,
0x00000000, 0x0005008e, 0x00000007, 0x0000008b, 0x00000068, 0x0000008a, 0x00050083, 0x00000007,
0x0000008c, 0x00000087, 0x0000008b, 0x0006000c, 0x00000007, 0x0000008d, 0x00000001, 0x00000045,
0x0000008c, 0x0004007f, 0x00000007, 0x0000008e, 0x0000008d, 0x0004003d, 0x00000091, 0x00000094,
0x00000093, 0x00050057, 0x0000000d, 0x00000096, 0x00000094, 0x00000071, 0x0008004f, 0x00000007,
0x00000097, 0x00000096, 0x00000096, 0x00000000, 0x00000001, 0x00000002, 0x0005008e, 0x00000007,
0x00000099, 0x00000097, 0x00000098, 0x00050083, 0x00000007, 0x0000009b, 0x00000099, 0x000000d6,
0x00060050, 0x00000040, 0x000000ad, 0x00000082, 0x0000008e, 0x00000064, 0x00050091, 0x00000007,
0x000000af, 0x000000ad, 0x0000009b, 0x0006000c, 0x00000007, 0x000000b0, 0x00000001, 0x00000045,
0x000000af, 0x00050091, 0x00000007, 0x000000b1, 0x0000005f, 0x000000b0, 0x0006000c, 0x00000007,
0x000000b2, 0x00000001, 0x00000045, 0x000000b1, 0x00060041, 0x000000b4, 0x000000b5, 0x00000046,
0x00000012, 0x00000019, 0x0004003d, 0x00000006, 0x000000b6, 0x000000b5, 0x00060041, 0x000000b4,
0x000000b7, 0x00000046, 0x0000004b, 0x00000019, 0x0004003d, 0x00000006, 0x000000b8, 0x000000b7,
0x00060041, 0x000000b4, 0x000000b9, 0x00000046, 0x0000004f, 0x00000019, 0x0004003d, 0x00000006,
0x000000ba, 0x000000b9, 0x00060050, 0x00000007, 0x000000bb, 0x000000b6, 0x000000b8, 0x000000ba,
0x00060041, 0x00000015, 0x000000bd, 0x00000010, 0x00000012, 0x00000078, 0x0004003d, 0x00000006,
0x000000be, 0x000000bd, 0x00050083, 0x00000006, 0x000000c1, 0x00000024, 0x000000be, 0x00050094,
0x00000006, 0x000000c4, 0x000000b2, 0x000000bb, 0x0007000c, 0x00000006, 0x000000c5, 0x00000001,
0x00000028, 0x000000c4, 0x00000034, 0x0008000c, 0x00000006, 0x000000c7, 0x00000001, 0x00000032,
0x000000c1, 0x000000c5, 0x000000be, 0x00050041, 0x00000047, 0x000000cb, 0x00000046, 0x000000ca,
0x0004003d, 0x0000000d, 0x000000cc, 0x000000cb, 0x0008004f, 0x00000007, 0x000000cd, 0x000000cc,
0x000000cc, 0x00000000, 0x00000001, 0x00000002, 0x0005008e, 0x00000007, 0x000000cf, 0x000000cd,
0x000000c7, 0x0004003d, 0x00000091, 0x000000d1, 0x000000d0, 0x00050057, 0x0000000d, 0x000000d3,
0x000000d1, 0x00000071, 0x0008004f, 0x00000007, 0x000000d4, 0x000000d3, 0x000000d3, 0x00000000,
0x00000001, 0x00000002, 0x00050085, 0x00000007, 0x000000d5, 0x000000cf, 0x000000d4, 0x0007000c,
0x00000007, 0x000000d7, 0x00000001, 0x00000025, 0x000000d5, 0x000000d6, 0x000300f7, 0x0000010a,
0x00000000, 0x000300fb, 0x00000014, 0x000000ed, 0x000200f8, 0x000000ed, 0x00060041, 0x00000015,
0x000000ee, 0x00000010, 0x00000012, 0x00000014, 0x0004003d, 0x00000006, 0x000000ef, 0x000000ee,
0x00060041, 0x00000015, 0x000000f0, 0x00000010, 0x00000018, 0x00000019, 0x0004003d, 0x00000006,
0x000000f1, 0x000000f0, 0x000500bc, 0x0000001c, 0x000000f2, 0x000000ef, 0x000000f1, 0x000300f7,
0x000000f5, 0x00000000, 0x000400fa, 0x000000f2, 0x000000f3, 0x000000f5, 0x000200f8, 0x000000f3,
0x000200f9, 0x0000010a, 0x000200f8, 0x000000f5, 0x00050041, 0x00000027, 0x000000f6, 0x00000026,
0x00000019, 0x0004003d, 0x00000006, 0x000000f7, 0x000000f6, 0x00050088, 0x00000006, 0x000000f8,
0x00000024, 0x000000f7, 0x00050083, 0x00000006, 0x000000fb, 0x000000f8, 0x000000f1, 0x00050083,
0x00000006, 0x00000100, 0x000000ef, 0x000000f1, 0x00050088, 0x00000006, 0x00000101, 0x000000fb,
0x00000100, 0x0008000c, 0x00000006, 0x00000102, 0x00000001, 0x0000002b, 0x00000101, 0x00000034,
0x00000024, 0x00050041, 0x00000037, 0x00000104, 0x00000010, 0x00000018, 0x0004003d, 0x0000000d,
0x00000105, 0x00000104, 0x0008004f, 0x00000007, 0x00000106, 0x00000105, 0x00000105, 0x00000000,
0x00000001, 0x00000002, 0x00060050, 0x00000007, 0x00000108, 0x00000102, 0x00000102, 0x00000102,
0x0008000c, 0x00000007, 0x00000109, 0x00000001, 0x0000002e, 0x000000d7, 0x00000106, 0x00000108,
0x000200f9, 0x0000010a, 0x000200f8, 0x0000010a, 0x000700f5, 0x00000007, 0x00000110, 0x000000d7,
0x000000f3, 0x00000109, 0x000000f5, 0x00060041, 0x000000b4, 0x000000da, 0x00000046, 0x000000ca,
0x00000019, 0x0004003d, 0x00000006, 0x000000db, 0x000000da, 0x00050051, 0x00000006, 0x000000dc,
0x00000110, 0x00000000, 0x00050051, 0x00000006, 0x000000dd, 0x00000110, 0x00000001, 0x00050051,
0x00000006, 0x000000de, 0x00000110, 0x00000002, 0x00070050, 0x0000000d, 0x000000df, 0x000000dc,
0x000000dd, 0x000000de, 0x000000db, 0x0003003e, 0x000000c9, 0x000000df, 0x000100fd, 0x00010038,
};
static const uint32_t s_vert_shd_spv[458] = {