Custom hlsl shader doesn’t get lit by additonnal lights

Hello there,

I’m trying to modify this shaders (

) to accept lightning and etc…
The main light work fine but I can’t get my shader to be lit by additionnals light (points light).

The lighting code is at the end in the Pass section.

The code: unityPFI/BotWGrass.shader at main · HeRobrain3/unityPFI · GitHub

I’m not good in shaderlab and this code is more grafted than Godrick the grafted. Sorry for the mess.


Image description: The grass doesn’t get lit by the point light (flame).
Thank you in advance.

you only have a forward base pass, you need forwardadd as well for additional lights.
Rendering 5 (catlikecoding.com)

not sure how vertex lights work with tessellation and geometry shaders, but those would more than likely suffice since the grass is so small on screen (provided you don’t need shadows, though i believe there’s a way to add a shadowcaster pass to them, i’ve just never researched it.)
also worth mentioning that vertex lights are all in one pass, and pixel lights add one (two with shadows) draw calls per mesh hit by a light, which will destroy batching and instancing for your grass.

if you’re interested in vertex lights, go read up on how they’re implemented in the built in shader code for vertex lit shaders.

see ShadeVertexLightsFull().
Unity-Built-in-Shaders/CGIncludes/UnityCG.cginc at master · TwoTailsGames/Unity-Built-in-Shaders · GitHub

1 Like