Difference between revisions of "Tony Hawk's Pro Skater 2x"

From xboxdevwiki
Jump to: navigation, search
(Demo)
(Add rough comments, based on skin.xvu knowledge)
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Demo ==
+
{{Game}}
 +
 
 +
== Shaders ==
 +
 
 +
These shaders have been disassembled.
 +
Any comment was added manually and does not come from the game files.
 +
 
 +
=== blackskin.xvu ===
 +
 
 +
<pre>
 +
xvs.1.1
 +
add r2.x, c32.z, -v1.x
 +
dph r3.x, v0, c0
 +
dph r3.y, v0, c1
 +
dph r3.z, v0, c2
 +
dph r4.x, v0, c3
 +
dph r4.y, v0, c4
 +
dph r4.z, v0, c5
 +
mul r5.xyz, r3.xyz, v1.x
 +
mad r6.xyz, r4.xyz, r2.x, r5.xyz
 +
dph oPos.x, r6, c21
 +
dph oPos.y, r6, c22
 +
dph oPos.z, r6, c23
 +
dph oPos.w, r6, c24
 +
mul oPos.xyz, r12, c-38
 +
+rcc r1.x, r12.w
 +
mad oPos.xyz, r12, r1.x, c-37
 +
</pre>
 +
 
 +
=== cloth.xvu ===
 +
 
 +
<pre>
 +
xvs.1.1
 +
 
 +
# Unknown
 +
mov r2.w, c48.x
 +
mul r3.w, r2.w, c80.z
 +
mad r4.xyz, c80.x, v0.xyz, r3.w
 +
 
 +
# Get (1.0 - vertex weight)
 +
add r5.x, c32.z, -v1.x
 +
 
 +
# Transform bone[0] vertex.x
 +
dph r6.x, v0, c0
 +
 
 +
# Unknown
 +
+exp r1.y, r4
 +
 
 +
# Transform bone[0] vertex.y
 +
dph r6.y, v0, c1
 +
 
 +
# Unknown
 +
mul r1.x, r1.y, r1.y
 +
mul r1.z, r1.x, r1.y
 +
dp3 r7.x, r1.xyz, c36
 +
 
 +
# Transform bone[0] vertex.z
 +
dph r6.z, v0, c2
 +
 
 +
# Unknown
 +
+exp r1.y, r4.y
 +
 
 +
# Transform bone[1] vertex.x
 +
dph r8.x, v0, c3
 +
 
 +
# Unknown
 +
mul r1.x, r1.y, r1.y
 +
mul r1.z, r1.x, r1.y
 +
dp3 r7.y, r1.xyz, c36
 +
 
 +
# Transform bone[1] vertex.y
 +
dph r8.y, v0, c4
 +
 
 +
# Unknown
 +
+exp r1.y, r4.z
 +
 
 +
# Transform bone[1] vertex.z
 +
dph r8.z, v0, c5
 +
 
 +
# Unknown
 +
mul r1.x, r1.y, r1.y
 +
mul r1.z, r1.x, r1.y
 +
dp3 r7.z, r1.xyz, c36
 +
 
 +
# Blend vertices: r10.xyz = mix(r8.xyz, r6.xyz, v1.x)
 +
mul r9.xyz, r6.xyz, v1.x
 +
mad r10.xyz, r8.xyz, r5.x, r9.xyz
 +
 
 +
# Unknown
 +
mul r11.w, v3.y, c80.y
 +
mul r0.w, r11.w, c92.w
 +
mad r2.xyz, r7.xyz, r0.w, r10.xyz
 +
mad r3.xyz, -c92.xyz, v3.z, r2.xyz
 +
 
 +
# Transform bone[0] normal ?
 +
dp3 r4.x, v2, c0
 +
dp3 r4.y, v2, c1
 +
dp3 r4.z, v2, c2
 +
 
 +
# Transform bone[1] normal ?
 +
dp3 r6.x, v2, c3
 +
dp3 r6.y, v2, c4
 +
dp3 r6.z, v2, c5
 +
 
 +
# Blend vertices: r8.xyz = mix(r6.xyz, r4.xyz, v1.x)
 +
mul r7.xyz, r4.xyz, v1.x
 +
mad r8.xyz, r6.xyz, r5.x, r7.xyz
 +
 
 +
# Calculate output position
 +
dph oPos.x, r3, c21
 +
dph oPos.y, r3, c22
 +
dph oPos.z, r3, c23
 +
dph oPos.w, r3, c24
 +
 
 +
