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
    • Register
    • Login

    Shader bitmap rendering with MemoryFileStruct

    Scheduled Pinned Locked Moved Cinema 4D SDK
    c++
    1 Posts 1 Posters 18 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.
    • WickedPW Offline
      WickedP
      last edited by

      Hi Folks,

      Terribly sorry, hoping not to take up anyone's time too much. But I can't see the forest through the trees on this one, and hoping someone can easily fix me!

      I have a document, housed at class level. I use it to render a simple scene, and then display the resulting image as a bitmap for the user. Inside this scene is an object with an assigned material that has a bitmap shader in it's colour channel. Everything works fine if I set the shader bitmap to a file on disk. But as soon as I try to use a bitmap I've drawn myself, it either renders blank, or throws a 'missing asset' error.

      End goal here is to render the shader with a bitmap I've created in memory.

      Some pseudo code below. Note - I'm cutting all the fluff out trying to keep it simple and to the point:

      void RenderMyDoc(...)
      {
      	// setup scene objects and shaders etc..
      	
      	BaseBitmap *bmp = ...;
      	AutoAlloc<BaseFile> writeHandler;
      	MemoryFileStruct *mfs = ...;
      	Filename fn;
      	fn.SetMemoryWriteMode(mfs);
      	bmp->Save(fn,...);
      	
      	/* Also tried with the following (scoped here just for clarity) */
      	{
      		fn.SetMemoryReadMode(void_p_here,void_p_sizehere);
      		writeHandler->Open(fn,...);
      		writeHandler->WriteBytes(void_p_here,void_p_sizehere);
      		// p.s. the void* and void data size all report numbers
      		
      		/* Wondering if it was because of the empty fn path, I tried calling GenerateTexturePath() on the fn, to no avail */
      	}
      	
      	// Add to shader
      	shader->SetParameter(BITMAPSHADER_FILENAME,GeData(fn),...);
      	
      	// A few other things here etc..
      	
      	// Render doc here all works, except when using my own bitmap
      	RenderDoc(...);
      }
      

      If I show the bitmap using the filename in the picture viewer, it works. But not when rendered. Sometimes it presents an 'Open file' dialog, despite having WriteMode set to the memory struct. I've seen quite a few topics elsewhere with python code, but my interpretation of python into C++ just isn't working. What am I doing wrong here?

      Hoping someone can fill the gaps for me. Cheers,

      WP.

      wickedp.com

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