Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Project Mode7 (https://forums.graalonline.com/forums/showthread.php?t=134266427)

Gunderak 05-15-2012 11:56 AM

Wow. Just wow.

Rave_J 05-15-2012 02:17 PM

y not just tell stefan to release the Graal 3d platform he made a while ago ?
oh wait this will be in 2020

DustyPorViva 05-15-2012 04:19 PM

I'm very close to getting something "playable" but I've run into a problem that I just can't seem to fix.

Here's what my rendered looked like:
http://i.imgur.com/rHj5O.png

Okay, but see that perspective is VERY wrong. It's especially obvious when turning as everything gets a very funnel/spiral distortion. So I want to correct this. What I need to do is make the render shrink as it nears the horizon. Sounded easily enough but I just can't seem to get it to work. I ended up with ONE result that works perfectly, visually, but with the sideeffect of... flipping the view vertically.
http://i.imgur.com/AzmjV.png

I desperately need to figure this out. That view is perfect, especially when you're moving. Everything is normalized great, but I just can't get the view oriented right.

Here is the portion of the script that deals with the positioning of the vertices:
PHP Code:

for (temp.p0;p<4;p++) {
  
// Rotate vertices
  
vert_px[p] = (vert_x[p] * cos(this.cam.angle)) - (vert_y[p] * sin(-this.cam.angle));
  
vert_py[p] = (vert_x[p] * sin(-this.cam.angle)) + (vert_y[p] * cos(this.cam.angle));

  
// Stretch horizontal view as it nears the camera
  
vert_px[p] *= ((vert_py[p]+(screenheight/1.5))/256);

  
// Problem line. This is what's currently rendering the distance, but also flipping the render
  
vert_py[p] *= abs(vert_py[p])/-screenheight;

  
// Orient new render to center of viewing
  
vert_px[p] += screenwidth/2;
  
vert_py[p] += screenheight;


Any help from you math guys would be awesome.

Fulg0reSama 05-15-2012 04:41 PM

Quote:

Originally Posted by DustyPorViva (Post 1694730)
Any help from you math guys would be awesome.

I'll see if I can get a friend to help ya on that math.

Emera 05-15-2012 04:57 PM

This is mind blowing! Amazing work dusty.

Hezzy002 05-15-2012 04:59 PM

Why don't you just flip the verts along the center of the screen and then translate them down? Also, I'm not sure how you're able to increase performance with the technique you discussed, unless it enables you to render in horizontal strips? But then how would you handle rotation?

It also looks like you have the same problem that everyone else has; if you were to change the viewing angle/view distance to properly look like a SNES racer's horizon, you'll find either horrific artifacts or if you increase the resolution to remedy that, really poor performance.

DustyPorViva 05-15-2012 05:28 PM

Quote:

Originally Posted by Hezzy002 (Post 1694733)
Why don't you just flip the verts along the center of the screen and then translate them down? Also, I'm not sure how you're able to increase performance with the technique you discussed, unless it enables you to render in horizontal strips? But then how would you handle rotation?

It also looks like you have the same problem that everyone else has; if you were to change the viewing angle/view distance to properly look like a SNES racer's horizon, you'll find either horrific artifacts or if you increase the resolution to remedy that, really poor performance.

I sorted out the distance issue, and here it is running at 20fps(a few frames lost while recording):

But I have yet to try it in a real "racing" level and I need to add gmap support before I can start tweaking FOV and how far to render out. A single level actually is pretty damn small for mode7.

As for how I'm accomplishing it, imagine I'm taking the level, rendering a flat image of it and slapping it on a single polygon. Now imagine I'm slicing that polygon up into multiple segments. Not visually, but mechanically. It's the same technique I was using from the start except now instead of grabbing level data in realtime I'm working off of a prerendered image of the level generated from the start. Then instead of one polygon per tile, I can render as many polygons as I desire, and just cropping the image into parts. I can lower or raise the quality of the plane with a single variable, so I suppose for those with more powerful machines they could crank even better quality. In the video I rendered I was processing 20x20 segments in the plane. Lowering it more and more 'causes all those seam issues with texture normals that Graal is so well known for. The segments help alleviate that issue.

Quote:

Originally Posted by Fulg0reSama (Post 1694731)
I'll see if I can get a friend to help ya on that math.

That'd be cool. I got it figured out, but as you can see in the video I'm still having the same issue with the sort of barrel effect. I don't like it and would love to have the plane render straighter.

Crono 05-15-2012 06:06 PM

hah that's awesome dusty, graal kart inc.

Tolnaftate2004 05-15-2012 06:07 PM

x' = x*h/z; h generally of your choosing.

hth

e:
x = orthogonal horizontal coordinate
x' = projected horizontal coordinate
h = "camera height"
z = distance along the axis that comes through your screen

James 05-15-2012 09:23 PM

nice work as always dusty

DustyPorViva 05-16-2012 12:51 AM

Well I feel I'm crippling the potential of this by doing it on my own. I'm not that great at math and I have absolutely no experience with 3D projection. This is my first attempt and I don't feel like I'll be able to accomplish my end goals.

So if anyone familiar with 3D projection wants to hop aboard and collaborate, I would absolutely love it. My goals are to:

1) have a fully customizable camera with roll, pitch, height so users can easily adjust the view.
2) Make the 2D to 3D transition smooth and hassle-free. Ideally I'd love to see a command that takes any position in the 2D world(in this case a level or gmap) and return the values needed to render it to the screen in a 3D space.

The two above combinations would make it insanely easy to share this functionality with others, and I'd love to have this sort of thing easily available to other developers to play with.

If someone with the math skills can help me out here and pull this together into a proper mode7 effect(instead of a hacked together version) then I'd be truly grateful. The functionality and backbone is already there, I just need the 2D -> 3D projection and camera smoothed out. I know there are at least a few scripters floating around with the experience to do this.

DustyPorViva 05-16-2012 01:49 AM

Also, future mockup!
http://i.imgur.com/eKHiZ.png

This sort of effect would be insanely easy to pull off. Basically I'd take water(in this case from pics1) and give it a semi-transparent fill(like 80% opaque or so). Then I'd take the sky/npcs/players and duplicate them under the horizon, vertically flipped and render them under mode7. Very, very easy to do and I can't wait to get to it. I want to do an entire water course with this. This effect, with some nice parallax sky scrolling... suhweet.

Also, sky was just ripped from New Super Mario Bros for mockup purposes and the noob in a kart was pulled from someone elses attempt at mode7 in Graal(I think obviously edited from Super Mario Kart).

BlueMelon 05-16-2012 02:39 AM

Now that would be pretty great to see. Mario kart style.

Unkownsoldier 05-16-2012 02:42 AM

That would be great, and you would do other things other than just Graal Kart right? It could have some great possibilities if you get it working properly.

Fulg0reSama 05-16-2012 02:53 AM

Quote:

Originally Posted by Unkownsoldier (Post 1694790)
That would be great, and you would do other things other than just Graal Kart right? It could have some great possibilities if you get it working properly.

Yeah, you could also venture into a whole different perspective based experience for Graal in general lol.

Graal Nukem Online, anyone?


All times are GMT +2. The time now is 05:22 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.