GRP1 discussion

Programming topics can be found here.
bikker
Posts: 67
Joined: Fri Sep 27, 2013 12:40 pm

Re: GRP1 discussion

Post by bikker » Tue Nov 05, 2013 11:54 am

Ow but that explains: you can't pick a random direction in a cube. If you do that, you get random directions with a density that is higher in the corners, leading to the artifacts you complained about. *If* you pick directions in a cube, you need to reject all directions with a magnitude greater than 1 (so you get a sphere again).

080933
Posts: 1
Joined: Tue Nov 05, 2013 11:51 am

Re: GRP1 discussion

Post by 080933 » Tue Nov 05, 2013 11:56 am

Impressive work there!
One of my favorite courses, hope everyone enjoys it!

121377
Posts: 6
Joined: Thu Nov 07, 2013 5:24 pm

Re: GRP1 discussion

Post by 121377 » Thu Nov 07, 2013 5:46 pm

Hey guys, have some trouble with my ray triangle intersections and was wondering if any1 could help me out,

here is the code i currently use:
Intersection IntersectionManager::Intersect(Triangle* pTriangle, Ray* pRay)
{
Vector3 edge1 = pTriangle->v1 - pTriangle->v0;
Vector3 edge2 = pTriangle->v2 - pTriangle->v0;

        Vector3 pvec = Cross(pRay->mDir, edge2);
        double det = Dot(edge1, pvec);
        if(CULLING)
        {
                if(det < EPSILON){return Intersection();}
                Vector3 tvec = pRay->mOrigin - pTriangle->v0;
                double u = Dot(tvec, pvec);
                if(u < 0.0f || u > det){return Intersection();}

                Vector3 qvec = Cross(tvec, edge1);
                double v = Dot(pRay->mDir, qvec);
                if(v < 0.0f || u + v > det){return Intersection();}

                float t = Dot(edge2, qvec) * (1.0f/(float)det);
                pRay->mDistToIntersect = t;
                return Intersection(pRay->mOrigin + (pRay->mDir * t), pTriangle->mNormal, pTriangle->mMaterial, Matrix4());
        }
        else
        {
                if(det > -EPSILON && det < EPSILON){ return Intersection();}

                float invdet = 1.0f/det;
                Vector3 tvec = pRay->mOrigin - pTriangle->v0;
                float u = Dot(tvec, pvec) * invdet;
                if(u < 0.0f || u > 1.0f){return Intersection();}

                Vector3 qvec = Cross(tvec, edge1);
                float v = Dot(pRay->mDir, qvec) * invdet;
                if(v < 0.0f || u + v > 1.0f){return Intersection();}

                float t = Dot(edge2, qvec) * invdet;
                pRay->mDistToIntersect = t;
                return Intersection(pRay->mOrigin + (pRay->mDir * t), pTriangle->mNormal, pTriangle->mMaterial, Matrix4());
        }
}

and here is an image of the result, the model used has 2500 triangles
Image

as you can see it doesn't render every other triangle, i already checked if my BVH was being filled correctly and if my model loader was working properly

thanks in advance!
Dave Schachtschabel - 121377
2GA - 2PR

User avatar
121356
Posts: 4
Joined: Wed Oct 02, 2013 5:31 pm
Location: Oudenbosch, Noord-Brabant
Contact:

Re: GRP1 discussion

Post by 121356 » Thu Nov 07, 2013 6:04 pm

Are you sure your model is triangulated? I've seen that same thing happen, because the model loader I used would load quads as triangles.
Wout van Poppel | 3GA-2PR

121377
Posts: 6
Joined: Thu Nov 07, 2013 5:24 pm

Re: GRP1 discussion

Post by 121377 » Wed Nov 13, 2013 10:38 pm

I know the course has ended, but here's a render of a 8.9kk triangle model :)

Image
Dave Schachtschabel - 121377
2GA - 2PR

bikker
Posts: 67
Joined: Fri Sep 27, 2013 12:40 pm

Re: GRP1 discussion

Post by bikker » Mon Nov 18, 2013 10:35 am

Hi all,

The pretty image contest has been opened on ompf2.com:

http://ompf2.com/viewtopic.php?f=5&t=1892

Please note that if you register on that forum you will need to send me an e-mail to get your account activated.
That's an awesome forum btw, with lots of discussions on ray tracing. It's hosted here at IGAD.

- Jacco.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests