Slightly adjust z-values calculated in the vertex shader so OGL does not clip the
final rendering of (at least) Sonic Unleashed. This should be (nearly) invisible in Z16 depth copies and in games, but there is some chance that it collides with other such border cases. There probably is some room to decrease the adjustment but 9999999/10000000 is not enough. A static offset may be an option, too. I don't know if the game can/does set something like that. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6225 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
e641323de2
commit
91036ae160
|
@ -507,13 +507,20 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
|
||||||
// this results in a scale from -1..0 to -1..1 after perspective
|
// this results in a scale from -1..0 to -1..1 after perspective
|
||||||
// divide
|
// divide
|
||||||
WRITE(p, "o.pos.z = o.pos.w + o.pos.z * 2.0f;\n");
|
WRITE(p, "o.pos.z = o.pos.w + o.pos.z * 2.0f;\n");
|
||||||
|
|
||||||
|
// Sonic Unleashed puts its final rendering at the near or
|
||||||
|
// far plane of the viewing frustrum(actually box, they use
|
||||||
|
// orthogonal projection for that), and we end up putting it
|
||||||
|
// just beyond, and the rendering gets clipped away. (The
|
||||||
|
// primitive gets dropped)
|
||||||
|
WRITE(p, "o.pos.z = o.pos.z * 1048575.0f/1048576.0f;\n");
|
||||||
|
|
||||||
// the next steps of the OGL pipeline are:
|
// the next steps of the OGL pipeline are:
|
||||||
// o.pos.xyz /= o.pos.w; //perspective divide
|
// (x_c,y_c,z_c,w_c) = o.pos //switch to OGL spec terminology
|
||||||
// o.pos.z = clamp(o.pos.z,-1,1) //clamp to -1..1
|
// clipping to -w_c <= (x_c,y_c,z_c) <= w_c
|
||||||
// o.pos.z = (o.pos.z+1)/2; //scale to 0..1
|
// (x_d,y_d,z_d) = (x_c,y_c,z_c)/w_c//perspective divide
|
||||||
// o.pos.z = o.pos.z/(glFar-glNear))+glNear
|
// z_w = (f-n)/2*z_d + (n+f)/2
|
||||||
//scale to glNear..glFar of glDepthRange
|
// z_w now contains the value to go to the 0..1 depth buffer
|
||||||
// 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
|
//trying to get the correct semantic while not using glDepthRange
|
||||||
//seems to get rather complicated
|
//seems to get rather complicated
|
||||||
|
|
Loading…
Reference in New Issue