mirror of
https://github.com/libretro/desmume.git
synced 2024-11-23 08:10:03 +00:00
OpenGL Renderer: When rendering the main geometry, adjusts all Z-positions in the vertex shader so that Z is more likely to naturally fall between the depth range of 0.0 and 1.0. Further mitigates the performance cost of using the NDS-Style Depth Calculation option.
This commit is contained in:
parent
9b1ce0efc3
commit
0f045d430c
@ -1,7 +1,7 @@
|
||||
/*
|
||||
Copyright (C) 2006 yopyop
|
||||
Copyright (C) 2006-2007 shash
|
||||
Copyright (C) 2008-2018 DeSmuME team
|
||||
Copyright (C) 2008-2019 DeSmuME team
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -294,7 +294,8 @@ void main() \n\
|
||||
\n\
|
||||
vtxTexCoord = texScaleMtx * inTexCoord0; \n\
|
||||
vtxColor = vec4(inColor / 63.0, polyAlpha); \n\
|
||||
gl_Position = inPosition; \n\
|
||||
gl_Position.xyw = inPosition.xyw;\n\
|
||||
gl_Position.z = (inPosition.z + inPosition.w) / 2.0;\n\
|
||||
} \n\
|
||||
"};
|
||||
|
||||
@ -419,10 +420,10 @@ void main()\n\
|
||||
#endif\n\
|
||||
#else\n\
|
||||
#if ENABLE_W_DEPTH\n\
|
||||
gl_FragDepth = clamp( (4096.0/gl_FragCoord.w) / 16777215.0, 0.0, 1.0 );\n\
|
||||
gl_FragDepth = (4096.0/gl_FragCoord.w) / 16777215.0;\n\
|
||||
#else\n\
|
||||
// hack: when using z-depth, drop some LSBs so that the overworld map in Dragon Quest IV shows up correctly\n\
|
||||
gl_FragDepth = clamp( (floor(gl_FragCoord.z * 4194303.0) * 4.0) / 16777215.0, 0.0, 1.0 );\n\
|
||||
gl_FragDepth = (floor(gl_FragCoord.z * 4194303.0) * 4.0) / 16777215.0;\n\
|
||||
#endif\n\
|
||||
#endif\n\
|
||||
#endif\n\
|
||||
|
@ -146,7 +146,8 @@ void main()\n\
|
||||
\n\
|
||||
vtxTexCoord = texScaleMtx * inTexCoord0;\n\
|
||||
vtxColor = vec4(inColor / 63.0, polyAlpha);\n\
|
||||
gl_Position = inPosition;\n\
|
||||
gl_Position.xyw = inPosition.xyw;\n\
|
||||
gl_Position.z = (inPosition.z + inPosition.w) / 2.0;\n\
|
||||
}\n\
|
||||
"};
|
||||
|
||||
@ -290,10 +291,10 @@ void main()\n\
|
||||
#endif\n\
|
||||
#else\n\
|
||||
#if ENABLE_W_DEPTH\n\
|
||||
gl_FragDepth = clamp( (4096.0/gl_FragCoord.w) / 16777215.0, 0.0, 1.0 );\n\
|
||||
gl_FragDepth = (4096.0/gl_FragCoord.w) / 16777215.0;\n\
|
||||
#else\n\
|
||||
// hack: when using z-depth, drop some LSBs so that the overworld map in Dragon Quest IV shows up correctly\n\
|
||||
gl_FragDepth = clamp( (floor(gl_FragCoord.z * 4194303.0) * 4.0) / 16777215.0, 0.0, 1.0 );\n\
|
||||
gl_FragDepth = (floor(gl_FragCoord.z * 4194303.0) * 4.0) / 16777215.0;\n\
|
||||
#endif\n\
|
||||
#endif\n\
|
||||
#endif\n\
|
||||
|
Loading…
Reference in New Issue
Block a user