2
$\begingroup$

I just started using Blender and am really confused about how to render images. When importing the .obj and .tga (texture map), Blender should render the images with the same RGB value shown in the .tga (texture map). There should not be any additive lighting. When I deleted all the lighting and Blender rendered black images. How can I achieve this? I have upload the code and the data. Thanks in advance for the help!

from pathlib import Path
import bpy
import numpy as np
import json

world = bpy.data.worlds['World']
world.use_nodes = True
bg = world.node_tree.nodes['Background']
bg.inputs[0].default_value[:3] = (0., 0., 0.)
bg.inputs[1].default_value = 0.

def delete_object_iteration(obj_name):
    for x in range(1, 15):
        obj = bpy.context.scene.objects.get(obj_name + '.' + str(x).zfill(3))
        obj_ini = bpy.context.scene.objects.get(obj_name)
        
        if obj_ini is not None:
            bpy.data.objects.remove(obj_ini, do_unlink=True) 
        if obj is not None:
            bpy.data.objects.remove(obj, do_unlink=True) 

delete_object_iteration("Bip01")
delete_object_iteration("Bip01 Footsteps")

if len(bpy.data.materials.keys()) > 1:
    for i, material in enumerate(bpy.data.materials):
        if i > 0:
           bpy.data.materials.remove(material, do_unlink=True)
           
bpy.ops.object.select_by_type(type='MESH')
bpy.ops.object.delete()

avatar_path = '/home/tiantian/Desktop/question/Female_Adult_03/Export/Female_Adult_03.fbx'

bpy.ops.import_scene.fbx(filepath=str(avatar_path))

# Fix paths to textures
for im in bpy.data.images:
    print(im.filepath)
    im.filepath = im.filepath.replace('../../../../../temp/Humans/with_opacity_version/f003/textures', '../Textures')


# Workaround: make opacity texture fully transparent
bpy.data.materials['f003_opacity'].blend_method = 'CLIP'
bpy.data.materials['f003_opacity'].alpha_threshold = 1


# remove default light    
bpy.ops.object.select_by_type(type='LIGHT')
bpy.ops.object.delete(use_global=False)

context = bpy.context
scene = bpy.context.scene
render = bpy.context.scene.render

RESOLUTION = 512

render.resolution_x = RESOLUTION
render.resolution_y = RESOLUTION
render.resolution_percentage = 100
render.film_transparent = True

scene.use_nodes = True
nodes = bpy.context.scene.node_tree.nodes
links = bpy.context.scene.node_tree.links

scene.display_settings.display_device = 'None'

# Clear default nodes
for n in nodes:
    nodes.remove(n)

render_layers = nodes.new('CompositorNodeRLayers')

# Create depth output nodes
depth_file_output = nodes.new(type="CompositorNodeOutputFile")
depth_file_output.label = 'Depth Output'
depth_file_output.base_path = ''
depth_file_output.file_slots[0].use_node_format = True
depth_file_output.format.file_format = 'OPEN_EXR'
links.new(render_layers.outputs['Depth'], depth_file_output.inputs[0])

albedo_file_output = nodes.new(type="CompositorNodeOutputFile")
albedo_file_output.label = 'Albedo Output'
albedo_file_output.base_path = ''
albedo_file_output.file_slots[0].use_node_format = True
albedo_file_output.format.file_format = 'OPEN_EXR'
albedo_file_output.format.color_mode = 'RGB'
links.new(render_layers.outputs['Image'], albedo_file_output.inputs[0])

xx = 0
# - camera
cam = scene.objects['Camera']
cam.location = (xx, -np.sqrt(3**2-xx**2), 0)

cam_constraint = cam.constraints.new(type='TRACK_TO')
cam_constraint.track_axis = 'TRACK_NEGATIVE_Z'
cam_constraint.up_axis = 'UP_Y'
cam_empty = bpy.data.objects.new("Empty", None)
cam_empty.location = (0, 0, 0.9)
cam.parent = cam_empty
scene.collection.objects.link(cam_empty)
context.view_layer.objects.active = cam_empty
cam_constraint.target = cam_empty

render_file_path = "/home/tiantian/Desktop/question/material0"

albedo_file_output.file_slots[0].path = render_file_path + "_albedo_"

bpy.ops.render.render(write_still=True)
```
$\endgroup$
1
  • 1
    $\begingroup$ I hardly ever use Eevee, but in Cycles you can use the Emission Shader, or plug the Color output directly into the Surface socket of the Output node, to create a material that doesn't reflect anything, i.e. no additional lighting effects, and no reflections of other objects. However, in Cycles this also makes such objects act as light sources that affect the total lighting of the scene. $\endgroup$
    – user143855
    Commented Jun 17, 2022 at 7:41

1 Answer 1

3
$\begingroup$

1 - Change the render color management to Standard Change the render color management to Standard

2 - Change the material properties of the object, feel free to change color of your liking or to replace it with a texture or whatever you want it to be Change the material properties of the object, feel free to change color of your liking or to replace it with a texture or whatever you want it to be

The color space will be respected this way and there is no need for lighting because this objects are self emissive, and they don't recieve shadows because of its emissive properties, however they can cast shadows.

3 - This image explains how to "disable" emissive light of your object leaking to the environment (notice how the scene is all populated with objects , i assure you they are nearby) but no light is beign calculated from the emissive object. Disable emissive light going to environment

4 - This is the same scene with the previous settings turned on for the emissive object. Image with things turned on

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .