Using simplepbr I set up the scene, in perspective projection it looks like this.
from direct.showbase.ShowBase import ShowBase
from panda3d.core import DirectionalLight, Material, NodePath
import simplepbr
class MyApp(ShowBase):
def __init__(self):
super().__init__()
# PBR initialization
pbr = simplepbr.init()
pbr.enable_shadows = True
# Creating a scene.
material = Material("test")
material.set_shininess(128)
plane = base.loader.load_model("plane.egg")
plane.set_material(material)
plane.reparent_to(render)
sphere = base.loader.load_model("sphere.egg")
sphere.set_material(material)
sphere.reparent_to(render)
light = DirectionalLight("sun")
light.set_shadow_caster(True, 512, 512)
light_np = NodePath(light)
light_np.set_hpr(35, -25, 0)
light_np.reparent_to(render)
render.set_light(light_np)
# Calculation of the bounding box for the shadow map.
bmin, bmax = render.get_tight_bounds(light_np)
light_lens = light.get_lens()
light_lens.set_film_offset((bmin.xz + bmax.xz) * 0.5)
light_lens.set_film_size(bmax.xz - bmin.xz)
light_lens.set_near_far(bmin.y, bmax.y)
app = MyApp()
app.run()
However, when I translate this into an orthographic projection, the properties of the material are lost, as you can see, the specular glare has disappeared.
from direct.showbase.ShowBase import ShowBase
from panda3d.core import DirectionalLight, Material, NodePath, Camera, OrthographicLens
import simplepbr
class MyApp(ShowBase):
def __init__(self):
super().__init__()
# Setting up a new node for rendering.
my_aspect2d = NodePath("my_aspect2d")
my_lens = OrthographicLens()
my_lens.set_film_size(8, 8)
my_lens.set_near_far(-1000, 1000)
camera = Camera("camera_orthographic")
camera.set_lens(my_lens)
camera_np = NodePath(camera)
camera_np.set_scale(base.win.get_x_size()/base.win.get_y_size()*1.0, 1.0, 1.0)
camera_np.reparent_to(my_aspect2d)
display_region = base.cam.node().get_display_region(0)
display_region.camera = camera_np
# PBR initialization
pbr = simplepbr.init(render_node = my_aspect2d, camera_node = camera_np)
pbr.enable_shadows = True
# Creating a scene.
material = Material("test")
material.set_shininess(128)
plane = base.loader.load_model("plane.egg")
plane.set_material(material)
plane.reparent_to(my_aspect2d)
sphere = base.loader.load_model("sphere.egg")
sphere.set_material(material)
sphere.reparent_to(my_aspect2d)
light = DirectionalLight("sun")
light.set_shadow_caster(True, 512, 512)
light_np = NodePath(light)
light_np.set_hpr(35, -25, 0)
light_np.reparent_to(my_aspect2d)
my_aspect2d.set_light(light_np)
# Calculation of the bounding box for the shadow map.
bmin, bmax = my_aspect2d.get_tight_bounds(light_np)
light_lens = light.get_lens()
light_lens.set_film_offset((bmin.xz + bmax.xz) * 0.5)
light_lens.set_film_size(bmax.xz - bmin.xz)
light_lens.set_near_far(bmin.y, bmax.y)
app = MyApp()
app.run()
Is it currently possible to use simplepbr with an orthogonal projection or only a perspective one? There is also another message in the console:
:display:gsg:glgsg(warning): Shader created-shader produced the following warnings:
WARNING: Too many temp register is used in Fragment shader, it may cause slow execution.
However, this does not always appear, I have not clarified the circumstances of this so it does not matter for the above mentioned problem.
plane.egg (1.0 KB)
sphere.egg (219.9 KB)