paint tool: redirect alpha
This commit is contained in:
@@ -176,6 +176,12 @@ void PaintToolWindow::Create(EditorComponent* _editor)
|
||||
pressureCheckBox.SetCheckText(ICON_PEN);
|
||||
AddWidget(&pressureCheckBox);
|
||||
|
||||
alphaCheckBox.Create("Redirect alpha: ");
|
||||
alphaCheckBox.SetTooltip("The red color will be redirected to write alpha channel. Alpha value controls the blending like normally.");
|
||||
alphaCheckBox.SetSize(XMFLOAT2(hei, hei));
|
||||
alphaCheckBox.SetPos(XMFLOAT2(x - 20 + 200, y));
|
||||
AddWidget(&alphaCheckBox);
|
||||
|
||||
axisCombo.Create("Axis Lock: ");
|
||||
axisCombo.SetTooltip("You can lock modification to an axis here.");
|
||||
axisCombo.SetPos(XMFLOAT2(x, y));
|
||||
@@ -567,7 +573,7 @@ void PaintToolWindow::Update(float dt)
|
||||
paintparams.push.xPaintBrushAmount = amount;
|
||||
paintparams.push.xPaintBrushSmoothness = smoothness;
|
||||
paintparams.push.xPaintBrushColor = color.rgba;
|
||||
paintparams.push.xPaintReveal = revealTex.IsValid() ? 1 : 0;
|
||||
paintparams.push.xPaintRedirectAlpha = alphaCheckBox.GetCheck();
|
||||
paintparams.push.xPaintBrushRotation = brush_rotation;
|
||||
paintparams.push.xPaintBrushShape = (uint)brushShapeComboBox.GetSelected();
|
||||
|
||||
@@ -1650,6 +1656,7 @@ void PaintToolWindow::ResizeLayout()
|
||||
add_right(backfaceCheckBox);
|
||||
wireCheckBox.SetPos(XMFLOAT2(backfaceCheckBox.GetPos().x - wireCheckBox.GetSize().x - 100, backfaceCheckBox.GetPos().y));
|
||||
add_right(pressureCheckBox);
|
||||
alphaCheckBox.SetPos(XMFLOAT2(pressureCheckBox.GetPos().x - alphaCheckBox.GetSize().x - 100, pressureCheckBox.GetPos().y));
|
||||
add(textureSlotComboBox);
|
||||
add(brushShapeComboBox);
|
||||
add(axisCombo);
|
||||
|
||||
@@ -52,6 +52,7 @@ public:
|
||||
wi::gui::CheckBox backfaceCheckBox;
|
||||
wi::gui::CheckBox wireCheckBox;
|
||||
wi::gui::CheckBox pressureCheckBox;
|
||||
wi::gui::CheckBox alphaCheckBox;
|
||||
wi::gui::ColorPicker colorPicker;
|
||||
wi::gui::ComboBox textureSlotComboBox;
|
||||
wi::gui::ComboBox brushShapeComboBox;
|
||||
|
||||
@@ -1264,7 +1264,7 @@ struct PaintTexturePushConstants
|
||||
|
||||
float xPaintBrushSmoothness;
|
||||
uint xPaintBrushColor;
|
||||
uint xPaintReveal;
|
||||
uint xPaintRedirectAlpha;
|
||||
float xPaintBrushRotation;
|
||||
|
||||
uint xPaintBrushShape;
|
||||
|
||||
@@ -35,7 +35,6 @@ void main( uint3 DTid : SV_DispatchThreadID )
|
||||
}
|
||||
|
||||
float4 brush_color = 1;
|
||||
float4 reveal_color = 1;
|
||||
|
||||
[branch]
|
||||
if(push.texture_brush >= 0)
|
||||
@@ -46,7 +45,7 @@ void main( uint3 DTid : SV_DispatchThreadID )
|
||||
const float2 brush_uv_quad_y = QuadReadAcrossY(brush_uv);
|
||||
const float2 brush_uv_dx = brush_uv - brush_uv_quad_x;
|
||||
const float2 brush_uv_dy = brush_uv - brush_uv_quad_y;
|
||||
brush_color = texture_brush.SampleGrad(sampler_linear_clamp, brush_uv, brush_uv_dx, brush_uv_dy);
|
||||
brush_color *= texture_brush.SampleGrad(sampler_linear_clamp, brush_uv, brush_uv_dx, brush_uv_dy);
|
||||
}
|
||||
|
||||
[branch]
|
||||
@@ -58,22 +57,26 @@ void main( uint3 DTid : SV_DispatchThreadID )
|
||||
const float2 reveal_uv_quad_y = QuadReadAcrossY(reveal_uv);
|
||||
const float2 reveal_uv_dx = reveal_uv - reveal_uv_quad_x;
|
||||
const float2 reveal_uv_dy = reveal_uv - reveal_uv_quad_y;
|
||||
reveal_color = texture_reveal.SampleGrad(sampler_linear_clamp, reveal_uv, reveal_uv_dx, reveal_uv_dy);
|
||||
brush_color *= texture_reveal.SampleGrad(sampler_linear_clamp, reveal_uv, reveal_uv_dx, reveal_uv_dy);
|
||||
}
|
||||
|
||||
const float affection = push.xPaintBrushAmount * smoothstep(0, push.xPaintBrushSmoothness, 1 - dist / radius);
|
||||
if (affection > 0 && dist < radius)
|
||||
{
|
||||
if (push.xPaintReveal)
|
||||
{
|
||||
brush_color *= reveal_color;
|
||||
}
|
||||
brush_color.a *= affection;
|
||||
brush_color *= unpack_rgba(push.xPaintBrushColor);
|
||||
float4 prevColor = texture_output[pixel];
|
||||
float4 color = 0;
|
||||
color.rgb = prevColor.rgb * (1 - brush_color.a) + brush_color.rgb * brush_color.a;
|
||||
color.a = prevColor.a * (1 - brush_color.a) + brush_color.a;
|
||||
if(push.xPaintRedirectAlpha)
|
||||
{
|
||||
color.rgb = prevColor.rgb;
|
||||
color.a = prevColor.a * (1 - brush_color.a) + brush_color.r * brush_color.a;
|
||||
}
|
||||
else
|
||||
{
|
||||
color.rgb = prevColor.rgb * (1 - brush_color.a) + brush_color.rgb * brush_color.a;
|
||||
color.a = prevColor.a * (1 - brush_color.a) + brush_color.a;
|
||||
}
|
||||
texture_output[pixel] = color;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3021,7 +3021,6 @@ void ProcessDeferredTextureRequests(CommandList cmd)
|
||||
for (auto& params : painttextures)
|
||||
{
|
||||
// overwrites some params!
|
||||
params.push.xPaintReveal = params.revealTex.IsValid() ? 1 : 0;
|
||||
if (params.brushTex.IsValid())
|
||||
{
|
||||
params.push.texture_brush = device->GetDescriptorIndex(¶ms.brushTex, SubresourceType::SRV);
|
||||
|
||||
@@ -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 = 430;
|
||||
const int revision = 431;
|
||||
|
||||
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user