# Calculation squared normal length
 +
dp3 r8.w, r8.xyz, r8.xyz
 +
 
 +
# Forward texture U
 +
dph oT0.x, v9, c9
 +
 
 +
# Unknown
 +
mov r9, c58
 +
 
 +
# Turn squared normal length into length: r1.w = 1.0 / length(normal)
 +
+rsq r1.w, r8.w
 +
 
 +
# Forward texture V
 +
dph oT0.y, v9, c10
 +
 
 +
# Unknown
 +
mul r10.xyz, r8.xyz, r1.w
 +
dp3 r11.x, r10, -c56
 +
dp3 r11.y, r10, -c57
 +
 
 +
# Generate fog depth (same as oPos.w - somehow not optimized?)
 +
dph oFog.x, r3, c24
 +
 
 +
# Something to do with lighting
 +
max r0.xy, r11.xy, c32.x
 +
mad r2, r0.x, c59, r9
 +
mad r3, r0.y, c60, r2
 +
 
 +
# Viewport or something? (D3D boilerplate part 1)
 +
mul oPos.xyz, r12, c-38
 +
+rcc r1.x, r12.w
 +
 
 +
# Calculate diffuse color
 +
mul oD0, r3, c90
 +
 
 +
# Viewport or something? (D3D boilerplate part 2)
 +
mad oPos.xyz, r12, r1.x, c-37
 +
</pre>
 +
 
 +
=== geom.xvu ===
 +
 
 +
<pre>
 +
xvs.1.1
 +
add r0.xyz, v0.xyz, c91.xyz
 +
mov oD0, v3
 +
dph oPos.x, r0, c21
 +
dph oPos.y, r0, c22
 +
dph oPos.z, r0, c23
 +
dph oPos.w, r0, c24
 +
dph oFog.x, r0, c24
 +
mov oT0.xy, v9
 +
mul oT1.xy, v9, c91.w
 +
mul oPos.xyz, r12, c-38
 +
+rcc r1.x, r12.w
 +
mad oPos.xyz, r12, r1.x, c-37
 +
</pre>
 +
 
 +
=== grass.xvu ===
 +
 
 +
'''Vertex attributes'''
 +
 
 +
* v0.xyz = Position
 +
* v3.xyzw = Diffuse color
 +
* v9.xy = Texture1 coordinates
 +
 
 +
'''Constants'''
 +
 
 +
* c-38.xyz = viewport? (D3D boilerplate)
 +
* c-37.xyz = viewport? (D3D boilerplate)
 +
* c21.xyzw - c24.xyzw = world-view-projection-matrix ?
 +
* c32.w = Texture1 scale
 +
* c91.xyz = Object position
 +
 
 +
'''Code'''
 +
 
 +
<pre>
 +
xvs.1.1
 +
 
 +
# Add object position to vertex position
 +
add r0.xyz, v0, c91
 +
 
 +
# Forward diffuse color
 +
mov oD0, v3
 +
 
 +
# Calculate output position
 +
dph oPos.x, r0, c21
 +
dph oPos.y, r0, c22
 +
dph oPos.z, r0, c23
 +
dph oPos.w, r0, c24
 +
 
 +
# Generate fog depth (same as oPos.w - somehow not optimized?)
 +
dph oFog.x, r0, c24
 +
 
 +
# Scale texture
 +
mul oT0.xy, v9, c32.w
 +
 
 +
# Viewport or something? (D3D boilerplate)
 +
mul oPos.xyz, r12, c-38
 +
+rcc r1.x, r12.w
 +
mad oPos.xyz, r12, r1.x, c-37
 +
</pre>
 +
 
 +
=== projectorlight.xvu ===
 +
 
 +
<pre>
 +
xvs.1.1
 +
dph r2.x, v0, c0
 +
dph r2.y, v0, c1
 +
dph r2.z, v0, c2
 +
dp3 r3.x, v2, c92
 +
dph oPos.x, r2, c21
 +
dph oPos.y, r2, c22
 +
dph oPos.z, r2, c23
 +
dph oPos.w, r2, c24
 +
mad oD0.xyz, r3.x, c32.y, c32.y
 +
dph r4.x, r2, c6
 +
dph r4.y, r2, c7
 +
dph r4.z, r2, c8
 +
mul oPos.xyz, r12, c-38
 +
+rcc r1.x, r12.w
 +
dph r5.w, r4, c12
 +
dph r7.y, r4, c10
 +
dph r7.x, r4, c9
 +
