- Modificato
Question about 3d lighting & spine objects + rotation
Hello,
we are currently using spine objects in a 3d world with 3d lighting.
We are using the Spine/Sprite/Pixel Lit shader and it's working 90% the way we want, BUT:
We need some spine objects to always be lit in the same intensity (depending on light sources and the spine object's position) regardless of its rotation.
Both with "fixed normals" (model space, x:0 y:1, z:0) and without, the spine object will be lit differently depending on its rotation. Is there any way to make it disregard the rotation so it always gets lit equally?
I have really tried every shader option 1000 times, tried solving it with different ideas but no idea yet..
help would be super appreciated!
EDIT: Basically what I would like to do (probably) would be to make the spine object's normal always face up, REGARDLESS of the object's rotation. currently, fixed normal: x:0 y:1 z:0 kind of does that but still respects the object's rotation.
EDIT 2: I realized that hacking the normals would not be able to fix it as the lighting of the object depends on all the light source's positions/rotations relative to the object so that would not be possible except by maybe modifying the shader?
Any input on this from someone knowledgeable would be really appreciated. I will try to clarify what I mean a bit more:
I am using Spine with the Sprite/Lit Shaders in a 3D game and always rotating the Spine objects towards the player camera so that they don't skew/distort or look "2D". This works well with unlit shaders but when they are lit they change their lighting because they are always rotating.
I would like the Spine obejcts to be lit/affected by light sources and ambient light but be unaffected by their own rotation so that the lighting doesn't look "off" in my context.
Is this possible at all? Where would I begin fixing this? Or is this just straight up impossible?
kbm ha scrittoBoth with "fixed normals" (model space, x:0 y:1, z:0) and without, the spine object will be lit differently depending on its rotation. Is there any way to make it disregard the rotation so it always gets lit equally?
If you want the rotation of the model to be ignored, then you need to set Fixed Normal Space
to View Space
, not Model Space
. Otherwise the vector is fixed in model-space and thus rotates with the model.
kbm ha scrittoI am using Spine with the Sprite/Lit Shaders in a 3D game and always rotating the Spine objects towards the player camera so that they don't skew/distort or look "2D". This works well with unlit shaders but when they are lit they change their lighting because they are always rotating.
If you are rotating the model to face the view already like billboards, then I wonder why you are experiencing problems here - in either view space or model space, the result should be consistent and as expected. Could you please post a screenshot or video of the problematic scene?
These two screenshots show a spine object in the air (the apple). I rotated the player camera (it's a first person game) to take the two shots, the apple does NOT change its position between those shots.
There is one sun (directional) light at a 45 degree angle.
The spine apple object has a script that makes it always rotate towards the player camera, here's the script:
public Camera m_Camera;
void LateUpdate()
{
transform.LookAt(transform.position + m_Camera.transform.rotation * Vector3.forward,
m_Camera.transform.rotation * Vector3.up);
}
The apple has the following settings:
Shader: Sprite/VertexLit
Fixed Normals: View Space: 0, 1, 0
My desired result would be for the apple not to change its lighting no matter how it's "billboard" rotated due to facing the player camera.
I also tried:
- Changing the normal to pretty much any other value or changing it to model space, but this doesn't solve anything.
- Disabling fixed normals on the shader, checking the 'Add Normals' Box in the Advanced tab of the SkeletonAnimation script
- Enable adjust back-face tangents
- Tweaking the billboard rotation script so that it only rotates some axes and not others
- Disabling the billboarding completely. This still produces changing lighting when I rotate the player cam if fixed normals/view space is enabled
I spent many hours trying pretty much any and all spine settings I could find, but so far I haven't been able to produce the result I wanted.
Did this explain the problem a little better?
Thanks for the clarification, now I can see your problem. What you need is neither fixed normals in view-space, nor in model-space, but in world-space.
I quickly added this feature, all Sprite shaders now offer a Fixed Normal Space
World-Space
option.
New unitypackages can be downloaded here as usual:
Spine Unity Download
For reference, this issue has been tracked under this ticket:
https://github.com/EsotericSoftware/spine-runtimes/issues/1638
Harald ha scrittoThanks for the clarification, now I can see your problem. What you need is neither fixed normals in view-space, nor in model-space, but in world-space.
I quickly added this feature, all Sprite shaders now offer a
Fixed Normal Space
World-Space
option.
New unitypackages can be downloaded here as usual:
Spine Unity DownloadFor reference, this issue has been tracked under this ticket:
https://github.com/EsotericSoftware/spine-runtimes/issues/1638
Wow! I am overjoyed, thank you so so much for this, you literally made my day! It works and was exactly what I was trying to clarify! :grinteeth:
Gald to hear it's working as desired now. Thanks for getting back to us and for your kind words.