Oysi's 3D Rendering & Physics Engine

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Oysi
Prole
Posts: 48
Joined: Fri May 02, 2014 11:18 pm
Location: Earth

Re: 3D Rigid Body Physics

Post by Oysi »

Should I make a new thread specifically for my rendering engine, or should I just keep posting in this one?



substitute541 wrote: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.
I don't believe that it sucked. And if you don't believe that I don't believe, take a look at this (http://love2d.org/forums/viewtopic.php?f=5&t=2494). I started out small. In fact, I was even doing some rendering stuff before that, back in 2008-ish. Projecting 3D points onto the 2D surface of a 3D object, with 3D objects. Yeah... But the point is, this isn't my first rodeo. I've had a long journey to get to where I am now. The most important advice I can give you is to not give up. I've been faced with numerous problems that I've nearly ripped my head off, trying to solve. I remember back when I was trying to wrap my head around matrices. I couldn't for the life of me understand what they were all about, but I kept trying. And now it's as simple as 2 + 3. You just need to be persistent. As cheesy as it sounds, never give up.
Jasoco wrote:I eschew per pixel z-indexing and shading for pure speed.
Actually, the depth buffer and shading hardly takes up any time at all. With 0.9, we can render to several canvases individually, from the shader. So all I do is just set 2 canvases and then pass the z buffer and color information to the z buffer and scene canvas respectively. And the shading is uber fast. Doesn't do anything to the performance. That is, as long as I keep it on the shader, and not in Lua. Can you imagine that? Running a calculation 480k times on the GPU with GLSL is A LOT faster than once on the CPU with Lua.
Jasoco wrote: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?
That is quite incorrect. The scene is set up in Lua. The scene is processed in Lua. The scene is projected in Lua. And lastly, the scene is drawn using love.graphics.polygon, in Lua. I only use a shader for special stuff like the z buffer, shadows (which is basically just the z buffer), and more recently I've been doing texture/normal mapping which requires a shader, as well as some per pixel shading and effects like god rays. But the engine itself is governed by Lua. I can render a scene quite nicely without using a shader. In fact, the demo originally showcased in this thread (the rigid body stuff) doesn't use a shader at all. Everything is Lua.
ArchAngel075 wrote: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!
Thank you! That means a lot to me. =)
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: Oysi's 3D Rendering and Physics Engine

Post by HugoBDesigner »

I don't think you should post another thread. This one is already focused on the project and is on the right subforum. Just change the title in the first post (I made my own title as a suggestion).

The video is REALLY, REALLY cool. You made it look so smooth and detailed that I could easily forget you were using LÖVE2D. Not sure how hard is it to make this engine looking so cool (3D related stuff are probably REALLY hard, I think), so I don't know whether or not you accept suggestions. I was going to suggest normal maps, so we can have the effect of your video in any texture. Here's a very good example of usage of Normal Maps, if you want to make it:

Löve "Light vs. Shadow" Engine [0.4.3]

Really good work until here, I can't wait to see the final result :awesome:
@HugoBDesigner - Twitter
HugoBDesigner - Blog
User avatar
Oysi
Prole
Posts: 48
Joined: Fri May 02, 2014 11:18 pm
Location: Earth

Re: 3D Rendering & Physics Engine

Post by Oysi »

Oh, cool, I didn't realize you could change titles. xD

And thanks. Also, I love suggestions! Anything to keep me learning and making stuff. =D And I would love to go ahead and execute your suggestion, BUT... I already made it. The video you just saw actually features normal maps. See, what I did was I took the basic black/white picture, used black as (0, 0, 1) normal, and did some hax and interpolation and whatnot in order to get the normal map. It essentially takes the edge of the black stuff and extends and rounds it by a certain amount of pixels (customizable in the shader), and creates a normal map. Took me a while to make, but it's quite cool to be able to just write down some text, pop it into the thing and have it work just like that.