+rcp r1.w, r5.w
 +
dph oT1.x, r4, c13
 +
max r6.w, r1.w, -r1.w
 +
mul oT0.xy, r7.xy, r6.w
 +
mad oPos.xyz, r12, r1.x, c-37
 +
</pre>
 +
 
 +
=== projectorshadow.xvu ===
 +
 
 +
<pre>
 +
xvs.1.1
 +
dph r2.x, v0, c0
 +
dph r2.y, v0, c1
 +
dph r2.z, v0, c2
 +
dp3 r3.x, v2, c92
 +
dph oPos.x, r2, c21
 +
dph oPos.y, r2, c22
 +
dph oPos.z, r2, c23
 +
dph oPos.w, r2, c24
 +
mad oD1.xyz, -r3.x, c32.y, c32.y
 +
dph r4.x, r2, c6
 +
dph r4.y, r2, c7
 +
dph r4.z, r2, c8
 +
mul oPos.xyz, r12, c-38
 +
+rcc r1.x, r12.w
 +
dph r5.x, r4, c9
 +
dph r5.y, r4, c10
 +
dph oT1.x, r4, c11
 +
mul oT0.xy, r5.xy, c33
 +
mad oPos.xyz, r12, r1.x, c-37
 +
</pre>
 +
 
 +
=== projectorskin.xvu ===
 +
 
 +
<pre>
 +
xvs.1.1
 +
add r2.x, c32.z, -v1.x
 +
dp3 r3.x, v2, c0
 +
dp3 r3.y, v2, c1
 +
dp3 r3.z, v2, c2
 +
dp3 r4.x, v2, c3
 +
dp3 r4.y, v2, c4
 +
dp3 r4.z, v2, c5
 +
mul r5.xyz, r3.xyz, v1.x
 +
mad r6.xyz, r4.xyz, r2.x, r5.xyz
 +
dph r7.x, v0, c0
 +
dph r7.y, v0, c1
 +
dph r7.z, v0, c2
 +
dph r8.x, v0, c3
 +
dph r8.y, v0, c4
 +
dph r8.z, v0, c5
 +
mul r9.xyz, r7.xyz, v1.x
 +
mad r10.xyz, r8.xyz, r2.x, r9.xyz
 +
dp3 r11.w, r6.xyz, r6.xyz
 +
dph oPos.y, r10, c22
 +
dph oPos.x, r10, c21
 +
+rsq r1.w, r11.w
 +
dph oPos.z, r10, c23
 +
mul r0.xyz, r6.xyz, r1.w
 +
dp3 r2.x, r0.xyz, c92
 +
dph oPos.w, r10, c24
 +
mad oD0.xyz, r2.x, c32.y, c32.y
 +
dph r3.x, r10, c6
 +
dph r3.y, r10, c7
 +
dph r3.z, r10, c8
 +
mul oPos.xyz, r12, c-38
 +
+rcc r1.x, r12.w
 +
dph r4.w, r3, c12
 +
dph r6.y, r3, c10
 +
dph r6.x, r3, c9
 +
+rcp r1.w, r4.w
 +
dph oT1.x, r3, c13
 +
max r5.w, r1.w, -r1.w
 +
mul oT0.xy, r6.xy, r5.w
 +
mad oPos.xyz, r12, r1.x, c-37
 +
</pre>
 +
 
 +
=== skin.xvu ===
 +
 
 +
'''Vertex attributes'''
 +
 
 +
* v0.xyzw = Position
 +
* v1.x = vertex weight
 +
* v2.xyz = Normal
 +
* v9.xyz = Texture1 coordinates
 +
 
 +
'''Constants'''
 +
 
 +
* c-38.xyz = viewport? (D3D boilerplate)
 +
* c-37.xyz = viewport? (D3D boilerplate)
 +
* c0.xyzw - c3.xyzw = matrix bone[0] ?
 +
* c3.xyzw - c5.xyzw = matrix bone[1] ?
 +
* c9.xyzw = Texture U matrix
 +
* c10.xyzw = Texture V matrix
 +
* c21.xyzw - c24.xyzw = projection-matrix ?
 +
* c32.x = CONSTANT() ?
 +
* c32.z = CONSTANT(1.0)
 +
* c56.xyz - c57.xyz = some normal matrix
 +
* c58.xyzw = ?
 +
* c59.xyzw = ?
 +
* c60.xyzw = ?
 +
* c90.xyzw = light diffuse color ?
 +
 
 +
'''Code'''
 +
 
 +
<pre>
 +
xvs.1.1
 +
 
 +
# Get (1.0 - vertex weight)
 +
add r2.x, c32.z, -v1.x
 +
 
 +
# Transform bone[0] normal ?
 +
dp3 r3.x, v2, c0
 +
dp3 r3.y, v2, c1
 +
dp3 r3.z, v2, c2
 +
 
 +
# Transform bone[1] normal ?
 +
dp3 r4.x, v2, c3
 +
dp3 r4.y, v2, c4
 +
dp3 r4.z, v2, c5
 +
 
 +
# Blend normals: r6.xyz = mix(r4.xyz, r3.xyz, v1.x)
 +
mul r5.xyz, r3.xyz, v1.x
 +
mad r6.xyz, r4.xyz, r2.x, r5.xyz
 +
 
 +
# Transform bone[0] vertex
 +
dph r7.x, v0, c0
 +
dph r7.y, v0, c1
 +
dph r7.z, v0, c2
 +
 
 +
# Transform bone[1] vertex
 +
dph r8.x, v0, c3
 +
dph r8.y, v0, c4
 +
dph r8.z, v0, c5
 +
 
 +
# Blend vertices: r10.xyz = mix(r8.xyz, r7.xyz, v1.x)
 +
mul r9.xyz, r7.xyz, v1.x
 +
mad r10.xyz, r8.xyz, r2.x, r9.xyz
 +
 
 +
# Calculation squared normal length
 +
dp3 r11.w, r6.xyz, r6.xyz
 +
 
 +
# Calculate output position (xy)
 +
dph oPos.y, r10, c22
 +
dph oPos.x, r10, c21
 +
 
 +
# Turn squared normal length into length: r1.w = 1.0 / length(normal)
 +
+rsq r1.w, r11.w
 +
 
 +
# Calculate output position (z)
 +
dph oPos.z, r10, c23
 +
 
 +
# Multiply normal by it's inverse length: r0.xyz = normalize(normal)
 +
mul r0.xyz, r6.xyz, r1.w
 +
 
 +
# Calculate output position (w)
 +
dph oPos.w, r10, c24
 +
 
 +
# Generate fog depth (same as oPos.w - somehow not optimized?)
 +
dph oFog.x, r10, c24
 +
 
 +
# Dead code?
 +
mov r2, c58
 +
 
 +
# Something with normal.xy
 +
dp3 r3.x, r0, -c56
 +
dp3 r3.y, r0, -c57
 +
 
 +
# Forward texture U
 +
dph oT0.x, v9, c9
 +
 
 +
# Something to do with lighting
 +
max r4.xy, r3.xy, c32.x
 +
mad r5, r4.x, c59, r2
 +
mad r6, r4.y, c60, r5
 +
 
 +
# Forward texture V
 +
dph oT0.y, v9, c10
  
There was a demo released for ??? on ???.
+
# Calculate diffuse color
 +
mul oD0, r6, c90
  
=== Rendering in the Demo ===
+
# Viewport or something? (D3D boilerplate)
 +
mul oPos.xyz, r12, c-38
 +
+rcc r1.x, r12.w
 +
mad oPos.xyz, r12, r1.x, c-37
 +
</pre>
  
This is a rundown of how the scene is being rendered in the THPS2X Demo version
+
=== wiggle.xvu ===
  
==== World ====
+
<pre>
==== Skater ====
+
xvs.1.1
 +
dph r2.x, v0, c0
 +
dph r2.y, v0, c1
 +
dph r2.z, v0, c2
 +
mov r3.xy, c48.x
 +
+mov oT0.xy, v9
 +
dp3 r4.x, r2, c72
 +
dp3 r4.y, r2, c73
 +
mad r5.xy, r3.xy, c74.xy, r4.xy
 +
dp3 r6.x, v2, c0
 +
mov r7.z, c32.x
 +
+exp r1.y, r5
 +
exp r8.y, r5.y
 +
mul r1.x, r1.y, r1.y
 +
mul r8.x, r8.y, r8.y
 +
+mov oD0, c32.z
 +
mul r1.z, r1.x, r1.y
 +
mul r8.z, r8.x, r8.y
 +
dp3 r7.x, r1.xyz, c36
 +
dp3 r7.y, r8.xyz, c36
 +
dp3 r6.y, v2, c1
 +
dp3 r6.z, v2, c2
 +
dp3 r9.x, r7.xyz, c74.zw
 +
