Archive: I really need help this time


22nd November 2003 20:38 UTC

I really need help this time
Ok, I have made a cool solid icosaherdon with phong lightning, but im having problems with the phong, it just isnt right... i hope that somebody can figure out what is wrong with it.
If you dont understand some part of the code just ask me, ill explain.

note that you need latest avs to run it... you can get it with winamp5
link: http://forums.winamp.com/showthread....hreadid=156829

I hope someone can help me, phong amd blinn has allways been trouble to me :(

oh yea, Sidd gave me the idea (and bit of code) making solids like this, hes working on similar presets himself, so... little credit goes to Sidd


22nd November 2003 21:10 UTC

Ummm... I'm not exactly sure about this, but isn't phong shading gonna be really slow in AVS? And considering the resolution wouldn't it just be better to use gouraud shading anyways? It'd be a lot faster. And considering the benefits of phong shading on a shape that has flat surfaces anyways...


22nd November 2003 21:29 UTC

well, im getting 41-50 fps here, new avs is much much faster

I still need help :P havent figured it out myself


22nd November 2003 21:59 UTC

Ok, here is new version of it, the phong is still not correct, i think, but code is more readlable and easily understandable... if you dont have the lates avs (from my link up there) you can just replace the invsqrt() with 1/sqrt() (but you still need pre)


22nd November 2003 22:49 UTC

UIUC85: In old demo terms, phong refers to per-pixel lighting, like gouraud refers to vertex-interpolated lighting and lambert refers to flat shading.

In this case, Jack means the phong lighting model (which can be applied in any fashion), like the Blinn lighting model.


23rd November 2003 01:25 UTC

:o

jeez... fuck man..i hadnt even finished this preset yet, not to mention posted it anywhere. You are the only one who had seen the idea.... Oh well, :(

If your going to do it, i dont see why you insist on phong lighting. You cant do much about having flat colored surfaces unles you draw the zigzags at parallel to all three edges. Right now you could only shade one way. Even shading by normals isnt really necessary, you could just take the average of the three points' z coord on each triangle, and it would look much nicer than it does now.

Also, when you are working with normals on triangles, its very important that you specify the points in a consistant order:

A------B
\ /
\ /
\/
C


if you use one formula to get all your normals, and you have specified some of your points clockwise (eg, A, then B, then C) and others anticlockwise, there is no way of telling whether you have the normal, or that backface normal. Which i suspect is why some of those faces look so funny.

Or it could be just that your faces oscillate color even when the shape isnt rotating !??! :igor:

Also, wheres the backface culling, i saved over 1/3 fps when i put mine in.
Since you have an even polyhedron, you can just get rid of all the faces that have a z midpoint of greater than zero. You can garauntee that on a shape like this one, those faces will be hidden.
use something like n=below((z1+z2+z3)*0.33,0)
for more crazy shapes, just use the normal. (only get it right)

also.. you really should change n as the triangles get smaller, thats another huge place to find fps. Right now, you have n static so that it satisfies the biggest possible triangle on your shape.
Since you are going diagonal between two lines, you can set n to be some multiple of the leangth larger of those two line.

attatched is my own abandoned idea.
I stopped working on it when i realised i would need arrays to make a single scope multi-polygon filler.

23rd November 2003 01:37 UTC

:confused:

//edit
sorry, i didnt notice your backface culling. Spread out over 3 lines :weird:


23rd November 2003 10:13 UTC

oh... sorry for posting this one here, but i really needed help with this one
but, like i now know (thanks to UCD) the icosahedron works like sphere does, so, i can get normal easily, vector between mid point of sphere and centre point of one edge, I think this way i dont have to specify the points in a consistant order, or do i?
If i still have to, then i dont know how i will do it, i prolly must write script that gives me all point coords for icosahedron, and i suck at coding (i mean, i havent even tryed to code :P)

omg, a single scope multi-polygon filler, that would be so cool, i hope we get vectors with avs some day :)


23rd November 2003 19:56 UTC

ok, i got this somewhat working, by displaying the normals and light point vectors, it works visualy but there is still some nasty bug in there, and this im unable to find :(

here is best version so far


24th November 2003 11:00 UTC

wow, I like this :) It looks impressive


24th November 2003 18:05 UTC

Ok, found one really really stupid mistake, I fixed it, now its looks better than before ;)
but im now having troubles with displaying normals (mx,my,mz) light point vectors (lvx,lvy,lvz) and point camera vectors (vox,voy,voz), if anyone can help me, let me know =)


24th November 2003 18:06 UTC

:mad: