Skip to content

Commit 2c0535f

Browse files
KuanlanKuanlan
authored andcommitted
[fixed] alpha+bal not working
1 parent 0f923dd commit 2c0535f

File tree

4 files changed

+65
-2
lines changed

4 files changed

+65
-2
lines changed

LuaSTG/Core/Graphics/Renderer_D3D11.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ namespace Core::Graphics
599599
return false;
600600
M_D3D_SET_DEBUG_NAME_SIMPLE(_blend_state[IDX(BlendState::RevSub)].Get());
601601

602-
blendt_.BlendOp = D3D11_BLEND_OP_REV_SUBTRACT;
602+
blendt_.BlendOp = D3D11_BLEND_OP_ADD;
603603
blendt_.SrcBlend = D3D11_BLEND_INV_DEST_COLOR;
604604
blendt_.DestBlend = D3D11_BLEND_INV_SRC_COLOR;
605605
blendt_.BlendOpAlpha = D3D11_BLEND_OP_ADD;

data/test/src/main.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ require("test_dwrite")
100100
require("test_colli")
101101
require("test_posteffect")
102102
require("test_blend_color_burn")
103+
require("test_blend_alpha_bal")
103104
require("test_monitor")
104105
require("test_utf8api")
105106
require("test_lfs")
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
local test = require("test")
2+
3+
---@class test.Module.PostEffect.Blend.AlphaBal : test.Base
4+
local M = {}
5+
6+
local function load_image(name, path)
7+
lstg.LoadTexture(name, path, false)
8+
local w, h = lstg.GetTextureSize(name)
9+
lstg.LoadImage(name, name, 0, 0, w, h)
10+
end
11+
12+
local function unload_image(pool, name)
13+
lstg.RemoveResource(pool, 2, name)
14+
lstg.RemoveResource(pool, 1, name)
15+
end
16+
17+
function M:onCreate()
18+
local last_pool = lstg.GetResourceStatus()
19+
lstg.SetResourceStatus("global")
20+
21+
load_image("image_2", "res/image_2.jpg")
22+
lstg.CreateRenderTarget("rt:white", 256, 256, false)
23+
lstg.CreateRenderTarget("rt:black", 256, 256, false)
24+
lstg.LoadImage("sprite:white", "rt:white", 0, 0, 256, 256)
25+
lstg.LoadImage("sprite:black", "rt:black", 0, 0, 256, 256)
26+
lstg.SetImageState("sprite:white", "alpha+bal", lstg.Color(255, 255, 255, 255))
27+
lstg.SetImageState("sprite:black", "alpha+bal", lstg.Color(255, 255, 255, 255))
28+
29+
lstg.SetResourceStatus(last_pool)
30+
31+
self.timer = 0
32+
end
33+
34+
function M:onDestroy()
35+
lstg.RemoveResource("global", 2, "sprite:white")
36+
lstg.RemoveResource("global", 2, "sprite:black")
37+
lstg.RemoveResource("global", 1, "rt:white")
38+
lstg.RemoveResource("global", 1, "rt:black")
39+
unload_image("global", "image_2")
40+
end
41+
42+
function M:onUpdate()
43+
self.timer = self.timer + 1
44+
end
45+
46+
function M:onRender()
47+
window:applyCameraV()
48+
49+
lstg.PushRenderTarget("rt:white")
50+
lstg.RenderClear(lstg.Color(255, 255, 255, 255))
51+
lstg.PopRenderTarget()
52+
53+
lstg.PushRenderTarget("rt:black")
54+
lstg.RenderClear(lstg.Color(255, 0, 0, 0))
55+
lstg.PopRenderTarget()
56+
57+
lstg.Render("image_2", window.width / 2, window.height / 2, 0, window.height / 2160)
58+
lstg.Render("sprite:white", 256, 256)
59+
lstg.Render("sprite:black", 512, 256)
60+
end
61+
62+
test.registerTest("test.Module.PostEffect.Blend.AlphaBal", M)

doc

Submodule doc updated 1 file

0 commit comments

Comments
 (0)