Friday, September 30, 2022
HomeGame Developmentunity - Sprite Form & URP Customized 2D Lighting Shader

unity – Sprite Form & URP Customized 2D Lighting Shader


I have been shedding my thoughts over this for a few days now, and might’t discover any concrete details about it.

I’m making an attempt to put in writing a customized shader (shader graph to be particular) to mild sprite form objects. This can be a comparatively easy shader:

Shader graph representation of a simple lit shader

That is what the shader materials appears to be like like utilized to a generic sq. sprite, and the sprite form. That is utilizing a Gentle 2D Spot mild:

A normal shape lit as expected, and a sprite shape not being lit with the same material applied

Clearly this shader is working high-quality for the generic sq. sprite, however not the sprite form. I’d suppose that perhaps sprite shapes simply cannot be lit, and that might be the top of that. However after I apply the default Sprite-Lit-Default materials, it appears to work simply high-quality:

2D Lighting working on both the sprite shape and square

Albeit it requires some kind of “refresh” of the sprite form, because it does not work when its assigned, however it would work as soon as the sprite form’s “Stretch UV” choice is toggled (to notice, it does not matter if “Stretch UV” is toggled on or off, toggling it’s simply used to refresh one thing concerning the sprite form).

The explanation I am unable to simply use the built-in Sprite-Lit-Default materials is as a result of I wish to embrace different properties/results to the customized shader past simply the fundamental lighting.

I am certain there is a piece of knowledge/information that I lack, or one thing that I am lacking, however for the time being I am all out of concepts. Even when a concrete reply of “it isn’t potential as a result of XYZ” would make me joyful at this level.

Some Housekeeping info:

  • Unity model: 2021.3.8f1
  • Sprite Form model: 7.0.6
  • Shader Graph model: 12.1.7
  • Utilizing the Renderer 2D in URP (As a result of 2nd lighting)

Another info I would be more than pleased to offer. I am unsure what else could be related.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments