Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Flat, per object shading

Discussion in '2D Experimental Preview' started by Armadous, Feb 15, 2021.

  1. Armadous

    Armadous

    Joined:
    Apr 6, 2013
    Posts:
    7
    This is a repot of my post on Graphics > URP, I believe this a more appropriate location.

    Straight to the point, I'm to achieve a flat shading on normals from 2D lights.

    How shading currently works.
    oh26qt2K9Z.gif

    How I want it to work.
    Em8dOal3Tg.gif

    The working example comes from modifying LightingUtility.hlsl to take either 1 or 0.5 color values based on the normal angle to the light and only works when objects are placed at the origin, I'm not using pixel position for the following reason.

    Normally lighting is computed per pixel but I need every pixel on the sprite to see the same angle to the point light. This solves undesirable artifacts introduced by the pixels at the top of the post having a different angel to the light from those at the bottom and the same for every pixel between. This causes the shadow that slides up and down the post as well as the irregular shading on the ground.
    PXs6MpAvTb.gif

    Very generally, is there a better way to achieve this effect besides messing with the shader guts? Very specifically, is it possible to determine the object position in world space from the input.positionWS available in LightingUtility.hlsl APPLY_NORMALS_LIGHTING?