update source

This commit is contained in:
2026-03-31 18:20:34 -03:00
parent 33e582920a
commit 25d53c4322
7 changed files with 31 additions and 11 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -22,8 +22,8 @@ float4 frag_main(post_transform_vertex input) : SV_Target {
uv.y = 1.0f - uv.y;
let normal = normals.Sample(uv).xyz;
let albedo = albedos.Sample(uv).xyz;
let lighting = saturate(dot(float3(0.0f, 1.0f, 0.0f), normal)) * 0.00001f;
//return float4(input.uv + (normal * albedo * 0.00001f).xy, 1.0f, 1.0f);
return float4(lighting * albedo + (normal), 1.0f);
// return float4(1.0f);
let lighting = saturate(dot(albedo, normal)) * 0.01f;
// return float4(input.uv + (normal * albedo * 0.00001f).xy, 1.0f, 1.0f);
return float4(lighting + albedo, 1.0f);
//return float4(lighting + float3(1.0f), 1.0f);
}

View File

@@ -12,6 +12,7 @@ struct input_vertex
struct post_transform_vertex {
float4 position : SV_Position;
float3 normal : NORMAL;
float2 uv : TEXCOORD;
};
[shader("vertex")]
@@ -19,8 +20,8 @@ post_transform_vertex vert_main(input_vertex vertex) {
post_transform_vertex output;
output.position = mul(camera.projection, mul(camera.view, float4(vertex.pos, 1.0f)));
output.normal = vertex.normal;
output.uv = vertex.texcoord;
return output;
}
@@ -35,7 +36,7 @@ fragment_output frag_main(post_transform_vertex input) : SV_Target {
fragment_output output;
output.normal = float4(normalize(input.normal), 1.0f);
output.albedo = float4(1.0f);
output.albedo = float4(input.uv, 1.0f, 1.0f);
return output;
}

View File

@@ -116,7 +116,7 @@ void engine::run() {
try {
const auto [map_min, map_max] = ::bounds_of(level_border);
const auto [view, projection] = ::calculate_camera_matrices(
map_min, map_max, 1920.0f / 1080.0f, 2.8f);
map_min, map_max, 1920.0f / 1080.0f, 1.1f);
renderer.render(level_border_render_ids, view, projection);
} catch (const vuk::VkException &ex) {
if (ex.what() != std::string("Out of date.")) {

View File

@@ -20,6 +20,9 @@ namespace {
auto *normal_it = it->findAttribute("NORMAL");
assert(normal_it != it->attributes.end());
auto *texcoord_it = it->findAttribute("TEXCOORD_0");
assert(texcoord_it != it->attributes.end());
const auto index = std::distance(mesh.primitives.begin(), it);
auto &primitive = meshes.emplace_back();
@@ -67,11 +70,27 @@ namespace {
});
}
for (const auto [position, normal] : std::views::zip(positions, normals)) {
auto texcoords = std::vector<glm::vec2>();
{
auto &texcoord_accessor = asset.accessors[texcoord_it->accessorIndex];
if (!texcoord_accessor.bufferViewIndex.has_value()) {
throw std::runtime_error(
"no index buffer was specified for mesh primitive");
}
fastgltf::iterateAccessorWithIndex<fastgltf::math::fvec2>(
asset, texcoord_accessor,
[&](fastgltf::math::fvec2 uv, std::size_t idx) {
texcoords.emplace_back(uv.x(), uv.y());
});
}
for (const auto [position, normal, texcoord] :
std::views::zip(positions, normals, texcoords)) {
primitive.vertices.push_back({
.position = position,
.normal = normal,
.uv = glm::vec2(),
.uv = texcoord,
});
}
}

View File

@@ -32,8 +32,8 @@
[[nodiscard]] auto composite() {
return vuk::make_pass("composite", [](vuk::CommandBuffer &command_buffer,
VUK_IA(vuk::eFragmentRead) normals,
VUK_IA(vuk::eFragmentRead) albedos,
VUK_IA(vuk::eFragmentSampled) normals,
VUK_IA(vuk::eFragmentSampled) albedos,
VUK_IA(vuk::eColorWrite) target) {
command_buffer.bind_graphics_pipeline("composite")
.set_dynamic_state(vuk::DynamicStateFlagBits::eScissor |