Home Game Development unity – Sprite Shape & URP Custom 2D Lighting Shader

unity – Sprite Shape & URP Custom 2D Lighting Shader

0
unity – Sprite Shape & URP Custom 2D Lighting Shader

[ad_1]

I’ve been dropping my thoughts over this for a few days now, and may’t discover any concrete details about it.

I’m attempting to write down a customized shader (shader graph to be particular) to gentle sprite form objects. This is a comparatively easy shader:

Shader graph representation of a simple lit shader

This is what the shader materials seems to be like utilized to a generic sq. sprite, and the sprite form. This is utilizing a Light 2D Spot gentle:

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

Clearly this shader is working effective 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 tip of that. But after I apply the default Sprite-Lit-Default materials, it appears to work simply effective:

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’s going to 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 motive I can not simply use the built-in Sprite-Lit-Default materials is as a result of I wish to embody different properties/results to the customized shader past simply the fundamental lighting.

I’m certain there is a piece of data/information that I lack, or one thing that I’m lacking, however for the time being I’m all out of concepts. Even if a concrete reply of “it is not doable as a result of XYZ” would make me pleased at this level.

Some Housekeeping info:

  • Unity model: 2021.3.8f1
  • Sprite Shape model: 7.0.6
  • Shader Graph model: 12.1.7
  • Using the Renderer 2D in URP (Because second lighting)

Any different info I’d be very happy to provide. I’m unsure what else could be related.

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here