8000 [WIP] Improved transparency with dual depth peeling by publixsubfan · Pull Request #166 · GLVis/glvis · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[WIP] Improved transparency with dual depth peeling #166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ee436a4
Restructure rendering code into separate passes
publixsubfan Mar 26, 2021
dc33051
Add functions for handling binding framebuffers in passes
publixsubfan Mar 30, 2021
4333a5d
Fix replacement of gl_FragData variables
publixsubfan Mar 31, 2021
e6ea065
Add in-progress depth peeling render pass
publixsubfan Mar 31, 2021
05589ec
Bugfixes to get stuff to display
publixsubfan Apr 14, 2021
939a47c
Fixes for background setting in depth peeling mode; use depth peeling…
publixsubfan Apr 14, 2021
3ce1688
Reset to default state after depth peel
publixsubfan Apr 15, 2021
c9a108e
Render opaque objects first without depth peeling
publixsubfan Apr 15, 2021
62d722b
Merge branch 'master' into depth-peel-oit-dev
publixsubfan Apr 15, 2021
07bde31
Try to fix warnings
publixsubfan Apr 16, 2021
4337bd8
Trying to fix linking issues
publixsubfan Apr 16, 2021
29a9069
Add missing source files to makefile
publixsubfan Apr 16, 2021
31acb33
Merge branch 'master' into depth-peel-oit-dev
publixsubfan Apr 20, 2021
b02284d
make style
tzanio Apr 24, 2021
ebf34f8
Retain rendering stages to avoid recompilation of shaders
publixsubfan Apr 26, 2021
48716f4
Consolidate screen texture creation code, set tighter max depths
publixsubfan Apr 27, 2021
8a045b3
Fix source texture for depth peel finalization
publixsubfan Apr 28, 2021
e7f28bd
Rename a function to GLDevice::isOpenGL3 for more general use
publixsubfan Apr 28, 2021
804d25a
Create a framebufffer class to handle common operations
publixsubfan Apr 29, 2021
8fe997b
Fix transform feedback varying setup
publixsubfan Apr 29, 2021
0db5ae8
Add missing shader
publixsubfan Apr 29, 2021
8ed9ed5
Fix for framebuffer blit code
publixsubfan Apr 29, 2021
26106b3
Fix leak of some GL objects in assignment move
publixsubfan Apr 29, 2021
8246775
Fix passing of renderbuffers in MultisamplePass
publixsubfan Apr 30, 2021
74be087
Use output depth texture for excluding clip plane fragments
publixsubfan Apr 30, 2021
aebfafb
Merge branch 'master' into depth-peel-oit-dev
publixsubfan May 3, 2021
aa41067
Fix build warning
publixsubfan May 3, 2021
d1f6b43
Fix makefile
publixsubfan May 3, 2021
1c58cd6
Fix depth peel finalization with multisampling enabled
publixsubfan May 3, 2021
5425e63
Build fixes for shader code
publixsubfan May 5, 2021
d52030b
Changes needed to get WebGL depth peeling running
publixsubfan May 5, 2021
eb5d2ba
Fix for shader-based blit method
publixsubfan May 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@
# CONTRIBUTING.md for details.

