mirror of
https://github.com/HackerN64/F3DEX3.git
synced 2026-01-21 10:37:45 -08:00
Changed occlusion plane components scaling
This commit is contained in:
3
build.sh
3
build.sh
@@ -4,5 +4,6 @@ make F3DEX3_BrW
|
||||
cp build/F3DEX3_BrW/F3DEX3_BrW.code ../../Mods/HackerOoT/data/F3DEX3_BrW.code
|
||||
cp build/F3DEX3_BrW/F3DEX3_BrW.data ../../Mods/HackerOoT/data/F3DEX3_BrW.data
|
||||
make -C ../../Mods/HackerOoT -j12
|
||||
cp ../../Mods/HackerOoT/HackerOoT.z64 /media/`whoami`/SOME2/
|
||||
#cp ../../Mods/HackerOoT/HackerOoT.z64 /media/`whoami`/SOME2/
|
||||
../../Flashcarts/SummerCart64/sw/deployer/target/debug/sc64deployer upload ../../Mods/HackerOoT/HackerOoT.z64
|
||||
printf "\n====\nDone\n====\n"
|
||||
|
||||
19
f3dex3.s
19
f3dex3.s
@@ -286,6 +286,18 @@ screenX < screenY * -8*c3 + 2*c7
|
||||
where screenX and screenY are in subpixels (e.g. screenX = 100 = 25.0 pixels),
|
||||
c0-c3 are shorts representing -1:0.99997,
|
||||
and c4-c7 are shorts representing "half pixels" (e.g. c4 = 50 = 25.0 pixels)
|
||||
|
||||
For the last equation, one option is to think of kx through kc as in s10.5 mode
|
||||
instead, so a value of 0x0020 is 1.0 and they can range from -0x400.00 to
|
||||
0x3FF.F8. This choice is because clipZ ranges from 0x0000.0000 at the camera
|
||||
plane to 0x03FF.0000 at the maximum distance away. The normal distance Adult
|
||||
Link is from the camera is about 0x00B0.0000.
|
||||
|
||||
A better option is to develop your plane equation in floating point, e.g.
|
||||
clipX[f] * -0.2f + clipY[f] * 0.4f + clipZ[f] * 1.0f + -200.0f >= 0
|
||||
then multiply everything by (32768.0f / max(abs(kx), abs(ky), abs(kz), abs(kc)))
|
||||
(here 32768.0f / 200.0f = 163.84f)
|
||||
clipX[f] * -32.77f + clipY[f] * 65.54f + clipZ[f] * 163.84f + -32768
|
||||
*/
|
||||
.dh 0x0000 // c0
|
||||
.dh 0x0000 // c1
|
||||
@@ -659,7 +671,7 @@ postOvlRA equ $12 // Commonly used locally
|
||||
// vtx write
|
||||
// $26: taskDataPtr (global)
|
||||
// $27: inputBufferPos (global)
|
||||
// $28: unused
|
||||
// $28: numPrimsDrawn (global)
|
||||
// $29: unused
|
||||
// $30: unused
|
||||
// $ra: Return address for jal, b*al
|
||||
@@ -1408,8 +1420,9 @@ vtx_store:
|
||||
vmadm $v20, vPairTPosI, vSTScl[2] // Persp norm
|
||||
vmadn $v21, vSTOfs, vSTOfs[3] // Zero
|
||||
cfc2 $12, $vcc // Load screen clipping results
|
||||
vmudn $v29, vPairTPosF, $v30 // X * X factor, Y * Y factor, Z * Z factor
|
||||
vmadh $v28, vPairTPosI, $v30 // Clamp result, not vreadacc
|
||||
vmudn $v29, vPairTPosF, $v30 // X * kx, Y * ky, Z * kz
|
||||
vmadh $v29, vPairTPosI, $v30 // Int * int
|
||||
vreadacc $v28, ACC_UPPER // Load int * int portion
|
||||
vne $v29, $v31, $v31[3h] // Set VCC to 11101110
|
||||
srl $24, $12, 4 // Shift second vertex screen clipping to first slots
|
||||
vmudn $v26, vPairTPosF, $v31[3] // W * clip ratio for scaled clipping
|
||||
|
||||
41
gbi.h
41
gbi.h
@@ -1087,6 +1087,21 @@ typedef struct {
|
||||
int y2;
|
||||
} Hilite_t;
|
||||
|
||||
typedef struct {
|
||||
short c0;
|
||||
short c1;
|
||||
short c2;
|
||||
short c3;
|
||||
short c4;
|
||||
short c5;
|
||||
short c6;
|
||||
short c7;
|
||||
short kx;
|
||||
short ky;
|
||||
short kz;
|
||||
short kc;
|
||||
} OcclusionPlane_t;
|
||||
|
||||
typedef union {
|
||||
Light_t l;
|
||||
long long int force_structure_alignment[2];
|
||||
@@ -1113,6 +1128,12 @@ typedef union {
|
||||
long int force_structure_alignment;
|
||||
} Hilite;
|
||||
|
||||
typedef union {
|
||||
OcclusionPlane_t o;
|
||||
short c[12];
|
||||
long long int force_structure_alignment[3];
|
||||
} OcclusionPlane;
|
||||
|
||||
typedef struct {
|
||||
Light l[9];
|
||||
Ambient a;
|
||||
@@ -2971,7 +2992,7 @@ _DW({ \
|
||||
|
||||
/*
|
||||
* Camera world position for Fresnel. Set this whenever you set the VP matrix,
|
||||
* viewport, etc. cam is the name/address of a PlainVtx struct.
|
||||
* viewport, etc. cam is the address of a PlainVtx struct.
|
||||
*/
|
||||
#define gSPCameraWorld(pkt, cam) \
|
||||
gDma2p((pkt), G_MOVEMEM, (cam), sizeof(PlainVtx), G_MV_LIGHT, 0)
|
||||
@@ -2981,7 +3002,7 @@ _DW({ \
|
||||
|
||||
/*
|
||||
* Reflection/Hiliting Macros.
|
||||
* la is the name/address of a LookAt struct.
|
||||
* la is the address of a LookAt struct.
|
||||
*/
|
||||
#define gSPLookAt(pkt, la) \
|
||||
gDma2p((pkt), G_MOVEMEM, (la), sizeof(LookAt), G_MV_LIGHT, 8)
|
||||
@@ -3028,6 +3049,22 @@ _DW({ \
|
||||
((((width) - 1) * 4) + (hilite)->h.x2) & 0xFFF, \
|
||||
((((height) - 1) * 4) + (hilite)->h.y2) & 0xFFF)
|
||||
|
||||
|
||||
/*
|
||||
* Occlusion plane
|
||||
*
|
||||
* TODO explain how to calculate the coefficients
|
||||
*
|
||||
* o is the address of an OcclusionPlane struct
|
||||
*/
|
||||
#define gSPOcclusionPlane(pkt, o) \
|
||||
gDma2p((pkt), G_MOVEMEM, (o), sizeof(OcclusionPlane), G_MV_LIGHT, \
|
||||
(G_MAX_LIGHTS * 0x10) + 0x18)
|
||||
#define gsSPOcclusionPlane(o) \
|
||||
gsDma2p( G_MOVEMEM, (o), sizeof(OcclusionPlane), G_MV_LIGHT, \
|
||||
(G_MAX_LIGHTS * 0x10) + 0x18)
|
||||
|
||||
|
||||
/*
|
||||
* FOG macros
|
||||
* fm = z multiplier
|
||||
|
||||
Reference in New Issue
Block a user