Black object with pbr texture

Hello, i try to apply a pbr texture with render pipeline to my object (like rock texture), but i have a black plane.

from __future__ import print_function

import os
import sys
from panda3d.core import Vec3, load_prc_file_data, ShaderTerrainMesh
from panda3d.core import NodePath, CardMaker, Texture
from panda3d.core import TextureStage
from direct.showbase.ShowBase import ShowBase
import numpy as np
import threading
import time

os.chdir(os.path.dirname(os.path.realpath(__file__)))
pipeline_path = "../../"

if not os.path.isfile(os.path.join(pipeline_path, "setup.py")):
    pipeline_path = "../RenderPipeline/"

sys.path.insert(0, pipeline_path)

from rpcore import RenderPipeline

# This is a helper class for better camera movement - its not really
# a rendering element, but it included for convenience
from rpcore.util.movement_controller import MovementController

class Application(ShowBase):
    def __init__(self):
        # Setup window size, title and so on
        load_prc_file_data("", """
            win-size 1600 900
            window-title Render Pipeline by tobspr
            stm-max-chunk-count 2048
            gl-coordinate-system default
            stm-max-views 20
            notify-level-linmath error
        """)

        self.render_pipeline = RenderPipeline()
        self.render_pipeline.create(self)

        # Set time of day
        self.render_pipeline.daytime_mgr.time = "12:25"
        self.set_background_color(0.1, 0.1, 0.1, 1)

        self.controller = MovementController(self)
        self.controller.set_initial_position_hpr(
            Vec3(0, -10, 2),  # Position : 10 unités derrière le plan et légèrement au-dessus.
            Vec3(0, 0, 0)  # Orientation : La caméra regarde vers l'origine.
        )
        self.controller.setup()
        self.create_plane()

    def create_plane(self):
        cm = CardMaker("plane")
        cm.set_frame(-2, 2, -2, 2)
        plane = NodePath(cm.generate())

        # PBR textures
        tex_albedo = loader.load_texture("textures/PavingStones131_1K-JPG_Color.jpg")  # Albedo map
        tex_normal = loader.load_texture("textures/PavingStones131_1K-JPG_NormalGL.jpg")  # Normal map
        tex_roughness = loader.load_texture("textures/PavingStones131_1K-JPG_Roughness.jpg")  # Roughness map

        plane.set_texture(tex_albedo, 1)
        plane.set_shader_input("normal_map", tex_normal)
        plane.set_shader_input("roughness_map", tex_roughness)

        plane.reparent_to(self.render)
        plane.set_pos(0, 0, 0)


Application().run()

i use this texture:

I forgot something?

i have an other question, if i want to render a metal, i need to add an other texture like this, right ? like this:

tex_metallic = loader.load_texture("textures/stone_metallic.jpg") 
plane.set_shader_input("metallic_map", tex_metallic)

i see that i can use a meterial object:

but is it compatible with render pipeline?

with only the texture, i have a black object too (but i have the texture without render pipeline)

It is not enough to apply an arbitrary texture to an object. It is necessary that the object has the necessary data for calculations, namely normals, tangents, tangents and others, it all depends on what you are doing.

CardMaker does not have any data for PBR rendering, it is an internal class for creating rendering areas, which, unfortunately, is being used for other purposes.

1 Like

ok thanks for your answer.

is it possible to load an egg cube (panda3d has a box.egg file) and apply a pbr texture to it?
or it’s not possible too, and i must to do it in blender directly ?

i try it, i have same issue…

    def create_box(self):
        model = self.loader.load_model("box.egg.pz")
        model.reparent_to(self.render)

        tex_albedo = self.loader.load_texture("textures/PavingStones131_1K-JPG_Color.jpg")
        tex_normal = self.loader.load_texture("textures/PavingStones131_1K-JPG_NormalGL.jpg")
        tex_roughness = self.loader.load_texture("textures/PavingStones131_1K-JPG_Roughness.jpg")

        model.set_texture(tex_albedo, 1)
        model.set_texture(tex_normal, 2)
        model.set_texture(tex_roughness, 3)
        model.set_pos(0, 0, 0)

but it’s strange, if I apply a basic texture (without pbr), my object will still be black

The problem is that the rendering pipeline expects a fixed set of data anyway; if there is none, this means that the product of the final color will be zero.

ok thx, i will use blender for set pbr

Something else you need to know, RenderPipeline requires a certain order of RenderState, new versions of Blender do not use texture slots, nodes are used instead. You will probably use the gltf format, but this format uses a four-component vector for the tangent, which again does not give compatibility.

I think you’re stuck with YABBE if you want to use RenderPipeline.

I do not know how up-to-date the exporter is now.

it’s work with blender 3.6 and gltf file :slight_smile:

so i found a “hack”, gltf is a basic text file, so i edit this in my python code for change texture and metallicFactor and roughnessFactor and after that i load my new gltf file.

1 Like