list(APPEND SOURCES
gl/framebuffer.cpp
gl/renderer.cpp
gl/renderer_core.cpp
gl/renderer_msaa.cpp
gl/renderer_print.cpp
gl/depth_peel_oit.cpp
gl/shader.cpp
gl/types.cpp
aux_vis.cpp
Expand All @@ -28,10 +32,14 @@ list(APPEND SOURCES
vsvector3d.cpp)

list(APPEND HEADERS
gl/framebuffer.hpp
gl/attr_traits.hpp
gl/platform_gl.hpp
gl/renderer.hpp
gl/renderer_core.hpp
gl/renderer_msaa.hpp
gl/renderer_print.hpp
gl/depth_peel_oit.hpp
gl/shader.hpp
gl/types.hpp
aux_vis.hpp
Expand Down
3 changes: 0 additions & 3 deletions lib/aux_js.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ bool startVisualization(const std::string input, const std::string data_type,
// 0 - scalar data, 1 - vector data, 2 - mesh only, (-1) - unknown
const int field_type = stream_state.ReadStream(ss, data_type);

// reset antialiasing
GetAppWindow()->getRenderer().setAntialiasing(0);

std::string line;
double minv = 0.0, maxv = 0.0;
while (ss >> line)
Expand Down
87 changes: 70 additions & 17 deletions lib/aux_vis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ using namespace mfem;
#include <fontconfig/fontconfig.h>
#endif

#include "gl/renderer_msaa.hpp"
#include "gl/renderer_print.hpp"
#include "gl/depth_peel_oit.hpp"

int visualize = 0;
VisualizationScene * locscene;

Expand All @@ -41,13 +45,18 @@ static int glvis_multisample = GLVIS_MULTISAMPLE;
#else
static int glvis_multisample = -1;
#endif
bool multisample_status = false;

float line_w = 1.f;
float line_w_aa = gl3::LINE_WIDTH_AA;

SdlWindow * wnd = nullptr;
bool wndLegacyGl = false;

gl3::DefaultPass rndr_main_pass;
gl3::DepthPeeler rndr_depth_peeled;
gl3::MultisamplePass rndr_msaa_pass;

SdlWindow * GetAppWindow()
{
return wnd;
Expand Down Expand Up @@ -85,12 +94,16 @@ int InitVisualization (const char name[], int x, int y, int w, int h)
wnd->clearEvents();
}

multisample_status = false;

rndr_main_pass.SetGLDevice(wnd->getRenderer().getDevice());
rndr_msaa_pass.SetGLDevice(wnd->getRenderer().getDevice());
rndr_depth_peeled.SetGLDevice(wnd->getRenderer().getDevice());

#ifdef GLVIS_DEBUG
cout << "Window should be up" << endl;
#endif
InitFont();
wnd->getRenderer().setLineWidth(line_w);
wnd->getRenderer().setLineWidthMS(line_w_aa);

// auxReshapeFunc (MyReshape); // not needed, MyExpose calls it
// auxReshapeFunc (NULL);
Expand All @@ -109,6 +122,7 @@ int InitVisualization (const char name[], int x, int y, int w, int h)

wnd->setTouchPinchCallback(TouchPinch);

wnd->setOnKeyDown('A', KeyAPressed);
// auxKeyFunc (AUX_p, KeyCtrlP); // handled in vsdata.cpp
wnd->setOnKeyDown (SDLK_s, KeyS);
wnd->setOnKeyDown ('S', KeyS);
Expand Down Expand Up @@ -317,7 +331,6 @@ void SetVisualizationScene(VisualizationScene * scene, int view,
// SendKeySequence(keys);
CallKeySequence(keys);
}
wnd->getRenderer().setPalette(&locscene->palette);
}

void RunVisualization()
Expand Down Expand Up @@ -377,16 +390,35 @@ void MyReshape(GLsizei w, GLsizei h)
void MyExpose(GLsizei w, GLsizei h)
{
MyReshape (w, h);
GLuint color_tex = locscene->palette.GetColorTexture();
GLuint alpha_tex = locscene->palette.GetAlphaTexture();
wnd->getRenderer().setColorTexture(color_tex);
wnd->getRenderer().setAlphaTexture(alpha_tex);
bool use_depth_peel = !(locscene->matAlpha == 1.0);
if (!use_depth_peel)
{
rndr_main_pass.setFontTexture(GetFont()->getFontTex());
rndr_main_pass.setPalette(locscene->palette);
}
else
{
rndr_depth_peeled.setFontTexture(GetFont()->getFontTex());
rndr_depth_peeled.setPalette(locscene->palette);
}
// Set antialiasing parameters
rndr_msaa_pass.SetAntialiasing(multisample_status);
rndr_msaa_pass.SetNumSamples(GetMultisample());
rndr_msaa_pass.SetLineWidth(line_w);
rndr_msaa_pass.SetLineWidthMS(line_w_aa);
gl3::SceneInfo frame = locscene->GetSceneObjs();
for (auto drawable_ptr : frame.needs_buffering)
{
wnd->getRenderer().buffer(drawable_ptr);
}
wnd->getRenderer().render(frame.queue);
if (!use_depth_peel)
{
wnd->getRenderer().render({&rndr_main_pass}, {&rndr_msaa_pass}, frame.queue);
}
else
{
wnd->getRenderer().render({&rndr_depth_peeled}, {&rndr_msaa_pass}, frame.queue);
}
}

void MyExpose()
Expand Down Expand Up @@ -1096,6 +1128,8 @@ void PrintCaptureBuffer(gl3::CaptureBuffer& cbuf)
}
}

gl3::CapturePass print_pass;

void KeyCtrlP()
{
#ifdef __EMSCRIPTEN__
Expand Down Expand Up @@ -1126,7 +1160,10 @@ void KeyCtrlP()
GL2PS_NO_BLENDING |
GL2PS_NO_OPENGL_CONTEXT,
GL_RGBA, 0, NULL, 16, 16, 16, 0, fp, "a" );
gl3::CaptureBuffer cbuf = wnd->getRenderer().capture(wnd_scn.queue);
print_pass.setFontTexture(GetFont()->getFontTex());
print_pass.setPalette(locscene->palette);
wnd->getRenderer().render( {&print_pass}, {}, wnd_scn.queue);
gl3::CaptureBuffer cbuf = print_pass.GetLastCaptureBuffer();
PrintCaptureBuffer(cbuf);
gl2psEndPage();
}
Expand All @@ -1137,6 +1174,28 @@ void KeyCtrlP()
#endif
}


void KeyAPressed()
{
if (glvis_multisample < 0)
{
cout << "Multisampling disabled." << endl;
return;
}
multisample_status = !multisample_status;

if (multisample_status)
{
cout << "Multisampling/Antialiasing: on" << endl;
}
else
{
cout << "Multisampling/Antialiasing: off" << endl;
}

SendExposeEvent();
}

void KeyQPressed()
{
wnd->signalQuit();
Expand Down Expand Up @@ -1501,18 +1560,13 @@ void SetLineWidth(float width)
line_w = width;
if (wnd)
{
wnd->getRenderer().setLineWidth(line_w);
wnd->getRenderer().SetLineWidth(line_w);
}
}

void SetLineWidthMS(float width_ms)
{
line_w_aa = width_ms;
if (wnd)
{
wnd->getRenderer().setLineWidthMS(line_w_aa);
}

}

float GetLineWidth()
Expand Down Expand Up @@ -1555,7 +1609,7 @@ void InitFont()
{
// This function is called after the window is created.
GLenum alphaChannel =
gl3::GLDevice::useLegacyTextureFmts() ? GL_ALPHA : GL_RED;
gl3::GLDevice::isOpenGL3() ? GL_RED : GL_ALPHA;
glvis_font.setAlphaChannel(alphaChannel);
bool try_fc_patterns = true;
if (!priority_font.empty())
Expand All @@ -1580,7 +1634,6 @@ void InitFont()
<< endl;
}
}
wnd->getRenderer().setFontTexture(glvis_font.getFontTex());
}

GlVisFont * GetFont()
Expand Down
1 change: 1 addition & 0 deletions lib/aux_vis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void RightButtonUp (EventInfo *event);

void TouchPinch(SDL_MultiGestureEvent & e);

void KeyAPressed();
void KeyCtrlP();
void KeyS();
void KeyQPressed();
Expand Down
Loading
0