Essentially it turns this (https://love2d.org/imgmirrur/f5FFbZO.png), into this:

Image

Then it renders 2 triangles with the proper texture coordinates for each vertex, runs the shader and boom tada, normal map is there. It's funny, I also found myself realizing why all normal maps always look so similar. I might not have used the exact same format, in the sense of which color is used for which direction, but it still looked very familiar. Fact is, it's just practical. I saved the normal map in a way I found most practical, which was (x + 1)/2, and logically looked it up as r*2 - 1. Anyway, for the picture of the other normal map:

Image

Just some random normal map I found from a quick google search. BTW, always disregard the fps of the screenshots that I take. Taking a screenshot will inconsistently lower my fps by around 5-10 for a brief moment. Rendering these bumpmaps is a small performance hit, but not too much. Primarily it's just because the shader code is horrible right now (And I mean HORRIBLE). But I can still render the same scene at about half fps while using the thing. But just to settle any doubts:

Image

I don't even remember how many triangles that was. A couple thousand, most likely. (I took these pics a few hours ago).
Follow the potato. Achieve enlightenment.
User avatar
Oysi
Prole
Posts: 48
Joined: Fri May 02, 2014 11:18 pm
Location: Earth

Re: Oysi's 3D Rendering & Physics Engine

Post by Oysi »

Bump
Follow the potato. Achieve enlightenment.
User avatar
Sheepolution
Party member
Posts: 264
Joined: Mon Mar 04, 2013 9:31 am
Location: The Netherlands
Contact:

Re: Oysi's 3D Rendering & Physics Engine

Post by Sheepolution »

Holy shit. I'm super impressed. I wouldn't even know how to begin creating something like this, good job! So how far can this go? How big can the games get?
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: Oysi's 3D Rendering & Physics Engine

Post by bobbyjones »

if you can do this why not try to make a 3d version of love. of course you would have to use C I think but the math would be the same.
User avatar
josefnpat
Inner party member
Posts: 955
Joined: Wed Oct 05, 2011 1:36 am
Location: your basement
Contact:

Re: Oysi's 3D Rendering & Physics Engine

Post by josefnpat »

Any released code for this project? I'd be interested in trying it out...
Missing Sentinel Software | Twitter

FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
User avatar
Oysi
Prole
Posts: 48
Joined: Fri May 02, 2014 11:18 pm
Location: Earth

Re: Oysi's 3D Rendering & Physics Engine

Post by Oysi »

Sheepolution wrote:Holy shit. I'm super impressed. I wouldn't even know how to begin creating something like this, good job! So how far can this go? How big can the games get?
Thank you. As for its practicality, not much. =P But you should be able to render a good couple thousand polygons on any computer, and tens of thousands on better computers. You won't be able to do any detailed scenes or big open world stuff or anything like that. The main point is the fun of making it, and the fact that it is done in a limited 2D framework (and I mean limited in the sense that it's made for 2D, not 3D). It forces me to find very special and fine tuned solutions for each problem, as well as keep everything highly optimized so that I can actually render stuff.
josefnpat wrote:Any released code for this project? I'd be interested in trying it out...
I'm actually working on the basic version I was talking about earlier. I've rewritten some of it for more clarity, made a mat3 library, and documented the vec3 and mat3 libraries. But I won't be releasing the entire thing. My plan is to give you the tools and a basic implementation that you can continue on yourself. And perhaps release more later on.

In fact, I have actually made a video tutorial on extremely basic 3D rendering done in Love. Stuff that pretty much anyone could understand, but is still quite fancy rendering, and the code is only 70 lines. However, I haven't gotten myself to uploading it. I have this dark passenger that tells me everything I make is shit, and so I become very insecure. =(
Follow the potato. Achieve enlightenment.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Oysi's 3D Rendering & Physics Engine

Post by kikito »

Oysi wrote:I have this dark passenger that tells me everything I make is shit, and so I become very insecure. =(
I had that some time ago. Then I realized that the worst that could happen is that someone would not like what I made. Sometimes they have good critics. I try to accomodate what I can, and apologize if I can't.

There's a "Light Passenger" too. When people tell you that they like what you do, and that they are using it, you get very nice warm feelings and stuff. I still giggle every time I remember when sheepolution used one of my libs while winning Ludum Dare (I don't mean to steal his credit - he did all the hard work and deserved the price).

Most people who don't like your stuff will realize that you are putting it out there for them to use for free, and will just be grateful.

Some of them are not. No one has ever gone so far as to insult me, but from time to time I get someone who is not interested in learning, and just want me to do work for them for free. The frame of mind you need to handle those guys is this:
Image
Be a gentleman, say that you can't help them, and say bye. It's easier than it seems :)

Also, the first couple things I did were not exactly great. But then I got a bit better. The job I have now (not in the videogames industry, in web development) I got it partly because some of the libraries I have out there.

Release whatever you have, it's awesome! :ultrahappy:
When I write def I mean function.
User avatar
HugoBDesigner
Party member
Posts: 403
Joined: Mon Feb 24, 2014 6:54 pm
Location: Above the Pocket Dimension
Contact:

Re: Oysi's 3D Rendering & Physics Engine

Post by HugoBDesigner »

Just what kikito said... It's awesome, and I HONESTLY DOUBT that someone will come here and say that this is bad and not be joking. Seriously...

As for the optimization, may I try a suggestion? I thought of making the engine having a variable, that when you set it to true it don't renders polygons out of the screen and/or behind opaque polygons. Not sure if you already did this, though, but if not, then this might save A LOT of memory, and increase A LOT the FPS while rendering big scenes... I don't know how you'd deal with textures (getting when they have transparency might be a slow process, but maybe if you use .jpg for opaque images this might be easier...).

Anyway, keep up the good work! And you shouldn't care about people that say that "everything you make is shit". They're surely jealous of your awesome stuff!!!
@HugoBDesigner - Twitter
HugoBDesigner - Blog
Post Reply

Who is online

Users browsing this forum: No registered users and 31 guests