Redfulness of models when lighting

I am trying to test my shaders, lights and materials, but I got some issues can’t solve during test.
Thank for anyone help!

as you can see, the models are all red

here are the full code:

from panda3d.physics import *
from panda3d.core import *
from direct.showbase.ShowBase import ShowBase
from panda3d.core import Material


class Game(ShowBase):
	def __init__(self):
		ShowBase.__init__(self)
		cube = loader.loadModel("models/man/block.egg")
		cube.setPos(0, 0, 0)
		cube.reparentTo(self.render)
		glass = loader.loadModel("models/man/thinglass.egg")
		glass.setPos(0, 0, 1)
		glass.setScale(0.1, 0.1, 0.1)
		glass.reparentTo(self.render)
		floor = loader.loadModel("models/man/floor.egg")
		floor.setPos(0, 0, -10)
		myMaterial = Material()
		myMaterial.setShininess(5.0) # Make this material shiny
		myMaterial.setAmbient((0, 0, 1, 1)) # Make this material blue
		floor.setMaterial(myMaterial) # Apply the material to this nodePath
		floor.reparentTo(self.render)
		plight = PointLight('plight')
		plight.setColor((1, 1, 1, 1))
		plight.setShadowCaster(True, 512, 512)
		plnp = render.attachNewNode(plight)
		plnp.setPos(0, 0, -8)
		render.setLight(plnp)
		render.setShaderAuto()
a = Game()
a.run()


Am I using wrong lighting/ material ? (the shaders works quite well.)
The effect I expect is like this

is there anyway to change my code into something like this?

What happens if you set the material’s diffuse-value to white? That is, if, in addition to calling “setAmbient”, etc., you also call “myMaterial.setDiffuse((1, 1, 1, 1))”?

Further, do you see this same reddening in other models–particularly, in the default models (such as either of the panda-models)?

1 Like

Perhaps your models already contain some material. Then try this.

floor.setMaterial(myMaterial, 1)

This is the override priority. Just don’t ask why it’s done this way. I don’t know myself.

2 Likes

@serega-kkz Thanks very much, that worked!!! @^V^@

@Thaumaturge Yes, it does, when I use PView on default models and open the light, it doesn’t show red, but when I use PView on my models, it turns red. Also could I ask that why the “myMaterial.setAmbient((0, 0, 1, 1))” didn’t work well, my model doesn’t show blue.
image
code now:

from panda3d.physics import *
from panda3d.core import *
from direct.showbase.ShowBase import ShowBase
from panda3d.core import Material


class Game(ShowBase):
	def __init__(self):
		ShowBase.__init__(self)
		cube = loader.loadModel("models/man/block.egg")
		cube.setPos(0, 0, 0)
		cube.reparentTo(self.render)
		glass = loader.loadModel("models/man/thinglass.egg")
		glass.setPos(0, 0, 1)
		glass.setScale(0.1, 0.1, 0.1)
		glass.reparentTo(self.render)
		floor = loader.loadModel("models/man/floor.egg")
		floor.setPos(0, 0, -10)
		myMaterial = Material()
		myMaterial.setShininess(10.0) # Make this material shiny
		myMaterial.setAmbient((0, 0, 1, 1)) # Make this material blue
		myMaterial.setDiffuse((1, 1, 1, 1))
		floor.setMaterial(myMaterial, 1) # Apply the material to this nodePath
		floor.reparentTo(self.render)
		plight = PointLight('plight')
		plight.setColor((1, 1, 1, 1))
		plight.setShadowCaster(True, 512, 512)
		plnp = render.attachNewNode(plight)
		plnp.setPos(0, 0, -8)
		render.setLight(plnp)
		render.setShaderAuto()
a = Game()
a.run()


I use blender2.8 and yabee to export those objects.
here are my blend and here are the files:
untitled.blend (792.1 KB)
untitled.egg (5.0 KB)
image

my “panda.egg.pz” look like this:
image
image

Blender 2.8 and YABBE, it can’t be. perhaps you are hiding something. :wink:

@serega-kkz I found that my “emitr” is 5.0 and I think thats why it’s red, but

Well, that would likely do it, I believe!

I may be mistaken, but I think that this is because this only sets the material’s response to ambient light. It doesn’t affect how the material responds to direct light, or how it produces specular highlights.

1 Like

I suspect that you are using an exporter that distorts the material. The last case was exporter PRPEE. If you need an egg format, use this one:

2 Likes

@Thaumaturge ah that make sense!!, it work well on other light
@serega-kkz It helps!! Thx very much^V^, so shall I re-install to reset its args?

1 Like

Remove the plugin just PRPEE

1 Like