Commit 49a02b55 authored by Christopher Tenter's avatar Christopher Tenter

fix shaders for resolving multisampled textures

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@20475 383ad7c9-94d9-4d36-a494-682f7c89f535
parent f6d7d6f2
......@@ -14,9 +14,9 @@ vec4 ReadMultisampledTexture(in sampler2DMS tex, in ivec2 pos, in int numSamples
return texel / float(numSamples);
}
vec4 ReadMultisampledTexture(in sampler2DMS tex, in vec2 texcood, in int numSamples)
vec4 ReadMultisampledTexture(in sampler2DMS tex, in vec2 texcoord, in int numSamples)
{
ivec2 pos = int(floor(texcoord));
ivec2 pos = ivec2(texcoord * vec2(textureSize(tex)));
return ReadMultisampledTexture(tex, pos, numSamples);
}
......@@ -35,9 +35,9 @@ vec4 ReadMultisampledTexture(in sampler2DMS tex, in ivec2 pos, in int numSamples
return texel;
}
vec4 ReadMultisampledTexture(in sampler2DMS tex, in vec2 texcood, in int numSamples, in samplerBuffer filterWeights)
vec4 ReadMultisampledTexture(in sampler2DMS tex, in vec2 texcoord, in int numSamples, in samplerBuffer filterWeights)
{
ivec2 pos = int(floor(texcoord));
ivec2 pos = ivec2(texcoord * vec2(textureSize(tex)));
return ReadMultisampledTexture(tex, pos, numSamples, filterWeights);
}
......
#version 150
#include "msaa.glsl"
uniform sampler2DMS inputTex;
uniform sampler2DMS inputDepthTex;
uniform int numSamples;
in vec2 vTexCoord;
out vec4 outFragment;
void main()
{
ivec2 pixelPos = ivec2( vTexCoord * vec2(textureSize(inputTex).xy) );
outFragment = ReadMultisampledTexture(inputTex, pixelPos, numSamples);
// outFragment = vec4(1,1,0,1);
// outFragment = texelFetch(inputTex, pixelPos, 0);
// high variance in depth at edges, so averaging depth values doesn't make sense
// -> choose sample closest to viewer as depth
float d = texelFetch(inputDepthTex, pixelPos, 0).x;
for (int i = 1; i < numSamples; ++i)
{
vec4 sample = texelFetch(inputDepthTex, pixelPos, i);
d = min(d, sample.x);
}
gl_FragDepth = d;
}
\ 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