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

Export Diffuse BSDF materials #1488

Closed
eugeneko opened this issue Nov 7, 2021 · 6 comments
Closed

Export Diffuse BSDF materials #1488

eugeneko opened this issue Nov 7, 2021 · 6 comments

Comments

@eugeneko
Copy link

eugeneko commented Nov 7, 2021

Is your feature request related to a problem? Please describe.
I am not an artist, I am only exporting existing models into the engine.
And I find it mildly frustrating that Diffuse BSDF materials used by certain artist are always exported as gray into glTF.

Describe the solution you'd like
I don't see any fundamental issues that prevent Blender from exporting Diffuse BSDF material as PBR material with roughness=1.
Yes, we kind of lose Diffuse BSDF roughness, but it's still 100 times better than losing everything.

Moreover, I can hack the desired behavior with only a couple of lines of code:

  • Replace bpy.types.ShaderNodeBsdfPrincipled with bpy.types.ShaderNodeBsdfDiffuse in gltf2_blender_get.get_socket
  • Replace "Base Color" with "Color" in gltf2_blender_gather_materials_pbr_metallic_roughness.__gather_base_color_factor
  • Hardcode roughness_factor to 1.0 in the same place
  • Probably need to do the same thing for albedo texture, but I didn't need it in my case.

I am not qualified enough to make proper fix and send it as PR, but I don't think it would be too hard.

Is there any reason why Diffuse BSDF should not be supported in this way?

Additional context
How it works after my hack:
image

@JaduBen
Copy link

JaduBen commented Dec 7, 2021

I'm also not getting textures on BSDF materials (other than Pricipaled). So I am unable to use transparent or metallic. There is a very bad workaround of exporting a gtlf and manually editing the material in the json

add
"baseColorTexture" : { "index" : 0 }
inside
"pbrMetallicRoughness" : {}

@donmccurdy
Copy link
Contributor

I'm also not getting textures on BSDF materials (other than Pricipaled). So I am unable to use transparent or metallic.

I'm not sure that I follow you here – the Principled BSDF supports metallic factors and textures, and several different types of transparency. Alpha Blending and Transmission transparencies can be exported to glTF. See: https://docs.blender.org/manual/en/latest/addons/import_export/scene_gltf2.html


Is there any reason why Diffuse BSDF should not be supported in this way?

From the Principled BSDF documentation, the Principled BSDF material has an "emphasis on compatibility with other software" that Blender's other materials do not, and it's (thankfully) a very good match for the PBR materials in glTF 2.0. We could try to approximate other shading models, but there the materials would not look the same and we'd receive bugs regularly about that, all of which takes time to debug and to answer.

My own preference would be to continue to focus on the Principled BSDF material – there's still plenty of work to do on that (like #1454) and rarely enough time to do it. But I'd be curious what others prefer, and open to the idea if someone is interested in adding and maintaining that addition.

@JaduBen
Copy link

JaduBen commented Dec 7, 2021

Thank you, I was finally able to get adequate results on my object using the Principled BSDF

@julienduroure
Copy link
Collaborator

So, seems there is no more issue here.
Closing this ticket. Don't hesitate to comment if needed

@nonl4331
Copy link

nonl4331 commented Dec 9, 2024

I'm interested in implementing and maintaining the diffuse material export.

I've been using the diffuse material in Blender with roughness 0 to produce reference images with specifically a lambertian cosine distribution for my path tracer. I also use blender to export gltf/glb scenes to my path tracer and was suprised to find that diffuse materials did not export their base colour. This was counter-intuitive to me and left me rather confused.

I understand wanting to focus on principled BSDF but I feel it shouldn't be a problem if I were to implement a diffuse material export as I am willing to implement and maintain it.

If there are no problems with me implementing this and creating a PR I will go ahead and do it.

@julienduroure
Copy link
Collaborator

Hello,
Please do not comment an (almost) 3 years old ticket.
If you want to propose an enhancement, please create a new ticket, with details about what can not be achieved with the Principled BSDF node, that is the best equivalent of PBR material in glTF.

See also #2390, that will export a simple version of materials

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants