• Welcome to Smashboards, the world's largest Super Smash Brothers community! Over 250,000 Smash Bros. fans from around the world have come to discuss these great games in over 19 million posts!

    You are currently viewing our boards as a visitor. Click here to sign up right now and start on your path in the Smash community!

In Progress Orthographic Camera Projection

schmooblidon

Smash Journeyman
Joined
Feb 18, 2014
Messages
496
Would be very useful to see melee in an orthographic view. It gives the best view of environmental collision, I think it would also be a popular gimmick to play around with.

I don't know how useful this is, but in psilupan's reverse engineered melee repo, it shows a projection_type field in the HSD camera object

https://github.com/PsiLupan/FRAY/blob/master/src/hsd/hsd_cobj.h

I really appreciate any effort made on this
 

Punkline

Dr. Frankenstack
Joined
May 15, 2015
Messages
423
Would be very useful to see melee in an orthographic view. It gives the best view of environmental collision, I think it would also be a popular gimmick to play around with.

I don't know how useful this is, but in psilupan's reverse engineered melee repo, it shows a projection_type field in the HSD camera object

https://github.com/PsiLupan/FRAY/blob/master/src/hsd/hsd_cobj.h

I really appreciate any effort made on this
One of my first encounters with CObjs was like a year ago or so, where I was studying how the game creates the ortho CObj used for drawing vector text to the screen in debug mode. It actually generates them procedurally, so I was experimenting with creating brand new ortho CObjs without any file data for the purpose of controlling the aspect ratio of drawn pixels for UI-like things in prim.

I remember playing around with some settings once and accidentally getting some ortho settings to work for the main camera. There's a big update function that updates the main camera every frame though that might need some tweaking to get a code working.

I'll try to take a look at this sometime this week, and let you know if it's an easy thing to do. It would be interesting to see what an ortho camera in Melee would be like compared to a perspective camera.
 
Last edited:

SinsOfApathy

Smash Journeyman
Joined
Feb 24, 2015
Messages
474
NNID
Psion312
One of my first encounters with CObjs was like a year ago or so, where I was studying how the game creates the ortho CObj used for drawing vector text to the screen in debug mode. It actually generates them procedurally, so I was experimenting with creating brand new ortho CObjs without any file data for the purpose of controlling the aspect ratio of drawn pixels for UI-like things in prim.

I remember playing around with some settings once and accidentally getting some ortho settings to work for the main camera. There's a big update function that updates the main camera every frame though that might need some tweaking to get a code working.

I'll try to take a look at this sometime this week, and let you know if it's an easy thing to do. It would be interesting to see what an ortho camera in Melee would be like compared to a perspective camera.
The easiest way is to override the Projection Type in CObjLoad from being the descriptor's to the Orthographic type (3).

The only concern is that the left and right projection will be 0, and you'll need to initialize them with a known good value.
 

Punkline

Dr. Frankenstack
Joined
May 15, 2015
Messages
423
Well, as I expected: the default camera behavior really screwed some things up here; but after a few experiments that gave me some vertigo, this concept turned out somewhat successful.


Orthographic Stage Camera - Concept 1
Code:
-==-
Orthographic Stage Camera - Concept 1
- Sets stage camera to orthographic mode
- Forces "eye" level WObj XY to be orthogonal to the "interest" WObj
- Creates a fake "zoom" camera effect to compensate no perspective
- Allows projected frame scale to be adjusted with custom values
- Modifies some camera tracking settings to smooth out character tracking
[Punkline]
<orthoStageCamera_data>
.float /*  You may change these values to whatever you like.

*/  0.05,   /*  top ratio  - these summarize new projection unit size
*/ -0.064,  /*  bot ratio
*/ -0.05,   /*  left ratio
*/  0.05,   /*  right ratio

*/  10.00, /*  zoom padding
*/   1.25, /*  character tracking size
*/   0.50, /*  character tracking zoom speed?
*/   0.66, /*  character tracking speed  - these help smooth out the zoom
*/ 125.00  /*  character min zoom
*/

NTSC 1.02 ----- 800301fc --- 4bffa2b1 -> Branch
bl 0x8002a4ac
lis r0, <<orthoStageCamera_data>>@h
ori r31, r0, <<orthoStageCamera_data>>@l
38000003 83DD0028 981E0050 E03F0000 E01E8018 10210018 817E0028 E05F0008 E01E8010 10420018 819E0024 3C008049 6003E6F0 C003002C 10210024 10420024 E06C8014 E00B8014 10630028 E01F8010 1063002A 102100D8 104200D8 C002847C F03E0040 D00C0014 E00B000C 389F0014 F05E0048 7CA484AA F00C000C 7CA385AA 00000000
#
Code:
-==-
ASM - Orthographic Stage Camera - Concept 1
- Sets stage camera to orthographic mode
- Forces "eye" level WObj XY to be orthogonal to the "interest" WObj
- Creates a fake "zoom" camera effect to compensate no perspective
- Allows projected frame scale to be adjusted with custom values
- Modifies some camera tracking settings to smooth out character tracking
[Punkline]
<orthoStageCamera_data>
.float /*  You may change these values to whatever you like.

*/  0.05,   /*  top ratio  - these summarize new projection unit size
*/ -0.064,  /*  bot ratio
*/ -0.05,   /*  left ratio
*/  0.05,   /*  right ratio

*/  10.00, /*  zoom padding
*/   1.25, /*  character tracking size
*/   0.50, /*  character tracking zoom speed?
*/   0.66, /*  character tracking speed  - these help smooth out the zoom
*/ 125.00  /*  character min zoom
*/

