So I've been following this project silently for about a year and a half for now as it interested me in the project I'm working on.
I have no c++ knowledge of any sorts, since I am primarily a Java programmer, but I hope I can help with one issue with vertex shaders.
For the longest time, the hardware shaders (Unreal Engine 2 combines vertex and pixel shaders) for some of the effects have not been being rebuilt properly. In d3d8, the shaders work fine, but in d3d8to9 it rebuilds the vertex shaders with wrong instructions.
Take for example: the hardware shader DynamicHologram, this is how it appears in editor
(I'm using quote since the code tag does not want to work with it)
vs.1.1
; Get the Position
mov r3, v0
; Add big rare flicker
mul r3.z, r3, c21
; Add small frequent flicker
add r3.xyz, r3, c22
////////// Distort /////////
// Position distort
mul r1, v0, c16.x
add r1.xy, r1.zx, r1.yz
// Time distort
mov r2, c17
mad r1, r2.x, c16.y, r1
frc r1.xy, r1 // 0 to 1
// Turn linear into sawtooth
add r1, r1, -c20.y // -.5 to .5
max r7, r1, -r1 // .5 to 0 to .5
// Distort
mul r4, r7, c16.zzww // z = Amp w = 0
mul r4, r4, r3
mov r4.z, r3.z
mov r4.w, c20.z
////////// Scan /////////
mov r5, r3
mov r5.z, c18.y
////////// Combine /////////
// If z > Scan then Distort
sge r0.x, r3.z, c18.x
// if z < distort and > Scan then scan
slt r0.y, r3.z, c18.x
sge r0.z, r3.z, c18.y
mul r0.y, r0.y, r0.z
// if z < Scan then scan
slt r0.z, r3.z, c18.y
mul r1, r4, r0.x
mad r1, r5, r0.y, r1
mad r3, r3, r0.z, r1
////////// Transform /////////
;transform position
dp4 r4.x, r3, c0
dp4 r4.y, r3, c1
dp4 r4.z, r3, c2
dp4 r4.w, r3, c3
/*;; CAMERA SCAN (in screen space)
; Interpolate with scan position
; Compare world space position
sge r5.x, r3.z, c31.x
; Get 1- scan
add r5.y, c20.z, -r5.x
mul r6, r5.x, c30
mad r4, r5.y, r4, r6
;; END CAMERA SCAN
*/
mov oPos, r4
;transform normal
dp3 r0.x, v1, c5
dp3 r0.y, v1, c6
dp3 r0.z, v1, c7
;normalize normal
dp3 r0.w, r0, r0
rsq r0.w, r0.w
mul r0, r0, r0.w
;compute world space position
dp4 r1.x, v0, c11
dp4 r1.y, v0, c12
dp4 r1.z, v0, c13
dp4 r1.w, v0, c14
;vector from point to eye
add r2, c10, -r1
;normalize e
dp3 r2.w, r2, r2
rsq r2.w, r2.w
mul r2, r2, r2.w
; eye dot n
dp3 r1, r2, r0
/*
mov r8, c16.y
mad r7, r8, c20.y, c20.y
max r7, r7, c20.y
mul r3, r1, r7
mul r3, r3, c15.x
mad r3, r1, c15.y, r3
*/
mul r3, r1, c15.y
add oT0.x, r3, c[20] ; add const offset held in c[20]
; Base Texture
mov oT1, v2
// Get Speed
mov r5, c25
mul r5, r5, c26.z
; Scale Noise Texture 2
;mul r6, r4, c26.y
mul r6, v0.zx, c26.y
// Add direction
mad oT2.xy, r5, c28, r6.yx
; Use the Dot as brightness and add flicker
mul oD0, r1, c22.x
mov oFog.x, c20.x
vs_1_1
dcl_position v0
dcl_blendweight v1
dcl_blendindices v2
mov r7, c0 /* initialize register r7 */
mov r6, c0 /* initialize register r6 */
mov r5, c0 /* initialize register r5 */
mov r4, c0 /* initialize register r4 */
mov r3, c0 /* initialize register r3 */
mov r2, c0 /* initialize register r2 */
mov r1, c0 /* initialize register r1 */
mov r0, c0 /* initialize register r0 */
mov oT2, c0 /* initialize output register oT2 */
mov oT1, c0 /* initialize output register oT1 */
mov oT0, c0 /* initialize output register oT0 */
mov oD0, c0 /* initialize output register oD0 */
mov r3, v0
mul r3.z, r3, c21
add r3.xyz, r3, c22
mul r1, v0, c16.x
add r1.xy, r1.zxxx, r1.yzzz
mov r2, c17
mad r1, r2.x, c16.y, r1
frc r1.xy, r1
add r1, r1, -c20.y
max r7, r1, -r1
mul r4, r7, c16.zzww
mul r4, r4, r3
mov r4.z, r3.z
mov r4.w, c20.z
mov r5, r3
mov r5.z, c18.y
sge r0.x, r3.z, c18.x
slt r0.y, r3.z, c18.x
sge r0.z, r3.z, c18.y
mul r0.y, r0.y, r0.z
slt r0.z, r3.z, c18.y
mul r1, r4, r0.x
mad r1, r5, r0.y, r1
mad r3, r3, r0.z, r1
dp4 r4.x, r3, c0
dp4 r4.y, r3, c1
dp4 r4.z, r3, c2
dp4 r4.w, r3, c3
mov oPos, r4
dp3 r0.x, v1, c5
dp3 r0.y, v1, c6
dp3 r0.z, v1, c7
dp3 r0.w, r0, r0
rsq r0.w, r0.w
mul r0, r0, r0.w
dp4 r1.x, v0, c11
dp4 r1.y, v0, c12
dp4 r1.z, v0, c13
dp4 r1.w, v0, c14
add r2, c10, -r1
dp3 r2.w, r2, r2
rsq r2.w, r2.w
mul r2, r2, r2.w
dp3 r1, r2, r0
mul r3, r1, c15.y
add oT0.x, r3, c20
mov oT1, v2
mov r5, c25
mul r5, r5, c26.z
mul r6, v0.zxxx, c26.y
mad oT2.xy, r5, c28, r6.yxxx
mul oD0, r1, c22.x
mov oFog /* removed swizzle */, c2.x /* select single component */0.x
I looked up the error and 88760B59 means invalid data (D3DXERR_INVALIDDATA).
vs_1_1
dcl_position v0
dcl_blendweight v1
dcl_blendindices v2
mov r7, c0 /* initialize register r7 */
mov r6, c0 /* initialize register r6 */
mov r5, c0 /* initialize register r5 */
mov r4, c0 /* initialize register r4 */
mov r3, c0 /* initialize register r3 */
mov r2, c0 /* initialize register r2 */
mov r1, c0 /* initialize register r1 */
mov r0, c0 /* initialize register r0 */
mov oT2, c0 /* initialize output register oT2 */
mov oT1, c0 /* initialize output register oT1 */
mov oT0, c0 /* initialize output register oT0 */
mov oD0, c0 /* initialize output register oD0 */
mov r3, v0
mul r3.z, r3, c21
add r3.xyz, r3, c22
mul r1, v0, c16.x
add r1.xy, r1.zxxx, r1.yzzz
mov r2, c17
mad r1, r2.x, c16.y, r1
frc r1.xy, r1
add r1, r1, -c20.y
max r7, r1, -r1
mul r4, r7, c16.zzww
mul r4, r4, r3
mov r4.z, r3.z
mov r4.w, c20.z
mov r5, r3
mov r5.z, c18.y
sge r0.x, r3.z, c18.x
slt r0.y, r3.z, c18.x
sge r0.z, r3.z, c18.y
mul r0.y, r0.y, r0.z
slt r0.z, r3.z, c18.y
mul r1, r4, r0.x
mad r1, r5, r0.y, r1
mad r3, r3, r0.z, r1
dp4 r4.x, r3, c0
dp4 r4.y, r3, c1
dp4 r4.z, r3, c2
dp4 r4.w, r3, c3
mov oPos, r4
dp3 r0.x, v1, c5
dp3 r0.y, v1, c6
dp3 r0.z, v1, c7
dp3 r0.w, r0, r0
rsq r0.w, r0.w
mul r0, r0, r0.w
dp4 r1.x, v0, c11
dp4 r1.y, v0, c12
dp4 r1.z, v0, c13
dp4 r1.w, v0, c14
add r2, c10, -r1
dp3 r2.w, r2, r2
rsq r2.w, r2.w
mul r2, r2, r2.w
dp3 r1, r2, r0
mul r3, r1, c15.y
add oT0.x, r3, c20
mov oT1, v2
mov r5, c25
mul r5, r5, c26.z
mul r6, v0.zxxx, c26.y
mad oT2.xy, r5, c28, r6.yxxx
mul oD0, r1, c22.x
mov oFog /* removed swizzle */, c2.x
// approximately 55 instruction slots used
Redirecting 'IDirect3DDevice8::CreatePixelShader(0F9C7C58, 11CC17B0, 11D866C0)' ...
Disassembling shader and translating assembly to Direct3D 9 compatible code ...
Dumping translated shader assembly:
ps_1_3
tex t0
tex t1
tex t2
dp3_sat r1, t1, c0
mul r0, r1, t0
mul r0.xyz, r0, t2
- mov r0.w, t0.w
mul r0.xyz, r0, v0
mul r0, r0, c1
// approximately 8 instruction slots used (3 texture, 5 arithmetic)
Now, I do not know c++ or directx at all, so I don't know how to fix it in d3d8to9, but this is the information I've collected on this issue, I only wanted to submit this once I had everything and had time to try everything.
A few other vertex shaders do not recompile correctly, but I do not know exactly which ones they are.
The primary ones that do not recompile are ones used for bump mapping, specularity, and the one hologram shader that is used on a lot of different objects throughout the game.
If anyone needs more information, like the raw log files, pictures, or the code to other shaders feel free to ask.