Custom shader not working in runtime

I made a toon shader via a custom shader node using a hlsl file but it does not work once I hit play. In the Unity scene the material does work tho.

So I wanted to know if custom toon shader is compatible with Needle, or ar least via custom shader. I am using unlit shader in URP.

Original Post on Discord

by user 392492156583018497

Hey, Unlit shaders can be converted, Lit shaders can’t. What’s not working in the web / how does it look?

In the Scene I can see the shader working but once I hit play it is not displaying in the web:

by user 392492156583018497

I am using an Unlit shader in URP

by user 392492156583018497

the shader also uses a custom function node

by user 392492156583018497

it is a .hlsl code

by user 392492156583018497

#define MAINLIGHT_INCLUDED


void GetMainLightData_float(out half3 direction, out half3 color)
{
#ifdef SHADERGRAPH_PREVIEW

    direction = half3(-0.3, -0.8, 0.6);
    color = half3(1, 1, 1);

#else

#if defined(UNIVERSAL_LIGHTING_INCLUDED)
    
        Light mainLight = GetMainLight();
        direction = mainLight.direction;
        color = mainLight.color;

    #endif


#endif
}

#endif```

*by user 392492156583018497*

do you think it is because of this code? thank you in advance!

by user 392492156583018497

Yes it is! So you’re using an Unlit node but you pull in basically the same code as a Lit node would use

Turning this into a Lit node effectively.

What you can do is get rid of that and just have direction (Vector3) and color (Vector3) inputs on the node, so “hardcode” them

Hi! do you mean like this:
image.png

by user 392492156583018497

Yes, that should work - if it gets rid of your custom node above that runs the light loop

Hello! I chaged it but still not working. Looks like in the first picture. I should point that I also got these warnings:

by user 392492156583018497

I have a feeling something is not correctly installed in my setup lol

by user 392492156583018497

Hi can you try/check two things:

  • the shader has the ExportShader asset tag?
  • a) remove the property in the shader and just plug in a normal vector 3 for the light values?
  • b) invert x in the light direction vector, it might look wrong in unity but would be interesting to see how it looks on the web

If you can share screenshots like above for each test it would be great