Downloading & Reuploading Individual VRAY Renders

I am still looking for a solution to a problem we are having with some of our renders. Basically, some various renders are not coming out well enough to suit our organization. So, our potential solution would involve downloading a single render layer .png, putting it in a photo editor to touch it up with the necessary edits, then re-uploading the resulting .png in place of the original. I’ve previously been told that this is theoretically possible using a combination of the API’s. I believe I have found the method in which we would upload the edited image, but I can not find any method that would allow us to download the original image.

Can anyone help us accomplish this?
@Will @AndreiSE

Related post by Steve, our 3D artist on staff: API for editing/retouching individual vray rendered layers

It sounds like you should start with the Layers Service.

You can get layers associated to an item or a configuration (Get List of Layers). Keep in mind assetLayerConfiguration must be passed as encoding stringified JSON.

This would return an array of objects, the layers. Each entry will have a fileId parameter which you can use to download the layer. It will be accessible at https://{ENV}.threekit.com/api/files/{FILE_ID}/content

You can then POST the touched up layer to the Files Service, which will store it in the platform. You can associate that file to a new layer with the Create a Layer API. As far as I know, you cannot update existing layers, you’ll have to create a new one.

If you need some additional guidance or examples, please let me know. Andrei will likely have some code snippets or we can cook one up for you.

2 Likes

I believe that files URL may be the answer that completes the puzzle for me. Thanks. If this gets me to a solution I will put it in this thread & the other one.

1 Like

Will’s answer should enable you to get the files in the most efficient way.
The URL he provided you to access the files is documented here:

https://developer.threekit.com/reference/getfile

I agree this particular workflow isn’t documented currently. I will see about solving this.
Please recall the note I made about the cropping that we apply to the individual layer renders.

@Will @AndreiSE Is there a way to delete a layer? I’m happy to recreate the layer via the API, but without being able to delete the layer that was previously there, wouldn’t we have two layers with duplicate stage & item configuration?

You can’t delete layers, because we can’t delete renders from the database. Everything is retained so it doesn’t get lost by mistake.
Simply create a new layer. There shouldn’t be any conflicts. It’s probably easiest to get the info from the previous layer first, and then pass it to the new create layer call.
The new entry will simply override the existing entry.

Oh, and yes, creating a new layer will indeed generate a new layerId, which is the only downside of this process that I can see.

1 Like

@AndreiSE @Will I have now successfully created the new layers with what seems to be the correct configuration. Is there some time period I have to wait before I see the results reflected in the configurator or something?

Or is there an extra set of steps that I have to do to associate the new layerId?

There shouldn’t be a need for additional steps.
We need to run some tests at our end as well to verify all options, but unfortunately this week we are all engaged with a series of company events. I will see if I can get more input from the engineering team tomorrow, but we might not be able to run any testing and debugging until Monday.

The only thing that comes to mind at the moment is that depending on how you are testing the player and your setup, you will need to republish the item where you posted the renders.
Publishing items refreshes the cache key. If you are testing an embedded player with published items then you are only receiving the existing cached renders from the previous version of the layer. Simply republishing the item will refresh the cache key, but you need to wait for the thumbnail job to finish before you test again.

I have only been looking at it in the Threekit platform on the player that is available on the Item details screen & the Renders screen. I can see the thumbnail of the new image on the render entry.

Thank you for all of your help on this.

@AndreiSE @Will Any movement on this?

We haven’t seen any issues yet.
Are you sure you passed both the asset and stage configuration correctly to the new layer?
If you are using a stage, it is important to also pass the stageId along with the stageConfiguration.

If you want us to have a look at your code, please feel free to email it to me at [email protected].

@UrbanElectricAlex
I ran some tests myself, and after comparing with the docs, it appears that the docs are missing a few required parameters.
In your case where you are working with composite assets, you need to pass the assetLayer parameter to the body, with the layerId.
In addition to that, you also need to include the width and height parameters, in addition to the metadata that includes the offsets and crop.

This is all info you have available in the GetLayer By ID or by Query Parameters return as well.

