OGL vs DirectX Cel-Shading

For some reason I’m getting very different results if I use DirectX when using cel-shading technique described in the manual:

Using OGL:

Using DirectX:

I’m also getting a very low fpson OGL when I use this effect (30 fps on my crappy laptop). If I remove the following lines:

       self.panda.setAttrib(LightRampAttrib.makeSingleThreshold(0.5, 0.4))
        self.panda.setShaderAuto()

It goes back to the fps cap (60fps). On DirectX I get 55 fps. For such a simple scene with only one light source this is really strange (even in DirectX I think I should get 60 fps).

Am I doing something wrong? Or panda directX shaders is not working?

Full source code:

from panda3d.core import *
loadPrcFileData('', 'load-display pandadx9')
loadPrcFileData('', 'show-frame-rate-meter 1')
loadPrcFileData('', 'framebuffer-multisample 1')
loadPrcFileData('', 'multisamples 4')


import direct.directbase.DirectStart
from direct.showbase import DirectObject
from panda3d.core import TextNode, Vec3, Vec4, TransparencyAttrib
from direct.interval.IntervalGlobal import *
from direct.gui.DirectGui import *
from direct.showbase.DirectObject import DirectObject
from direct.task.Task import Task
from direct.actor.Actor import Actor
from direct.filter.CommonFilters import CommonFilters
from pandac.PandaModules import Material, VBase4

class World(DirectObject):
    def __init__(self):
        base.setBackgroundColor(0, 0, 0)
        base.disableMouse()
        self.loadSky()
        
        
        
        self.grass= loader.loadModel('models/environment')
        self.grass.setPos(0,0,-10)
        self.grass.setScale(0.07)
        self.grass.reparentTo(render)
        self.moon.setPos(50.00, -10.00, 10.00)

        
        
        alight= AmbientLight('alight')
        alight.setColor(VBase4(0.2, 0.2, 0.2, 1))
        self.alight = render.attachNewNode(alight)
        render.setLight(self.alight)
        
        plight= PointLight('plight')
        plight.setColor(VBase4(1,1,1, 1))
        self.plight= self.moon.attachNewNode(plight)
        render.setLight(self.plight)
        
        self.panda = Actor("models/panda-model", {"walk": "models/panda-walk4"})
        self.panda.loop("walk")
        self.panda.setPlayRate(0.5,"walk")
        self.panda.setBlend(frameBlend=True) #smooth animation
        self.panda.setPosHpr(0.00, -25.00, -10.00, 106.87, 0.00, 0.00)
        self.panda.setScale(0.005)
        self.panda.reparentTo(render)
        self.panda.setAttrib(LightRampAttrib.makeSingleThreshold(0.5, 0.4))
        self.panda.setShaderAuto()
        
        
        self.panda_mat= Material()
        self.panda_mat.setShininess(0.01)
        self.panda_mat.setSpecular(VBase4(0.1,0.1,0.1,0.1))
        self.panda_mat.setAmbient(VBase4(1,1,1,1))
        self.panda.setMaterial(self.panda_mat)
        
        
        #camera.setPos(6, -45, -10)
        #camera.setPosHprScale(-15.00, -20.00, -9.00, 262.87, 10.30, 0.00, 1.00, 1.00, 1.00)
        camera.setPos(6,-40,-10)
        camera.lookAt(self.panda)
        camera.setP(camera.getP()+10)
        #camera.place()
        #self.moon.place()
        #self.panda.place()
        render.setAntialias(AntialiasAttrib.MMultisample)
        render.ls()

    def loadSky(self):
        self.sky = loader.loadModel("solar_sky_sphere")

        self.sky_tex = loader.loadTexture("stars_1k_tex.jpg")
        self.sky.setTexture(self.sky_tex, 1)
        self.sky.reparentTo(render)
        self.sky.setScale(80)

        self.moon= loader.loadModel("planet_sphere")
        self.moon_tex= loader.loadTexture("moon_1k_tex.jpg")
        ts = TextureStage('ts')
        ts.setMode(TextureStage.MAdd)
        self.moon.setTexture(ts, self.moon_tex, 1)
        self.moon.reparentTo(render)
        self.moon.setScale(6)


w = World()

run()

Hi, welcome to the forums!

Unfortunately, our DirectX support is severely lacking. This is probably what has been causing your trouble.

What about the performance? Is the shader performance sub-par on opengl? I wouldn’t mind using OGL as long as the performance is acceptable.

That depends on the graphics drivers, how OpenGL support in them are implemented.

I dont see any cell shading is both openGL and DX broken?

it’s kinda hard to see the cel shaded on the panda model but it’s there, what you are missing is probably the thick line around the model (that is done with camera filters but I’m not using those).