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

Render pplastic material using mesh vertex attributes stored in a .PLY 3D model #496

Closed
ZhaoJinyu96 opened this issue Sep 10, 2021 · 5 comments

Comments

@ZhaoJinyu96
Copy link

  • [❔ other question]

Summary

I can use a texture to set spatially varying diffuse albedos of 'pplastic' material, but I wonder whether the diffuse albedo can be assigned spatially using the color of vertices stored in .ply 3D models.

System configuration

  • Platform: Windows
  • Compiled variants:
    • scalar_rgb
    • scalar_spectral
    • scalar_rgb_polarized
    • scalar_mono_polarized
    • scalar_spectral_polarized

Description

I used your sample code of 'bsdf_pplastic.xml', and changed the uniform albedo to a texture.
I also tried to set the albedo according to the vertex color stored in the .ply model but it says that
unreferenced object MeshAttribute[
[xml.cpp:1059] name = "vertex_color",
[xml.cpp:1059] scale = "1"
[xml.cpp:1059] ] (within bsdf of type "pplastic")
Is there something wrong or 'pplastic' does not support MeshAttribute plugin?

bsdf_pplastic.zip

@tizian
Copy link
Contributor

tizian commented Sep 10, 2021

Could you please post the full version of your test scene that also includes your matpreview.xml file and the .ply mesh?

Also, do you observe the same problem with a simpler diffuse BSDF (without any polarization)?

@ZhaoJinyu96
Copy link
Author

This is the full version of my test scene (I modified docs/scenes/bsdf_pplastic.xml).
sample.zip

I had no problem when I used diffuse BSDF.

@tizian
Copy link
Contributor

tizian commented Sep 10, 2021

Ah ok, I see what is happening now. It's a combination of two things:

  • The diffuse color argument of the pplastic plugin is actually called diffuse_reflectance (instead of only reflectance in the diffuse BSDF)
  • The mesh_attribute texture does not implement the mean function that is used during importance sampling of the pplastic. To work around that, you can go into pplastic.cpp and adjust the parameters_changed function:
void parameters_changed(const std::vector<std::string> &/*keys*/ = {}) override {
    m_specular_sampling_weight = 0.5f;
}

@ZhaoJinyu96
Copy link
Author

ZhaoJinyu96 commented Sep 11, 2021

Thank you very much! The problem is solved.

@tizian
Copy link
Contributor

tizian commented Sep 12, 2021

Great :)

@tizian tizian closed this as completed Sep 12, 2021
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

2 participants