Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exporting BSDF layers (roughness, metallic, etc.) #282

Closed
RaresAmbrus opened this issue Sep 27, 2021 · 5 comments
Closed

Exporting BSDF layers (roughness, metallic, etc.) #282

RaresAmbrus opened this issue Sep 27, 2021 · 5 comments
Assignees
Labels
first answer provided question Question, not yet a bug ;)

Comments

@RaresAmbrus
Copy link

Hi,
Thank you for creating and maintaining this excellent repo! I have a question that I hope you can help me with, or point me in the right direction. I would like to export various surface properties such as roughness, metallic, specullar etc. As far as I could tell that's not supported right now - I saw this issue #177 but wasn't sure if there was a follow up (outputting the diffuse image is an excellent addition!).

Digging a bit through the code, I saw that here we have access to all the relevant layers, including roughness, metallic -- is that the right place to look? Any hints on how I could go about exporting that information are very welcome!

Thanks for the help!

@themasterlink
Copy link
Contributor

Hey,

first question would be do you want it per object or per pixel? Both should be possible just different approaches for each.

Best,
Max

@themasterlink themasterlink self-assigned this Sep 28, 2021
@themasterlink themasterlink added the question Question, not yet a bug ;) label Sep 28, 2021
@RaresAmbrus
Copy link
Author

RaresAmbrus commented Sep 28, 2021

Hi Max -- thanks for the quick response! Per-pixel would be ideal. Thanks!!

@themasterlink
Copy link
Contributor

Hey,

could then you are up for a ride :D I don't know how you guys manage to do this, but whenever someone open an issue, we are currently in the process of rewriting the class in question.

So, what you can do is you can use the SegMapRenderer. It allows you to write down custom properties in a pixel wise fashion.
You have now many options on achieving your goal, the most easy one would be to store the properties of your material per object inside of the custom properties of that object. I assume each object here has the same properties and does not consist out of many different materials. If that is the case you can split them by material: bpy.ops.mesh.separate(type = 'MATERIAL').

How would that look in code, create a new module and add this to the run function, if you already use the python api you just have to copy that code after you loaded your objects.

objects = get_all_mesh_objects()
for obj in objects:
    materials = obj.get_materials()
    for material in materials:
        principled_bsdf = material.get_the_one_node_with_type("BsdfPrincipled")
        for key in ["Roughness", "Metallic", "Specular"]:
            obj.set_cp("cp_"+ key,  principled_bsdf.inputs[key].default_value)

After that you specify in the SegMapRender Module which attributes you want to render, which then would be these custom properties: cp_Roughness and so on.

I hope this helps.

PS: I have not tested this piece of code, I wrote it in the browser.

Best,
Max

@RaresAmbrus
Copy link
Author

That's awesome, thanks a lot Max! I'll give this a shot first thing tomorrow morning! Thanks again!

@themasterlink
Copy link
Contributor

If you want to thank me tell you friends about BlenderProc ;)

I will close this for now, if you have a follow up you can reopen it. If it is a new question, you can just open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
first answer provided question Question, not yet a bug ;)
Projects
None yet
Development

No branches or pull requests

2 participants