I'd like to note that code like this is in just about every tutorial on AVS/superscopes. I'm assuming you looked up those already because of their wide accessability and that you are having problems conceptually. So instead of parsing through this code I'll offer some webpages that can explain all of this better than I can. Here is one great example:
http://www.gamedev.net/reference/art...article795.asp
http://www.gamedev.net/reference/art...article796.asp
http://www.gamedev.net/reference/art...article797.asp
This series offers all the math you need to know to create the preset you posted.
OK ---- I GIVE UP! I'll take my chances and ask...
99 posts
Ok. After a few days of deep thought and study, I do believe I get it. Thanks. How about the sphere DM in UnconeD's Nuke Warfare? I think that could be simpler example of raytracing than any of these other DMs.
Thanks to UnconeD fot the single greatest preset saga ever...You know which one I mean...
Thanks to UnconeD fot the single greatest preset saga ever...You know which one I mean...
Originally posted by UIUC85He rotates in 3d, is just only in two axes. 2d rotation is two lines, one of the pairs used for 3d on its own.
This only has the 4.
Anyway...
If you think the sphere is going to be simpler, then you don't really get it yet 😉
Here is another explanation... again (I have written this before I am sure...). I'll use unconeds variable name conventions so you can compare to his dms
the idea of raytracing is that you find the distance to the object being 'traced' by projecting a line from the camera, through a point (defined by our frustrum) and out into the world. this sounds horribly abstract... but is pretty simple if we use vectors (read as three numbers in a row, if 'vector' scares you).
we represent our camera position as (ox,oy,oz)
dm uses a grid from 1 to -1 of x and y values which we recycle into our 45 degree view frustrum with lines like this:
dx=x;
dy=y;
dz=1;
these define the directions out of the eye we look into the world for each grid. where 0,0,1 is forward, 1,0,0 is right, 0,1,0 is down etc... usual avs stuff. in a square window this would give us a square pyramid view with a 90 degree fov. you can rotate the frustrum vectors to get the effect of rotating the camera.
we then trace along each of these directions from the camera and find where it intersects the model by using simultaneous equations and some other simple maths. first we use the vector equation for a line to find our 'ray' that goes along the direction from the camera:
(x,y,z)=(ox+dx*k,oy+dy*k,oz+dz*k) (k is a parameter which allows us to 'travel along the ray')
we want to find k where there is an intersection with our geometry. for our example lets use a plane z = 1, then from the above we can see that z = oz+dz*k = 1 and so k = (1-oz)/dz.
now we know how far down the ray the intersection point is we can mangle our texture coordinates to make it look right. the normal way to do this is with a planar projection:
x=ox+dx*k;
y=oy+dy*k;
looks deceptively simple in this case, but here is how it works: everything samples from a 0-1 grid of texture coordinates, with wrap it auto clamps all the x's and y's to 0-1. since z=1 has is x component and y component describing the plane at right angles and ox+dx*k and oy+dy*k are these components in world space, then hopefully you can see that we are simply projecting the existing texture coordinate grid onto the plane (with or without wrap). if we used the plane x = 1 then we would use the y and Z component for this instead, e.g. x=oy+dy*k;y=oz+dz*k; (yes 'y' not 'z')
so drawing a shape with raytracing involves two problems:
finding 'k' which means you need an equation for the shape which you can solve.
finding a suitable texture projection (trivial for planes)
the first is a lot easier than the second, but you cant really do anything that great in terms of applying texture coordinates to most of the more powerful shapes anyway....
hope this helps
Aha. I get it. I'll go mess around with it later...
Good call Jheriko.
I'm sure I posted this before... i must have forgot to submit it :P
But... raytracing and the '3d ssc' are related. If you ignore rotation for a minute and raytrace from a 0,0,0 through any point x1,y1,z1 onto the plane z=1 and find the local plane coordinates (x,y) at this intersection then you get the perpective transformation everyone loves to use. The reason we use z = 1 is that the 0..1 in x and y define the intersection area with a pyramidal view frustrum, in this case it is a 90 degree frustrum since the pyramid has a base length 1 and height 1.
Putting this into effect you get:
ox,oy,oz = 0,0,0
dx,dy,dz = x1,y1,z1
(because the direction from ox,oy,oz to the point x1,y1,z1 = x1-ox,y1-oy,z1-oz)
.: k = 1/z1 (oz=0, from plane equation dz*k+oz = 1)
.: x = x1*k; y = y1*k; (remember ox,oy are 0)
which is just the same as the usual code at the end of a superscope, after the rotation...
this helps understand one of the fundamental differences between ssc and dm presets, which is that when you rotate in a superscope you are normally rotating the point around the origin, when you rotate in a dm you are rotating the view frustrum. this is why rotations and shifts have to be done differently in the superscope to the dm.
But... raytracing and the '3d ssc' are related. If you ignore rotation for a minute and raytrace from a 0,0,0 through any point x1,y1,z1 onto the plane z=1 and find the local plane coordinates (x,y) at this intersection then you get the perpective transformation everyone loves to use. The reason we use z = 1 is that the 0..1 in x and y define the intersection area with a pyramidal view frustrum, in this case it is a 90 degree frustrum since the pyramid has a base length 1 and height 1.
Putting this into effect you get:
ox,oy,oz = 0,0,0
dx,dy,dz = x1,y1,z1
(because the direction from ox,oy,oz to the point x1,y1,z1 = x1-ox,y1-oy,z1-oz)
.: k = 1/z1 (oz=0, from plane equation dz*k+oz = 1)
.: x = x1*k; y = y1*k; (remember ox,oy are 0)
which is just the same as the usual code at the end of a superscope, after the rotation...
this helps understand one of the fundamental differences between ssc and dm presets, which is that when you rotate in a superscope you are normally rotating the point around the origin, when you rotate in a dm you are rotating the view frustrum. this is why rotations and shifts have to be done differently in the superscope to the dm.
Quick detail. Do the points in the DM keep their r and d value when the rectangular coords are turned on, and vice versa?
no. rectangular coordinates only enables x and y. otherwise only d and r are enabled. you need to backwards work them out if you want them, using something like:
x=d*cos(r);
y=d*sin(t);
d=sqrt(sqr(x)+sqr(y);
r=atan2(-y,x);
This is mentioned else where on the forums...
x=d*cos(r);
y=d*sin(t);
d=sqrt(sqr(x)+sqr(y);
r=atan2(-y,x);
This is mentioned else where on the forums...
So if rect is turned on, then a pint has only (x,y) and if polar is on then it only has (r,d)?
Right, either (x,y) OR (r,d) are sufficient to exactly define where a point is located in an coordinate system (or: on the screen, in our case).
For more info about coordinates you can read
this wikipedia article.
For more info about coordinates you can read
this wikipedia article.
Ok. Cool. This explains a lot.
Good, cause imo it's essential to understand that polar (r,d) and cartesian (x,y) coordiantes are two different things. But that doesn't mean that you cannot "translate" coordinates between both systems (as Jheriko already mentioned)!!
For example, take a random point: you can either describe it with (r,d) or (x,y) values. If you chose polar you can translate these values into cartesion and vice versa. now the dynamic movement does exactly the same: using either polar or cartesian values.
/sorry if this was too much of a repetition, but i'm in an 'explainatory' mood at,! 😉
For example, take a random point: you can either describe it with (r,d) or (x,y) values. If you chose polar you can translate these values into cartesion and vice versa. now the dynamic movement does exactly the same: using either polar or cartesian values.
/sorry if this was too much of a repetition, but i'm in an 'explainatory' mood at,! 😉
Im in a mood at which in i... kick your ass and then... something, oh fuck... im just drunk so that's my mood 😁
But that isn't your mood just at the moment. Unfortunately it's the mood you're always in...
...except while you're asleep. 😛
Anyway, didn't we agree to restrict this kind of conversation to the bin? 😕
...except while you're asleep. 😛
Anyway, didn't we agree to restrict this kind of conversation to the bin? 😕
Oh you're right, as always utterly unpronouncable ^..^ 😛
Okay, so what i want to say is that maybe JFASI needs to stop asking so many questions and start learning things by himself, i dunno, but if i were the one giving him tutoring lessons, i would pretty much freak out by now 😁
Okay, so what i want to say is that maybe JFASI needs to stop asking so many questions and start learning things by himself, i dunno, but if i were the one giving him tutoring lessons, i would pretty much freak out by now 😁
Heeeeeeey...I'm learning. It's not like you give actual lines of code and I use them blindly!
to Tug:
Well it's a good thing I'm not drunk then. 🙂
Well it's a good thing I'm not drunk then. 🙂
Originally posted by JFASIYeah, but learning for yourself is much more effective than being taught.
Heeeeeeey...I'm learning. It's not like you give actual lines of code and I use them blindly!
best way of learning is reading plain code
I had no idea what raytracing was about, or how certain DM worked. I came and found out. That's ok.
Now, if I had gone and just asked you for code and used it without any analysis, then it would be different.
Now, if I had gone and just asked you for code and used it without any analysis, then it would be different.
Just cause there's a lot about raytracing on here and I was playing around with some stuff I decided to post this up here. Something fun for other tech-heads to look at maybe? Maybe it's been done and I didn't know but I haven't seen it so enjoy.
Originally posted by JFASIYeah, and if you looked up raytracing on the internet, and then looked up the things you didnt understand on those pages... etc... it would be different again. The information is out there, and if you can't get it for yourself, you will only be able to go as far as other people take you.
I had no idea what raytracing was about, or how certain DM worked. I came and found out. That's ok.
Now, if I had gone and just asked you for code and used it without any analysis, then it would be different.
True. But don't condemn me for this little foray into explanation...
Any thoughts on my tech preset? (not in terms of it being a music visualization but just a tech demo)
I've never seen anything like this before, and I think it's pretty nifty! 🙂
I especially like that slick and polished look of it.
review resolution[s]: 172x172 & 344x344
I especially like that slick and polished look of it.
review resolution[s]: 172x172 & 344x344
That texture on the sphere is pretty awesome. I like it. Oh, yeah, technical...its cool...
It's indeed cool!
But unfortunately not the first such thing! Jheriko has already made a pretty similar sphere tech-demo preset before:
http://www.deviantart.com/deviation/13908660
But unfortunately not the first such thing! Jheriko has already made a pretty similar sphere tech-demo preset before:
http://www.deviantart.com/deviation/13908660
Awww...
It's still cool, though.
It's still cool, though.
i made some thing similar to this preset tho, using texture sources to do normal mapping. you can break the lighting down into stuff you can do with blend modes and unique tones etc..
But yeah, using the superscope looks better i think... and its faster for a lot of stuff too
But yeah, using the superscope looks better i think... and its faster for a lot of stuff too
You did a dm that does specular highlights and bump mapping? I'd like to see that. I knew you did the ssc version but I wanted to do it with dm's instead.
Here's another neat tech demo that I whipped up today. Like I said in the comment, I know UnConeD did a reflection dm but this has both objects reflecting and textures on the objects that are reflecting as well. I made a few comments about other things in the preset if you're interested. Good stuff 🙂
Here's another neat tech demo that I whipped up today. Like I said in the comment, I know UnConeD did a reflection dm but this has both objects reflecting and textures on the objects that are reflecting as well. I made a few comments about other things in the preset if you're interested. Good stuff 🙂