NTSC 1.02 ----- 800301fc --- 4bffa2b1 -> Branch
rData = 31;  rCObj = 30;  rGObj = 29;  rIntr = 11;  rEye = 12
fTB = 1;  fLR = 2;  fZoom = 3;
bl 0x8002a4ac # default WObj update
# at this point, WObjs may be intercepted before they are used this draw frame

lis r0, <<orthoStageCamera_data>>@h
ori rData, r0, <<orthoStageCamera_data>>@l
li  r0, 3
lwz rCObj, 0x28(rGObj)
stb r0, 0x50(rCObj)
# set type to orthographic projection

psq_l  fTB, 0x0(rData), 0, 0
psq_l  f0, 0x18(rCObj), 1, 0
ps_muls0 fTB, fTB, f0
lwz rIntr, 0x28(rCObj)
psq_l  fLR, 0x8(rData), 0, 0
psq_l  f0, 0x10(rCObj), 1, 0
ps_muls0 fLR, fLR, f0
lwz rEye, 0x24(rCObj)
lis r0, 0x8049E6F0@h
ori r3, r0, 0x8049E6F0@l
lfs f0, 0x2C(r3)
ps_div fTB, fTB, f0
ps_div fLR, fLR, f0
# fTB and fLR = projection units

psq_l  fZoom, 0x14(rEye), 1, 0
psq_l  f0, 0x14(rIntr), 1, 0
ps_sub fZoom, fZoom, f0
psq_l  f0, 0x10(rData), 1, 0
ps_add fZoom, fZoom, f0
ps_muls0 fTB, fTB, fZoom
ps_muls0 fLR, fLR, fZoom
# fTB and fLR = scaled dimensions

lfs f0, -0x7B84(rtoc)  # 1000.0
psq_st fTB, 0x40(rCObj), 0, 0
stfs f0, 0x14(rEye)    # prevent Z depth from culling geometry
psq_l  f0, 0xC(rIntr), 0, 0
addi r4, rData, 0x14
psq_st fLR, 0x48(rCObj), 0, 0
lswi r5, r4, 0x10
psq_st f0, 0xC(rEye), 0, 0
stswi r5, r3, 0x10
# all values have been updated

_return:
.long 0


This is just a concept, but you can use it to experiment with an ortho camera in a way that works on at least some stages, schmooblidon schmooblidon

Most stages also work very well with the Simple Stage Geometry code, since this eliminates many of the eyesores created by perspective issues in some stages. In other cases, the lack of perspective makes for some really crisp looking platforms:



I found an injection point in the stage camera GX callback function that lets me intercept the camera WObjs just after they're updated each frame, but also just before the camera utilizes them.

With this power over the camera's WObj update, I can force the camera “Eye” to always be orthogonal to the “interest” point. This stopped the game’s behavior of wanting to make sickening angles every time something happened on screen. (Without perspective, this makes the skybox look it's being panned through a telescope, basically.)


Obviously, the “zoom” feature is worthless in an orthographic camera because of the Z tangent created from having no perspective. Furthermore, the zoom that is driven by the normal stage camera behavior would cause now-perceivable geometry to become culled; as though it were not perceivable.

So, I also made it so that the Z distance at any given frame between “Eye” and “interest” is used to sample a sort of zoom multiplier. This gets divided by a "normal Z" stage camera setting, and then multiplied by some customizable units to create procedural projection dimensions. These procedural dimensions then create a fake “zoom” that works in ortho camera mode, despite the Z tangent issue.


The Z distance -- after being sampled each frame -- gets discarded for the “Eye” and is then replaced with a large, constant number before being utilized by the camera. This prevents any geometry from being culled by the Eye's true Z position.

---


The fake zoom is a bit crude, and it confuses a few of the game’s normal camera boundary rules; but I think it can be fixed up with some polish later on. For now I’ve included a few stage camera parameter overrides that can help smooth out the zoom tracking a little bit.

You can modify any of the settings in the <orthoStageCamera_data> function in MCM:


The TBLR ratios are used to sample the viewport dimensions of the stage camera. For some reason, this makes a slightly stretched aspect, so I've tweaked the bottom ratio a little to make things look very close-to-standard. You can modify the same setting to create a widescreen aspect, if desired.


