Oysi's 3D Rendering & Physics Engine

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
ArchAngel075
Party member
Posts: 319
Joined: Mon Jun 24, 2013 5:16 am

Re: 3D Rigid Body Physics

Post by ArchAngel075 »

Even though the impracticality of the idea is large, the FUN and JOY of playing around in a 3D environment is still jupiter-sized.

I personally would love to try and make a simple arena shooter for me and friends to enjoy occasionaly.
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: 3D Rigid Body Physics

Post by Roland_Yonaba »

Oysi wrote:Thanks! =D Although, if you guys are more interested in the rendering engine and less so in the physics, then prepare to be amazed.
This guy is killing me. As if the "rendering" part was no big deal.
Seriously, this looks amazing. I'll wait to have some code to try it out by myself, but it indeed looks astonishing.

Personally, I am not interested in 3D, and if I was going to dive into 3D, then I would probably not choose Löve. But anyway,
such proof-of-concepts are just brilliant, and I look forward to see how far this can go. So please, keep it up!

What would be very interesting is to share some of your techniques, math and calculations involved in this work as articles or blog posts. If you are inclined to do so, I am pretty sure it would be very learningful to others out there. By the way, is there any chance to abstract the actual code as an engine, so that others can include it as a third-party library to render their own custom "3D" scenes in their games ?
Jasoco wrote:Well. This makes my 3D engine look like crap.
Your engine is awesome.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: 3D Rigid Body Physics

Post by Jasoco »

Roland_Yonaba wrote:
Jasoco wrote:Well. This makes my 3D engine look like crap.
Your engine is awesome.
Haha. I know. I'd love to compare notes though. I notice some similarities between our engines. I'd planned on putting shadow casting sun in mine too but always thought since I like seeing the sun in the sky it would make the shadow always being cast from the faces you're looking at and everything would always be dark. But it looks odd with a sun in the distance and shadows from above like Minecraft. And since I rewrote the engine I haven't gotten around to reimplementing shadows anyway. I've been more preoccupied with my cave generation lately and haven't done any work on the 3D engine in a while. I keep having ideas for games I want to use my engine for but I can't bring myself to start coding them.

