Skip to content

Commit

Permalink
Fixed Imgui::Image() alpha blend issue(According to ocornut/imgui#3447).
Browse files Browse the repository at this point in the history
  • Loading branch information
erosnick committed Feb 28, 2023
1 parent c7a600e commit 14d0b48
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
8 changes: 7 additions & 1 deletion Assets/Shaders/LandAndOcean.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,16 @@ float4 PSMain(PSInput input) : SV_TARGET
litColor = lerp(litColor, FogColor, fogAmount);
#endif

// Common convention to take alpha from diffuse material.
litColor.a = diffuseAlbedo.a;

#ifdef NO_ALPHA
// Common convention to take alpha from diffuse material.
litColor = float4(1.0f, 0.0f, 0.0f, 1.0f);
litColor.a = 1.0f;
#endif
// litColor = float4(fogAmount, fogAmount, fogAmount, 1.0);
// litColor = FogColor;
// litColor = float4(litColor.a, litColor.a, litColor.a, 1.0f);

return litColor;
}
Binary file added Assets/Textures/Mirror.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Src/7.D3DAppGLFW.cpp
Binary file not shown.
12 changes: 7 additions & 5 deletions Src/7.D3DAppGLFW.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ class D3DApp

int32_t run();

void renderImGui();

private:
bool initGLFW();
bool initWindow(HINSTANCE hInstance, int32_t cmdShow);
Expand Down Expand Up @@ -274,6 +272,8 @@ class D3DApp
void processInput(float deltaTime);
void render();

void renderScene();

void present();

void executeCommandLists();
Expand Down Expand Up @@ -310,6 +310,8 @@ class D3DApp
void preprareResize();
void onResize();
void onRenderTextureResize(uint32_t width, uint32_t height);

void disableAlphaBlend();
private:
const static uint32_t FrameBackbufferCount = 3;
int32_t windowWidth = 1280;
Expand Down Expand Up @@ -387,8 +389,8 @@ class D3DApp
ComPtr<IDXGISwapChain1> swapChain1;

// DXR stuff
ComPtr<IDXGISwapChain4> swapChain;
//ComPtr<IDXGISwapChain3> swapChain;
//ComPtr<IDXGISwapChain4> swapChain;
ComPtr<IDXGISwapChain> swapChain;
ComPtr<ID3D12DescriptorHeap> renderTargetViewDescriptorHeap;
ComPtr<ID3D12DescriptorHeap> renderTextureRTVDescriptorHeap;
ComPtr<ID3D12DescriptorHeap> shaderResourceViewDescriptorHeap;
Expand Down Expand Up @@ -455,7 +457,7 @@ class D3DApp
// Our state
bool showDemoWindow = true;
bool showAnotherWindow = false;
ImVec4 clearColor = ImVec4(0.4f, 0.6f, 0.9f, 1.00f);
ImVec4 clearColor = ImVec4(0.4f, 0.6f, 0.9f, 1.0f);

static D3DApp* app;

Expand Down
12 changes: 6 additions & 6 deletions imgui.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Collapsed=0

[Window][Dear ImGui Demo]
Pos=934,0
Size=346,341
Size=346,357
Collapsed=0
DockId=0x00000005,0

Expand All @@ -15,8 +15,8 @@ Size=400,400
Collapsed=0

[Window][Hello, world!]
Pos=934,343
Size=346,377
Pos=934,359
Size=346,361
Collapsed=0
DockId=0x00000006,0

Expand All @@ -37,9 +37,9 @@ DockSpace ID=0x29A038FF Window=0x4647B76E Pos=0,0 Size=1280,720 Split=X
DockNode ID=0x00000001 Parent=0x29A038FF SizeRef=932,1080 Split=Y
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=1368,561 CentralNode=1 Selected=0x13926F0B
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=1368,157 Selected=0xF780C014
DockNode ID=0x00000002 Parent=0x29A038FF SizeRef=346,1080 Split=Y Selected=0xE87781F4
DockNode ID=0x00000005 Parent=0x00000002 SizeRef=550,341 Selected=0xE87781F4
DockNode ID=0x00000006 Parent=0x00000002 SizeRef=550,377 Selected=0xD00C9CD4
DockNode ID=0x00000002 Parent=0x29A038FF SizeRef=346,1080 Split=Y Selected=0xD00C9CD4
DockNode ID=0x00000005 Parent=0x00000002 SizeRef=346,357 Selected=0xE87781F4
DockNode ID=0x00000006 Parent=0x00000002 SizeRef=346,361 Selected=0xD00C9CD4

[imgui-console][imgui-console]
m_AutoScroll=1
Expand Down

0 comments on commit 14d0b48

Please sign in to comment.