Dark Bit Factory & Gravity

PROGRAMMING => Freebasic => Topic started by: Stonemonkey on February 07, 2012

Title: Triangles again!
Post by: Stonemonkey on February 07, 2012
Not having done much for a while I've been looking at triangles again. It's not really doing much atm, affine mapping with vertex colour modulation. Anyway, I remembered Jim suggesting ages ago about using types for the edges so using that I found I can get away with only calculating the gradients down the main edge no matter what side it's on and the clip/sub-pixel code can still take care of it without any changes and only the gradient for x is needed for the short edges.

Not very exciting but thought it was pretty cool as it tidies up some things I didn't like before.
Title: Accidental function!
Post by: Stonemonkey on February 18, 2012
Taken this a bit further now and got some cubes, to allow some flexibility, instead of shading the pixels in the rasterizer I am just writing the shade value into the alpha channel then shading in a pass over the buffer after rendering. I did this before for doing stencil shadows so only 1 pass was needed. I wasn't masking the alpha from the texture in the rasteriser and thought I should just make sure there's no alpha in the texture to interfere with the shading.
Anyway, I was just trying to come up with a way using the brushes to switch shading on/off for the triangles when I noticed I could just write &ff into the alpha of a texel and it won't be shaded.
Might be other stuff I can do with this too, not sure what yet but I could make the shading 7 bit instead and use the last bit in the texture for other things, any ideas anyone?
Title: Re: Triangles again!
Post by: ttemper on February 18, 2012
WOW, you've been busy, and a nice 3d engine to boot. I'd like to see this in action, got any binary examples to show? I can definitely learn from this, excellent stuff Stonemonkey.

*edit, nevermind about that binary, I should have read the whole code first, saw the loops at the end. nice once. looks fantastic.
Title: Re: Triangles again!
Post by: Stonemonkey on February 20, 2012
It's mostly some old stuff I'm trying to cobble together  with some new bits n pieces since I've not done anything for ages.
Title: Re: Triangles again!
Post by: Kirl on February 20, 2012
Can you post an exe?
Title: Re: Triangles again!
Post by: Stonemonkey on February 20, 2012
Sure but it's just another of my wierd cube tests. Been trying a bit of sse/mmx here but I need to look into other things too, been reading some of Abrash and Carmacks stuff so have some things to think about.

There's a slight bug in the sse version, the first pixel of the scanlines isn't always coloured properly.
Title: Re: Triangles again!
Post by: Raizor on February 20, 2012
That's really quite trippy and hypnotic to watch Stonemonkey :)

How many cubes are there?
Title: Re: Triangles again!
Post by: Stonemonkey on February 20, 2012
Only 10k cubes atm.
Title: Re: Triangles again!
Post by: Kirl on February 20, 2012
Thanks for compiling Stonemonkey, I'll second Raizor! :)

I love tests, especially weird ones where most of the stuff doesn't make sense to the uninitiated! You did well!  ;D