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

Possible to disable lighting (directly render base RGB)? #51

Open
aamini opened this issue Aug 2, 2019 · 13 comments · May be fixed by #211
Open

Possible to disable lighting (directly render base RGB)? #51

aamini opened this issue Aug 2, 2019 · 13 comments · May be fixed by #211

Comments

@aamini
Copy link

aamini commented Aug 2, 2019

Hi, thanks for setting up this amazing library!! I was wondering if its possible to render a scene without the need for adding lights. For example, since a mesh has an associated set of face colors and vertex colors, we should be able to directly render those RGB colors.

I noticed that OpenGL supported disabling lighting glDisable(GL_LIGHTING); however, I couldn't figure out how to add this functionality to pyrender -- in the even that you don't already support this :)

@aamini
Copy link
Author

aamini commented Aug 2, 2019

I think I've figured out the trick:

  1. turn off all external light sources
  2. instantiate the scene with white ambient light: scene = pyrender.Scene(ambient_light=[1., 1., 1.])
  3. change the baseColorFactor of the mesh material to be RGBA white: baseColorFactor=[1., 1., 1., 1.]

Thanks!

@aamini aamini closed this as completed Aug 2, 2019
@aamini
Copy link
Author

aamini commented Aug 2, 2019

Closing this issue. If anyone else has a better solution please let me know!

@simbaforrest
Copy link

I think this doesn't solve the problem. If I want to render a mesh with face_colors=[0,200,0], what I get is [0,228,0] (same for vertex_colors).

@mmatl it would be great to have an option to disable PBR since people can use the color to simulate segmentation labels. Also would be great to have an option to disable anti-aliasing for the same purpose.

I think I've figured out the trick:

  1. turn off all external light sources
  2. instantiate the scene with white ambient light: scene = pyrender.Scene(ambient_light=[1., 1., 1.])
  3. change the baseColorFactor of the mesh material to be RGBA white: baseColorFactor=[1., 1., 1., 1.]

Thanks!

@simbaforrest
Copy link

Oh, forget about my previous comment. Just notice this post:
#15 (comment)

Thanks again for this great library.

@aamini
Copy link
Author

aamini commented Aug 11, 2019

@simbaforrest do you have a sample of code replicating the problem you see (with [0,200,0] becoming [0,228,0])? The comment in #15 is a solution only in the context of semantic segmentation and would require iterating over the number of objects -- which is certainly not a computationally ideal solution either.

@aamini aamini reopened this Aug 11, 2019
@xuelin-chen
Copy link

I guess what you need is the albedo pass, which is not implemented in the code.

I am looking for this feature too. :)

@simbaforrest
Copy link

@simbaforrest do you have a sample of code replicating the problem you see (with [0,200,0] becoming [0,228,0])? The comment in #15 is a solution only in the context of semantic segmentation and would require iterating over the number of objects -- which is certainly not a computationally ideal solution either.

Sorry, my code is a mess now. But you should be able to try this easily with your own code.

@markus-sp
Copy link

@simbaforrest do you have a sample of code replicating the problem...

Hi, I just came across the same issue @simbaforrest had a while ago. I would like to render a mesh with the exact colors specified in the vertex colors, without any additional lighting etc. Find below a code snippet that shows the problem. In this test I'm coloring all vertices with a constant color (e.g. [10,20,30]). The rendered image shows the object with constant color, but completely different color values. I also played around with the material properties but couldn't find a setting that renders the vertex colors correctly. Maybe I'm using the lighting/material in a wrong way?

#load from trimesh
trimesh_mesh = trimesh.load_mesh(path)

#colorize all vertices with testcolor
for idx in range(len(trimesh_mesh.vertices)):
    trimesh_mesh.visual.vertex_colors[idx, :3] = [10, 20, 30]

material = pyrender.MetallicRoughnessMaterial(
            baseColorFactor=[1, 1, 1, 1.],
            metallicFactor=0.0,
            roughnessFactor=0.0,
            smooth=False,
            alphaMode='OPAQUE')
    
pyrender_mesh = pyrender.Mesh.from_trimesh(trimesh_mesh, material=material)
camera = pyrender.IntrinsicsCamera(320, 240, 320, 320, znear=1, zfar=1000)
renderer = pyrender.OffscreenRenderer(viewport_width=320, viewport_height=320)

scene = pyrender.Scene(bg_color=np.zeros(4), ambient_light=np.ones(3))            
scene.add(pyrender_mesh, pose=np.eye(4))
scene.add(camera, pose=camera_pose)

img, _ = renderer.render(scene)

@nubertj
Copy link

nubertj commented Jan 20, 2020

I encounter the same problems as @markus-sp, also after specifying the face colors as in the case of @simbaforrest. Any news on this issue?

@ranftlr
Copy link

ranftlr commented Jan 22, 2020

It seems like flat shading, as also referenced in #15, was added a while ago but the documentation wasn't updated. You can enable it using the render flags:

color, depth = r.render(scene, flags=pyrender.constants.RenderFlags.FLAT)

@twcostain
Copy link

Ideally what would fix this is a new flag that disables GL_MUTLISAMPLE in this line. Althought my quick test on this hasn't completely fixed this problem for me, but its a big step in the right direction. There still seems to be some strange blurring/blending of pixel values at certain points on the model.

@krips89
Copy link

krips89 commented Dec 7, 2021

still no update on this?

@pbsds pbsds linked a pull request Jan 18, 2022 that will close this issue
@Kairobo
Copy link

Kairobo commented Feb 7, 2023

My method is : 1)turn off all external light sources
2) instantiate the scene with white ambient light: scene = pyrender.Scene(ambient_light=[1., 1., 1.])
3) do not pass Material variable and use color, depth = r.render(scene, flags=pyrender.constants.RenderFlags.FLAT).

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

Successfully merging a pull request may close this issue.

9 participants