mul r10.xyz, r6, v3.x
 +
mad r11.xyz, r10, r9.x, r2
 +
dph oPos.x, r11, c21
 +
dph oPos.y, r11, c22
 +
dph oPos.z, r11, c23
 +
dph oPos.w, r11, c24
 +
dph oFog.x, r11, c24
 +
mul oPos.xyz, r12, c-38
 +
+rcc r1.x, r12.w
 +
mad oPos.xyz, r12, r1.x, c-37
 +
</pre>
  
Shader:
 
  
==== HUD ====
+
== Demo ==
  
==== Shadow ====
+
There was a demo released for ??? on ???.
  
===== Skater =====
+
=== Rendering in the Demo ===
Skater shadows are rendered into a 256x256 texture after the entire scene has been rendered
 
  
====== Shader ======
+
This is a rundown of how the scene is being rendered in the THPS2X Demo version
 +
Rendering happens in this order:
  
<code>
+
# World
  /* Slot 0: 0x00000000 0x007002AA 0x0C361400 0x28200FF8 */
+
# Skater
  ADD(R2,x, c[128].z, -v1.x);
+
#* Shader: cloth.xvu
  /* Slot 1: 0x00000000 0x00CC001B 0x0836186C 0x28300FF8 */
+
# HUD
  DPH(R3,x, v0, c[96]);
+
# Shadows
  /* Slot 2: 0x00000000 0x00CC201B 0x0836186C 0x24300FF8 */
+
## Skater
  DPH(R3,y, v0, c[97]);
+
##* Skater shadows are rendered into a 256x256 texture after the entire scene has been rendered
  /* Slot 3: 0x00000000 0x00CC401B 0x0836186C 0x22300FF8 */
+
##* Shader: blackskin.xvu
  DPH(R3,z, v0, c[98]);
 
  /* Slot 4: 0x00000000 0x00CC601B 0x0836186C 0x28400FF8 */
 
  DPH(R4,x, v0, c[99]);
 
  /* Slot 5: 0x00000000 0x00CC801B 0x0836186C 0x24400FF8 */
 
  DPH(R4,y, v0, c[100]);
 
  /* Slot 6: 0x00000000 0x00CCA01B 0x0836186C 0x22400FF8 */
 
  DPH(R4,z, v0, c[101]);
 
  /* Slot 7: 0x00000000 0x0040021A 0x3400106C 0x2E500FF8 */
 
  MUL(R5,xyz, R3.xyz, v1.x);
 
  /* Slot 8: 0x00000000 0x0080001A 0x44004869 0x5E600FF8 */
 
  MAD(R6,xyz, R4.xyz, R2.x, R5.xyz);
 
  /* Slot 9: 0x00000000 0x00CEA01B 0x6436186C 0x20708800 */
 
  DPH(oPos,x, R6, c[117]);
 
  /* Slot 10: 0x00000000 0x00CEC01B 0x6436186C 0x20704800 */
 
  DPH(oPos,y, R6, c[118]);
 
  /* Slot 11: 0x00000000 0x00CEE01B 0x6436186C 0x20702800 */
 
  DPH(oPos,z, R6, c[119]);
 
  /* Slot 12: 0x00000000 0x00CF001B 0x6436186C 0x20701800 */
 
  DPH(oPos,w, R6, c[120]);
 
  /* Slot 13: 0x00000000 0x0647401B 0xC4361BFF 0x1078E800 */
 
  MUL(oPos,xyz, R12, c[58]);
 
  RCC(R1,x, R12.w);
 
  /* Slot 14: 0x00000000 0x0087601B 0xC400286C 0x3070E801 */
 
  MAD(oPos,xyz, R12, R1.x, c[59]);
 
</code>
 

Latest revision as of 23:34, 17 August 2018


Shaders

These shaders have been disassembled. Any comment was added manually and does not come from the game files.

blackskin.xvu

xvs.1.1
add r2.x, c32.z, -v1.x
dph r3.x, v0, c0
dph r3.y, v0, c1
dph r3.z, v0, c2
dph r4.x, v0, c3
dph r4.y, v0, c4
dph r4.z, v0, c5
mul r5.xyz, r3.xyz, v1.x
mad r6.xyz, r4.xyz, r2.x, r5.xyz
dph oPos.x, r6, c21
dph oPos.y, r6, c22
dph oPos.z, r6, c23
dph oPos.w, r6, c24
mul oPos.xyz, r12, c-38
+rcc r1.x, r12.w
mad oPos.xyz, r12, r1.x, c-37

