Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Where to put static consts in URP shader file?

Discussion in 'Universal Render Pipeline' started by Serotonindude, Jun 15, 2021.

  1. Serotonindude

    Serotonindude

    Joined:
    Aug 28, 2015
    Posts:
    8
    Hi,
    i'm currently transitioning to URP shaders and having troubles to place my static consts somewhere... Like e.g.

    Code (CSharp):
    1. static const float PI = 3.14159265359;
    No mattter where i put it, it keeps telling me

    Code (CSharp):
    1. Shader error in 'Hidden/PlanetEffects/Water': syntax error: unexpected float constant at line 35 (on d3d11)
     
  2. Serotonindude

    Serotonindude

    Joined:
    Aug 28, 2015
    Posts:
    8
    replace it with defines? really? :confused:
     
  3. TheMave

    TheMave

    Joined:
    Jan 9, 2015
    Posts:
    8
    Try to place it above the functions. That did seemed to do the trick for me.
     
  4. MonsterAttackingCrew

    MonsterAttackingCrew

    Joined:
    Mar 4, 2021
    Posts:
    4
    URP include files may contain a #define PI ....., so it will collide with your definition, simply use another name, say PI_ME solves it.
     
    Propagant likes this.