diff --git a/Editor/Editor.cpp b/Editor/Editor.cpp index 456837318..4b4cbc4cf 100644 --- a/Editor/Editor.cpp +++ b/Editor/Editor.cpp @@ -5253,6 +5253,7 @@ Texture EditorComponent::CreateThumbnail(Texture texture, uint32_t target_width, // Crop target: { TextureDesc desc = thumbnail.desc; + desc.format = Format::R8G8B8A8_UNORM; desc.width = current_width; desc.height = current_height; desc.mip_levels = mipmaps? 0 : 1; @@ -5308,6 +5309,7 @@ Texture EditorComponent::CreateThumbnail(Texture texture, uint32_t target_width, while (thumbnail.desc.width > target_width || thumbnail.desc.height > target_height) { TextureDesc desc = thumbnail.desc; + desc.format = Format::R8G8B8A8_UNORM; desc.width = std::max(target_width, desc.width / 4u); desc.height = std::max(target_height, desc.height / 4u); desc.mip_levels = mipmaps ? 0 : 1; diff --git a/Editor/MaterialWindow.cpp b/Editor/MaterialWindow.cpp index 8de4661f6..9a6410853 100644 --- a/Editor/MaterialWindow.cpp +++ b/Editor/MaterialWindow.cpp @@ -317,14 +317,15 @@ void MaterialWindow::Create(EditorComponent* _editor) MaterialComponent* material = get_material(scene, x); if (material == nullptr) continue; - material->userBlendMode = (wi::enums::BLENDMODE)args.iValue; + material->userBlendMode = (wi::enums::BLENDMODE)args.userdata; } }); - blendModeComboBox.AddItem("Opaque"); - blendModeComboBox.AddItem("Alpha"); - blendModeComboBox.AddItem("Premultiplied"); - blendModeComboBox.AddItem("Additive"); - blendModeComboBox.AddItem("Multiply"); + blendModeComboBox.AddItem("Opaque", wi::enums::BLENDMODE_OPAQUE); + blendModeComboBox.AddItem("Alpha", wi::enums::BLENDMODE_ALPHA); + blendModeComboBox.AddItem("Premultiplied", wi::enums::BLENDMODE_PREMULTIPLIED); + blendModeComboBox.AddItem("Additive", wi::enums::BLENDMODE_ADDITIVE); + blendModeComboBox.AddItem("Multiply", wi::enums::BLENDMODE_MULTIPLY); + blendModeComboBox.AddItem("Inverse", wi::enums::BLENDMODE_INVERSE); blendModeComboBox.SetEnabled(false); blendModeComboBox.SetTooltip("Set the blend mode of the material."); AddWidget(&blendModeComboBox); diff --git a/Editor/ProjectCreatorWindow.cpp b/Editor/ProjectCreatorWindow.cpp index edb123fff..47ea7b7df 100644 --- a/Editor/ProjectCreatorWindow.cpp +++ b/Editor/ProjectCreatorWindow.cpp @@ -132,7 +132,7 @@ void ProjectCreatorWindow::Create(EditorComponent* _editor) cursorButton.font_description.params.v_align = wi::font::WIFALIGN_BOTTOM; cursorButton.font_description.params.h_align = wi::font::WIFALIGN_CENTER; cursorButton.SetSize(XMFLOAT2(64, 64)); - cursorButton.SetTooltip("The cursor can be used as a custom cursor for your app."); + cursorButton.SetTooltip("The cursor can be used as a custom cursor for your app. Here you can load an image to create it."); cursorButton.OnClick([this](wi::gui::EventArgs args) { if (cursorResource.IsValid()) { @@ -177,7 +177,7 @@ void ProjectCreatorWindow::Create(EditorComponent* _editor) AddWidget(&backgroundColorPicker); colorPreviewButton.Create("colorPreviewButton"); - colorPreviewButton.SetText("Preview:\nThese colors will be used by the application when showing the initialization screen. The text color will be also used for the backlog.\n\n[Click on this preview to reset colors]"); + colorPreviewButton.SetText("Preview: these colors will be used by the application when showing the initialization screen and backlog text. [Click here to reset colors]"); colorPreviewButton.SetSize(XMFLOAT2(256, 64)); colorPreviewButton.OnClick([this](wi::gui::EventArgs args) { backlogColorPicker.SetPickColor(exe_customization.backlog_color); @@ -446,9 +446,10 @@ void ProjectCreatorWindow::Render(const wi::Canvas& canvas, wi::graphics::Comman fx.pos.x = cursorButton.GetPos().x + cursorButton.GetSize().x * hotspotX; fx.pos.y = cursorButton.GetPos().y + cursorButton.GetSize().y * hotspotY; fx.pivot = XMFLOAT2(0.5f, 0.5f); - fx.color = wi::Color::Black(); + fx.color = wi::Color::White(); fx.siz.x = 2; fx.siz.y = 16; + fx.blendFlag = wi::enums::BLENDMODE_INVERSE; wi::image::Draw(nullptr, fx, cmd); fx.rotation = XM_PI * 0.5f; wi::image::Draw(nullptr, fx, cmd); diff --git a/Editor/ProjectCreatorWindow.h b/Editor/ProjectCreatorWindow.h index 3979de7c5..d515bc5df 100644 --- a/Editor/ProjectCreatorWindow.h +++ b/Editor/ProjectCreatorWindow.h @@ -29,8 +29,8 @@ public: wi::Resource splashScreenResourceCroppedPreview; wi::Resource cursorResource; - float hotspotX = 0.0f; - float hotspotY = 0.0f; + float hotspotX = 0.5f; + float hotspotY = 0.5f; void Render(const wi::Canvas& canvas, wi::graphics::CommandList cmd) const override; void ResizeLayout() override; diff --git a/Editor/SpriteWindow.cpp b/Editor/SpriteWindow.cpp index 3a560bf47..3c6fb51e3 100644 --- a/Editor/SpriteWindow.cpp +++ b/Editor/SpriteWindow.cpp @@ -325,6 +325,7 @@ void SpriteWindow::Create(EditorComponent* _editor) blendModeCombo.AddItem("Premultiplied", wi::enums::BLENDMODE_PREMULTIPLIED); blendModeCombo.AddItem("Additive", wi::enums::BLENDMODE_ADDITIVE); blendModeCombo.AddItem("Multiply", wi::enums::BLENDMODE_MULTIPLY); + blendModeCombo.AddItem("Inverse", wi::enums::BLENDMODE_INVERSE); blendModeCombo.OnSelect([=](wi::gui::EventArgs args) { wi::scene::Scene& scene = editor->GetCurrentScene(); for (auto& x : editor->translator.selected) diff --git a/Editor/main_Windows.cpp b/Editor/main_Windows.cpp index 5fae53fa4..be27316da 100644 --- a/Editor/main_Windows.cpp +++ b/Editor/main_Windows.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" -#include - #include #include // drag n drop diff --git a/WickedEngine/wiEmittedParticle.cpp b/WickedEngine/wiEmittedParticle.cpp index 42056a451..981a548d7 100644 --- a/WickedEngine/wiEmittedParticle.cpp +++ b/WickedEngine/wiEmittedParticle.cpp @@ -1083,6 +1083,18 @@ namespace wi bd.independent_blend_enable = false; blendStates[BLENDMODE_MULTIPLY] = bd; + bd.render_target[0].src_blend = Blend::INV_DEST_COLOR; + bd.render_target[0].dest_blend = Blend::ZERO; + bd.render_target[0].blend_op = BlendOp::ADD; + bd.render_target[0].src_blend_alpha = Blend::DEST_ALPHA; + bd.render_target[0].dest_blend_alpha = Blend::ZERO; + bd.render_target[0].blend_op_alpha = BlendOp::ADD; + bd.render_target[0].blend_enable = true; + bd.render_target[0].render_target_write_mask = ColorWrite::ENABLE_ALL; + bd.alpha_to_coverage_enable = false; + bd.independent_blend_enable = false; + blendStates[BLENDMODE_INVERSE] = bd; + bd.render_target[0].blend_enable = false; blendStates[BLENDMODE_OPAQUE] = bd; diff --git a/WickedEngine/wiEnums.h b/WickedEngine/wiEnums.h index 68385f4ba..c016d2b50 100644 --- a/WickedEngine/wiEnums.h +++ b/WickedEngine/wiEnums.h @@ -11,6 +11,7 @@ namespace wi::enums BLENDMODE_PREMULTIPLIED, BLENDMODE_ADDITIVE, BLENDMODE_MULTIPLY, + BLENDMODE_INVERSE, BLENDMODE_COUNT }; @@ -486,6 +487,7 @@ namespace wi::enums BSTYPE_PREMULTIPLIED, BSTYPE_COLORWRITEDISABLE, BSTYPE_MULTIPLY, + BSTYPE_INVERSE, BSTYPE_TRANSPARENTSHADOW, BSTYPE_COUNT }; diff --git a/WickedEngine/wiImage.cpp b/WickedEngine/wiImage.cpp index f60b1a9ef..665061855 100644 --- a/WickedEngine/wiImage.cpp +++ b/WickedEngine/wiImage.cpp @@ -577,8 +577,8 @@ namespace wi::image blendStates[BLENDMODE_ADDITIVE] = bd; bd.render_target[0].blend_enable = true; - bd.render_target[0].src_blend = Blend::ZERO; - bd.render_target[0].dest_blend = Blend::SRC_COLOR; + bd.render_target[0].src_blend = Blend::DEST_COLOR; + bd.render_target[0].dest_blend = Blend::ZERO; bd.render_target[0].blend_op = BlendOp::ADD; bd.render_target[0].src_blend_alpha = Blend::ZERO; bd.render_target[0].dest_blend_alpha = Blend::SRC_ALPHA; @@ -587,6 +587,17 @@ namespace wi::image bd.independent_blend_enable = false; blendStates[BLENDMODE_MULTIPLY] = bd; + bd.render_target[0].blend_enable = true; + bd.render_target[0].src_blend = Blend::INV_DEST_COLOR; + bd.render_target[0].dest_blend = Blend::ZERO; + bd.render_target[0].blend_op = BlendOp::ADD; + bd.render_target[0].src_blend_alpha = Blend::ZERO; + bd.render_target[0].dest_blend_alpha = Blend::SRC_ALPHA; + bd.render_target[0].blend_op_alpha = BlendOp::ADD; + bd.render_target[0].render_target_write_mask = ColorWrite::ENABLE_ALL; + bd.independent_blend_enable = false; + blendStates[BLENDMODE_INVERSE] = bd; + SamplerDesc samplerDesc; samplerDesc.filter = Filter::MIN_MAG_MIP_LINEAR; samplerDesc.address_u = TextureAddressMode::MIRROR; diff --git a/WickedEngine/wiRenderer.cpp b/WickedEngine/wiRenderer.cpp index bee9854b1..aac4be605 100644 --- a/WickedEngine/wiRenderer.cpp +++ b/WickedEngine/wiRenderer.cpp @@ -1908,6 +1908,9 @@ void LoadShaders() case BLENDMODE_MULTIPLY: desc.bs = &blendStates[BSTYPE_MULTIPLY]; break; + case BLENDMODE_INVERSE: + desc.bs = &blendStates[BSTYPE_INVERSE]; + break; default: assert(0); break; @@ -2481,6 +2484,18 @@ void SetUpStates() bd.independent_blend_enable = false; blendStates[BSTYPE_MULTIPLY] = bd; + bd.render_target[0].src_blend = Blend::INV_DEST_COLOR; + bd.render_target[0].dest_blend = Blend::ZERO; + bd.render_target[0].blend_op = BlendOp::ADD; + bd.render_target[0].src_blend_alpha = Blend::DEST_ALPHA; + bd.render_target[0].dest_blend_alpha = Blend::ZERO; + bd.render_target[0].blend_op_alpha = BlendOp::ADD; + bd.render_target[0].blend_enable = true; + bd.render_target[0].render_target_write_mask = ColorWrite::ENABLE_ALL; + bd.alpha_to_coverage_enable = false; + bd.independent_blend_enable = false; + blendStates[BSTYPE_INVERSE] = bd; + bd.render_target[0].src_blend = Blend::ZERO; bd.render_target[0].dest_blend = Blend::SRC_COLOR; bd.render_target[0].blend_op = BlendOp::ADD; diff --git a/WickedEngine/wiScene.cpp b/WickedEngine/wiScene.cpp index 869d27105..b2c0da34f 100644 --- a/WickedEngine/wiScene.cpp +++ b/WickedEngine/wiScene.cpp @@ -4416,13 +4416,14 @@ namespace wi::scene { struct { - uint32_t shadertype : MaterialComponent::SHADERTYPE_COUNT; - uint32_t blendmode : wi::enums::BLENDMODE_COUNT; + uint32_t shadertype : 6; // max 64 shader types + uint32_t blendmode : 3; // max 8 blendmodes uint32_t doublesided : 1; // bool uint32_t tessellation : 1; // bool uint32_t alphatest : 1; // bool uint32_t customshader : 8; uint32_t sort_priority : 4; + uint32_t unused : 8; } bits; uint32_t value; } sort_bits; diff --git a/WickedEngine/wiTrailRenderer.cpp b/WickedEngine/wiTrailRenderer.cpp index a67d3258a..8bd752a2a 100644 --- a/WickedEngine/wiTrailRenderer.cpp +++ b/WickedEngine/wiTrailRenderer.cpp @@ -419,6 +419,18 @@ namespace wi bd.independent_blend_enable = false; blendStates[BLENDMODE_MULTIPLY] = bd; + bd.render_target[0].src_blend = Blend::INV_DEST_COLOR; + bd.render_target[0].dest_blend = Blend::ZERO; + bd.render_target[0].blend_op = BlendOp::ADD; + bd.render_target[0].src_blend_alpha = Blend::DEST_ALPHA; + bd.render_target[0].dest_blend_alpha = Blend::ZERO; + bd.render_target[0].blend_op_alpha = BlendOp::ADD; + bd.render_target[0].blend_enable = true; + bd.render_target[0].render_target_write_mask = ColorWrite::ENABLE_ALL; + bd.alpha_to_coverage_enable = false; + bd.independent_blend_enable = false; + blendStates[BLENDMODE_INVERSE] = bd; + bd.render_target[0].blend_enable = false; blendStates[BLENDMODE_OPAQUE] = bd; diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 1277e13a3..8da5ea7eb 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wi::version // minor features, major updates, breaking compatibility changes const int minor = 71; // minor bug fixes, alterations, refactors, updates - const int revision = 792; + const int revision = 793; const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);