diff options
| author | Pierre Bourdon <delroth@gmail.com> | 2014-08-17 22:08:42 +0200 |
|---|---|---|
| committer | Pierre Bourdon <delroth@gmail.com> | 2014-08-17 22:08:42 +0200 |
| commit | 9e2fbaf40551b6d037a94274433b03c580dc1604 (patch) | |
| tree | eee9bed87f65f73765e0a6578c6542b246a10c34 /Source/Core/VideoBackends/OGL/TextureCache.cpp | |
| parent | 15a3b30e27121ad89805b2e3ac8920d3a5e92960 (diff) | |
| parent | 97dce14368c3323b9738ba661cf3bcabcb0e670d (diff) | |
Merge pull request #823 from KScorp/depthmatrixshaders
Fixed depth matrix shaders in OpenGL and Direct3D to be more precise.
Diffstat (limited to 'Source/Core/VideoBackends/OGL/TextureCache.cpp')
| -rw-r--r-- | Source/Core/VideoBackends/OGL/TextureCache.cpp | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/Source/Core/VideoBackends/OGL/TextureCache.cpp b/Source/Core/VideoBackends/OGL/TextureCache.cpp index 9837795ce6..38cbcc388a 100644 --- a/Source/Core/VideoBackends/OGL/TextureCache.cpp +++ b/Source/Core/VideoBackends/OGL/TextureCache.cpp @@ -358,9 +358,29 @@ TextureCache::TextureCache() "\n" "void main(){\n" " vec4 texcol = texture(samp9, uv0);\n" - " vec4 EncodedDepth = fract((texcol.r * (16777215.0/16777216.0)) * vec4(1.0,256.0,256.0*256.0,1.0));\n" - " texcol = round(EncodedDepth * (16777216.0/16777215.0) * vec4(255.0,255.0,255.0,15.0)) / vec4(255.0,255.0,255.0,15.0);\n" - " ocol0 = texcol * mat4(colmat[0], colmat[1], colmat[2], colmat[3]) + colmat[4];" + + // 255.99998474121 = 16777215/16777216*256 + " float workspace = texcol.x * 255.99998474121;\n" + + " texcol.x = floor(workspace);\n" // x component + + " workspace = workspace - texcol.x;\n" // subtract x component out + " workspace = workspace * 256.0;\n" // shift left 8 bits + " texcol.y = floor(workspace);\n" // y component + + " workspace = workspace - texcol.y;\n" // subtract y component out + " workspace = workspace * 256.0;\n" // shift left 8 bits + " texcol.z = floor(workspace);\n" // z component + + " texcol.w = texcol.x;\n" // duplicate x into w + + " texcol = texcol / 255.0;\n" // normalize components to [0.0..1.0] + + " texcol.w = texcol.w * 15.0;\n" + " texcol.w = floor(texcol.w);\n" + " texcol.w = texcol.w / 15.0;\n" // w component + + " ocol0 = texcol * mat4(colmat[0], colmat[1], colmat[2], colmat[3]) + colmat[4];\n" "}\n"; const char *VProgram = |
