hi guys: i want to know how to set point light type in spriteIIIumnator, can somebody know it ? thanks:)
You should ask @AndreasLoew, he is the author of this great tool.
What do you mean with point light type? Point light vs. directional light?
At the moment SpriteIlluminator supports only one point light, no directional light.
yes, when i use default camera is ok , but when i create a camera (such as createPerspective or createOrthographic), the light direction all change.e
the a2.png, i did not use camera, show ok , the a1.png, that i use perpective camera, show strange. now i think if image in perpective camera , the point light direction did not show right. maybe problem is here:
void LightEffect::prepareForRender(Sprite *sprite, Texture2D *normalmap)
{
auto gl = getGLProgramState();
gl->setUniformVec2("u_contentSize", sprite->getContentSize());
Point posRelToSprite = PointApplyAffineTransform(Point(_lightPos.x, _lightPos.y), sprite->getWorldToNodeAffineTransform());
gl->setUniformVec3("u_lightPos", Vec3(posRelToSprite.x, posRelToSprite.y, _lightPos.z));
gl->setUniformTexture("u_normals", normalmap);
SpriteFrame *frame = sprite->getSpriteFrame();
Size untrimmedSize = frame->getOriginalSize();
Size trimmedSize = frame->getRect().size;
Vec2 framePos = frame->getRect().origin;
Size texSize = frame->getTexture()->getContentSize();
// set sprite position in sheet
gl->setUniformVec2("u_spritePosInSheet", Vec2(framePos.x / texSize.width, framePos.y / texSize.height));
gl->setUniformVec2("u_spriteSizeRelToSheet", Vec2(untrimmedSize.width / texSize.width, untrimmedSize.height / texSize.height));
gl->setUniformInt("u_spriteRotated", frame->isRotated());
// set offset of trimmed sprite
Vec2 bottomLeft = frame->getOffset() + (untrimmedSize - trimmedSize) / 2;
Vec2 cornerOffset = frame->isRotated() ? Vec2(bottomLeft.y, bottomLeft.x)
: Vec2(bottomLeft.x, untrimmedSize.height - trimmedSize.height - bottomLeft.y);
gl->setUniformVec2("u_spriteOffset", cornerOffset);
}
Point posRelToSprite = PointApplyAffineTransform(Point(_lightPos.x, _lightPos.y), sprite->getWorldToNodeAffineTransform());
Point posRelToSprite = PointApplyAffineTransform(Point(_lightPos.x, _lightPos.y), sprite->getWorldToNodeAffineTransform());
cause sprite is in a camera, so need camera with sprite together getWorldToNodeAffineTransform? because i do not about getWorldToNodeAffineTransform.

