dolphin/Source/Core/VideoCommon
Pierre Bourdon ed67d1ae2f Fix the Zelda: The Wind Waker heat effect glitch.
Let's talk a bit about this bug. 12nd oldest bug not fixed in Dolphin, it was a
lot of fun to debug and it kept me busy for a while :)

Shoutout to Nintendo for framework.map, without which this could have taken a
lot longer.

Basic debugging using apitrace shows that the heat effect is rendered in an
interesting way:
* An EFB copy texture is created, using the hardware scaler to divide the
  texture resolution by two and that way create the blur effect.
* This texture is then warped using indirect texturing: a deformation map is
  used to "move" the texture coordinates used to sample the framebuffer copy.

Pixel shader: http://pastie.org/private/25oe1pqn6s0h5yieks1jfw

Interestingly, when looking at apitrace, the deformation texture was only 4x4
pixels... weird. It also does not have any feature that you would expect from a
deformation map. Seeing how the heat effect glitches, this deformation texture
being wrong looks like a good candidate for the problem. Let's see how it's
loaded!

By NOPing random calls to GXSetTevIndirect, we find a call that when removed
breaks the effect completely. The parameters used for this call come from the
results of methods of JPAExTexShapeArc objects. 3 different objects go through
this code path, by breaking each one we can notice that the one "controlling"
the heat effect is the one at 0x81575b98.

Following the path of this object a bit more, we can see that it has a method
called "getIndTexId". When this is called, the returned texture ID is used to
index a map and get a JPATextureArc object stored at 0x81577bec.

Nice feature of JPATextureArc: they have a getName method. For this object, it
returns "AK_kagerouInd01". We can probably use that to see how this texture
should look like, by loading it "manually" from the Wind Waker DVD.
Unfortunately I don't know how to do that. Fortunately @Abahbob got me the
texture I wanted in less than 10min after I asked him on Twitter.
AK_kagerouInd01 is a 32x32 texture that really looks like a deformation map:
http://i.imgur.com/0TfZEVj.png . Fun fact: "kagerou" means "heat haze" in JP.

So apparently we're not using the right texture object when rendering! The
GXTexObj that maps to the JPATextureArc is at offset 0x81577bf0 and points to
data at 0x80ed0460, but we're loading texture data from 0x0039d860 instead.

I started to suspect the BP write that loads the texture parameters "did not
work" somehow. Logged that and yes: nothing gets loaded to texture stage 1! ...
but it turns out this is normal, the deformation map is loaded to texture stage
5 (hardcoded in the DOL). Wait, why is the TextureCache trying to load from
texture stage 1 then?!

Because someone sucked at hex.

Fixes issue 2338.
2014-01-05 11:33:15 +01:00
..
AVIDump.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
AVIDump.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
BPFunctions.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
BPFunctions.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
BPMemory.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
BPMemory.h Fix the Zelda: The Wind Waker heat effect glitch. 2014-01-05 11:33:15 +01:00
BPStructs.cpp ogl: clamp to edge for out of bound efb access 2014-01-03 08:15:19 +01:00
BPStructs.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
CMakeLists.txt Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
CPMemory.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
CPMemory.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
CommandProcessor.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
CommandProcessor.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
ConstantManager.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
DLCache.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
DLCache_Generic.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
DLCache_x64.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
DataReader.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
Debugger.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
Debugger.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
DriverDetails.cpp Merge branch 'master' into buffer_storage 2013-12-31 19:18:30 -06:00
DriverDetails.h Merge branch 'master' into buffer_storage 2013-12-31 19:18:30 -06:00
EmuWindow.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
EmuWindow.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
FPSCounter.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
FPSCounter.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
Fifo.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
Fifo.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
FramebufferManagerBase.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
FramebufferManagerBase.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
HiresTextures.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
HiresTextures.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
ImageWrite.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
ImageWrite.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
IndexGenerator.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
IndexGenerator.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
LightingShaderGen.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
LookUpTables.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
MainBase.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
MainBase.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
NativeVertexFormat.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
OnScreenDisplay.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
OnScreenDisplay.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
OpcodeDecoding.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
OpcodeDecoding.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
PerfQueryBase.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
PerfQueryBase.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
PixelEngine.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
PixelEngine.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
PixelShaderGen.cpp OpenGL: use shader 420pack if available to staticly bind ubo location 2014-01-05 10:38:45 +01:00
PixelShaderGen.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
PixelShaderManager.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
PixelShaderManager.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
RenderBase.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
RenderBase.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
ShaderGenCommon.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
Statistics.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
Statistics.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
TextureCacheBase.cpp TextureCache: Warn for invalid custom textures 2014-01-03 14:30:12 +01:00
TextureCacheBase.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
TextureConversionShader.cpp OpenGL: drop UBO-workaround usage for efb2ram shaders 2014-01-05 09:52:26 +01:00
TextureConversionShader.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
TextureDecoder.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
TextureDecoder_Generic.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
TextureDecoder_x64.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
VertexLoader.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
VertexLoader.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
VertexLoaderManager.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
VertexLoaderManager.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
VertexLoader_Color.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
VertexLoader_Color.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
VertexLoader_Normal.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
VertexLoader_Normal.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
VertexLoader_Position.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
VertexLoader_Position.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
VertexLoader_TextCoord.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
VertexLoader_TextCoord.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
VertexManagerBase.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
VertexManagerBase.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
VertexShaderGen.cpp OpenGL: use shader 420pack if available to staticly bind ubo location 2014-01-05 10:38:45 +01:00
VertexShaderGen.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
VertexShaderManager.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
VertexShaderManager.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
VideoBackendBase.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
VideoBackendBase.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
VideoCommon.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
VideoCommon.vcxproj Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
VideoCommon.vcxproj.filters Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
VideoConfig.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
VideoConfig.h OpenGL: use shader 420pack if available to staticly bind ubo location 2014-01-05 10:38:45 +01:00
VideoState.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
VideoState.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
XFMemory.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
XFMemory.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
XFStructs.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
XFStructs.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
memcpy_amd.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
stdafx.cpp Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00
stdafx.h Remove unnecessary Src/ folders 2013-12-31 14:03:19 -05:00