Archive 17/01/2023.

Light with 2D sprites

codder

Hello,

How to make an AnimatedSprite2D illuminated by 3D Light? I need to use a custom material? If yes, someone can make a small material example?

Thanks

codder

I have this technique (SpriterTechnique.xml)

<technique vs="LitSolid" ps="LitSolid" psdefines="DIFFMAP">
        <pass name="alpha" depthwrite="false" blend="alpha" vs="Urho2D" ps="Urho2D" />
</technique>

And this material

<?xml version="1.0"?>
<material>
	<technique name="Techniques/SpriteTechnique.xml" />
	<texture unit="diffuse" name="Urho2D/Box.png" />
</material>

I still don’t know how to figure the lighting.
What I want to achieve is exactly how the lighting affects a simple Cube or a Sphere in the editor.

codder

Using OpenGL and DiffAlpha.xml technique seems working partially.

Basically the image is darker and probably it doesn’t get illuminated because of normal image.

EDIT:
I tried to add

<texture unit="normal" name="Urho2D/Box2.png" />

And

But the same thing…

Bananaft

Can you provide a reference of what effect you trying to achieve?

You can’t use normal maps on billboards in Urho right out the box. As tangent and binormal vectors are not generated for billboard mesh. You can write custom shader, to calculate tangent and binormal vectors in vertex programm.

codder

Solved by using a plane with a material that use DiffLightMapAlpha.xml as technique.