View Full Version : Point Cloud Ray Tracing
Blackstone 09-26-2008, 09:08 AM For generating the shadow pass in my relighting system, I decided use both ray tracing and shadow mapping, here is the RT result,
http://forums.cgsociety.org/attachment.php?attachmentid=133278&stc=1
but, I found there is big problem, because my point cloud is genereated by renderman, so when I trace the shadow ray, some point can't hit the point light source, according the paper "Ray Tracing Point Sampled Geometry" from Henrik Wann Jesen, we have to test the distance between the points and the ray with their radius, I did found that it's not accuracy enough.
So I coded like this,
if( Distance(HitPos,P) < 25.0*Radius )
{
RTResultPtr[i] = Vector3(1,1,1);
}
But if the scene is very small, the 25 times of radius is quite big, so the sphere above is wrong, but the bottom is nearly right, is there anybody could help me ?
|
|
yarniso
10-12-2008, 06:52 PM
Hi,
why do you say that the "Ray Tracing Point Sampled Geometry" approach is not accurate enough? What are the results you're getting? And how did you determine the radius?
Perhaps if you post some results of your trials with the algorithm, we can help you out a bit better.
Kind regards.
Blackstone
10-13-2008, 02:25 AM
Hi,
why do you say that the "Ray Tracing Point Sampled Geometry" approach is not accurate enough? What are the results you're getting? And how did you determine the radius?
Perhaps if you post some results of your trials with the algorithm, we can help you out a bit better.
Kind regards.
Here is the algorithim I implemented from the paper,
float* PosArray = _DataTable.find("P")->second.get();
float* NrmArray = _DataTable.find("N")->second.get();
float* RadArray = _DataTable.find("R")->second.get();
for( size_t i=0; i<Lookup.HitNodes.size(); ++i )
{
map<float,OctNode*>::iterator Itr = Lookup.HitNodes.begin();
Vector3 PosSum;
Vector3 NrmSum;
//std::vector<float> DistVec;
float DistSum = 0.0f;
for( size_t i=0; i<Itr->second->Index.size(); ++i )
{
size_t Idx = Itr->second->Index[i];
Vector3 P( PosArray[Idx*3 + 0],PosArray[Idx*3 + 1],PosArray[Idx*3 + 2] );
float Dist = R.DistanceToPoint(P);
float r = 10.0*RadArray[Idx];
//printf("Dist [%f] r[%f]\n",Dist,r);
if( Dist < r )
{
float delta = r - Dist;
PosSum += P*( delta );
NrmSum += Vector3( NrmArray[Idx*3 + 0],NrmArray[Idx*3 + 1],NrmArray[Idx*3 + 2] );
DistSum += delta;
}
}
if( DistSum < EPSILON )
continue;
PosSum /= DistSum;
HitPos = PosSum;
The mean is as the same as the paper said, use the distance between the points in ray cylinder and the ray center as weight to get a average position and others attributes.
Because I am using the point cloud baked by RenderMan, so the radius of points can be changed by the parameter "Shading Rate", that's makes a high density or low density point cloud.
Here is my program code
if( pcptr->Intersect(ray,HitPos) )
{
float HitDist = Distance(HitPos,P);
//cout<<Distance(HitPos,P)<<'\t'<<10.0*RaArray[i]<<endl;
if( Distance(HitPos,P) < 25.0*RaArray[i] )
{
RTResultPtr[i] = Vector3(1,1,1);
}
}
The 25.0 is the adjustment parameter. If it is too small, the other part of scene will be also "in shadow", but if too big, the shadow part will be smaller in scene, that's wrong.
playmesumch00ns
10-13-2008, 12:08 PM
Sorry, it's hard to see the problem. The shadows look OK to me. Which area exactly is causing you trouble??
Blackstone
10-15-2008, 02:21 PM
Sorry, it's hard to see the problem. The shadows look OK to me. Which area exactly is causing you trouble??
Yes, it's hard to see the problem, and at the same time I can adjust the parameter to get the correct effect.
I refused to use RT to generate the shadow result because it's too slow, I decided to use the shadow map all the same.
Thank for your attention.
CGTalk Moderation
10-15-2008, 02:21 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.