you are talking about ray tracing. maybe you would like to try ray marching them? the basics seem simple, but when its put all together it looks scary. read a lot about it on pouet

"It's... Hmm. Interesting. Maybe if you start with... No, wait. Hmm... You could -" Ughh... I feel the truck coming

Thanks for that idea, now I have what to do at workplace

Statistics: Posted by popmilo — Tue Apr 15, 2014 5:27 am

]]>

Statistics: Posted by Oswald — Mon Apr 14, 2014 7:21 pm

]]>

what I love about it, that it straight assigns each x,y an u,v.

Well, it's basically just calculation of intersection between one ray and one sphere centered on Z axis...

Would be cool to do it with Sphere anywhere in x,y,z space and with multiple spheres.

But, I haven't thought of case where it would be interesting or practical on 6502

As always, I had fun with it, and didn't burn too much time

ps. What problems like these do to me

nerd_sniping.png

Statistics: Posted by popmilo — Mon Apr 14, 2014 7:07 pm

]]>

what I love about it, that it straight assigns each x,y an u,v.

my naive approach is horrible compared to this (rotate circles & project them to screen until they make up a solid sphere, it takes ages if you dont want holes )

Statistics: Posted by Oswald — Mon Apr 14, 2014 1:29 pm

]]>

took me half an hour, but I got it running in Vb6. this sphere generator is pretty slick and solid AND fast!

...edit: wow, and the sphere scales along with the image height/width constants. pretty cool stuff. n Z is weird, because it also changes how many times the texture is wrapped on. no such thing for radius. strange, maybe z and radius is mixed up.

Glad you like it, only thing I did is to write it in python

Yes, there is something weird going on with texture, but I had no time to test it... Would be nice to find ratios between texture size and sphere_z and sphere_r.

Statistics: Posted by popmilo — Mon Apr 14, 2014 12:11 pm

]]>

@heaven, when is your demo due ?

edit: wow, and the sphere scales along with the image height/width constants. pretty cool stuff. n Z is weird, because it also changes how many times the texture is wrapped on. no such thing for radius. strange, maybe z and radius is mixed up.

Statistics: Posted by Oswald — Mon Apr 14, 2014 10:37 am

]]>

Statistics: Posted by Oswald — Fri Apr 11, 2014 7:17 pm

]]>

Thanks Popmilo. Will have a look. First I need to finish Revision but your resources help a lot for the sequel

You're welcome

At least I got this 'out of my system' and now can return to my totally not 3d related stuff that I really need to solve as soon as possible

Statistics: Posted by popmilo — Fri Apr 11, 2014 6:50 pm

]]>

Statistics: Posted by heaven6502 — Fri Apr 11, 2014 3:13 pm

]]>

http://nbviewer.ipython.org/gist/popmilo/10386384

rendered_sphere.png

Basic function is:

def get_intersection(ray_x,ray_y,ray_z,sphere_z,sphere_r):

c = sphere_z*sphere_z - sphere_r*sphere_r

a = ray_x*ray_x + ray_y*ray_y + ray_z*ray_z

b = -2.0*sphere_z*ray_z

tmp = b*b - 4.0*a*c

if tmp<0:

return 0

else:

t = (-b - sqrt(tmp))/2.0/a

t_ray_x = t*ray_x

t_ray_y = t*ray_y

t_ray_z = t*ray_z

j = arcsin(t_ray_y/sphere_r)

i = arccos(t_ray_x/sphere_r/cos(j))

tx = i/pi

ty = 0.5 + j/pi

return (tx,ty)

c = sphere_z*sphere_z - sphere_r*sphere_r

a = ray_x*ray_x + ray_y*ray_y + ray_z*ray_z

b = -2.0*sphere_z*ray_z

tmp = b*b - 4.0*a*c

if tmp<0:

return 0

else:

t = (-b - sqrt(tmp))/2.0/a

t_ray_x = t*ray_x

t_ray_y = t*ray_y

t_ray_z = t*ray_z

j = arcsin(t_ray_y/sphere_r)

i = arccos(t_ray_x/sphere_r/cos(j))

tx = i/pi

ty = 0.5 + j/pi

return (tx,ty)

Sphere is at sphere_z distance. Radius is sphere_r.

ray_x and ray_y are x,y coordinates of pixel on screen (0,0 is in center).

ray_z i distance from the "eye" to the screen.

Function returns x,y coordinates between 0 and 0.5 (or 1.0 I'm not sure ).

So to get u,v coordinates in texture I multiplied it with texture_x_size and calculated modulo with max_texture_size to produce wrap-around if texture is not big enough to fill sphere surface.

Interesting stuff

Statistics: Posted by popmilo — Thu Apr 10, 2014 2:17 pm

]]>