Fix the OpenGL depth buffer values from the vertex shader.

I am not sure i am understanding what the pipeline really does, and more so what
the GC/WII expects here. If my comments are incorrect, please let me know.

This was tested with MP2:E, ZWW on r6075.


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6078 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
pierre 2010-08-08 22:27:35 +00:00
parent 244191f18f
commit 468b9bfe68
2 changed files with 14 additions and 2 deletions

View File

@ -22,7 +22,7 @@ static const char ID[4] = {'D', 'C', 'A', 'C'};
// Update this to the current SVN revision every time you change shader generation code.
// We don't automatically get this from SVN_REV because that would mean regenerating the
// shader cache for every revision, graphics-related or not, which is simply annoying.
const int version = 5896;
const int version = 6078;
LinearDiskCache::LinearDiskCache()
: file_(NULL), num_entries_(0) {

View File

@ -468,7 +468,19 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
if (is_d3d) {
WRITE(p, "o.pos.z = "I_DEPTHPARAMS".x * o.pos.w + o.pos.z * "I_DEPTHPARAMS".y;\n");
} else {
WRITE(p, "o.pos.z = "I_DEPTHPARAMS".x * o.pos.w + o.pos.z * "I_DEPTHPARAMS".y * 2.0f;\n");
// this results in a scale from -1..0 to -1..1 after perspective
// divide
WRITE(p, "o.pos.z = o.pos.w + o.pos.z * 2.0f;\n");
// the next steps of the OGL pipeline are:
// o.pos.xyz /= o.pos.w; //perspective divide
// o.pos.z = clamp(o.pos.z,-1,1) //clamp to -1..1
// o.pos.z = (o.pos.z+1)/2; //scale to 0..1
// o.pos.z = o.pos.z/(glFar-glNear))+glNear
//scale to glNear..glFar of glDepthRange
// o.pos.z now contains the value to go to the 0..1 depth buffer
//trying to get the correct semantic while not using glDepthRange
//seems to get rather complicated
}
WRITE(p, "return o;\n}\n");