Can i just use only one light and only apply this light for my hero and don’t apply for other models in my game scene?
I had tryed to set the lighting mask of other models as 0,but all of this models disappeared from the screen!
You could add an Ambient Light for the other models. If they receive no light at all, they will be black.
setting 0 as the mask ‘should’ use a non lit shader, not sure why is doesn’t work. What version of cocos2d-x are you using?
If you add an Ambient light as LIGHT0 and the hero light as LIGHT1
hero mask = (unsigned int)(-1)
other mask = (unsigned int)(-1) ^ LightFlag.LIGHT1
-1 = unsigned int wrapped backwards to max: all bits set true
hero mask will be lit by all lights
other mask will be lit by everything except LIGHT0
I am using ‘cocos2d-x 3.4 final’.
Maybe this is a bug? I’m not sure.
All 3.4 versions switch shaders in Sprite3D::draw()
bool usingLight = false;
for (const auto light : lights) {
usingLight = ((unsigned int)light->getLightFlag() & _lightMask) > 0;
if (usingLight)
break;
}
if (usingLight != _shaderUsingLight)
genGLProgramState(usingLight);
Try putting a break point in here in a simple scene - you hero and one other object. See if your masks are being set and resolved correctly.
Thanks!!!