OpenGL vs. DirectX lighting

I’ve noticed that lighting in DirectX mode can be very different than in OpenGL mode, sometimes drastically, depending on exactly how you have things setup.

As an example, here’s a teapot with specular highlights in OpenGL:

and in DirectX 9:

Here’s the code:


import direct.directbase.DirectStart
from direct.showbase.ShowBaseGlobal import *

class World( DirectObject.DirectObject ):
	def __init__( self ):
		base.mouseInterfaceNode.setPos( 0, 10, -2 )
		base.setBackgroundColor( Vec4( 0 ) )
		self.accept( "f9", base.screenshot )

		self.teapot = loader.loadModelCopy( "teapot" )
		self.teapotMaterial = Material()
		self.teapotMaterial.setSpecular( VBase4( 1, 1, 1, 1 ) )
		self.teapotMaterial.setShininess( 30.0 )
		self.teapot.setMaterial( self.teapotMaterial )
		self.teapot.reparentTo( render )

		self.ambientLight = AmbientLight( "ambientLight" )
		self.ambientLight.setColor( Vec4( 0.2, 0.2, 0.2, 1.0 ) )
		self.ambientLightNodePath = render.attachNewNode( self.ambientLight.upcastToPandaNode() )

		self.directionalLight = DirectionalLight( "directionalLight" )
		self.directionalLight.setColor( Vec4( 0.7, 0.7, 0.7, 1 ) )
		self.directionalLightNodePath = render.attachNewNode( self.directionalLight.upcastToPandaNode() )
		self.directionalLightNodePath.setHpr( -40, -50, 0 )

		render.setLight( self.ambientLightNodePath )
		render.setLight( self.directionalLightNodePath )

world = World()

run()

Specular highlights are perhaps a bit esoteric, but I’ve also seen differences in the way particles and CardMaker geometry is rendered (see here also).

Are these differences known and considered bugs? Are there any known workarounds?

I’ve never seen this before, but I’d definitely consider it a bug. I will investigate more closely.

David

Yep, it was a bug. The specular equation was not getting enabled in DirectX mode. A fix has been committed to the CVS trunk. Sorry about that, but thanks for pointing it out. :slight_smile:

David

Great, thanks. I’ll try to track down other differences that I think I’ve seen.

Oops, wasn’t logged in. I wish there was some way to change accidental Guest posts to reflect who actually made the post when it’s discovered that it was by an existing user.