From 7835c935100b4fba0f0fe1e1036bf7264a9cc646 Mon Sep 17 00:00:00 2001 From: redstrate <54911369+redstrate@users.noreply.github.com> Date: Mon, 17 Aug 2020 08:05:30 -0400 Subject: [PATCH] Fix texture asset thumbnails --- shaders/post.frag.glsl | 6 ++++++ tools/common/src/commoneditor.cpp | 32 ++++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/shaders/post.frag.glsl b/shaders/post.frag.glsl index 0da62c6..92bddc1 100755 --- a/shaders/post.frag.glsl +++ b/shaders/post.frag.glsl @@ -43,6 +43,12 @@ float calculate_sobel() { } void main() { + // passthrough + if(options.w == 1) { + outColor = texture(colorSampler, inUV); + return; + } + vec3 sceneColor = vec3(0); if(options.x == 1) // enable AA sceneColor = SMAANeighborhoodBlendingPS(inUV, inOffset, colorSampler, blendSampler).rgb; diff --git a/tools/common/src/commoneditor.cpp b/tools/common/src/commoneditor.cpp index 5b71246..3d2ac69 100755 --- a/tools/common/src/commoneditor.cpp +++ b/tools/common/src/commoneditor.cpp @@ -765,6 +765,18 @@ void CommonEditor::drawAssets() { if(ImGui::ImageButton(get_asset_thumbnail(file::app_domain / p), ImVec2(64, 64))) asset_selected(p, type); + if(ImGui::BeginPopupContextItem()) { + ImGui::TextDisabled("%s", p.string().c_str()); + + ImGui::Separator(); + + if(ImGui::Button("Regenerate thumbnail")) { + asset_thumbnails.erase(asset_thumbnails.find(file::app_domain / p)); + } + + ImGui::EndPopup(); + } + column++; if(column == max_columns) { @@ -779,7 +791,7 @@ GFXTexture* CommonEditor::get_material_preview(Material& material) { Scene scene; auto sphere = scene.add_object(); - scene.add(sphere).mesh = assetm->get(file::app_domain / "models/sphere.model"); + scene.add(sphere).mesh = assetm->get(file::app_domain / "models" / "sphere.model"); scene.get(sphere).materials.push_back(assetm->get(file::app_domain / material.path)); // we throw away our material handle here :-( return generate_common_preview(scene); @@ -790,14 +802,14 @@ GFXTexture* CommonEditor::get_mesh_preview(Mesh& mesh) { auto mesh_obj = scene.add_object(); scene.add(mesh_obj).mesh = assetm->get(file::app_domain / mesh.path); - scene.get(mesh_obj).materials.push_back(assetm->get(file::app_domain / "materials/Material.material")); + scene.get(mesh_obj).materials.push_back(assetm->get(file::app_domain / "materials" / "Material.material")); return generate_common_preview(scene); } GFXTexture* CommonEditor::get_texture_preview(Texture& texture) { auto gfx = engine->get_gfx(); - + GFXTextureCreateInfo texture_create_info = {}; texture_create_info.width = thumbnail_resolution; texture_create_info.height = thumbnail_resolution; @@ -823,6 +835,12 @@ GFXTexture* CommonEditor::get_texture_preview(Texture& texture) { command_buffer->set_render_pass(begin_info); + Viewport viewport = {}; + viewport.width = thumbnail_resolution; + viewport.height = thumbnail_resolution; + + command_buffer->set_viewport(viewport); + command_buffer->set_pipeline(renderer->renderToUnormTexturePipeline); command_buffer->bind_texture(texture.handle, 1); @@ -832,13 +850,9 @@ GFXTexture* CommonEditor::get_texture_preview(Texture& texture) { struct PostPushConstants { Vector4 viewport; - float fade; - unsigned int performGammaCorrection; - unsigned int performAA; + Vector4 options; } pc; - pc.fade = 0.0; - pc.performGammaCorrection = false; - pc.performAA = false; + pc.options.w = 1.0; pc.viewport = Vector4(1.0 / (float)thumbnail_resolution, 1.0 / (float)thumbnail_resolution, thumbnail_resolution, thumbnail_resolution); command_buffer->set_push_constant(&pc, sizeof(PostPushConstants));