UnderwareDesign
February 23, 2018, 06:22:11 PM *
News: PlayBASIC V1.64P4 (Revision 4) Released  (24th,Mar,2016)
   Home    
Pages: 1 [2]
 
Author Topic: Building a basic 3D Engine  (Read 2044 times)
Member
Development Team


WWW
« Reply #15 on: April 09, 2017, 12:20:36 AM »




 Steve,

     dragged some super old code out and made a version  for PB that supports Z buffered rendering at least..  if nothing more it might be handy as reference.  Actually runs OK in PBV1.65, but we are talking about plotting pixels here so it'll never be extreme in plain PB.. 

Logged

Member

« Reply #16 on: April 10, 2017, 09:08:52 AM »

cool kev, i would like to see the code for reference.

i have looked at a few videos about this, and it seems you need to be able to code in parallel for the graphics card, for this to work effectively, so that several pixels are calculated at the same time. has playbasic got commands to do this?

   thanks, stevmjon
Logged

re-starting my platform game from scratch...determined to release a demo!
...if i can stop playing 'Skyrim' that is. oh look, another game expansion. must download now.
Member
Development Team


WWW
« Reply #17 on: April 10, 2017, 09:47:11 AM »

Quote
i have looked at a few videos about this, and it seems you need to be able to code in parallel for the graphics card, for this to work effectively, so that several pixels are calculated at the same time. has playbasic got commands to do this?

  They're most likely talkings about shaders..  Old hardware renders are fixed function pipeline,  which is what it sounds like, the old device has a chunk of logic to render a triangle (or a DOT/LINE etc etc or each surface stype).   The issue with those is the more effects they need to jam in the bigger foot print of the GPU..

   So they move to the shaders about DX9..  These are user defined code code fragments that run on the GPU.  They used to be very limited in terms of size and speed..  but today high end GPU's are like like a rats nest of shader units..  So  shader code runs in parallel across as many many shader units at time as possible. So rather doing one texel at time they can do many.

  You could do shader via OpenGL ..    In other words do all your scene and just render meshes...  Which is how GL apps work anyway..  


  G2D - 2D OpenGL library for PlayBASIC V1.64P (login required)

  
Logged

Member
Development Team


WWW
« Reply #18 on: April 11, 2017, 09:32:08 PM »

 Z buffered gouraud shading in PB V1.65 runtime  :  get Source Code



PB165-Z buffered Gouraud Shading.jpg (79.57 KB, 816x639 - viewed 30 times.)

PB165-Z buffered Gouraud Shading-V002.jpg (69.92 KB, 813x639 - viewed 27 times.)
Logged

Member

« Reply #19 on: April 12, 2017, 02:47:50 AM »

that looks good kev.

can you post the code?

just a question, i am not too sure about part 3 in my pic. it seems you need to squish the frustum down the z to form a cube. that i understand, but the z values are too high and bunched up(0.8 to 1.0). only the points very close to the camera get lower values. not sure if you are supposed to center part 2 in the 3D world then do part 3?

NOTE: the formulas in the pic are only there as reference. i don't expect you to calculate them (i know you get busy). just wondering if my theory is correct.

thanks,  stevmjon








perspective grid_1.png (80.32 KB, 1440x1000 - viewed 28 times.)
Logged

re-starting my platform game from scratch...determined to release a demo!
...if i can stop playing 'Skyrim' that is. oh look, another game expansion. must download now.
Member
Development Team


WWW
« Reply #20 on: April 12, 2017, 04:50:58 AM »


  The code was posted to the source code board ..  Smiley
Logged

Member
Development Team


WWW
« Reply #21 on: August 30, 2017, 08:11:35 AM »


 Here's some OLD examples you might find useful,


   - Direct X (ASCII) loader
   - ASC II 3D Object Loader / Viewer V0.02


Logged

Member

« Reply #22 on: September 02, 2017, 02:42:00 AM »

thanks kev, you read my mind.
i was thinking about loading .obj files in soon. i can make them with 3D software i have(Lightwave 3D).

i am tinkering with the UV maps at the moment. i have re-made my clipping routines with a more efficient one(i am clipping in two locations), and i am just getting the UV maps to match the clip, then i will subdivide the closer polygons for a better looking texture. i am also reading up on perspective correct texture routines too.

i hope to release another update very soon.

stevmjon

Logged

re-starting my platform game from scratch...determined to release a demo!
...if i can stop playing 'Skyrim' that is. oh look, another game expansion. must download now.
Member
Development Team


WWW
« Reply #23 on: December 11, 2017, 08:32:29 AM »

 Here's a site with some 3D game model rips

 https://www.models-resource.com/


 something like StarFox64 could be fun

 https://www.models-resource.com/nintendo_64/starfox64/


Could prolly do somthing like the SNES version at least.






Logged

Member

« Reply #24 on: January 08, 2018, 04:26:42 AM »

hello

   about time i put up another update. this one has all polygons textured, and i have modified the clipping routine to clip in 2 locations in the game engine.

 1> clip early in the camera space by clipping everything behind the near border (this gets rid of everything behind the camera).
 2> then clip later in the perspective space (frustum transformed into a cube) by clipping on the remaining borders because here is a faster clipping operation.

   the reason for this split gives the advantage of 1 clip done early in the engine with 1 efficient border check, and the remainder of the clips done in the more efficient perspective cube stage, preventing the need to interrupt the matrix calculations at this perspective stage if all borders were checked here.
    this way all the clips are done on frustum borders that are perpendicular to an axis, so eliminating the need for dot product calculations in the border checks. all i need to do is simply check the position of a point/vector and compare this with the border location. eg. is X<-1(left border) , is X>1(right border) etc. even the camera space near border is perpendicular to the z axis so is just a location check too(eg. is Z<0.1(near border).

i have applied 1 formula for all polygon clipping routines regardless of where in the game engine, and also applied this to the clipped UV texture too. the UV's seems to work well with clipped quad polygons, but i don't think the UV is completely accurate with clipped tri polygons(mainly on the inside edge). i may have play around with this a little more.
i want to work out this UV clip before i move on to subdividing poly's etc.

Version 0.5.2

   enjoy this early update, stevmjon


3D Engine Build v05_2.zip (3290.09 KB - downloaded 3 times.)
Logged

re-starting my platform game from scratch...determined to release a demo!
...if i can stop playing 'Skyrim' that is. oh look, another game expansion. must download now.
Member

« Reply #25 on: January 08, 2018, 04:35:02 AM »

here is a pic for the above post. it wouldn't let me post both the image and the pic, saying over maximum allowed size. i thought each attachment was up to 3,500k each? it must be a total of 3,500k for all attachments combined size?

pic for above post v0.5.2



3D Engine build_v052.jpg (242.92 KB, 1040x807 - viewed 15 times.)
Logged

re-starting my platform game from scratch...determined to release a demo!
...if i can stop playing 'Skyrim' that is. oh look, another game expansion. must download now.
Pages: 1 [2]
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.13 | SMF © 2006-2009, Simple Machines LLC | Privacy Policy Valid XHTML 1.0! Valid CSS!