Closed Goldname100 closed 4 years ago
Yes, it is possible, but you'll need to write some code! The texturing sample already shows how to do simple textured rendering, but I don't have an example for the rest. You'll need to write code to load the obj and mtl files, 'rearrange' and tile the material parameters into a tensor shaped like the vertex colours, then follow the pattern of the texturing sample -- do deferred rendering passes that write out the relevant material parameters and UVs to gbuffers, then do the final lighting & texturing calculations using those buffers.
On Sat, 20 Jul 2019 at 08:35, Goldname100 notifications@github.com wrote:
I have a .obj, .mtl, and png texture file. Is it possible to render a complete textured version of the model using this library? I wasn't too sure as I don't see any examples taking mtl files as input.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
Can you explain what you mean by simple textured rendering? How is that different from normal textured rendering?
I meant by 'simple' that there's a single material (diffuse only), single texture, and the mesh is given directly in the code. However, there is nothing fundamentally different about rendering an obj+mtl.
Can you explain what you mean by simple textured rendering? How is that different from normal textured rendering?
I think sample/deferred.py
provides a good demo. And I successfully made my model with texture based on this code. You can have a try.
@pmh47 Hi~ sorry for bothering. I want to know how to render an obj with a transparent background or specific image? I rendered some results, and all my results are like:
I know I should adjust the background_attributes, but I do not know how to set it.
pixels = dirt.rasterise_deferred(
vertices=cube_vertices_clip,
vertex_attributes=tf.concat([
tf.ones_like(cube_vertices_object[:, :1]), # mask
cube_uvs, # texture coordinates
cube_normals_world # normals
], axis=1),
faces=cube_faces,
background_attributes=(tf.ones([frame_height, frame_width, 6])*255),
shader_fn=shader_fn,
shader_additional_inputs=[texture, light_direction]
)
Thanks for any help and guidance!
I have a .obj, .mtl, and png texture file. Is it possible to render a complete textured version of the model using this library? I wasn't too sure as I don't see any examples taking mtl files as input.