Commit 18a4b35d authored by Martin Schultz's avatar Martin Schultz

fixed some glErrors for OSX and reenabled depthPeeling plugin.

On core profiles, osx does not support glsl #version150 texture2D calls
added 330 implementation which uses texture call.
parent 947d4b20
......@@ -132,9 +132,19 @@ public:
{
_code->push_back("float fragDepth = gl_FragCoord.z;");
#ifdef __APPLE__
if(ACG::openGLVersion(3,3))
{
//on Apple systems with OpenGL 3.3 or higher, ht eGLSL version 330 is used no matter what we write
_code->push_back("vec2 depthLayer = texture(g_DepthLayer, sg_vScreenPos).xy;");
_code->push_back("vec4 forwardTemp = texture(g_FrontLayer, sg_vScreenPos);");
}
else
#endif
{
_code->push_back("vec2 depthLayer = texture2D(g_DepthLayer, sg_vScreenPos).xy;");
_code->push_back("vec4 forwardTemp = texture2D(g_FrontLayer, sg_vScreenPos);");
}
_code->push_back("outDepth = vec4(depthLayer, 0, 0);");
_code->push_back("outFragment = forwardTemp;");
_code->push_back("outBackColor = vec4(0,0,0,0);");
......@@ -215,8 +225,8 @@ DepthPeeling::~DepthPeeling()
QString DepthPeeling::checkOpenGL()
{
if(!ACG::compatibilityProfile())
return QString("DepthPeeling render-plugin is nto yet compatible with core profile contexts.");
//if(!ACG::compatibilityProfile())
// return QString("DepthPeeling render-plugin is nto yet compatible with core profile contexts.");
if (!ACG::openGLVersion(3, 2))
return QString("Insufficient OpenGL Version! OpenGL 3.2 or higher required");
......@@ -910,14 +920,19 @@ void DepthPeeling::ViewerResources::resize(bool _dualPeeling, unsigned int _widt
// depth textures: store layer depth as float
// front color textures: store (r,g,b,a) colors as R8G8B8A8
// color blending and accumulation texture: (r,g,b,a) color as R8G8B8A8
GLint wrapmode;
if(ACG::openGLVersion(3,2))
wrapmode = GL_CLAMP_TO_EDGE;
else
wrapmode = GL_CLAMP;
singleFbo_->attachTexture2D(GL_COLOR_ATTACHMENT0, width_, height_, GL_R32F, GL_RGB, GL_CLAMP, GL_NEAREST, GL_NEAREST);
singleFbo_->attachTexture2D(GL_COLOR_ATTACHMENT1, width_, height_, GL_RGBA, GL_RGBA, GL_CLAMP, GL_NEAREST, GL_NEAREST);
singleFbo_->attachTexture2D(GL_COLOR_ATTACHMENT0, width_, height_, GL_R32F, GL_RGB, wrapmode, GL_NEAREST, GL_NEAREST);
singleFbo_->attachTexture2D(GL_COLOR_ATTACHMENT1, width_, height_, GL_RGBA, GL_RGBA, wrapmode, GL_NEAREST, GL_NEAREST);
singleFbo_->attachTexture2D(GL_COLOR_ATTACHMENT2, width_, height_, GL_R32F, GL_RGB, GL_CLAMP, GL_NEAREST, GL_NEAREST);
singleFbo_->attachTexture2D(GL_COLOR_ATTACHMENT3, width_, height_, GL_RGBA, GL_RGBA, GL_CLAMP, GL_NEAREST, GL_NEAREST);
singleFbo_->attachTexture2D(GL_COLOR_ATTACHMENT2, width_, height_, GL_R32F, GL_RGB, wrapmode, GL_NEAREST, GL_NEAREST);
singleFbo_->attachTexture2D(GL_COLOR_ATTACHMENT3, width_, height_, GL_RGBA, GL_RGBA, wrapmode, GL_NEAREST, GL_NEAREST);
singleFbo_->attachTexture2D(GL_COLOR_ATTACHMENT4, width_, height_, GL_RGBA, GL_RGBA, GL_CLAMP, GL_NEAREST, GL_NEAREST);
singleFbo_->attachTexture2D(GL_COLOR_ATTACHMENT4, width_, height_, GL_RGBA, GL_RGBA, wrapmode, GL_NEAREST, GL_NEAREST);
singleFbo_->attachTexture2DDepth(width_, height_);
......@@ -953,16 +968,22 @@ void DepthPeeling::ViewerResources::resize(bool _dualPeeling, unsigned int _widt
// depth textures: store (min,max) depth as float2
// front+back color textures: store (r,g,b,a) colors as R8G8B8A8
// color blending and accumulation texture: (r,g,b) color as R8G8B8X8
dualFbo_->attachTexture2D(GL_COLOR_ATTACHMENT0, width_, height_, GL_RG32F, GL_RGB, GL_CLAMP, GL_NEAREST, GL_NEAREST);
dualFbo_->attachTexture2D(GL_COLOR_ATTACHMENT1, width_, height_, GL_RGBA, GL_RGBA, GL_CLAMP, GL_NEAREST, GL_NEAREST);
dualFbo_->attachTexture2D(GL_COLOR_ATTACHMENT2, width_, height_, GL_RGBA, GL_RGBA, GL_CLAMP, GL_NEAREST, GL_NEAREST);
GLint wrapmode;
if(ACG::openGLVersion(3,2))
{
wrapmode = GL_CLAMP_TO_EDGE;
}
else
wrapmode = GL_CLAMP;
dualFbo_->attachTexture2D(GL_COLOR_ATTACHMENT0, width_, height_, GL_RG32F, GL_RGB, wrapmode, GL_NEAREST, GL_NEAREST);
dualFbo_->attachTexture2D(GL_COLOR_ATTACHMENT1, width_, height_, GL_RGBA, GL_RGBA, wrapmode, GL_NEAREST, GL_NEAREST);
dualFbo_->attachTexture2D(GL_COLOR_ATTACHMENT2, width_, height_, GL_RGBA, GL_RGBA, wrapmode, GL_NEAREST, GL_NEAREST);
dualFbo_->attachTexture2D(GL_COLOR_ATTACHMENT3, width_, height_, GL_RG32F, GL_RGB, GL_CLAMP, GL_NEAREST, GL_NEAREST);
dualFbo_->attachTexture2D(GL_COLOR_ATTACHMENT4, width_, height_, GL_RGBA, GL_RGBA, GL_CLAMP, GL_NEAREST, GL_NEAREST);
dualFbo_->attachTexture2D(GL_COLOR_ATTACHMENT5, width_, height_, GL_RGBA, GL_RGBA, GL_CLAMP, GL_NEAREST, GL_NEAREST);
dualFbo_->attachTexture2D(GL_COLOR_ATTACHMENT3, width_, height_, GL_RG32F, GL_RGB, wrapmode, GL_NEAREST, GL_NEAREST);
dualFbo_->attachTexture2D(GL_COLOR_ATTACHMENT4, width_, height_, GL_RGBA, GL_RGBA, wrapmode, GL_NEAREST, GL_NEAREST);
dualFbo_->attachTexture2D(GL_COLOR_ATTACHMENT5, width_, height_, GL_RGBA, GL_RGBA, wrapmode, GL_NEAREST, GL_NEAREST);
dualFbo_->attachTexture2D(GL_COLOR_ATTACHMENT6, width_, height_, GL_RGB, GL_RGB, GL_CLAMP, GL_NEAREST, GL_NEAREST);
dualFbo_->attachTexture2D(GL_COLOR_ATTACHMENT6, width_, height_, GL_RGB, GL_RGB, wrapmode, GL_NEAREST, GL_NEAREST);
dualDepthTex_[0] = dualFbo_->getAttachment(GL_COLOR_ATTACHMENT0);
dualDepthTex_[1] = dualFbo_->getAttachment(GL_COLOR_ATTACHMENT3);
......@@ -1002,11 +1023,24 @@ void DepthPeeling::initDepthPeeling()
ShaderProgGenerator::registerModifier(&PeelLayerModifier::instance);
// load intermediate blending and final shader
#ifdef __APPLE__
if(ACG::openGLVersion(3,3))
{
if (!peelBlend_)
peelBlend_ = GLSL::loadProgram("DepthPeeling/screenquad_330.glsl", "DepthPeeling/blend_330.glsl");
if (!peelFinal_)
peelFinal_ = GLSL::loadProgram("DepthPeeling/screenquad_330.glsl", "DepthPeeling/final_330.glsl");
}
else
#endif
{
if (!peelBlend_)
peelBlend_ = GLSL::loadProgram("DepthPeeling/screenquad.glsl", "DepthPeeling/blend.glsl");
if (!peelFinal_)
peelFinal_ = GLSL::loadProgram("DepthPeeling/screenquad.glsl", "DepthPeeling/final.glsl");
}
// occ query id
if (!peelQueryID_)
......@@ -1026,11 +1060,22 @@ void DepthPeeling::initDualDepthPeeling()
ShaderProgGenerator::registerModifier(&PeelDualLayerModifier::instance);
// load intermediate blending and final shader
if (!peelBlendDual_)
peelBlendDual_ = GLSL::loadProgram("DepthPeeling/screenquad.glsl", "DepthPeeling/blend_dual.glsl");
if (!peelFinalDual_)
peelFinalDual_ = GLSL::loadProgram("DepthPeeling/screenquad.glsl", "DepthPeeling/final_dual.glsl");
#ifdef __APPLE__ //this is fugly, pimpl pattern would be much appreciated
if(ACG::openGLVersion(3,3))
{
if(!peelBlendDual_)
peelBlendDual_ = GLSL::loadProgram("DepthPeeling/screenquad_330.glsl", "DepthPeeling/blend_dual_330.glsl");
if (!peelFinalDual_)
peelFinalDual_ = GLSL::loadProgram("DepthPeeling/screenquad_330.glsl", "DepthPeeling/final_dual_330.glsl");
}
else
#endif
{
if(!peelBlendDual_)
peelBlendDual_ = GLSL::loadProgram("DepthPeeling/screenquad.glsl", "DepthPeeling/blend_dual.glsl");
if (!peelFinalDual_)
peelFinalDual_ = GLSL::loadProgram("DepthPeeling/screenquad.glsl", "DepthPeeling/final_dual.glsl");
}
// occ query id
if (!peelQueryID_)
......
#version 330
uniform sampler2D BlendTex;
in vec2 vTexCoord;
out vec4 oColor;
void main()
{
oColor = texture(BlendTex, vTexCoord);
}
\ No newline at end of file
#version 330
uniform sampler2D BlendTex;
in vec2 vTexCoord;
out vec4 oColor;
void main()
{
oColor = texture(BlendTex, vTexCoord);
// for occlusion query
if (oColor.a == 0) discard;
}
\ No newline at end of file
#version 330
uniform sampler2D SceneTex;
uniform vec3 BkgColor;
in vec2 vTexCoord;
out vec4 oColor;
void main()
{
vec4 c = texture(SceneTex, vTexCoord);
oColor = vec4(c.rgb + BkgColor * c.a, 1.0);
}
\ No newline at end of file
#version 330
uniform sampler2D FrontSceneTex;
uniform sampler2D BackSceneTex;
in vec2 vTexCoord;
out vec4 oColor;
void main()
{
vec4 cf = texture(FrontSceneTex, vTexCoord);
vec4 cb = texture(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 330
in vec4 inPosition;
out vec2 vTexCoord;
void main()
{
gl_Position = inPosition;
vTexCoord = inPosition.xy * 0.5 + vec2(0.5, 0.5);
}
\ 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