Indigo SDK 18

Discussion for users of the Indigo Renderer SDK.
User avatar
rgigante
Posts: 326
Joined: Wed Jun 28, 2006 6:46 am
Location: Italy

Post by rgigante » Sat Feb 28, 2009 8:36 pm

well... thanks Fused.

Here are my final considerations:
if u modify driver.cpp in indigo_dll_example adding in the renderer settings a super_sample_factor = 1 and the run the code u'll see that everything works fine as you mentioned above.

But if u modify the creation of the buffer from

Code: Select all

	// Get the rendered & tone mapped image:
	// Alloc a buffer
	const indUInt32 buffer_width = indigo->getBufferWidth();
	const indUInt32 buffer_height = indigo->getBufferHeight();
   std::vector<indUChar8> buffer(buffer_width * buffer_height * 3);
to

Code: Select all

	// Get the rendered & tone mapped image:
	// Alloc a buffer
	const indUInt32 buffer_width = 600 //(equal to the renderer settings params);
	const indUInt32 buffer_height = 600; //(equal to the renderer settings params);
   std::vector<indUChar8> buffer(buffer_width * buffer_height * 3);
u'll see that the bmp image which is created at the end of the story is totally black.

At the end of the story u have to use getBufferWidth() and getBufferHeight() to define your framebuffer (but always after the tonemapping operation otherwise they return "0") or u have to stitch on ssf > 1.

Once again something "must" be fixed.

Here my two cents.

R.

User avatar
fused
Developer
Posts: 3648
Joined: Fri Sep 22, 2006 7:19 am
Location: Berlin, Germany
3D Software: Cinema 4D

Post by fused » Sat Feb 28, 2009 10:09 pm

heres my tonemapping func. basically i check if the buffer size is larger than the size of the c4d buffer. if yes i just crop

Code: Select all

Bool IndigoData::CopyToC4DBuffer(VideoPostStruct *vps)
{
	//Get handle
	IndigoHandle<IndigoInterface1> indigo = indigoClass->GetIndigoHandle();

	//pause 4 tonemapping
	indigo->pauseRendering();

	//tonemapping output
	GePrint(RealToString(indigo->getNumSamples()/indigo->getRenderTimeElapsed()));

	// Start the tonemapping process.  We will get a message back later, when the tonemapping is done.
	indigo->toneMap();

	// Wait for tonemapping done message
	bool tonemapping_done = false;
	while(!tonemapping_done)
	{
		indigo->acquireMessageQueueLock();

		while(!indigo->isMessageQueueEmpty())
		{
			IndigoMessageInterface1* message = indigo->dequeueMessage();

			if(message->getType() == IndigoMessageInterface1::TONEMAPPING_DONE)
			{
				tonemapping_done = true;
			}
			else if(message->getType() == IndigoMessageInterface1::ERROR_MESSAGE)
			{
				MessageDialog(String("ERROR: ") + static_cast<IndigoErrorMessageInterface*>(message)->getMessage());
				//TODO proper error handling
				return FALSE;
			}
			else if(message->getType() == IndigoMessageInterface1::LOG_MESSAGE)
			{
				GePrint(static_cast<IndigoLogMessageInterface*>(message)->getMessage());
			}

			delete message;
		}
		indigo->releaseMessageQueueLock();

		if(!tonemapping_done)
		{
			GeSleep(100);
		}
	}

	// Get the rendered & tone mapped image:
	// Alloc a buffer
	const indUInt32 buffer_width = indigo->getBufferWidth();
	const indUInt32 buffer_height = indigo->getBufferHeight();
	std::vector<indUChar8> indBuffer(buffer_width * buffer_height * 3);

	if(!indBuffer.empty())
	{
		// Copy the image from the indigo DLL buffer to our buffer
		indigo->copyBuffer(&indBuffer[0], indBuffer.size());

		//get number of channels
		LONG cpp = rgba->GetInfo(VPGETINFO_CPP);
		LONG bh = rgba->GetBh();
		LONG bw = rgba->GetBw();

		//alloc mem for line buffer
		LONG bufLength = cpp*irstruc.width*sizeof(indUChar8);
		indUChar8* buffer = bNew indUChar8[bufLength];
		if (!buffer) return RAY_NOMEM;

		//copy indigo buffer to c4d buffer
		LONG y, i;
		for (i=irstruc.indY,y=irstruc.canvasYtop;y<=irstruc.canvasYbottom;y++,i++)
		{
			rgba->GetLine(irstruc.canvasXleft,y,irstruc.width,buffer,8,FALSE);

			LONG j, x;
			for (j=irstruc.indX,x=0;x<=irstruc.width-1;x++,j++)
			{
				LONG ip = i;
				LONG jp = j;
				if (buffer_width != irstruc.indWidth) {
					ip += 2;
					jp += 2;
				}
				buffer[x*cpp + 0]=indBuffer[((ip)*buffer_width + (jp))*3 + 0];
				buffer[x*cpp + 1]=indBuffer[((ip)*buffer_width + (jp))*3 + 1];
				buffer[x*cpp + 2]=indBuffer[((ip)*buffer_width + (jp))*3 + 2];
			}

			rgba->SetLine(irstruc.canvasXleft,y,irstruc.width,buffer,8,FALSE);
		}
		bDelete(buffer);
		
		//update screen
		vps->render->UpdateScreen();
	}

	if (!indigoClass->IsPaused()) {
		indigo->resumeRendering();
	}

	return TRUE;
}

Post Reply
17 posts

Who is online

Users browsing this forum: No registered users and 13 guests