Commit 0cf22447 authored by Christopher Tenter's avatar Christopher Tenter

dual depth peeling renderer update

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@16709 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 75739932
This diff is collapsed.
......@@ -94,7 +94,16 @@ private slots:
private:
// draw a projected quad in [-1, -1] - [1, 1] range
/// peel the scene from front to back, one layer per pass
void renderFrontPeeling(ACG::GLState* _glState, Viewer::ViewerProperties& _properties);
/// peel the scene with dual depth peeling, two layers per pass
void renderDualPeeling(ACG::GLState* _glState, Viewer::ViewerProperties& _properties);
/// draw a projected quad in [-1, -1] - [1, 1] range
void drawProjQuad(GLSL::Program* _prog);
/// vbo containing a quad in projection space
......@@ -105,13 +114,15 @@ private:
// single layer depth peeling
struct PeelLayer
{
/// target framebuffer for colorTex and depthTex
/// target framebuffer for colorTex and depthBuf
GLuint fbo;
/// color rendertarget
GLuint colorTex;
/// depth-buf rendertarget
GLuint depthTex;
/// hardware depth buffer
GLuint depthBuf;
/// depth-buffer rendertarget
GLuint depthTex; // encountered gpu-model specific problems when reading from depthBuf directly
};
/// blends one depth-layer into the current scene target
......@@ -130,6 +141,12 @@ private:
GLuint peelQueryID_;
/// dual depth peeling shaders
GLSL::Program* peelBlendDual_;
GLSL::Program* peelFinalDual_;
GLSL::Program* peelInitDual_;
/// Collection of framebuffers for each viewport
struct ViewerResources
{
......@@ -149,17 +166,38 @@ private:
GLuint peelBlendTex_;
GLuint peelBlendFbo_;
// dual depth peeling textures
// ping-pong buffer for (depth, front, back) targets
GLuint dualDepthTex_[2]; // float2: (-minDepth, maxDepth)
GLuint dualFrontTex_[2]; // rgba: color of front-peeled layer
GLuint dualBackTex_[2]; // rgba: color of back-peeled layer
GLuint dualBlendTex_; // rgb: color accumulation buffer
GLuint dualFbo_; // targets: {depth0, front0, back0, depth1, front1, back1, blend}
};
/// Allocate framebuffers and load shaders for depth-peeling.
void initDepthPeeling();
/// Allocate framebuffers and load shaders for dual-depth-peeling.
void initDualDepthPeeling();
/// Change viewport size for allocated rendertargets.
void updateViewerResources(int _viewerId, unsigned int _newWidth, unsigned int _newHeight);
void updateViewerResources(bool _dualPeeling, int _viewerId, unsigned int _newWidth, unsigned int _newHeight);
/**
* Stores framebuffer resources for each viewport.
* Mapping: viewerID -> ViewerResources
*/
std::map<int, ViewerResources> viewerRes_;
// debug functions
// GLSL::Program* dbgProg_;
//
// void dbgDrawTex(GLuint _texID);
};
#version 150
uniform sampler2D BlendTex;
in vec2 vTexCoord;
out vec4 oColor;
void main()
{
oColor = texture2D(BlendTex, vTexCoord);
// for occlusion query
if (oColor.a == 0) discard;
}
\ No newline at end of file
#version 150
uniform sampler2D Tex;
in vec2 vTexCoord;
out vec4 oColor;
void main()
{
vec4 d = texture2D(Tex, vTexCoord);
oColor = -d.xxxx;
oColor = d.yyyy;
oColor = d;
// if (d.a == 0)
// oColor = vec4(1.0, 0, 0, 0);
}
\ No newline at end of file
#version 150
uniform sampler2D FrontSceneTex;
uniform sampler2D BackSceneTex;
in vec2 vTexCoord;
out vec4 oColor;
void main()
{
vec4 cf = texture2D(FrontSceneTex, vTexCoord);
vec4 cb = texture2D(BackSceneTex, vTexCoord);
// combine front and back color
oColor = vec4(cf.rgb + cb.rbg * (1.0 - cf.a), 1.0);
}
\ No newline at end of file
#version 150
out vec4 oColor;
void main()
{
oColor = vec2(-gl_FragCoord.z, gl_FragCoord.z);
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment