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

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

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

Post by arneoog » Mon Apr 30, 2007 10:13 am

Intro, and stuff
I am really trying to programme a real-time renderer.
At the moment I'm just at still frames, and only drawing lines :P
And it's, at the moment, written in PHP :lol: because that's the language I know best..
But when I've got it working at a per pixel level, I will make it into C++

Now, it's this per pixel part I'm having problems with.. :? (If that's actually what I must do)
I can't find good enough info on Z-buffering or just perpixel drawing.
How to scan the image, set color where there is tris, find depth, ect..


The renderer, so far
It isn't all that much.. It decodes OBJ files, projects and transforms them,
then it just draw lines :)
(This is what I don't want it to do, eventually..)

>>Link to the "renderer"<<
(or what ever you want to call it, heh)


Url variables:
  • f - [file] - you can use all the files in the /obj directory (/?f=suzanne)
    s - [size] - this changes the size of the object (/?s=4)
    rx - [rotateX] - this changes the x rotation of the object, in degrees (/?rx=45)
    ry - [rotateY] - this changes the y rotation of the object, in degrees (/?ry=30)
Example using all the variables:
/?f=srr&s=50&rx=40&ry=-20
in action


Some questions
Okay.. How do you do the Z-Buffering or do anyone know an excellent tut on how to code a simple one?
And How to use this Z/pixel info for materials?
And so on.. :)

I don't need full anweres on everything, but tips and such would be nice :)
Probably after understanding the Z-Buffer and made it, I will know better how to do the rest.. :P


Cheers!

Oh, sh*t! This got long, hehe..
Last edited by arneoog on Tue May 01, 2007 11:42 am, edited 1 time in total.
Arne OOG - My Portfolio

User avatar
daniel_nieto
Posts: 173
Joined: Wed Apr 11, 2007 10:45 am
Location: Ciudad Guzman, Jalisco, México
Contact:

Post by daniel_nieto » Mon Apr 30, 2007 7:00 pm

it would be very interesting to see indigo's competition, (just kidding, or it will be?), wooow, man, i really want to do a render from scratch in the future too, maybe in java, like kerkythea, or some... well, at least it would be easy to emmigrate to C++ from php, since their sentences are very similar... i love php! unfortunately, i cant help you with any of your Q's, sorry, keep on the good work!!! Cheers!
Image From México, Daniel Nieto .·.

User avatar
manitwo
Posts: 1029
Joined: Wed Jul 05, 2006 4:50 am
Location: Tirol - Austria

Post by manitwo » Mon Apr 30, 2007 8:23 pm


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

Post by arneoog » Mon Apr 30, 2007 11:50 pm

daniel_nieto, Thank you! :)

manitwo, Yepp, I've seen them.. but they are way to advanced for me to
understand how it's made, but I'm not going to make a raytracer anyways :P
If I've understood the meaning of the words, biased and unbiased..
This will be a very biased renderer :D

...
Arne OOG - My Portfolio

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

Post by zsouthboy » Tue May 01, 2007 2:00 am

Z buffering is simply storing an extra buffer, then comparing your current pixel's "z" value with the corresponding spot in the buffer. If the current z value is closer to the camera than the current z buffer value, the pixel is written to the framebuffer, and the z buffer is updated with that just written pixel's z value.

It's a way of preventing yourself from rasterizing tris that are are going to end up being occluded in the final render. That's all. Nothing special.

:)

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

Post by Kram1032 » Tue May 01, 2007 2:29 am

Raytracing = biased form of Pathtracing, as far as I know...
It's rays, that are shooten ONCE, and then get redirected with the camera.
Mirrored surfaces just are bouncing a limited time (very few, like between just once and maximally ten times...)
Diffuse mats wont have ANY effect of the "Neighbour" material. A simple white diffuse wont get redish, when there is a red diffuse next to it.

This can be done in realtime.

Realtime-fakeSSS is done a quite nice way, as far as I know:
It uses blurmaps, that define, how much the light gets blurred and it uses the same ray, that is reflected AND goes throught the surface, instead of beeing reflected hundrets of times...

_______
More or less guessed ;)

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 2:43 am

heh...
I know how a Z-Buffer works, but not how to code it.. :S
Or how to get a script to understand that it's hitting a triangel..
This is the part I need help with..
Is it done on a par triangle level, or the whole scene/model at once?

Arg.. It's hard to find the info I need, have been searching for days now :(
Arne OOG - My Portfolio

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

Post by zsouthboy » Tue May 01, 2007 4:16 am

arne:

I don't understand the touble you are having with z-buffer:

*goes to check the link to your current version*


Oooooooooooooooh. Okay.

Right now, you're not really doing rasterization. You're simply drawing vector graphics (using a drawLine function or some sort probably?) with no care for occlusion or material color.

To make the move to rasterization, you have to do more work :)

http://en.wikipedia.org/wiki/Rasterisation

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 4:24 am

I knew I had to do something like that! :D
Thanks for the link, I'll read my eyes out (almost) :P

I wrote that it's just drawing lines, hehe :)

Thanks!
Arne OOG - My Portfolio

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

Post by zsouthboy » Tue May 01, 2007 4:36 am

I didn't mention it, but you are doing a good job :) You've already figured out perspective and transformation.

If you need some more help feel free to ask.

Hell, I have to be honest, I entertained the idea of creating a renderer in ASP, just to play with. Never got around to it.

EDIT: I'm going to try to find the name of the book that finally made rendering "click" in my head. It goes, step by step, through how to make a software scanline renderer, explains lighting and how to implement it, etc. It's all in C or C++ IIRC.

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 4:44 am

Sweet!
Thank you, zsouthboy! :D :D
(I doubt that's your real name, but whatever..)

I like images :)
Image
Hehe..

EDIT: But I still don't understand how to code it :P :lol:
I'll read and search more...
Arne OOG - My Portfolio

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

Post by zsouthboy » Tue May 01, 2007 7:03 am

Here you go, straight from SIGG:

http://www.siggraph.org/education/mater ... lygon1.htm

then

http://www.siggraph.org/education/mater ... lygon2.htm

That should be exactly where you're stuck.

EDIT: Real name is Chris, btw. "zsouthboy" is.. a long story. Don't ask :)

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 7:25 am

Yay! :D
That's exactly what I needed! ..I think :P

Thanks, Chris! :D
Arne OOG - My Portfolio

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:02 am

!!!WARNING: MAY CONTAIN BAD LANGUAGE!!!


SWEET FUCK, I MADE IT!!! :D
IT'S DRAWING TRIANGLES!!! :D :D :D


Okay, now I'm happy. :P


EDIT: it's alittle slow.. but here is a small model as a preview :P
http://roxworth.elqx.com/obj_viewer/?f=box2&s=10
Last edited by arneoog on Tue May 01, 2007 10:07 am, edited 1 time 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 » Tue May 01, 2007 10:04 am

:D

Post Reply
64 posts

Who is online

Users browsing this forum: No registered users and 4 guests