Hey, Oysi. I'd love to see some video of the engine in action. Also, on the topic of your framerate, that's pretty low. I know I get low framerate if I do too much too but I keep the number of polygons low and use 4-sided polys when I can instead of two triangles to draw less on screen. (Unless Löve actually draws two triangles when doing a 4-sided polygon anyway then I'm only saving myself trouble of coding the two triangles) I also don't bother with diffusion and shading. Keeping to a more SuperFX-like feel. In fact my engine is called "SuprEffex".

I also have texture support, it's kind of slow, but as long as I don't use too many textures it's fine. Thanks to a library created by xXxMoNkEyMaNxXx. I can even use canvases for the texture and in one case I actually draw a separate 3D world to a canvas and display it on another object in my main world.
Image
#ExplanaBrag

My question is how did you create the scene in those screenshots? Did you use a 3D program that exports a specific file type? Because it's hard enough for me to code the objects I have now by hand. I'd kill for a 3D program that could export in a format I could use. Also, do you split your worlds up into chunks or are you rendering the entire scene at once including stuff not on screen? Man, I'd love to compare notes. I'd be interested in seeing what parallels we used. And if your camera and 2D to 3D math is any different because mine is clunky and doesn't work exactly how a 3D camera should. (Hard to explain without showing it off really.)
User avatar
Oysi
Prole
Posts: 48
Joined: Fri May 02, 2014 11:18 pm
Location: Earth

Re: 3D Rigid Body Physics

Post by Oysi »

Jasoco wrote:Okay maybe not, but still. I see you have the same z-indexing issue as me. Not really something you can solve without actual per-pixel z-indexing. Also an early version of my engine had shadows too. But I haven't implemented them in my remade version yet.
Yeah, but I do actually have per-pixel z-indexing. And it works perfectly, actually. It's how the shadows work, as well. The problem comes with the actual depth testing. There are these strange artefacts that occur when you write to the same canvas you are reading from, from a shader. Meaning that when I get the depth and match it against the depth already stored, I get problems when I write the stored depth back into the buffer/canvas. But my actual depth buffer works fine, here's a pic of how it's saved: (you can see the artefacts in the upper left and right corners)

Image
Nixola wrote:If I recall correctly, you shouldn't be using the currently set canvas like this, as it could cause this kind of issues
I figured as much. Eventually, anyway. Heh, I spent hours trying to fix my thing, thinking it was something with my code. I finally realized it wasn't a problem with my code, but a problem with love. I tried it in a basic testing thingy where I drew random triangles and prioritized lighter color with a shader (so that they would appear on top), and I got the exact same artefacts.
Roland_Yonaba wrote:What would be very interesting is to share some of your techniques, math and calculations involved in this work as articles or blog posts. If you are inclined to do so, I am pretty sure it would be very learningful to others out there. By the way, is there any chance to abstract the actual code as an engine, so that others can include it as a third-party library to render their own custom "3D" scenes in their games ?
The code is already like an engine, excluding shadows and z buffer, where I have to manually enter all the render settings. Everything else is done from functions to my graphics lib. But like I said, I think I will upload a basic version. Containing only vec3, mat4, and some basic rendering. At least at first.
Jasoco wrote:Hey, Oysi. I'd love to see some video of the engine in action.
Well, I don't have any videos of the newest stuff. I will rewrite and optimize, as it's currently a big pile of frog legs. However, you can check out my youtube channel for some videos of some older stuff:
https://www.youtube.com/watch?v=DDS7d9hlDk8
https://www.youtube.com/watch?v=nPa6KFRSflg (this one has cloth physics =O)
Jasoco wrote:My question is how did you create the scene in those screenshots? Did you use a 3D program that exports a specific file type? Because it's hard enough for me to code the objects I have now by hand. I'd kill for a 3D program that could export in a format I could use. Also, do you split your worlds up into chunks or are you rendering the entire scene at once including stuff not on screen? Man, I'd love to compare notes. I'd be interested in seeing what parallels we used. And if your camera and 2D to 3D math is any different because mine is clunky and doesn't work exactly how a 3D camera should. (Hard to explain without showing it off really.)
I actually used Roblox. The scene in those pictures is from a map in a game that I made years ago. The game got a bit popular, but I went away for a year, never balanced shit, and never consistently updated, so yeah. But the map I made is still nice, though. xD
As for how I render stuff, I would love to go in depth into that, but I feel this post is big enough as it is. My projection is rather simple (and orthodox), in that it's a simple camera:inverse() * vertex, and then do x = x/-z, y = y/-z, and some other stuff for fov and screen ratio.
Follow the potato. Achieve enlightenment.
User avatar
Oysi
Prole
Posts: 48
Joined: Fri May 02, 2014 11:18 pm
Location: Earth

Re: 3D Rigid Body Physics

Post by Oysi »

I currently can't do all too much, as I have 4 exams coming at me in the near future, and one of them is in 12 hours. So any uploads won't happen very soon. But I did check out your engine, Jasoco. Cool stuff. And in doing so, I realized that I really fucking need some textures. So I sat down for 10 minutes, writing up a simple math problem, and boom, the textures were there. xD

I originally used a potato as the texture, but you couldn't see too much 3D in it. So I swapped to a checkers board.

Image

And just to show some speed...

Image

That is rendering 2000 triangles. Which is also the beauty of it. That reminds me, you talked a bit about rendering quads instead of triangles, for more speed. I guess that would somewhat work, but the thing is that triangles are much easier to work with. Especially with stuff like clipping and texture mapping.
Follow the potato. Achieve enlightenment.
User avatar
Oysi
Prole
Posts: 48
Joined: Fri May 02, 2014 11:18 pm
Location: Earth

Re: 3D Rigid Body Physics

Post by Oysi »

I can't control myself. With this texture mapping, since I have the UV coordinates for each pixel, I can also do normal mapping. So I applied that to my mesh, and boom. Went from this:

Image

To this:

Image

Damn, I should get back to reading for my exam now...

EDIT: swapped out the pictures with ones that use backface culling and specular shading
Last edited by Oysi on Wed May 07, 2014 5:51 pm, edited 1 time in total.
Follow the potato. Achieve enlightenment.
User avatar
HugoBDesigner
Party member
Posts: 403
Joined: Mon Feb 24, 2014 6:54 pm
Location: Above the Pocket Dimension
Contact:

Re: 3D Rigid Body Physics

Post by HugoBDesigner »

Now you can't just "not share" it. It's WONDERFUL!
@HugoBDesigner - Twitter
HugoBDesigner - Blog
User avatar
substitute541
Party member
Posts: 484
Joined: Fri Aug 24, 2012 9:04 am
Location: Southern Leyte, Visayas, Philippines
Contact:

Re: 3D Rigid Body Physics

Post by substitute541 »

This is awesome!

Reminds me of my own 3D engine which I discontinued because it sucked. I don't have my graphics card yet though, so I can't do anything that requires shaders.

Also,
shaders.png
shaders.png (921 Bytes) Viewed 4652 times
Currently designing themes for WordPress.

Sometimes lurks around the forum.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: 3D Rigid Body Physics

Post by Jasoco »

I eschew per pixel z-indexing and shading for pure speed. The way our SNES Star Fox forefathers did it before fancy graphics cards came along and Quake'd the world up. I use Lua for calculating everything except for the texture library which is a shader and just accepts four X,Y coordinate pairs and draws an image warped to that shape to the screen. The texture library only causes noticeable slowdown when a lot are used at once. But the original Star Fox games didn't use textures all that much nor did most of the 3D SFX games so I like sticking to that art style. Of course since each polygon is drawn as a separate shape sorted by distance from camera, it causes visual problems with complex 3D geometry, (Each polygon consists of 3-4 distances that are averaged. So some that should be both in front of and behind another polygon will end up being drawn improperly. This is fixed by breaking a polygon into smaller pieces.) but then again, so did the original SFX chip. (Believe me I've played enough Star Fox to notice these artifacts. They're rare but they happen.)

I just don't have any sort of 3D object creator so I do all my objects by hand through trial and error.
Oysi wrote:The code is already like an engine, excluding shadows and z buffer, where I have to manually enter all the render settings. Everything else is done from functions to my graphics lib. But like I said, I think I will upload a basic version. Containing only vec3, mat4, and some basic rendering. At least at first.
That would be really cool. Maybe then I could see what I'm doing wrong and try to fix it. Though it sounds like you're using shaders to do all the 3D work. Is this correct?
Oysi wrote:Well, I don't have any videos of the newest stuff. I will rewrite and optimize, as it's currently a big pile of frog legs. However, you can check out my youtube channel for some videos of some older stuff:
https://www.youtube.com/watch?v=DDS7d9hlDk8
https://www.youtube.com/watch?v=nPa6KFRSflg (this one has cloth physics =O)
My code is always a pile of frogs legs. It would seem physics just slows things down a lot. But it's cool. I wouldn't try to make a whole game utilize it though. Sooo sloooow.
Oysi wrote:My projection is rather simple (and orthodox), in that it's a simple camera:inverse() * vertex, and then do x = x/-z, y = y/-z, and some other stuff for fov and screen ratio.
Nope. You lost me.
Oysi wrote:I currently can't do all too much, as I have 4 exams coming at me in the near future, and one of them is in 12 hours. So any uploads won't happen very soon. But I did check out your engine, Jasoco. Cool stuff. And in doing so, I realized that I really fucking need some textures. So I sat down for 10 minutes, writing up a simple math problem, and boom, the textures were there. xD
Oh come on. Now you're just bragging. Well I can brag too. :P

At one point I had this working:
Image Image

And this was a version that has since been destroyed and not recreated yet.
User avatar
ArchAngel075
Party member
Posts: 319
Joined: Mon Jun 24, 2013 5:16 am

Re: 3D Rigid Body Physics

Post by ArchAngel075 »

Personally i WISH i had a good 3D rendering engine for LOVE, as my ultimate desired game (Agora) requires the feeling of peeking around corners ad such in a not- topdown view! (other wise doing thriller and horror is impossible)

Otherwise i can use the 3D for some effects here n there, say the baboViolent2 inspired game i am building...i need them 3D topdown walls!

BUT the most interesting piece for me is that cloth physics, im allways interested in some physics that does cool things...Heck the day i sat down and did gravitational pull from my physics class in a LOVE world i was astounded to actually have orbiting objects! (physics is fun!)

Please do keep up the work! even if its not shared code wise, just seeing it possible and happen in LUA/LOVE is a brilliant read/inspiration!
Post Reply

Who is online

Users browsing this forum: No registered users and 30 guests