Old 18th April 2005, 09:59   #1
ASD5A
Titeleinzigartigkeit
Senior Member
 
ASD5A's Avatar
 
Join Date: Apr 2005
Location: under a bridge
Posts: 620
Unhappy Can´t get that loop to work

i need help, please look through this code:

loop(32,exec2(assign(sb,if(above(gmegabuf(ct+2),z3),1,if(above,(r0/(1+gmegabuf(ct3+2)/dst),sqrt(sqr(x-gmegabuf(ct3))+sqr(y-gmegabuf(ct3+1)))),0,1))),assign(ct3,ct3+3)));

this loop should assign sb 0 if the current point lies
behind(z3 value)and near any buffered points.
This code should be used to find invisible points.
if you find any mistakes in the code feel free to post
the corrected code or if you have a faster method to
find invisible points please post.
Attached Files
File Type: zip asd5a-sscshadingbuf.zip (970 Bytes, 138 views)

oversized e-penis replacement
ASD5A is offline   Reply With Quote
Old 18th April 2005, 12:39   #2
Jaak
Major Dude
 
Jaak's Avatar
 
Join Date: Jan 2003
Location: Estonia.
Posts: 851
second if is fucked

was that really worth posting?

Phi = (1+sqrt(5))/2
Jaak is offline   Reply With Quote
Old 18th April 2005, 13:08   #3
ASD5A
Titeleinzigartigkeit
Senior Member
 
ASD5A's Avatar
 
Join Date: Apr 2005
Location: under a bridge
Posts: 620
i really don´t see the point
please post a corrected code

oversized e-penis replacement
ASD5A is offline   Reply With Quote
Old 18th April 2005, 13:35   #4
Jaak
Major Dude
 
Jaak's Avatar
 
Join Date: Jan 2003
Location: Estonia.
Posts: 851
if(above,(r0/(1+gmegabuf(ct3+2)/dst), ...

Phi = (1+sqrt(5))/2
Jaak is offline   Reply With Quote
Old 18th April 2005, 13:38   #5
ASD5A
Titeleinzigartigkeit
Senior Member
 
ASD5A's Avatar
 
Join Date: Apr 2005
Location: under a bridge
Posts: 620
oh a veery stupid mistake thanx jaak

oversized e-penis replacement
ASD5A is offline   Reply With Quote
Old 18th April 2005, 13:42   #6
PAK-9
Major Dude
 
PAK-9's Avatar
 
Join Date: Oct 2002
Location: The United Kingdom of Great Britain and Northern Ireland
Posts: 1,374
Just a hint: Noone can be bothered to read that code because its all in one big block, people will be much more likely to help if you format it better, for example:

code:

loop(32,
exec2(
assign(
sb
,
if(above(gmegabuf(ct+2),z3),
1
,
if(
above,( //extra comma
r0/(1+gmegabuf(ct3+2)/dst)
,
sqrt(
sqr(
x-gmegabuf(ct3)
)
+sqr(
y-gmegabuf(ct3+1)
)
)
)
,
0
,
1
)
)
)
,
assign(
ct3
,
ct3+3
)
)
);




I know it looks long but its a lot easier to read

http://PAK-9.deviantart.com

...innit
PAK-9 is offline   Reply With Quote
Old 18th April 2005, 17:28   #7
ASD5A
Titeleinzigartigkeit
Senior Member
 
ASD5A's Avatar
 
Join Date: Apr 2005
Location: under a bridge
Posts: 620
thanx pak-9
but i have a more complicated (coding) problem in this preset.
even with the mistake removed that code doesn´t filter out
normally invisible points.
But i have totally no clue why.
there are now two ways to go for me :
1.hoping somebody gives me a working code or
2.i figure out how to sort fast 4096 points.
I´ll start developing a sorting engine.

oversized e-penis replacement
ASD5A is offline   Reply With Quote
Old 18th April 2005, 18:16   #8
PAK-9
Major Dude
 
PAK-9's Avatar
 
Join Date: Oct 2002
Location: The United Kingdom of Great Britain and Northern Ireland
Posts: 1,374
I think its unlikely you need to sort the points in your preset.

If you explain the problem fully and in context it would help

http://PAK-9.deviantart.com

...innit
PAK-9 is offline   Reply With Quote
Old 18th April 2005, 18:27   #9
ASD5A
Titeleinzigartigkeit
Senior Member
 
ASD5A's Avatar
 
Join Date: Apr 2005
Location: under a bridge
Posts: 620
i assume u downloaded the preset above corrected the silly mistake.
ok..
in certain angles of torus u see points of the inner side of the torus which should be invisible.
there two way get rid of these points:
1. sort all the points by z3 value
2. filter them with a very simple raytrace.
my code above should be the 2. way but it filters only a little circle out.
gmegabuf(ct3) is the x value of an simple geometrical model
used for the raytrace.
gmegabuf(ct3+1) y value.
gmegabuf(ct3+2) z3 value.

oversized e-penis replacement
ASD5A is offline   Reply With Quote
Old 18th April 2005, 18:28   #10
ASD5A
Titeleinzigartigkeit
Senior Member
 
ASD5A's Avatar
 
Join Date: Apr 2005
Location: under a bridge
Posts: 620
probably it could be the fault of my laptop
3ghz 12fps at this preset. how fast is yours?

oversized e-penis replacement
ASD5A is offline   Reply With Quote
Old 18th April 2005, 20:09   #11
PAK-9
Major Dude
 
PAK-9's Avatar
 
Join Date: Oct 2002
Location: The United Kingdom of Great Britain and Northern Ireland
Posts: 1,374
Oh sorry I didnt see that you posted the preset already, I'll check it when I get home.

preliminarily (having not seen the preset) you just have a culling/occlusion problem. If you store/calculate the normal at each point on the torus you can do a simple check to see if the vertex is facing away from the camera. Do a dot product with the camera vector and check if the angle is above a certain value, well, zero I guess (I cant really remember this all off the top of my head)

torus is a bit of a bastard because you cant do any nice quick hacks that I can think of.... hmm, maybe splitting the torus into rings. Nah, I think a hack would be more complicated than just doing it right.

http://PAK-9.deviantart.com

...innit
PAK-9 is offline   Reply With Quote
Old 18th April 2005, 22:19   #12
Jaak
Major Dude
 
Jaak's Avatar
 
Join Date: Jan 2003
Location: Estonia.
Posts: 851
Pak, simple normal calculation and bf culling isn`t enough for torus

http://www.deviantart.com/deviation/6457036/

really old preset and unfinished preset...
it`s with little help from coned, to correct the clipping problem. It is quite nasty hack ya know.
Torus can get intersected in 4 places if you trace line from eye through it, this means that regular bf culling does not work, if you do not want to use use max. blending... which you could actually live with in your example preset.

Anyways, to correct the torus clipping problem, which i assume you want to do, you can use
a) expencive raytracing hack
b) relatevely fast and really nasty hack described below
c) even slower way to sort the verices and do some dark magic *g*

as for b. the one you can see from example preset:
basically you have to split torus in 2, front and back and then:
1. draw back normally
2. draw front so it overlays not required part of back (try to disable 3rd scope in my preset)
3. draw front normally

as for you, if you are not going to advance that preset from its current state, i reccomend you just to use simple depth shading in addition to lighting shading to be able to use max blending so you won`t have clipping problems.

[edit]
Actually, I don`t know, I am really really sleepy right now. It would be best if you tolf us exactly what are you trying to do, because using the "correct" and "perfect" method with avs is usually the stupidest way of doing something, just remember that





As a side note... This preset is just a tech demo. I had a much better and similar stuff cooking for a actual preset, but I`m not working on it anymore...

Phi = (1+sqrt(5))/2
Jaak is offline   Reply With Quote
Old 19th April 2005, 01:50   #13
jheriko
Forum King
 
jheriko's Avatar
 
Join Date: Aug 2002
Location: a twist in the fabric of space
Posts: 2,150
Send a message via ICQ to jheriko
actually simple bf culling is enough for the torus if you render four superscopes. this is done by rendering the back facing back half, front facing back half then back facing front half and finally front facing front half. This can be done with a simple z check and normal check and using all four combinations.

anything based totally on circles can usually be done correctly with no sorting or hax. this means shapes like torii, spheres and cylinders and arrangements like having objects on the points of a regular polygon etc...

-- Jheriko

'Everything around us can be represented and understood through numbers'
jheriko is offline   Reply With Quote
Old 19th April 2005, 06:43   #14
Jaak
Major Dude
 
Jaak's Avatar
 
Join Date: Jan 2003
Location: Estonia.
Posts: 851
...and which is what i am doing in the preset


...basically

Phi = (1+sqrt(5))/2
Jaak is offline   Reply With Quote
Old 19th April 2005, 07:03   #15
ASD5A
Titeleinzigartigkeit
Senior Member
 
ASD5A's Avatar
 
Join Date: Apr 2005
Location: under a bridge
Posts: 620
pak that what you suggest is already in the preset.
got an idea : using my current scope as feeder scope.
split the points into +z and -z and draw the nearer points later. that is actually what jheriko did suggest but i will leave out the backfacing halfes.
I´ll report if that works.

oversized e-penis replacement
ASD5A is offline   Reply With Quote
Old 19th April 2005, 12:55   #16
PAK-9
Major Dude
 
PAK-9's Avatar
 
Join Date: Oct 2002
Location: The United Kingdom of Great Britain and Northern Ireland
Posts: 1,374
Quote:
Originally posted by jheriko
actually simple bf culling is enough for the torus if you render four superscopes. this is done by rendering the back facing back half, front facing back half then back facing front half and finally front facing front half. This can be done with a simple z check and normal check and using all four combinations.

anything based totally on circles can usually be done correctly with no sorting or hax. this means shapes like torii, spheres and cylinders and arrangements like having objects on the points of a regular polygon etc...
I dont see how this would work, because you cant split the torus into 4 in the same way for all angles. If you imagine looking at the tours from the side and splitting it into 4 as you suggest, then rotate it 90 degrees so you are looking at it from the top (i.e. it looks like a fat circle) the four pieces are the wrong shape to represent the front and back of the torus from the camera. You would have to reshape the 4 pieces depending on the rotation, which is a pretty nasty way to approach the problem imo. In fact rereading Jaak's post he is suggesting something similar where the torus is split into 2, where reshaping the two pieces is still necessary because the 'front' and 'back' different shapes from different angles.

I'm surprised the standard bf culling method doesnt work to be honest, because I would think you would compare the normal of the vertex on the torus with a camera ray, but not literaly fire a ray from the camera, just consider a vector which is 0 degrees from the camera direction. Then dot product that with the normal. But I havent actually implemented a torus model in AVS so I'm not going to pretend to be an authority on it.

Like Jaak says you need to post an updated version of the preset really, that version you posted at the start is just a ring of dots :P

http://PAK-9.deviantart.com

...innit
PAK-9 is offline   Reply With Quote
Old 19th April 2005, 15:06   #17
ASD5A
Titeleinzigartigkeit
Senior Member
 
ASD5A's Avatar
 
Join Date: Apr 2005
Location: under a bridge
Posts: 620
i finally solved the problem.
i have split that superscope into two:
one with z3<0 and one with z3>0;
i added noexecution for performance issues(the if(skip,...);doubles my framerate )
here is the correctet version.
thank you all for providing help.
Attached Files
File Type: zip asd5a-sscshadingbuf2.zip (997 Bytes, 131 views)

oversized e-penis replacement
ASD5A is offline   Reply With Quote
Old 19th April 2005, 17:09   #18
Jaak
Major Dude
 
Jaak's Avatar
 
Join Date: Jan 2003
Location: Estonia.
Posts: 851
nope, it doesn`t fix the problem 100%
torus still occludes itself under certain angles

[edit]
make it resolution independent and bigger... i`d make it myself, but the code you have produced is absolutely ugly, unoptimized and uncommented... not that it means there is something wrong with your coding skill

Phi = (1+sqrt(5))/2
Jaak is offline   Reply With Quote
Old 19th April 2005, 18:51   #19
ASD5A
Titeleinzigartigkeit
Senior Member
 
ASD5A's Avatar
 
Join Date: Apr 2005
Location: under a bridge
Posts: 620
do you mean the torus itself or the resolution of the grid ?
yes it´s not 100% perfect but the rest is only tweaking values, nothing to bother you.

oversized e-penis replacement
ASD5A is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Visualizations > AVS > AVS Troubleshooting

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump