Hi, I’m new to unity, and I’m currently following this tutorial to create a caustics effect for a unity environment I’m completing for university.
#ifndef MAINLIGHT_INCLUDED
#define MAINLIGHT_INCLUDED
void MainLight_float(in float3 WorldPos, out half3 Direction, out half3 Color, out half DistanceAtten, out half ShadowAtten)
{
#ifdef SHADERGRAPH_PREVIEW
Direction = half3(0, 1, 0);
Color = 1;
DistanceAtten = 1;
ShadowAtten = 1;
#else
#if SHADOWS_SCREEN
half4 clipPos = TransformWorldToHClip(WorldPos);
half4 shadowCoord = ComputeScreenPos(clipPos);
#else
half4 shadowCoord = TransformWorldToShadowCoord(WorldPos);
#endif
#if defined(UNIVERSAL_LIGHTING_INCLUDED)
Light mainLight = GetMainLight(shadowCoord);
Direction = mainLight.direction;
Color = mainLight.color;
DistanceAtten = mainLight.distanceAttenuation;
ShadowAtten = mainLight.shadowAttenuation;
#endif
#endif
}
#endif
this is the code the tutorial provides, in a HLSL file format, and it uses it as a custom function in shadergraph for grabbing the directional light in the scene to cast shadows on the caustics.
But at 4:13 in the video, when plugging multiply nodes into the other multiply nodes, the error
“Shader error in ‘Lit Master’: undeclared identifier ‘TransformWorldToShadowCoord’ at Models/Caustics/HLSL/Main_Light.hlsl(16) (on d3d11)”
appears and i cant fix it.
I’ve read that “TransformWorldToShadowCoord” isn’t a function in HDRP. Is this true? and if so, are there any alternatives I can use?