Render Prepasses

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 25/04/2010 at 23:15, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   11.5 
Platform:   Windows  ;   
Language(s) :     C++  ;

---------
Hi everyone !
I'm trying to implement a plugin which needs some pre render passes like the GI.

Is there a way to let the c4d core do a pre pass (like the AR GI) ?

I've implemented my own prepass in the plugin. but it's very slow compared to a standard c4d 
rendering. and the sampling is even less (every 4th pixel and no AA at all) than the main pass.

I used TraceColorDirect() and this may be slower but that many (10 times ore more) ?
Maybe there is something missing ... here the code from the thread:

VolumeData \*vd = vps->render->GetInitialVolumeData(threadNum);
if(vd==NULL)
	return;


for(Real fy=0; fy<h; fy+=step)
{
	for(Real fx=0; fx<w; fx+=step)
	{
		screen_x = left + fx;
		screen_y = top  \+ fy;


		vd->GetRay(screen_x, screen_y, &ray);
		vd->SetXY(screen_x, screen_y);


		ray.ior       = 1.0f;
		ray.transport = Vector(1.0,1.0,1.0);


		color = vd->TraceColorDirect(&ray, 1.0e30f, 0, vd->raybits, lastHit, &oldP, &si);
	// ...
	}
}


if(colors)
{
	for(LONG iy=top; iy<bottom; ++iy)
	{		
		bitmap->SetLine(left, iy, w, &colors[(iy-top)\*w], 32, TRUE);
	}
}

and of course I use threads for it ... here is how I do that:

LONG render = 0;
for(LONG i=0; i<numThreads; ++i)
{
	LC_RECT rect = buckets _;
	threads _.Init(vps, i, rect.left, rect.top, rect.right, rect.bottom, ...);
	thList _= &threads _;
	render++;
}


MPThread mp;
if(!mp.Init(vps->thread, numThreads, thList))
{
	ret = RAY_MP;
	goto bailout;
}

if(!mp.Start(THREADPRIORITY_NORMAL))
{
	ret = RAY_MP;
	goto bailout;
}


while(render<numBuckets)
{
	// wait for a thread
	VPRenderThread \*thread = VPRenderThread\* )mp.WaitForNextFree();
	if(vps->vd->TestBreak())
	{
		ret = RAY_USERBREAK;
		break;
	}


	LONG threadID = thread->GetThreadID();


	// ok, assign a new bucket
	LC_RECT rect = buckets[render];
	thread->Init(vps, threadID, rect.left, rect.top, rect.right, rect.bottom, ..);
	thread->Start(TRUE, THREADPRIORITY_NORMAL);


	render++;


	Real prog = (Real)render/(Real)numBuckets;
	vd->StatusSetBar(prog);
}
mp.Wait();

so not sure why it's so slow ... sure, the raytracer takes more time for camera rays than the scanliner ... but that many ?

the project you can download from here 
rapidshare.com/files/380244055/VPPrepass.zip.html

if you like 🙂

Many thanks,
~Mike