math - 3D Affine transformation problem in raytracing -


all,

i writing rather non conventional ray tracer calculate heat transfer properties of various objects in scene. in ray tracer random rays shot surface of primitive objects scene check intersections.

this particular algorithm requires each ray developed in primitive space affine transformed source object world space subsequently affine transformed primitive space of other objects in scene check intersection.

all until anisotropic scale example scaling object [2 2 1] (isotropic scales fine). leads me believe not transforming directional component of ray correctly. transform ray direction primitive space world space multiplying directional component transpose of source objects inverse transformation matrix , transform ray world space each primitive space multiplying transpose of destination objects transformation matrix.

i have tried multiplying source primitive's transformation matrix go primitive world space , multiplying the destinations inverse transformation go world space primitive space unsuccessful.

i believe ray launched surface of primitive object (at random point , in random direction) should transformed in same manner surface normal in 'regular' ray tracing not certain.

any of experts out there know flaw in methodology is? feel free ask if more information required.


the basic algorithm ray tracer follows:

for each object, i, in scene {     each ray, r, in number of rays per object     {         determine random ray primitive         convert ray primitive space of world space          each object, j, in scene         {             convert ray primitive space of object j             check intersection object j         }     } } 

hopefully clear question lets @ example. lets assume have cylinder extending along z-axis (unit radius , height) , annulus lying in x-y plane inner diameter 7 , outer diameter 8. want scale cylinder factor 6 in x , y directions (but not z direction) affine transformation matrix follows:

m(cylinder) = |2 0 0 0|        m^-1(cylinder) = | .5 0. 0. 0. |               |0 2 0 0|                         | 0. .5 0. 0. |               |0 0 1 0|                         | 0. 0. 1. 0. |               |0 0 0 1|                         | 0. 0. 0. 1. |  m(annulus) =  |1 0 0 0|        m^-1(annulus) =  |1 0 0 0|               |0 1 0 0|                         |0 1 0 0|               |0 0 1 0|                         |0 0 1 0|               |0 0 0 1|                         |0 0 0 1| 

now assume have ray has random starting point on surface of cylinder s , random direction away surface of cylinder c giving ray r(os) = s + ct.

i want transform ray primitive (object) space world space , test intersection other objects in scene (the annulus).

the first question correct way transform ray, r(os), world space, r(ws), using m(cylinder) or m^-1(cylinder).

the second question correct way transform ray, r(ws), world space object space check intersection other objects using m(annulus) , m^-1(annulus).


some additional background information:

this application calculating radiative heat transfer between n objects. ray launched random point on object direction being randomly selected lie within hemispherical distribution orientated surface normal @ random point.


here visualisation of problem. ray directional distribution when first generated: initial ray directional distribution

if apply transformation world co-ordinates using transformation matrix m: direction transformed m

if apply transformation world co-ordinates using inversetransformation matrix m^-1 direction transformed m^-1

this came other day in this question

one of answers links ray tracing news article discussing use of transpose of inverse transform normals.

i have agree jcooper in asking "what going wrong?". first thought seem simulating radiated heat transfer, , have careful non-uniform scaling of objects. if have uniform distribution of "photons" on objects surface being emitted, , apply non-uniform scaling of object, have non-uniform distribution of photons leaving surface. 1 possible pitfall, since don't indicate what's going wrong it's hard if problem.

to answer questions correct way transformations, follow this link ray tracing news


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -