Render pipeline bad texture

Hello I would like to understand how to display textures with renderPipeline

without renderPipeline i have a plane with a correct texture

from panda3d.core import *
from direct.showbase.ShowBase import ShowBase
import os, sys

import logging
from direct.showbase.ShowBase import ShowBase
from panda3d.core import (
    loadPrcFileData,
    Vec3,
    Point3,
    DirectionalLight,
    VBase4,
    AmbientLight,
    CollisionTraverser,
    CollisionPlane,
    CollisionBox,
    CollisionNode,
    Plane,
    BitMask32,

    # For building Bullet collision geometry
    Geom,
    GeomTriangles,
    GeomVertexFormat,
    GeomVertexData,
    GeomVertexWriter)
from panda3d.bullet import (
    BulletWorld,
    BulletDebugNode,
    BulletPlaneShape,
    BulletRigidBodyNode,
    BulletGhostNode,
    BulletTriangleMesh,
    BulletTriangleMeshShape,
    BulletHelper)
from panda3d.physics import ForceNode, LinearVectorForce
from direct.interval.IntervalGlobal import Sequence, Wait

class MyApp(ShowBase):

    def __init__(self):

        ShowBase.__init__(self)


        # setup the camera

        self.disableMouse()
        self.camera.setPos(0., -250., 130.)
        self.camera.setHpr(0., -30., 0.)

        # create the plane

        cm = CardMaker("plane")
        # set the size of the card (left, right, bottom, top - in XZ-plane)
        cm.setFrame(-100., 100., -100., 150.)
        self.plane = self.render.attachNewNode(cm.generate())
        # the card is created vertically in the XZ-plane, so it has to be rotated
        # to make it horizontal
        self.plane.setP(-90.)

        road_tex = self.loader.loadTexture("texture.jpeg")
        self.plane.setTexture(road_tex)

app = MyApp()
app.run()

but with render Pipeline

from panda3d.core import *
from direct.showbase.ShowBase import ShowBase
import os, sys

import logging
from direct.showbase.ShowBase import ShowBase
from panda3d.core import (
    loadPrcFileData,
    Vec3,
    Point3,
    DirectionalLight,
    VBase4,
    AmbientLight,
    CollisionTraverser,
    CollisionPlane,
    CollisionBox,
    CollisionNode,
    Plane,
    BitMask32,

    # For building Bullet collision geometry
    Geom,
    GeomTriangles,
    GeomVertexFormat,
    GeomVertexData,
    GeomVertexWriter)
from panda3d.bullet import (
    BulletWorld,
    BulletDebugNode,
    BulletPlaneShape,
    BulletRigidBodyNode,
    BulletGhostNode,
    BulletTriangleMesh,
    BulletTriangleMeshShape,
    BulletHelper)
from panda3d.physics import ForceNode, LinearVectorForce
from direct.interval.IntervalGlobal import Sequence, Wait

class MyApp(ShowBase):

    def __init__(self):

        ShowBase.__init__(self)
        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, SpotLight
        self.render_pipeline = RenderPipeline()
        self.render_pipeline.create(self)
        self.render_pipeline.daytime_mgr.time = "7:40"

        # setup the camera

        self.disableMouse()
        self.camera.setPos(0., -250., 130.)
        self.camera.setHpr(0., -30., 0.)

        # create the plane

        cm = CardMaker("plane")
        # set the size of the card (left, right, bottom, top - in XZ-plane)
        cm.setFrame(-100., 100., -100., 150.)
        self.plane = self.render.attachNewNode(cm.generate())
        # the card is created vertically in the XZ-plane, so it has to be rotated
        # to make it horizontal
        self.plane.setP(-90.)

        road_tex = self.loader.loadTexture("texture.jpeg")
        self.plane.setTexture(road_tex)

app = MyApp()
app.run()

i lost my texture why ?
and can i apply a reflection in my plane object (like a wet surface)

I don’t think this will work with a card maker, since it doesn’t have tangents or other data. In addition, you need to adjust the material and observe the texture order.

In order not to dwell on this for too long, I suggest that you study the material settings and texture order in the examples you got with RP.

ok but can I still have my texture (without the reflection)
or disable renderPipeline for this object only

in the examples it is always importing .bam models
otherwise I’ll draw a rectangle with blender…

I would like to be able to create parallelepipeds with a texture (I don’t know if you can have more than one texture), bullet collision and reflection with render pipeline.
Is it mandatory to use a blender?

No, it’s not. If you use the GeomVertexData classes to create your own geometry, you’ll just have to be sure to add tangent and binormal columns.

You can do something like this to load non-RP models.

 # Use a special effect for rendering the scene, this is because the
 # roaming ralph model has no normals or valid materials
self.render_pipeline.set_effect(render, "scene-effect.yaml", {}, sort=250)

This snippet is taken from 02-Roaming-Ralph

I’m going to use blender it seems simpler to me (i can create easily metallic or wet rock effect), I am able to have reflection.

I have a last question… how can I improve my performance ?


i reduce mesh with flattenStrong but I didn’t understand how to “share the same state.”
is it possible to disable light effects on elements with render pipeline that are too far away?
I have 200 cubes but I’d like to have 1000 with 60fps (I have a gtx980), is this feasible ?
from panda3d.core import *
from direct.showbase.ShowBase import ShowBase
import os, sys

import logging
from direct.showbase.ShowBase import ShowBase
from panda3d.core import (
    loadPrcFileData,
    Vec3,
    Point3,
    DirectionalLight,
    VBase4,
    AmbientLight,
    CollisionTraverser,
    CollisionPlane,
    CollisionBox,
    CollisionNode,
    Plane,
    BitMask32,

    # For building Bullet collision geometry
    Geom,
    GeomTriangles,
    GeomVertexFormat,
    GeomVertexData,
    GeomVertexWriter)
from panda3d.bullet import (
    BulletWorld,
    BulletDebugNode,
    BulletPlaneShape,
    BulletRigidBodyNode,
    BulletGhostNode,
    BulletTriangleMesh,
    BulletTriangleMeshShape,
    BulletHelper)

class MyApp(ShowBase):

    def __init__(self):
        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, SpotLight
        from rpcore.util.movement_controller import MovementController
        self.render_pipeline = RenderPipeline()
        self.render_pipeline.create(self)
        self.render_pipeline.daytime_mgr.time = "7:40"
        self.render_pipeline.set_effect(render, "scene-effect.yaml", {}, sort=250)
        self.controller = MovementController(self)
        self.controller.set_initial_position_hpr(
            Vec3(-17.2912578583, -23.290019989, 26.88211250305),
            Vec3(-39.7285499573, -14.6770210266, 0.0))
        self.controller.setup()

        # World
        world = BulletWorld()
        world.setGravity(Vec3(0, 0, -9.81))

        # Plane earth
        shape = BulletPlaneShape(Vec3(0, 0, 1), 1)
        node = BulletRigidBodyNode('Ground')
        node.addShape(shape)
        np = render.attachNewNode(node)
        np.setPos(0, 0, -2)
        world.attachRigidBody(node)

        for i in range(0, 20):
            for j in range(0, 20):
                shard = loader.loadModel("cube.bam")
                shard.reparent_to(render)
                # shard.setScale(100,1,1)
                road_tex = self.loader.loadTexture("texture.jpeg")
                ts = TextureStage('ts')
                shard.setTexture(ts, road_tex)
                shard.setTexScale(TextureStage.getDefault(), 2)
                shard.setPos(i, j, 10)
                shard.flattenStrong()

app = MyApp()
app.run()

I think the problem is what you apply .flattenStrong() is local to each object. I think you should first attach them to a shared node and call it on it.

There was another thread on a similar topic recently, as I recall–I believe that it was this one linked here following:

Perhaps you might find some useful information therein!

In addition to what @serega-kkz said, you also need to call clearModelNodes to be able to flatten multiple models together.

thank you for your answers, I think you talked about this ?

i try to used hardware instancing but i have same performance

from panda3d.core import *
from direct.showbase.ShowBase import ShowBase
import os, sys

import logging
from direct.showbase.ShowBase import ShowBase
from panda3d.core import (
    loadPrcFileData,
    Vec3,
    Point3,
    DirectionalLight,
    VBase4,
    AmbientLight,
    CollisionTraverser,
    CollisionPlane,
    CollisionBox,
    CollisionNode,
    Plane,
    BitMask32,

    # For building Bullet collision geometry
    Geom,
    GeomTriangles,
    GeomVertexFormat,
    GeomVertexData,
    GeomVertexWriter)
from panda3d.bullet import (
    BulletWorld,
    BulletDebugNode,
    BulletPlaneShape,
    BulletRigidBodyNode,
    BulletGhostNode,
    BulletTriangleMesh,
    BulletTriangleMeshShape,
    BulletHelper)

