Making a 3D (viewport-ish)/real-time renderer.. from skratch

Discuss stuff not about Indigo.
User avatar
zsouthboy
Posts: 1395
Joined: Fri Oct 13, 2006 5:12 am

Post by zsouthboy » Tue May 01, 2007 11:51 am

Holy shit man!

Nice job!


Now hurry up and kick Indigo's ass, and we'll all be using Arnego in no time at all :D

User avatar
zsouthboy
Posts: 1395
Joined: Fri Oct 13, 2006 5:12 am

Post by zsouthboy » Tue May 01, 2007 2:44 pm

arne, you've inspired me to try my hand at actually implementing a rasterizer too.

Here's a link to how far I got today: http://www.zsouthboy.com/lame.zip

Almost have a coherent triangle! :D (The extra lines are fun, eh? Wee!)

Such a great brain exercise though - having to remember trig functions that i don't get to use in every day life!

First thing I'm doing when I get to rasterizing multiple triangles (correctly) is finding a way to write to a buffer, that is memcpy'd to the screen - it's farkin slow to write line by line.

User avatar
CTZn
Posts: 7240
Joined: Thu Nov 16, 2006 4:34 pm
Location: Paris, France

Post by CTZn » Tue May 01, 2007 3:47 pm

Hehe, nice Arne !

Er, I'm counting 8 tris, is that me ?
obsolete asset

User avatar
Kram1032
Posts: 6649
Joined: Tue Jan 23, 2007 3:55 am
Location: Austria near Vienna

Post by Kram1032 » Tue May 01, 2007 9:10 pm

lollish raserizer, zsouthboy!
yup funny lines :P

User avatar
arneoog
Indigo 100
Posts: 504
Joined: Sun Jun 25, 2006 2:19 am
Location: Norway
Contact:

Post by arneoog » Tue May 01, 2007 10:39 pm

I just woke up just now and knew exactly what I had to do to make it z-buffer the image! :D
So I fixed this in five minutes after I got out of bed,
and now it's working!!!
WOOHEE!!! :D

>>Working Z-Buffer<< :D :D :D

zsouthboy/Chris, I couldn't run you "Lame" renderer.. :?
Cool name on a renderer :P

I don't think I can even think of kicking indigo's ass yet :lol:
Arne OOG - My Portfolio

User avatar
Kram1032
Posts: 6649
Joined: Tue Jan 23, 2007 3:55 am
Location: Austria near Vienna

Post by Kram1032 » Tue May 01, 2007 10:45 pm

!!!
:D
what are those splitted edges?

Btw: what ever you did: I don't need to rewrite the link anymore, now :D It works directly!!

User avatar
zsouthboy
Posts: 1395
Joined: Fri Oct 13, 2006 5:12 am

Post by zsouthboy » Wed May 02, 2007 12:14 am

You need .net 2.0 installed, to run my crappy crap crap. :)

Awesome that you got z buffering up and running.

What is next? I suggest working on the aliasing between tris (in the large box).

User avatar
arneoog
Indigo 100
Posts: 504
Joined: Sun Jun 25, 2006 2:19 am
Location: Norway
Contact:

Post by arneoog » Wed May 02, 2007 4:03 am

WoooHoooooo!!! :D :D :D
I got colors and selection to work!!!

http://roxworth.elqx.com/obj_viewer/?s= ... =cubeSmall


EDIT:
New Url variables:
- &selected= (model name)
- &wire= (1)
- &hide= (model name)
Last edited by arneoog on Wed May 02, 2007 4:31 am, edited 3 times in total.
Arne OOG - My Portfolio

User avatar
Kram1032
Posts: 6649
Joined: Tue Jan 23, 2007 3:55 am
Location: Austria near Vienna

Post by Kram1032 » Wed May 02, 2007 4:26 am

looks great, already!
the edges still are splitted :S

User avatar
arneoog
Indigo 100
Posts: 504
Joined: Sun Jun 25, 2006 2:19 am
Location: Norway
Contact:

Post by arneoog » Sun May 13, 2007 11:10 pm

Questions:
How can I find the current depth on a triangle for any given point?
Having big problems finding a way to do it.. :?
..right now it's just taking the mid depth of each tri..

And, any idea why there is gaps between each tri? :)
example

Thanks! :D
Arne OOG - My Portfolio

User avatar
Kram1032
Posts: 6649
Joined: Tue Jan 23, 2007 3:55 am
Location: Austria near Vienna

Post by Kram1032 » Sun May 13, 2007 11:14 pm

maybe, your float isn't accurate enough???

two last problems, before it can called somehow a 3D-renderer :S

User avatar
arneoog
Indigo 100
Posts: 504
Joined: Sun Jun 25, 2006 2:19 am
Location: Norway
Contact:

Post by arneoog » Wed May 16, 2007 5:18 pm

Yeah you're probably right, Mark..
I'll try to fix this later..

But does no one know how to do per pixel Z-Buffering? :?
I really want to get this working, and make it C++ :)

...
Arne OOG - My Portfolio

User avatar
zsouthboy
Posts: 1395
Joined: Fri Oct 13, 2006 5:12 am

Post by zsouthboy » Wed May 16, 2007 11:52 pm

Two things:

1) For any given point you're shading in a tri, to find the distance from camera, simply interpolate the z value of each vertex to that pixel. Same equation as the scanline rasterization!


2) Gaps between the tris are result of subpixel inaccuracy. All modern renderers (OGL & D3D) take care of this problem by shading a pixel :: the TOP LEFT POINT of it is inside the tri.

Check http://www.devmaster.net/articles/softw ... /part4.php :)

User avatar
arneoog
Indigo 100
Posts: 504
Joined: Sun Jun 25, 2006 2:19 am
Location: Norway
Contact:

Post by arneoog » Fri May 18, 2007 11:13 am

ah, okay :)
Thanks, zsouthboy (again :P) :D

New question: :lol:
I can't find any info/tutorial on how to write a .bmp file using only basic C++..
I have an example of it, but it's in such a complex code that I can't figur out how it actually work :?
Would be very nice if someone knew a page with all info regarding this,
or could post/send a very simple example of how to do it.. :)

Btw, I have transformation, projection and triangle filling working in C++ now :D
..but only printing the result as characters.. *hint hint* hehe ;)


Cheers!
Arne OOG - My Portfolio

User avatar
zsouthboy
Posts: 1395
Joined: Fri Oct 13, 2006 5:12 am

Post by zsouthboy » Fri May 18, 2007 11:30 am

.BMP files!

Yay!

Something I know!

I'll find my notes, but I wrote something to generate graphs in ASP a while back, and it out put 24-bit BMP files. I didnt' deal with any compression BS :)

I'll have to find the list I have in mind, it was basically byte offsets (where to write what values).

Post Reply
64 posts

Who is online

Users browsing this forum: No registered users and 16 guests