Where to put static consts in URP shader file?

Hi,
i’m currently transitioning to URP shaders and having troubles to place my static consts somewhere… Like e.g.

static const float PI = 3.14159265359;

No mattter where i put it, it keeps telling me

Shader error in 'Hidden/PlanetEffects/Water': syntax error: unexpected float constant at line 35 (on d3d11)

replace it with defines? really? :face_with_spiral_eyes:

Try to place it above the functions. That did seemed to do the trick for me.

URP include files may contain a #define PI …, so it will collide with your definition, simply use another name, say PI_ME solves it.

1 Like