class MyApp(ShowBase):

    def __init__(self):
        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, SpotLight
        from rpcore.util.movement_controller import MovementController
        self.render_pipeline = RenderPipeline()
        self.render_pipeline.create(self)
        self.render_pipeline.daytime_mgr.time = "7:40"
        self.render_pipeline.set_effect(render, "scene-effect.yaml", {}, sort=250)
        self.controller = MovementController(self)
        self.controller.set_initial_position_hpr(
            Vec3(-17.2912578583, -23.290019989, 26.88211250305),
            Vec3(-39.7285499573, -14.6770210266, 0.0))
        self.controller.setup()

        # World
        world = BulletWorld()
        world.setGravity(Vec3(0, 0, -9.81))

        # Plane earth
        shape = BulletPlaneShape(Vec3(0, 0, 1), 1)
        node = BulletRigidBodyNode('Ground')
        node.addShape(shape)
        np = render.attachNewNode(node)
        np.setPos(0, 0, -2)
        world.attachRigidBody(node)

        shard = loader.loadModel("Cuboid.bam")
        shard.setPos(0,0,0)
        road_tex = self.loader.loadTexture("texture.jpeg")
        ts = TextureStage('ts')
        shard.setTexture(ts, road_tex)
        shard.setTexScale(TextureStage.getDefault(), 2)

        chorusline = NodePath('chorusline')
        for i in range(0, 20):
            for j in range(0, 20):
                placeholder = render.attachNewNode("Dancer-Placeholder")
                placeholder.setPos(i, j, 10)
                shard.instanceTo(placeholder)

        for i in range(0, 20):
            for j in range(0, 20):
                placeholder = render.attachNewNode("Line-Placeholder")
                placeholder.setPos(i, j, 15)
                chorusline.instanceTo(placeholder)
        # chorusline.flattenStrong()

app = MyApp()
app.run()

I missed something ?
Is it compatible with the bullet physics engine ? Could I have “independant” collisions with my cubes? or will it be shared?

I think I understood how it works, I was able to double my cubes (400) and I stagnate at 50fps

from panda3d.core import *
from direct.showbase.ShowBase import ShowBase
import os, sys

import logging
from direct.showbase.ShowBase import ShowBase
from panda3d.core import (
    loadPrcFileData,
    Vec3,
    Point3,
    DirectionalLight,
    VBase4,
    AmbientLight,
    CollisionTraverser,
    CollisionPlane,
    CollisionBox,
    CollisionNode,
    Plane,
    BitMask32,

    # For building Bullet collision geometry
    Geom,
    GeomTriangles,
    GeomVertexFormat,
    GeomVertexData,
    GeomVertexWriter)
from panda3d.bullet import (
    BulletWorld,
    BulletDebugNode,
    BulletPlaneShape,
    BulletRigidBodyNode,
    BulletGhostNode,
    BulletTriangleMesh,
    BulletTriangleMeshShape,
    BulletHelper)

class MyApp(ShowBase):

    def __init__(self):
        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, SpotLight
        from rpcore.util.movement_controller import MovementController
        self.render_pipeline = RenderPipeline()
        self.render_pipeline.create(self)
        self.render_pipeline.daytime_mgr.time = "7:40"
        self.render_pipeline.set_effect(render, "scene-effect.yaml", {}, sort=250)
        self.controller = MovementController(self)
        self.controller.set_initial_position_hpr(
            Vec3(-17.2912578583, -23.290019989, 26.88211250305),
            Vec3(-39.7285499573, -14.6770210266, 0.0))
        self.controller.setup()

        # World
        world = BulletWorld()
        world.setGravity(Vec3(0, 0, -9.81))

        # Plane earth
        shape = BulletPlaneShape(Vec3(0, 0, 1), 1)
        node = BulletRigidBodyNode('Ground')
        node.addShape(shape)
        np = render.attachNewNode(node)
        np.setPos(0, 0, -2)
        world.attachRigidBody(node)

        shard = loader.loadModel("Cuboid.bam")
        shard.setPos(0,0,0)
        road_tex = self.loader.loadTexture("texture.jpeg")
        ts = TextureStage('ts')
        shard.setTexture(ts, road_tex)
        shard.setTexScale(TextureStage.getDefault(), 2)

        chorusline = NodePath('chorusline')
        for i in range(0, 20):
            for j in range(0, 20):
                placeholder = chorusline.attachNewNode("Dancer-Placeholder")
                placeholder.setPos(i, j, 10)
                shard.instanceTo(placeholder)
        for i in range(0, 2):
            placeholder = render.attachNewNode("Line-Placeholder")
            placeholder.setPos(0, i*40, 0)
            chorusline.instanceTo(placeholder)
        print(chorusline.flattenStrong())
        print(placeholder.flattenStrong())

app = MyApp()
app.run()

can we degrade the effects of render pipeline for distant objects?
I think it already does it automatically (maybe intern lod) but I would like to reinforce this effect.
or disable light and shadow effects for distant objects ?

I don’t think it’s possible to have good performance with models.
it would be necessary to use panda primitives instead (with planes)

400 cubes is a lot to have as separate nodes, can you flatten them or generate them as part of the same Geom?