added inverse blend mode (#1124)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include <SDKDDKVer.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <shellapi.h> // drag n drop
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user