flat assembler
Message board for the users of flat assembler.

Index > Projects and Ideas > generic software rendering question

Author
Thread Post new topic Reply to topic
bitshifter



Joined: 04 Dec 2007
Posts: 764
Location: Massachusetts, USA
bitshifter
Hello, i am writing a triangle rendering software for my game engine.
So far i have the basics done, consisting of a projection algorithm, a midpoint line clipping algorithm and an incremental line drawing routine.
Now its time to start splitting triangles in the clipper and then filling them using the standard scan line approach.
I have seen a few snippets of code that do this but they allocated memory on the heap every time they split a polygon.
What i propose to do is store some room for the splitting on the stack.
So my main question is (for you heavy thinkers) what is the maximum number a triangle would need to be split against the viewing rectangle.
After playing around in my favorite paint program i came to the conclusion that a triangle would never need to be split into more than five pieces.
If you can produce a situation where the triangle is to be split into more than five children then i would like to to know how. (an image would be preferable).
Ok, thanks for your time...
Post 08 Mar 2009, 18:38
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2141
Location: Estonia
Madis731
Too bad the DevMasters.net site is down currently, but I'll try to draw something.

You mean like this (see attachment)?
Actually you don't need stack if you are certain how much you need to store. Things on stack, at least what I think, are of uncertain size. Recursive stuff etc. When you know that five triangles is max, then make a buffer of 5 triangles Smile

Can you show us a demo of your engine maybe in some near future?


Description: Clipped to 7-corner polygon and 5 trisegments
Filesize: 3.54 KB
Viewed: 4800 Time(s)

Clipped.png



_________________
My updated idol Very Happy http://www.agner.org/optimize/
Post 09 Mar 2009, 17:45
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 764
Location: Massachusetts, USA
bitshifter
Hi Madis731
It seems we are are the same page.
My triangle to viewport placement is just like your image.
(Besides my version as triangle strips, and your version as triangle fan)
As for data storage, i agree with you also.

Since i am doing this project alone, i choose to firstly write/debug using C/C++.
Right now i have two basic render engines written in C/C++.
One of them uses opengl only to place a pixel in dc.
The other uses win32 gdi to place pixel in a dib.

Right now, my line clipper and line renderer are not agreeing with each other.
(They dont match up when i render the line, then clip it to a test box, then render it again)
It seems im suffering from a round off error but i havnt found it yet.
I know the line rederer is solid because it matches opengl lines perfectly.
The clipper is a mid-point algo and the renderer is an incremental algo.
This seemed like the quick and easy approach to start with.
I might even end up punching out a mid-point algo for the renderer.
I may even switch the clipper over to a barsky type method, which calcultes the clip in a single pass.
The only problem with this method is that it uses a farking huge switch block.
I have so many great ideas for this with all these great method choices.
As soon as i can get this stuff squared off i will then start some fasm code.
I am going to initially use the dib method when i do switch over to fasm.
Post 10 Mar 2009, 01:55
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2141
Location: Estonia
Madis731
Don't forget to visit us again, if you have any FASM-specific questions Smile Btw, I've written some rendering code in my lifetime. Most of it was for the MenuetOS, but I have also tried some binary test-code in my machine that I can't use anywhere without a complete solution Razz

EDIT: I finally got the DevMasters page, its up again.
Probably too beginning: http://www.devmaster.net/articles/software-rendering/part3.php
I've read this too and it gave me quite a bit: http://www.devmaster.net/articles/software-rendering/part4.php

Now the real gem: http://www.devmaster.net/forums/showthread.php?t=1884
It wasn't until 29th March 2007 that I found it and converted to FASM on page 3 (http://www.devmaster.net/forums/showthread.php?t=1884&page=3).
You can read from there on because then some new ideas are thrown in and discussed on...
...and as I'm reading now, it seems to be still active after 5 or so years Very Happy
Post 10 Mar 2009, 08:46
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 764
Location: Massachusetts, USA
bitshifter
Madis731:
It seems you guys are way ahead of me.
Are you using triangle bounding box tests in your code?
Do you even have to split triangles to render them?
I will study your code a bit when i get some more time.
Post 15 Mar 2009, 22:28
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2141
Location: Estonia
Madis731
Actually not very far ahead. I'm not doing triangle splitting, but I am checking for screen edges. I don't know yet what is more reasonable.

What my little engine could do the last time I touched it, was http://www.tud.ttu.ee/~t060429/Up/Cars5.PNG or this: http://www.tud.ttu.ee/~t060429/Up/Cars3.PNG

NB!!! Actually you can see holes in the geometry and this is because of my ASM-code. I still haven't found a bug so you should use the C-code first. I will get to the code sometimes later (maybe months) and start optimizing with more care on precision. Smile
Post 24 Mar 2009, 10:10
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.