Author Topic: 3D frustum clipping  (Read 310 times)

Krion

  • Newbie
  • *
  • Posts: 3
    • View Profile
3D frustum clipping
« on: January 10, 2017, 05:30:45 AM »
Do the 3D sprites handle full 3D frustum clipping? Or will I need to manually clip against the near and far planes?

I'm expecting my Vectrex32 to arrive tomorrow and am really keen to use that 200MHz processor + floating point for some 3D graphics. I'm hoping to have lighting and hidden surface removal going at a decent frame rate.

A couple of years ago I coded this demo in 6809 assembly.

https://www.youtube.com/watch?v=awMUFCYnQ4U

Vectrex32

  • Administrator
  • Full Member
  • *****
  • Posts: 101
    • View Profile
Re: 3D frustum clipping
« Reply #1 on: January 10, 2017, 11:17:22 AM »
Vectrex32 has a clipping feature for 2D sprites. The way to do 3D fustrum clipping is to apply the 2D clipping feature to the view, after the perspective transform has been done (since, after the perspective transform, 3D sprites have been flattened to 2D). In the Vectrex32 manual, see sections 7.9.5 and 7.6.2.4.

- Bob

Krion

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: 3D frustum clipping
« Reply #2 on: January 10, 2017, 09:11:55 PM »
Thanks Bob.

I actually want to have large 3D models (like terrain) so I'll have line segments that will intersect the front clipping plane and go behind the camera, causing divisions by negative numbers in the perspective transform.

I'll code my own full 3D frustum clip instead and share the code on here when I'm done.

Vectrex32

  • Administrator
  • Full Member
  • *****
  • Posts: 101
    • View Profile
Re: 3D frustum clipping
« Reply #3 on: January 10, 2017, 10:50:00 PM »
I was thinking of writing a Tail Gunner game which would have enemy spaceships flying towards and then behind the camera. So I wrote the Vectrex32 code to do the necessary clipping of a line that goes behind the camera. Don't write your own frustum clipping until you test the built-in capabilities.

- Bob

Krion

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: 3D frustum clipping
« Reply #4 on: January 11, 2017, 04:16:29 AM »
Oh cool, but if it can go behind the camera and look right surely there must be more to it than just doing the perspective and then clipping in 2D? Plus there's the risk of division by zero if a point has the exact same z coordinate as the camera?

Anyway unfortunately my Vectrex32 didn't arrive today, according to the tracking code it's in Australia and up to our local postal service to get it to me. But when it arrives I'll certainly spend a lot of time tinkering before writing any of my own code.

Since the Vectrex can only render a limited number of lines per frame, that 200MHz processor can do an awful lot of processing for each one. Even algorithms that run in O(n^2) (as many do) should be possible. So I'm really hoping to get some low-res but ultra fancy 3D working on Vectrex32, especially some sort of geometric depth buffer to produce proper clipped occlusion.

Really excited about the possibilities, can't wait till it arrives! :)

Vectrex32

  • Administrator
  • Full Member
  • *****
  • Posts: 101
    • View Profile
Re: 3D frustum clipping
« Reply #5 on: January 11, 2017, 09:00:23 AM »
Oh cool, but if it can go behind the camera and look right surely there must be more to it than just doing the perspective and then clipping in 2D? Plus there's the risk of division by zero if a point has the exact same z coordinate as the camera?

Right. It's a different chunk of code doing the behind-the-camera clipping.

Please keep us up to date on your Vectrex32 work. It sounds interesting.

- Bob