Permalink
Browse files

Fix texture coord calculation in depthtile2_fp.glsl.

  • Loading branch information...
1 parent 4a361fb commit 45089b50834b8ca194e9c98554a75d986152d211 @gimhael gimhael committed Mar 11, 2016
Showing with 57 additions and 62 deletions.
  1. +53 −56 daemon/src/engine/renderer/shaders.cpp
  2. +4 −6 main/glsl/depthtile2_fp.glsl
@@ -2559,62 +2559,59 @@ const char depthtile2_fp[] = {
0x67, 0x6c, 0x73, 0x6c, 0x20, 0x2a, 0x2f, 0x0a, 0x0a, 0x75, 0x6e, 0x69,
0x66, 0x6f, 0x72, 0x6d, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72,
0x32, 0x44, 0x20, 0x75, 0x5f, 0x44, 0x65, 0x70, 0x74, 0x68, 0x4d, 0x61,
- 0x70, 0x3b, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x20, 0x76, 0x65,
- 0x63, 0x32, 0x20, 0x70, 0x69, 0x78, 0x65, 0x6c, 0x53, 0x63, 0x61, 0x6c,
- 0x65, 0x20, 0x3d, 0x20, 0x72, 0x5f, 0x46, 0x42, 0x75, 0x66, 0x53, 0x63,
- 0x61, 0x6c, 0x65, 0x3b, 0x0a, 0x0a, 0x23, 0x69, 0x66, 0x20, 0x5f, 0x5f,
- 0x56, 0x45, 0x52, 0x53, 0x49, 0x4f, 0x4e, 0x5f, 0x5f, 0x20, 0x3e, 0x20,
- 0x31, 0x32, 0x30, 0x0a, 0x6f, 0x75, 0x74, 0x20, 0x76, 0x65, 0x63, 0x34,
- 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72,
- 0x3b, 0x0a, 0x23, 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x23, 0x64, 0x65, 0x66,
- 0x69, 0x6e, 0x65, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x43, 0x6f,
- 0x6c, 0x6f, 0x72, 0x20, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43,
- 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x23, 0x65, 0x6e, 0x64, 0x69, 0x66,
- 0x0a, 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x09, 0x6d, 0x61, 0x69, 0x6e, 0x28,
- 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x73,
- 0x74, 0x20, 0x3d, 0x20, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43,
- 0x6f, 0x6f, 0x72, 0x64, 0x2e, 0x73, 0x74, 0x20, 0x2a, 0x20, 0x34, 0x2e,
- 0x30, 0x20, 0x2a, 0x20, 0x70, 0x69, 0x78, 0x65, 0x6c, 0x53, 0x63, 0x61,
- 0x6c, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20,
- 0x78, 0x2c, 0x20, 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34,
- 0x20, 0x61, 0x63, 0x63, 0x75, 0x6d, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63,
- 0x34, 0x28, 0x20, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x39, 0x39, 0x39, 0x39,
- 0x39, 0x2e, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x30, 0x2e,
- 0x30, 0x20, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74,
- 0x20, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x20, 0x3d, 0x20, 0x30, 0x2e, 0x30,
- 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x66, 0x6f, 0x72, 0x28, 0x20, 0x78, 0x20,
- 0x3d, 0x20, 0x2d, 0x31, 0x2e, 0x35, 0x3b, 0x20, 0x78, 0x20, 0x3c, 0x20,
- 0x32, 0x2e, 0x30, 0x3b, 0x20, 0x78, 0x20, 0x2b, 0x3d, 0x20, 0x31, 0x2e,
- 0x30, 0x20, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f,
- 0x72, 0x28, 0x20, 0x79, 0x20, 0x3d, 0x20, 0x2d, 0x31, 0x2e, 0x35, 0x3b,
- 0x20, 0x79, 0x20, 0x3c, 0x20, 0x32, 0x2e, 0x30, 0x3b, 0x20, 0x79, 0x20,
- 0x2b, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x20, 0x29, 0x20, 0x7b, 0x0a, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x64, 0x61,
- 0x74, 0x61, 0x20, 0x3d, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65,
- 0x32, 0x44, 0x28, 0x20, 0x75, 0x5f, 0x44, 0x65, 0x70, 0x74, 0x68, 0x4d,
- 0x61, 0x70, 0x2c, 0x20, 0x73, 0x74, 0x20, 0x2b, 0x20, 0x76, 0x65, 0x63,
- 0x32, 0x28, 0x78, 0x2c, 0x20, 0x79, 0x29, 0x20, 0x2a, 0x20, 0x70, 0x69,
- 0x78, 0x65, 0x6c, 0x53, 0x63, 0x61, 0x6c, 0x65, 0x20, 0x29, 0x3b, 0x0a,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x28, 0x20, 0x64, 0x61,
- 0x74, 0x61, 0x2e, 0x79, 0x20, 0x3c, 0x20, 0x39, 0x39, 0x39, 0x39, 0x39,
- 0x2e, 0x30, 0x20, 0x29, 0x20, 0x7b, 0x0a, 0x09, 0x61, 0x63, 0x63, 0x75,
- 0x6d, 0x2e, 0x78, 0x20, 0x3d, 0x20, 0x6d, 0x61, 0x78, 0x28, 0x20, 0x61,
- 0x63, 0x63, 0x75, 0x6d, 0x2e, 0x78, 0x2c, 0x20, 0x64, 0x61, 0x74, 0x61,
- 0x2e, 0x78, 0x20, 0x29, 0x3b, 0x0a, 0x09, 0x61, 0x63, 0x63, 0x75, 0x6d,
- 0x2e, 0x79, 0x20, 0x3d, 0x20, 0x6d, 0x69, 0x6e, 0x28, 0x20, 0x61, 0x63,
- 0x63, 0x75, 0x6d, 0x2e, 0x79, 0x2c, 0x20, 0x64, 0x61, 0x74, 0x61, 0x2e,
- 0x79, 0x20, 0x29, 0x3b, 0x0a, 0x09, 0x61, 0x63, 0x63, 0x75, 0x6d, 0x2e,
- 0x7a, 0x77, 0x20, 0x2b, 0x3d, 0x20, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x7a,
- 0x77, 0x3b, 0x0a, 0x09, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x20, 0x2b, 0x3d,
- 0x20, 0x31, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x7d, 0x0a,
- 0x0a, 0x20, 0x20, 0x69, 0x66, 0x28, 0x20, 0x63, 0x6f, 0x75, 0x6e, 0x74,
- 0x20, 0x3e, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x20, 0x29, 0x20, 0x7b, 0x0a,
- 0x20, 0x20, 0x20, 0x20, 0x61, 0x63, 0x63, 0x75, 0x6d, 0x2e, 0x7a, 0x77,
- 0x20, 0x2a, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x20, 0x2f, 0x20, 0x63, 0x6f,
- 0x75, 0x6e, 0x74, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x0a, 0x0a, 0x20, 0x20,
- 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20,
- 0x3d, 0x20, 0x61, 0x63, 0x63, 0x75, 0x6d, 0x3b, 0x0a, 0x7d, 0x0a, 0x00
+ 0x70, 0x3b, 0x0a, 0x0a, 0x23, 0x69, 0x66, 0x20, 0x5f, 0x5f, 0x56, 0x45,
+ 0x52, 0x53, 0x49, 0x4f, 0x4e, 0x5f, 0x5f, 0x20, 0x3e, 0x20, 0x31, 0x32,
+ 0x30, 0x0a, 0x6f, 0x75, 0x74, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x6f,
+ 0x75, 0x74, 0x70, 0x75, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a,
+ 0x23, 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x23, 0x64, 0x65, 0x66, 0x69, 0x6e,
+ 0x65, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x43, 0x6f, 0x6c, 0x6f,
+ 0x72, 0x20, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c,
+ 0x6f, 0x72, 0x3b, 0x0a, 0x23, 0x65, 0x6e, 0x64, 0x69, 0x66, 0x0a, 0x0a,
+ 0x76, 0x6f, 0x69, 0x64, 0x09, 0x6d, 0x61, 0x69, 0x6e, 0x28, 0x29, 0x0a,
+ 0x7b, 0x0a, 0x20, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x73, 0x74, 0x20,
+ 0x3d, 0x20, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6f,
+ 0x72, 0x64, 0x2e, 0x73, 0x74, 0x20, 0x2a, 0x20, 0x72, 0x5f, 0x74, 0x69,
+ 0x6c, 0x65, 0x53, 0x74, 0x65, 0x70, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c,
+ 0x6f, 0x61, 0x74, 0x20, 0x78, 0x2c, 0x20, 0x79, 0x3b, 0x0a, 0x20, 0x20,
+ 0x76, 0x65, 0x63, 0x34, 0x20, 0x61, 0x63, 0x63, 0x75, 0x6d, 0x20, 0x3d,
+ 0x20, 0x76, 0x65, 0x63, 0x34, 0x28, 0x20, 0x30, 0x2e, 0x30, 0x2c, 0x20,
+ 0x39, 0x39, 0x39, 0x39, 0x39, 0x2e, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30,
+ 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x20, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x66,
+ 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x20, 0x3d,
+ 0x20, 0x30, 0x2e, 0x30, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x66, 0x6f, 0x72,
+ 0x28, 0x20, 0x78, 0x20, 0x3d, 0x20, 0x2d, 0x30, 0x2e, 0x33, 0x37, 0x35,
+ 0x3b, 0x20, 0x78, 0x20, 0x3c, 0x20, 0x30, 0x2e, 0x35, 0x3b, 0x20, 0x78,
+ 0x20, 0x2b, 0x3d, 0x20, 0x30, 0x2e, 0x32, 0x35, 0x20, 0x29, 0x20, 0x7b,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x72, 0x28, 0x20, 0x79, 0x20,
+ 0x3d, 0x20, 0x2d, 0x30, 0x2e, 0x33, 0x37, 0x35, 0x3b, 0x20, 0x79, 0x20,
+ 0x3c, 0x20, 0x30, 0x2e, 0x35, 0x3b, 0x20, 0x79, 0x20, 0x2b, 0x3d, 0x20,
+ 0x30, 0x2e, 0x32, 0x35, 0x20, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x64, 0x61, 0x74, 0x61,
+ 0x20, 0x3d, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x44,
+ 0x28, 0x20, 0x75, 0x5f, 0x44, 0x65, 0x70, 0x74, 0x68, 0x4d, 0x61, 0x70,
+ 0x2c, 0x20, 0x73, 0x74, 0x20, 0x2b, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28,
+ 0x78, 0x2c, 0x20, 0x79, 0x29, 0x20, 0x2a, 0x20, 0x72, 0x5f, 0x74, 0x69,
+ 0x6c, 0x65, 0x53, 0x74, 0x65, 0x70, 0x20, 0x29, 0x3b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x28, 0x20, 0x64, 0x61, 0x74, 0x61,
+ 0x2e, 0x79, 0x20, 0x3c, 0x20, 0x39, 0x39, 0x39, 0x39, 0x39, 0x2e, 0x30,
+ 0x20, 0x29, 0x20, 0x7b, 0x0a, 0x09, 0x61, 0x63, 0x63, 0x75, 0x6d, 0x2e,
+ 0x78, 0x20, 0x3d, 0x20, 0x6d, 0x61, 0x78, 0x28, 0x20, 0x61, 0x63, 0x63,
+ 0x75, 0x6d, 0x2e, 0x78, 0x2c, 0x20, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x78,
+ 0x20, 0x29, 0x3b, 0x0a, 0x09, 0x61, 0x63, 0x63, 0x75, 0x6d, 0x2e, 0x79,
+ 0x20, 0x3d, 0x20, 0x6d, 0x69, 0x6e, 0x28, 0x20, 0x61, 0x63, 0x63, 0x75,
+ 0x6d, 0x2e, 0x79, 0x2c, 0x20, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x79, 0x20,
+ 0x29, 0x3b, 0x0a, 0x09, 0x61, 0x63, 0x63, 0x75, 0x6d, 0x2e, 0x7a, 0x77,
+ 0x20, 0x2b, 0x3d, 0x20, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x7a, 0x77, 0x3b,
+ 0x0a, 0x09, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x20, 0x2b, 0x3d, 0x20, 0x31,
+ 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x7d, 0x0a, 0x0a, 0x20,
+ 0x20, 0x69, 0x66, 0x28, 0x20, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x20, 0x3e,
+ 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x20, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x61, 0x63, 0x63, 0x75, 0x6d, 0x2e, 0x7a, 0x77, 0x20, 0x2a,
+ 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x20, 0x2f, 0x20, 0x63, 0x6f, 0x75, 0x6e,
+ 0x74, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x0a, 0x0a, 0x20, 0x20, 0x6f, 0x75,
+ 0x74, 0x70, 0x75, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20,
+ 0x61, 0x63, 0x63, 0x75, 0x6d, 0x3b, 0x0a, 0x7d, 0x0a, 0x00
};
const char depthtile2_vp[] = {
0x2f, 0x2a, 0x0a, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,
@@ -24,8 +24,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
uniform sampler2D u_DepthMap;
-const vec2 pixelScale = r_FBufScale;
-
#if __VERSION__ > 120
out vec4 outputColor;
#else
@@ -34,14 +32,14 @@ out vec4 outputColor;
void main()
{
- vec2 st = gl_FragCoord.st * 4.0 * pixelScale;
+ vec2 st = gl_FragCoord.st * r_tileStep;
float x, y;
vec4 accum = vec4( 0.0, 99999.0, 0.0, 0.0 );
float count = 0.0;
- for( x = -1.5; x < 2.0; x += 1.0 ) {
- for( y = -1.5; y < 2.0; y += 1.0 ) {
- vec4 data = texture2D( u_DepthMap, st + vec2(x, y) * pixelScale );
+ for( x = -0.375; x < 0.5; x += 0.25 ) {
+ for( y = -0.375; y < 0.5; y += 0.25 ) {
+ vec4 data = texture2D( u_DepthMap, st + vec2(x, y) * r_tileStep );
if( data.y < 99999.0 ) {
accum.x = max( accum.x, data.x );
accum.y = min( accum.y, data.y );

0 comments on commit 45089b5

Please sign in to comment.