I will get the CreateLayer API updated in the docs to list those additional parameters.

Here is an example of the JSON that I could pass to the request body, for a layer without configuration.

{
    "assetId": "3f8684ed-785f-4862-93bf-af7eeaaab961",
  "assetLayer": "7333c93c-a7ef-4fb1-88ae-6d6bb466bc9e",
  "assetVersion": "",
  "assetLayerConfiguration": {},
  "stageId": "ba8eb8d6-e2e2-4b89-a9de-a3fbb48b6fe4",
  "stageConfiguration": {
    "CamAngle": "Main"
  },
  "metadata": {
    "offsetX": 0,
    "offsetY": 0,
    "cropWidth": 2048,
    "cropHeight": 1151,
    "originalWidth": 2048,
    "originalHeight": 1151,
    "originalOffsetX": 0,
    "originalOffsetY": 0
  },
  "orgId": "5348a737-f3b0-4eb2-959c-3bdbe3e0abe6",
  "width": 2048,
  "height": 1151,
  "fileId":"b75a3915-bb42-445e-9d4a-45d2a9d6d358"
}

@AndreiSE
Here’s an example of the request I’m sending to the create layer API. I’m seeing the layer get created just fine with the thumbnail of my edited image. But the configurator doesn’t show it.

{
    "assetId": "fc4b5997-8a76-484c-b241-475082300fe2",
    "assetLayerConfiguration": {
        "Primary Glass": {
            "assetId": "066d9c9b-609a-4840-81cf-70946ee8fe7b"
        },
        "Primary Finish": {
            "assetId": "74716511-ea09-4004-8604-f9ffd0c2bae8"
        }
    },
    "orgId": "correct org id",
    "stageId": "939cd0d9-7899-405c-b631-eaaed931684c",
    "stageConfiguration": {
        "Camera Position v2": 2
    },
    "assetVersion": "",
    "metadata": {
        "offsetX": 400,
        "offsetY": 126,
        "cropWidth": 225,
        "cropHeight": 768,
        "originalWidth": 225,
        "originalHeight": 768,
        "originalOffsetX": 400,
        "originalOffsetY": 126
    },
    "fileId": "6dea8ba4-c7bd-406a-bf45-dfa5f4f3992e",
    "assetLayer": "883b7033-8253-49f9-b20f-9cbc67e3755e",
    "width": 1024,
    "height": 1024
}

It looks like your originalWidth and originalHeight in the metadata are incorrect. They should be matching the width and height of 1024.

And originalOffsetX and Y might need to be set to 0 in that case as well.

@AndreiSE
Here’s my new JSON after implementing your feedback. I see in the docs that it’s calling assetVersion a required field. Currently, I’m just passing that as an empty string because I’m not sure where to get that from. Could that be my issue?

{
    "assetId": "fc4b5997-8a76-484c-b241-475082300fe2",
    "assetLayerConfiguration": {
        "Primary Glass": {
            "assetId": "066d9c9b-609a-4840-81cf-70946ee8fe7b"
        },
        "Primary Finish": {
            "assetId": "74716511-ea09-4004-8604-f9ffd0c2bae8"
        }
    },
    "orgId": "correct org id",
    "stageId": "939cd0d9-7899-405c-b631-eaaed931684c",
    "stageConfiguration": {
        "Camera Position v2": 2
    },
    "assetVersion": "",
    "metadata": {
        "offsetX": 400,
        "offsetY": 126,
        "cropWidth": 225,
        "cropHeight": 768,
        "originalWidth": 1024,
        "originalHeight": 1024,
        "originalOffsetX": 0,
        "originalOffsetY": 0
    },
    "fileId": "03aed18c-663f-4293-a5b4-92fa5bb6c727",
    "assetLayer": "883b7033-8253-49f9-b20f-9cbc67e3755e",
    "width": 1024,
    "height": 1024
}

The assetVersion should just be empty. I think I will be removing it from the docs, as it’s more of an internal parameter only.

1 Like