AWS Thinkbox Discussion Forums

render element is supposed to be a jpg, but is actually exr

Hey guys,

No idea whats happening here, but one of our standard jpg render elements is randomly rendering out as an exr when using deadline… i checked through the _Functions script, and our handling scripts, but could not find anything that could be related

i found these parameters,and have turned them off:
RenderElementsUpdatePaths = true,
RenderElementsUpdateFilenames = true,

But no difference…

Is lighting / deadline doing some further render element wrangling?

The files are named .jpg btw. But they arent jpegs…

If i just open the file off the repository, then hit render on a frame, it comes out as a proper jpg… so something goes amiss in deadline.

The only way i could fix it, is by writing a maxscript extension plugin that gets called before the file is saved, that does this:

Value* FixRenderElementDevice_cf(Value **arg_list, int count)
{
	check_arg_count(FixRenderElementDevice, 1, count);

	int elementIndex = arg_list[0]->to_int();


    IRenderElementMgr* reMgr = GetCOREInterface()->GetCurRenderElementMgr();
    int numElements = reMgr->NumRenderElements();

	if (elementIndex < 0 || elementIndex >= numElements)
		throw RuntimeError (MSTR("RenderElement index is outside valid range"));

	IRenderElement* re = reMgr->GetRenderElement(elementIndex);
	PBBitmap *mBitmap = NULL;
	re->GetPBBitmap(mBitmap);

#define DEVICECOUNT 3
    CStr extensions[DEVICECOUNT] = {".jpg", ".jpeg", ".exr"};
    CStr devices[DEVICECOUNT] = {"JPEG File", "JPEG File", "OpenEXR Image File"};

	if (mBitmap!=NULL)
	{
        MaxSDK::Util::Path p = mBitmap->bi.GetPathEx();
		mBitmap->bi.FixDeviceName();

        MSTR pstr = p.GetString();
        pstr.toLower();

        bool bSuccess = false;
        bool bTried = false;
        for (int i=0; i<DEVICECOUNT && bTried==false; i++)
        {
            if (pstr.length() >= extensions[i].length())
            {
                CStr ext = pstr.Substr(pstr.length() - extensions[i].length(), extensions[i].length());
                if (ext == extensions[i] && devices[i] != CStr(mBitmap->bi.Device()))
                {
                    bTried = true;
                    const char* setthis = mBitmap->bi.SetDevice(devices[i]);
                    if (devices[i] == CStr(setthis))
                    {
                        bSuccess = true;
                        mBitmap->bi.FixDeviceName();
                    }
                }
            }
        }

        if (bTried && bSuccess)
        {
		    if (mBitmap->bi.GetPiData() == NULL)
		    {
			    mBitmap->bi.CreateFmtSpecBlock();
		    }
            return &true_value;
        }

        return &false_value;
	}

	return &undefined;
}

If i dont do a SetDevice manually, the FixDeviceName does not always properly set the output device… so even though we have a jpg in the filename, it uses the exr plugin.

It seems that using the 3dsmax command line renderer, it auto fixes the outputs properly. When using deadline + lighting, this does not happen.

Further info here: viewtopic.php?f=86&t=10511

This fix is not sufficient on its own.

Privacy | Site terms | Cookie preferences