Archived
1
Fork 0

Fix texture asset thumbnails

This commit is contained in:
redstrate 2020-08-17 08:05:30 -04:00
parent 6ce34dc2cf
commit 7835c93510
2 changed files with 29 additions and 9 deletions

View file

@ -43,6 +43,12 @@ float calculate_sobel() {
} }
void main() { void main() {
// passthrough
if(options.w == 1) {
outColor = texture(colorSampler, inUV);
return;
}
vec3 sceneColor = vec3(0); vec3 sceneColor = vec3(0);
if(options.x == 1) // enable AA if(options.x == 1) // enable AA
sceneColor = SMAANeighborhoodBlendingPS(inUV, inOffset, colorSampler, blendSampler).rgb; sceneColor = SMAANeighborhoodBlendingPS(inUV, inOffset, colorSampler, blendSampler).rgb;

View file

@ -765,6 +765,18 @@ void CommonEditor::drawAssets() {
if(ImGui::ImageButton(get_asset_thumbnail(file::app_domain / p), ImVec2(64, 64))) if(ImGui::ImageButton(get_asset_thumbnail(file::app_domain / p), ImVec2(64, 64)))
asset_selected(p, type); 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++; column++;
if(column == max_columns) { if(column == max_columns) {
@ -779,7 +791,7 @@ GFXTexture* CommonEditor::get_material_preview(Material& material) {
Scene scene; Scene scene;
auto sphere = scene.add_object(); auto sphere = scene.add_object();
scene.add<Renderable>(sphere).mesh = assetm->get<Mesh>(file::app_domain / "models/sphere.model"); scene.add<Renderable>(sphere).mesh = assetm->get<Mesh>(file::app_domain / "models" / "sphere.model");
scene.get<Renderable>(sphere).materials.push_back(assetm->get<Material>(file::app_domain / material.path)); // we throw away our material handle here :-( scene.get<Renderable>(sphere).materials.push_back(assetm->get<Material>(file::app_domain / material.path)); // we throw away our material handle here :-(
return generate_common_preview(scene); return generate_common_preview(scene);
@ -790,7 +802,7 @@ GFXTexture* CommonEditor::get_mesh_preview(Mesh& mesh) {
auto mesh_obj = scene.add_object(); auto mesh_obj = scene.add_object();
scene.add<Renderable>(mesh_obj).mesh = assetm->get<Mesh>(file::app_domain / mesh.path); scene.add<Renderable>(mesh_obj).mesh = assetm->get<Mesh>(file::app_domain / mesh.path);
scene.get<Renderable>(mesh_obj).materials.push_back(assetm->get<Material>(file::app_domain / "materials/Material.material")); scene.get<Renderable>(mesh_obj).materials.push_back(assetm->get<Material>(file::app_domain / "materials" / "Material.material"));
return generate_common_preview(scene); return generate_common_preview(scene);
} }
@ -823,6 +835,12 @@ GFXTexture* CommonEditor::get_texture_preview(Texture& texture) {
command_buffer->set_render_pass(begin_info); 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->set_pipeline(renderer->renderToUnormTexturePipeline);
command_buffer->bind_texture(texture.handle, 1); command_buffer->bind_texture(texture.handle, 1);
@ -832,13 +850,9 @@ GFXTexture* CommonEditor::get_texture_preview(Texture& texture) {
struct PostPushConstants { struct PostPushConstants {
Vector4 viewport; Vector4 viewport;
float fade; Vector4 options;
unsigned int performGammaCorrection;
unsigned int performAA;
} pc; } pc;
pc.fade = 0.0; pc.options.w = 1.0;
pc.performGammaCorrection = false;
pc.performAA = false;
pc.viewport = Vector4(1.0 / (float)thumbnail_resolution, 1.0 / (float)thumbnail_resolution, thumbnail_resolution, thumbnail_resolution); 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)); command_buffer->set_push_constant(&pc, sizeof(PostPushConstants));