SphereLighting

Hi, I just begin to learn Panda3d.

Here is my small code:

from direct.showbase.ShowBase import ShowBase
from panda3d.core import *
from direct.task import Task

from math import *


class MyApp(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)

        self.render.setAntialias(AntialiasAttrib.MAuto)

        self.cam.setY(-10)

        self.dl1 = PointLight('dl1')
        self.dl1n = self.render.attachNewNode(self.dl1)
        self.dl1n.setY(10)

        self.render.setLight(self.dl1n)

        self.m1 = Material()
        self.m1.setShininess(10)
        self.m1.setAmbient((0.5, 0.5, 1, 1))
        self.m1.setDiffuse((0.5, 0.5, 1, 1))
        self.m1.setSpecular((0.8, 0.8, 1, 1))

        self.b1 = self.loader.loadModel('planet_sphere.egg.pz')
        self.b1.reparentTo(self.render)

        self.b1.setMaterial(self.m1)

        self.taskMgr.add(self.spinL, 'SpinL')


    def spinL(self, task):
        angleRadians = radians(task.time*45)
        self.dl1n.setPos(10*sin(angleRadians), 10*cos(angleRadians), 0)
        return Task.cont

app = MyApp()
app.run()

The file ‘planet_sphere.egg.pz’ is from the ‘samples’ folder of Panda3d.

I want to display GLOSSY sphere with rotating Light around it.

  1. May be I do not understood materials - the Sphere is not very glossy as I saw in webGL version of VPython.

  2. At the light terminators - some blinking is visible, very bad effect, not smooth lighting.

Please, help me - where is my understanding error?

What you’re seeing is the default per-vertex lighting offered by fixed-function OpenGL. If you want to get per-pixel lighting, you will need some sort of shader.

The easiest approach is to enable the shader generator:

self.b1.setShaderAuto()