Even with these settings, some stage cameras are still very messy. In particular, some stages cause the zoom to go way too far out, and in many cases this will make it difficult to see where the blast zones begin. I think this could be fixed; but if not, then we could probably just make some stage-specific configurations that help ease the problem.

Something however that might not be so easy to fix is the fact that ortho does some funky stuff to the perceived scale of far-away background elements. Additionally, stages that have some kind of floor-oriented plane that would normally hide a blank background becomes sorely noticeable in a few stages. I've also noticed that ortho seems to ignore some rotation information in a few kinds of background and particle effects. My hunch is that this is caused by some JObj flags used by those effects that make it face the camera.

Because of these things, many stages are not-so-pretty in this mode.


However, some other stages are kinda gorgeous:


Even in some of the better-looking stages, I think it might help visually distinguish the foreground from the bacfkground if there was some extra fog element or something to help create a sense of atmospheric perspective.
 
Last edited:

schmooblidon

Smash Journeyman
Joined
Feb 18, 2014
Messages
496
This looks fantastic dude! Thank you very much

I'm having trouble converting this to a gecko code, does it require any special instructions?

Edit: UnclePunch the homie hooked me up! Thanks again Punkline, this code is really awesome, ive been wondering what it would look like for a long time haha!
 
Last edited:

brie

Smash Rookie
Joined
Jun 25, 2020
Messages
1
Slippi.gg
brie#964
Sorry to bump an old thread but do any of you still have the gecko code? I'm getting persistent errors in MCM

Edit: For anyone who stumbles across this thread later and wants a 16:9 orthographic code...

-==-
Orthographic Stage Camera - Concept 1
- Sets stage camera to orthographic mode
- Forces "eye" level WObj XY to be orthogonal to the "interest" WObj
- Creates a fake "zoom" camera effect to compensate no perspective
- Allows projected frame scale to be adjusted with custom values
- Modifies some camera tracking settings to smooth out character tracking
[Punkline]
<orthoStageCamera_data>
.float /* You may change these values to whatever you like.

*/ 0.05, /* top ratio - these summarize new projection unit size
*/ -0.064, /* bot ratio
*/ -0.073, /* left ratio
*/ 0.073, /* right ratio

*/ 10.00, /* zoom padding
*/ 1.25, /* character tracking size
*/ 0.50, /* character tracking zoom speed?
*/ 0.66, /* character tracking speed - these help smooth out the zoom
*/ 125.00 /* character min zoom
*/

NTSC 1.02 ----- 800301fc --- 4bffa2b1 -> Branch
bl 0x8002a4ac
lis r0, <<orthoStageCamera_data>>@h
ori r31, r0, <<orthoStageCamera_data>>@l
38000003 83DD0028 981E0050 E03F0000 E01E8018 10210018 817E0028 E05F0008 E01E8010 10420018 819E0024 3C008049 6003E6F0 C003002C 10210024 10420024 E06C8014 E00B8014 10630028 E01F8010 1063002A 102100D8 104200D8 C002847C F03E0040 D00C0014 E00B000C 389F0014 F05E0048 7CA484AA F00C000C 7CA385AA 00000000
#
 
Last edited:

Punkline

Dr. Frankenstack
Joined
May 15, 2015
Messages
423
Sorry to bump an old thread but do any of you still have the gecko code? I'm getting persistent errors in MCM
Oh, it seems like I had a register name in my special branch syntax in the DOL Mod that couldn't be interpreted without the ASM.
Not sure why I hadn't caught this when it was posted (I must have been testing the ASM rather than the DOL Mod)

I made a quick edit, and now the DOL Mod should install without complaining about the register name.
 
Last edited:

NeilHarbin0

Smash Rookie
Joined
Feb 16, 2010
Messages
7
Slippi.gg
NEIL#0
This will be a big help for creating consistent documentation.

For those looking for a gecko code, here is the one UnclePunch compiled from this for Schmoo.

Code:
C20301FC 00000019
4800002C 4E800021
3D4CCCCD BD83126F
BD4CCCCD 3D4CCCCD
41200000 3FA00000
3F000000 3F28F5C3
42FA0000 3D808002
618CA4AC 7D8903A6
4E800421 4BFFFFC9
7FE802A6 38000003
83DD0028 981E0050
E03F0000 E01E8018
10210018 817E0028
E05F0008 E01E8010
10420018 819E0024
3C608049 6063E6F0
C003002C 10210024
10420024 E06C8014
E00B8014 10630028
E01F8010 1063002A
102100D8 104200D8
C002847C F03E0040
D00C0014 E00B000C
389F0014 F05E0048
7CA484AA F00C000C
7CA385AA 00000000

Doesn't seem to have any conflicts for me, aside from it being a bit long and limiting the number of codes I can use.

I also tested it with External Melee Camera, and it worked properly.
 
Top Bottom