Misc renderer improvements:
- Reuse renderer and gltf loader between scenes - Use puish descriptors to simplify the management of descriptor sets in the scene renderer - Don't keep the imgui swapchain in the scene classes - Fix alpha blending, add alpha masking - Fix mipmaps not being used in renderer - Add cache when loading images and models - Only premultiply the colours if required - Add support for gltTF animations Allow removing an object and its descendants from the scene, allow loading from a memory buffer
This commit is contained in:
+20
-11
@@ -30,7 +30,7 @@ const float fog_min_dist = 20.0;
|
||||
const float fog_max_dist = 35.0;
|
||||
const vec4 fog_color = vec4(0.0, 0.25, 0.5, 1.0);
|
||||
|
||||
layout(set = 0, binding = 0) uniform scene_ssbo
|
||||
layout(set = 0, binding = 0) uniform scene_ubo
|
||||
{
|
||||
mat4 view;
|
||||
mat4 proj;
|
||||
@@ -39,7 +39,7 @@ layout(set = 0, binding = 0) uniform scene_ssbo
|
||||
vec4 light_color;
|
||||
} scene;
|
||||
|
||||
layout(set = 0, binding = 1) uniform mesh_ssbo
|
||||
layout(set = 0, binding = 1) uniform mesh_ubo
|
||||
{
|
||||
mat4 model;
|
||||
mat4 modelview;
|
||||
@@ -47,18 +47,18 @@ layout(set = 0, binding = 1) uniform mesh_ssbo
|
||||
vec4 clipping_plane[nb_clipping];
|
||||
} mesh;
|
||||
|
||||
layout(set = 0, binding = 2) uniform joints_ssbo
|
||||
layout(set = 0, binding = 2) uniform joints_ubo
|
||||
{
|
||||
mat4 joint_matrices[32];
|
||||
} joints;
|
||||
|
||||
#ifdef FRAG_SHADER
|
||||
layout(set = 1, binding = 0) uniform sampler2D base_color;
|
||||
layout(set = 1, binding = 1) uniform sampler2D metallic_roughness;
|
||||
layout(set = 1, binding = 2) uniform sampler2D occlusion;
|
||||
layout(set = 1, binding = 3) uniform sampler2D emissive;
|
||||
layout(set = 1, binding = 4) uniform sampler2D normal_map;
|
||||
layout(set = 1, binding = 5) uniform material_ubo
|
||||
layout(set = 0, binding = 3) uniform sampler2D base_color;
|
||||
layout(set = 0, binding = 4) uniform sampler2D metallic_roughness;
|
||||
layout(set = 0, binding = 5) uniform sampler2D occlusion;
|
||||
layout(set = 0, binding = 6) uniform sampler2D emissive;
|
||||
layout(set = 0, binding = 7) uniform sampler2D normal_map;
|
||||
layout(set = 0, binding = 8) uniform material_ubo
|
||||
{
|
||||
vec4 base_color_factor;
|
||||
vec4 base_emissive_factor;
|
||||
@@ -66,6 +66,7 @@ layout(set = 1, binding = 5) uniform material_ubo
|
||||
float roughness_factor;
|
||||
float occlusion_strength;
|
||||
float normal_scale;
|
||||
float alpha_cutoff;
|
||||
|
||||
int base_color_texcoord;
|
||||
int metallic_roughness_texcoord;
|
||||
@@ -79,7 +80,7 @@ layout(set = 1, binding = 5) uniform material_ubo
|
||||
#ifdef VERT_SHADER
|
||||
layout(location = 0) in vec3 in_position;
|
||||
layout(location = 1) in vec3 in_normal;
|
||||
layout(location = 2) in vec3 in_tangent;
|
||||
layout(location = 2) in vec4 in_tangent;
|
||||
layout(location = 3) in vec2 in_texcoord[2];
|
||||
layout(location = 5) in vec4 in_color;
|
||||
layout(location = 6) in vec4 in_joints;
|
||||
@@ -212,9 +213,17 @@ void main()
|
||||
ivec2 tmp = ivec2(gl_FragCoord.xy) % 4;
|
||||
float dither_thd = 1.0f - dither_pattern[tmp.x][tmp.y];
|
||||
|
||||
out_color = bc + one_over_d_linear_to_srgb(bc) * vec4(dither_thd, dither_thd, dither_thd, dither_thd) / 255.0f;
|
||||
out_color = bc + one_over_d_linear_to_srgb(bc) * vec4(dither_thd, dither_thd, dither_thd, 0) / 255.0f;
|
||||
}
|
||||
else
|
||||
out_color = bc;
|
||||
|
||||
if (alpha_cutout)
|
||||
{
|
||||
if (out_color.a <= material.alpha_cutoff)
|
||||
out_color.a = 0.0;
|
||||
else
|
||||
out_color.a = 1.0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user