cloth.xvu

xvs.1.1

# Unknown
mov r2.w, c48.x
mul r3.w, r2.w, c80.z
mad r4.xyz, c80.x, v0.xyz, r3.w

# Get (1.0 - vertex weight)
add r5.x, c32.z, -v1.x

# Transform bone[0] vertex.x
dph r6.x, v0, c0

# Unknown
+exp r1.y, r4

# Transform bone[0] vertex.y
dph r6.y, v0, c1

# Unknown
mul r1.x, r1.y, r1.y
mul r1.z, r1.x, r1.y
dp3 r7.x, r1.xyz, c36

# Transform bone[0] vertex.z
dph r6.z, v0, c2

# Unknown
+exp r1.y, r4.y

# Transform bone[1] vertex.x
dph r8.x, v0, c3

# Unknown
mul r1.x, r1.y, r1.y
mul r1.z, r1.x, r1.y
dp3 r7.y, r1.xyz, c36

# Transform bone[1] vertex.y
dph r8.y, v0, c4

# Unknown
+exp r1.y, r4.z

# Transform bone[1] vertex.z
dph r8.z, v0, c5

# Unknown
mul r1.x, r1.y, r1.y
mul r1.z, r1.x, r1.y
dp3 r7.z, r1.xyz, c36

# Blend vertices: r10.xyz = mix(r8.xyz, r6.xyz, v1.x)
mul r9.xyz, r6.xyz, v1.x
mad r10.xyz, r8.xyz, r5.x, r9.xyz

# Unknown
mul r11.w, v3.y, c80.y
mul r0.w, r11.w, c92.w
mad r2.xyz, r7.xyz, r0.w, r10.xyz
mad r3.xyz, -c92.xyz, v3.z, r2.xyz

# Transform bone[0] normal ?
dp3 r4.x, v2, c0
dp3 r4.y, v2, c1
dp3 r4.z, v2, c2

# Transform bone[1] normal ?
dp3 r6.x, v2, c3
dp3 r6.y, v2, c4
dp3 r6.z, v2, c5

# Blend vertices: r8.xyz = mix(r6.xyz, r4.xyz, v1.x)
mul r7.xyz, r4.xyz, v1.x
mad r8.xyz, r6.xyz, r5.x, r7.xyz

# Calculate output position
dph oPos.x, r3, c21
dph oPos.y, r3, c22
dph oPos.z, r3, c23
dph oPos.w, r3, c24

# Calculation squared normal length
dp3 r8.w, r8.xyz, r8.xyz

# Forward texture U
dph oT0.x, v9, c9

# Unknown
mov r9, c58

# Turn squared normal length into length: r1.w = 1.0 / length(normal)
+rsq r1.w, r8.w

# Forward texture V
dph oT0.y, v9, c10

# Unknown
mul r10.xyz, r8.xyz, r1.w
dp3 r11.x, r10, -c56
dp3 r11.y, r10, -c57

# Generate fog depth (same as oPos.w - somehow not optimized?)
dph oFog.x, r3, c24

# Something to do with lighting
max r0.xy, r11.xy, c32.x
mad r2, r0.x, c59, r9
mad r3, r0.y, c60, r2

# Viewport or something? (D3D boilerplate part 1)
mul oPos.xyz, r12, c-38
+rcc r1.x, r12.w

# Calculate diffuse color
mul oD0, r3, c90

# Viewport or something? (D3D boilerplate part 2)
mad oPos.xyz, r12, r1.x, c-37

geom.xvu

xvs.1.1
add r0.xyz, v0.xyz, c91.xyz
mov oD0, v3
dph oPos.x, r0, c21
dph oPos.y, r0, c22
dph oPos.z, r0, c23
dph oPos.w, r0, c24
dph oFog.x, r0, c24
mov oT0.xy, v9
mul oT1.xy, v9, c91.w
mul oPos.xyz, r12, c-38
+rcc r1.x, r12.w
mad oPos.xyz, r12, r1.x, c-37

grass.xvu

Vertex attributes

  • v0.xyz = Position
  • v3.xyzw = Diffuse color
  • v9.xy = Texture1 coordinates

Constants

  • c-38.xyz = viewport? (D3D boilerplate)
  • c-37.xyz = viewport? (D3D boilerplate)
  • c21.xyzw - c24.xyzw = world-view-projection-matrix ?
  • c32.w = Texture1 scale
  • c91.xyz = Object position

Code

xvs.1.1

# Add object position to vertex position
add r0.xyz, v0, c91

# Forward diffuse color
mov oD0, v3

# Calculate output position
dph oPos.x, r0, c21
dph oPos.y, r0, c22
dph oPos.z, r0, c23
dph oPos.w, r0, c24

# Generate fog depth (same as oPos.w - somehow not optimized?)
dph oFog.x, r0, c24

# Scale texture
mul oT0.xy, v9, c32.w

# Viewport or something? (D3D boilerplate)
mul oPos.xyz, r12, c-38
+rcc r1.x, r12.w
mad oPos.xyz, r12, r1.x, c-37

projectorlight.xvu

xvs.1.1
dph r2.x, v0, c0
dph r2.y, v0, c1
dph r2.z, v0, c2
dp3 r3.x, v2, c92
dph oPos.x, r2, c21
dph oPos.y, r2, c22
dph oPos.z, r2, c23
dph oPos.w, r2, c24
mad oD0.xyz, r3.x, c32.y, c32.y
dph r4.x, r2, c6
dph r4.y, r2, c7
dph r4.z, r2, c8
mul oPos.xyz, r12, c-38
+rcc r1.x, r12.w
dph r5.w, r4, c12
dph r7.y, r4, c10
dph r7.x, r4, c9
+rcp r1.w, r5.w
dph oT1.x, r4, c13
max r6.w, r1.w, -r1.w
mul oT0.xy, r7.xy, r6.w
mad oPos.xyz, r12, r1.x, c-37

projectorshadow.xvu

xvs.1.1
dph r2.x, v0, c0
dph r2.y, v0, c1
dph r2.z, v0, c2
dp3 r3.x, v2, c92
dph oPos.x, r2, c21
dph oPos.y, r2, c22
dph oPos.z, r2, c23
dph oPos.w, r2, c24
mad oD1.xyz, -r3.x, c32.y, c32.y
dph r4.x, r2, c6
dph r4.y, r2, c7
dph r4.z, r2, c8
mul oPos.xyz, r12, c-38
+rcc r1.x, r12.w
dph r5.x, r4, c9
dph r5.y, r4, c10
dph oT1.x, r4, c11
mul oT0.xy, r5.xy, c33
mad oPos.xyz, r12, r1.x, c-37

projectorskin.xvu

xvs.1.1
add r2.x, c32.z, -v1.x
dp3 r3.x, v2, c0
dp3 r3.y, v2, c1
dp3 r3.z, v2, c2
dp3 r4.x, v2, c3
dp3 r4.y, v2, c4
dp3 r4.z, v2, c5
mul r5.xyz, r3.xyz, v1.x
mad r6.xyz, r4.xyz, r2.x, r5.xyz
dph r7.x, v0, c0
dph r7.y, v0, c1
dph r7.z, v0, c2
dph r8.x, v0, c3
dph r8.y, v0, c4
dph r8.z, v0, c5
mul r9.xyz, r7.xyz, v1.x
mad r10.xyz, r8.xyz, r2.x, r9.xyz
dp3 r11.w, r6.xyz, r6.xyz
dph oPos.y, r10, c22
dph oPos.x, r10, c21
+rsq r1.w, r11.w
dph oPos.z, r10, c23
mul r0.xyz, r6.xyz, r1.w
dp3 r2.x, r0.xyz, c92
dph oPos.w, r10, c24
mad oD0.xyz, r2.x, c32.y, c32.y
dph r3.x, r10, c6
dph r3.y, r10, c7
dph r3.z, r10, c8
mul oPos.xyz, r12, c-38
+rcc r1.x, r12.w
dph r4.w, r3, c12
dph r6.y, r3, c10
dph r6.x, r3, c9
+rcp r1.w, r4.w
dph oT1.x, r3, c13
max r5.w, r1.w, -r1.w
mul oT0.xy, r6.xy, r5.w
mad oPos.xyz, r12, r1.x, c-37

skin.xvu

Vertex attributes

  • v0.xyzw = Position
  • v1.x = vertex weight
  • v2.xyz = Normal
  • v9.xyz = Texture1 coordinates

Constants

  • c-38.xyz = viewport? (D3D boilerplate)
  • c-37.xyz = viewport? (D3D boilerplate)
  • c0.xyzw - c3.xyzw = matrix bone[0] ?
  • c3.xyzw - c5.xyzw = matrix bone[1] ?
  • c9.xyzw = Texture U matrix
  • c10.xyzw = Texture V matrix
  • c21.xyzw - c24.xyzw = projection-matrix ?
  • c32.x = CONSTANT() ?
  • c32.z = CONSTANT(1.0)
  • c56.xyz - c57.xyz = some normal matrix
  • c58.xyzw = ?
  • c59.xyzw = ?
  • c60.xyzw = ?
  • c90.xyzw = light diffuse color ?

Code

xvs.1.1

# Get (1.0 - vertex weight)
add r2.x, c32.z, -v1.x

# Transform bone[0] normal ?
dp3 r3.x, v2, c0
dp3 r3.y, v2, c1
dp3 r3.z, v2, c2

# Transform bone[1] normal ?
dp3 r4.x, v2, c3
dp3 r4.y, v2, c4
dp3 r4.z, v2, c5

# Blend normals: r6.xyz = mix(r4.xyz, r3.xyz, v1.x)
mul r5.xyz, r3.xyz, v1.x
mad r6.xyz, r4.xyz, r2.x, r5.xyz

# Transform bone[0] vertex
dph r7.x, v0, c0
dph r7.y, v0, c1
dph r7.z, v0, c2

# Transform bone[1] vertex
dph r8.x, v0, c3
dph r8.y, v0, c4
dph r8.z, v0, c5

# Blend vertices: r10.xyz = mix(r8.xyz, r7.xyz, v1.x)
mul r9.xyz, r7.xyz, v1.x
mad r10.xyz, r8.xyz, r2.x, r9.xyz

# Calculation squared normal length
dp3 r11.w, r6.xyz, r6.xyz

# Calculate output position (xy)
dph oPos.y, r10, c22
dph oPos.x, r10, c21

# Turn squared normal length into length: r1.w = 1.0 / length(normal)
+rsq r1.w, r11.w

# Calculate output position (z)
dph oPos.z, r10, c23

# Multiply normal by it's inverse length: r0.xyz = normalize(normal)
mul r0.xyz, r6.xyz, r1.w

# Calculate output position (w)
dph oPos.w, r10, c24

# Generate fog depth (same as oPos.w - somehow not optimized?)
dph oFog.x, r10, c24

# Dead code?
mov r2, c58

# Something with normal.xy
dp3 r3.x, r0, -c56
dp3 r3.y, r0, -c57

# Forward texture U
dph oT0.x, v9, c9

# Something to do with lighting
max r4.xy, r3.xy, c32.x
mad r5, r4.x, c59, r2
mad r6, r4.y, c60, r5

# Forward texture V
dph oT0.y, v9, c10

# Calculate diffuse color
mul oD0, r6, c90

# Viewport or something? (D3D boilerplate)
mul oPos.xyz, r12, c-38
+rcc r1.x, r12.w
mad oPos.xyz, r12, r1.x, c-37

wiggle.xvu

xvs.1.1
dph r2.x, v0, c0
dph r2.y, v0, c1
dph r2.z, v0, c2
mov r3.xy, c48.x
+mov oT0.xy, v9
dp3 r4.x, r2, c72
dp3 r4.y, r2, c73
mad r5.xy, r3.xy, c74.xy, r4.xy
dp3 r6.x, v2, c0
mov r7.z, c32.x
+exp r1.y, r5
exp r8.y, r5.y
mul r1.x, r1.y, r1.y
mul r8.x, r8.y, r8.y
+mov oD0, c32.z
mul r1.z, r1.x, r1.y
mul r8.z, r8.x, r8.y
dp3 r7.x, r1.xyz, c36
dp3 r7.y, r8.xyz, c36
dp3 r6.y, v2, c1
dp3 r6.z, v2, c2
dp3 r9.x, r7.xyz, c74.zw
mul r10.xyz, r6, v3.x
mad r11.xyz, r10, r9.x, r2
dph oPos.x, r11, c21
dph oPos.y, r11, c22
dph oPos.z, r11, c23
dph oPos.w, r11, c24
dph oFog.x, r11, c24
mul oPos.xyz, r12, c-38
+rcc r1.x, r12.w
mad oPos.xyz, r12, r1.x, c-37


Demo

There was a demo released for ??? on ???.

Rendering in the Demo

This is a rundown of how the scene is being rendered in the THPS2X Demo version Rendering happens in this order:

  1. World
  2. Skater
    • Shader: cloth.xvu
  3. HUD
  4. Shadows
    1. Skater
      • Skater shadows are rendered into a 256x256 texture after the entire scene has been rendered
      • Shader: blackskin.xvu