Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login
    The Maxon SDK Team is currently short staffed due to the winter holidays. No forum support is being provided between 15/12/2025 and 5/1/2026. For details see Maxon SDK 2025 Winter Holidays.

    Render Prepasses

    Scheduled Pinned Locked Moved SDK Help
    1 Posts 0 Posters 137 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • First post
        Last post