Custom Lighting Shader HELP!

PLEASE READ THE WHOLE THING SO YOU DON’T SUGGEST THINGS I ALREADY TRIED.Thank you :slight_smile:

I am trying to create a .hlsl file to get custom lighting for shader using shader graph, but the include won’t work. I am going crazy because all video I’ve seen don’t need to include it because it is automatically included. So what is wrong with it? I even made a new project to see if there was corruption in my URP project.

#C:\Users\User\Documents\Games Repository\TLS\Library\PackageCache\com.unity.render-pipelines.universal@10.4.0\ShaderLibrary\Lighting.hlsl"

I shouldn’t even have to include this file because it should be automatically included but I get this error instead: Shader error in ‘Shader Graphs/Cel Toon Shader’: undeclared identifier ‘CalculateMainLight_float’ at line 233 (on d3d11)

Here is my hlslcode:

Code
#ifndef UNIVERSAL_LIGHTING_INCLUDED
#define UNIVERSAL_LIGHTING_INCLUDED

void CalculateMainLight_float(float3 WorldPos, out float3 Direction, out float3 Color) 
{

#ifdef SHADERGRAPH_PREVIEW
    Direction = float3(0.5, 0.5, 0);
    Color = 1;
#else
    Light mainLight = GetMainLight(0);
    Direction = mainLight.direction;
    Color = mainLight.color;
#endif

}

#endif

Maybe one of the Teaching Assistants can help you with this, but that being said, the majority of the people on this forums are beginners, maybe you’ll have a hard time finding your answer, so, I suggest, if you haven’t done this already, ask in the Gamedev Discord channel, you’ll probably get a much faster response there.

On my part, I stayed with CG and never truly tried HLSL, sorry, the best I can do is point you towards more experienced people.

Thanks

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms