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. Dismiss Notice

Question I am new to HDRP and idk why costume function breaks when I put a value in.

Discussion in 'High Definition Render Pipeline' started by inakirayman, Jun 11, 2023.

  1. inakirayman

    inakirayman

    Joined:
    Feb 18, 2022
    Posts:
    4
    Idk if I am doing something wrong but my function breaks the moment I put a value in.


    Sub Graph With values on zero:
    upload_2023-6-11_4-9-17.png
    Source For Main Light (Called "Lighting"):

    void MainLight_half(float3 WorldPos, out float3 Direction, out float3 Color,
    out float DistanceAtten, out float ShadowAtten)
    {
    #ifdef SHADERGRAPH_PREVIEW
    Direction = normalize(float3(0.5h, 0.5h, 0.25h));
    Color = float3(1.0h, 1.0h, 1.0h);
    DistanceAtten = 1.0h;
    ShadowAtten = 1.0h;
    #else
    #if SHADOWS_SCREEN
    float4 clipPos = TransformWorldToHClip(WorldPos);
    float4 shadowCoord = ComputeScreenPos(clipPos);
    #else
    float4 shadowCoord = TransformWorldToShadowCoord(WorldPos);
    #endif
    Light mainLight;
    GetMainLight(shadowCoord, out mainLight);
    Direction = mainLight.direction;
    Color = mainLight.color;
    DistanceAtten = mainLight.distanceAttenuation;
    ShadowAtten = mainLight.shadowAttenuation;
    #endif
    }


    Shader Graph:

    upload_2023-6-11_4-10-51.png

    Error:
    upload_2023-6-11_4-11-9.png
     
  2. Qleenie

    Qleenie

    Joined:
    Jan 27, 2019
    Posts:
    734
    I think it’s because you only define the half variant, you might also need to define the float variant if your graph is not using half precision only.