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

same mesh, but different rendering result when using different texture type #1420

Open
lcc815 opened this issue Nov 29, 2024 · 0 comments
Open

Comments

@lcc815
Copy link

lcc815 commented Nov 29, 2024

Summary

System configuration

System information:

CPU: AMD EPYC 7542 32-Core Processor
GPU: NVIDIA GeForce RTX 4090
Python: 3.8.13 (default, Apr 19 2022, 00:53:22) [GCC 7.5.0]
NVidia driver: 535.129.03
LLVM: 10.0.0

Dr.Jit: 0.4.6
Mitsuba: 3.5.2
Is custom build? False
Compiled with: GNU 10.2.1
Variants:
scalar_rgb
scalar_spectral
cuda_ad_rgb
llvm_ad_rgb

Description

I render two meshes. Their vertices & faces are completely the same, except that one is vertex-colored and the other is texture-mapped.
If open them in meshlab, they look the same.
However, I rendered them by mitsuba but got different result.
(1) the texture-mapped rendering result:
image
(2) the vertex-colored rendering result:
image

Everything of the scene keeps the same except the shape(e.g. the mesh). Also I divided the vertex color values by 255 to map it from 0-255 to 0-1.

Steps to reproduce

issue.zip

  1. download the data I attached, which contains:
    image
  2. simply run python main.py, which is:
import mitsuba as mi

mi.set_variant("llvm_ad_rgb")

from mitsuba.scalar_rgb import Transform4f as T


def update_vertex_color():
    pillar_raw = mi.load_dict({
        "type": "ply",
        "filename": "pillar_vertex_colored.ply",
        "face_normals": False,
        "to_world": mi.ScalarTransform4f().rotate([0, 0, 1], angle=10),
    })

    params = mi.traverse(pillar_raw)
    params['vertex_color'] = params['vertex_color'] / 255.
    params.update()
    pillar_raw.write_ply("pillar_vertex_colored_updated.ply")


def build_scene(shape):
    emitter = {
            'type': 'envmap',
            'filename': 'city.hdr',
            'to_world': T.rotate([1,0,0], 90),
        }

    integrator = {
        'type': 'direct',
        'shading_samples': 4
    }


    sensor = mi.load_dict({
        'type': 'orthographic',
        'to_world': mi.ScalarTransform4f().look_at(
            origin=[0, 0, 0],
            target=[1, 0, 0],
            up=[0, 0, 1]
        )
    })

    scene =  mi.load_dict({
            'type': 'scene',
            'integrator': integrator,
            'sensor': sensor,
            "emitter": emitter,
            'shape': shape,
            })
    return scene


if __name__ == "__main__":
    update_vertex_color()
    shape1 = {
            'type': 'ply',
            'filename': 'pillar_vertex_colored_updated.ply',                   
            'to_world': T.translate([5, 0, -1]).scale(0.2).rotate([1, 0, 0], 45),
            'bsdf':{
                'type': 'diffuse',
                'reflectance': {
                    'type': 'mesh_attribute',
                    'name': 'vertex_color'
                },
            }
        }
    shape2 = {
            'type': 'obj',
            'filename': 'pillar_texture_map/pillar_texture_map.obj',
            'to_world': T.translate([5, 0, -1]).scale(0.2).rotate([1, 0, 0], 45),
            'bsdf':{
                'type': 'diffuse',
                'reflectance': {
                    'type': 'bitmap',
                    'filename': 'pillar_texture_map/material_0.png'
                },
            }
        }
    scene1 = build_scene(shape1)
    scene2 = build_scene(shape2)
    image1 = mi.render(scene1, spp=128)
    image2 = mi.render(scene2, spp=128)
    mi.util.write_bitmap("vertex_render.png", image1)
    mi.util.write_bitmap("texture_map_render.png", image2)
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

1 participant