Search Unity

Resolved Can someone help me understand why my Custom Function doesn't work.

Discussion in 'Shader Graph' started by nikofon007, Feb 23, 2021.

  1. nikofon007

    nikofon007

    Joined:
    Sep 10, 2020
    Posts:
    38
    Hello, I want to recreate the effects from Doom 2 that melts the screen down.
    So far I came up with this:
    bandicam 2021-02-23 02-36-29-386.jpg
    Generated code: https://pastebin.com/wE0MpS5r

    Now I want to combine all these nodes in a one custom node that will repeat the described by these nodes specified amount of times in order to fill the whole screen (by incrementing the number that compare functions compare to (like from 0 to 0.1 and 0.1 to 0.2 and so on).
    So for now I have this: https://pastebin.com/ifVXqqpd
    But for some reason it doesnt work (it says
    Shader error in 'hidden/preview/CustomFunction_7B896545': undeclared identifier 'TextureOffset_float' at line 50 (on d3d11)

    Compiling Fragment program
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_RGBM_ENCODING
    Disabled keywords: UNITY_NO_DXT5nm UNITY_ENABLE_NATIVE_SHADOW_LOOKUPS UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_NO_FULL_STANDARD_SHADER UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_COLORSPACE_GAMMA UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_FULL_HDR UNITY_VIRTUAL_TEXTURING
    )
    Can someone help me with this?
     
    Last edited: Feb 24, 2021
  2. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    Hi,

    I think you got a few things set up a bit weird fashion here - I am not sure how you ended up with this code you have so far.

    A few things to note.
    Check custom function node documentation to see what is needed for correct operation.
    https://docs.unity3d.com/Packages/com.unity.shadergraph@6.7/manual/Custom-Function-Node.html

    When using the file mode, your functions need always that _float suffix, but don't write it to the name in the panel, i.e.
    If it would be called DoomEffect, you would name the function in your file DoomEffect_float.

    All the inputs/outputs need to be incorrect order and have to be correctly spelled, case matters etc.

    You don't probably need those includes you included, I am not sure why you added them?

    You got also some of the syntax wrong too and other minor things:

    TEXTURE2D should be Texture2D.

    SAMPLER, you should just input a SamplerState if you need one.
    Then, when you sample a texture, you would do it like this:
    Code (HLSL):
    1. SAMPLE_TEXTURE2D(myTexture, samplermyTexture, (_Combine_DEB4E04B_RGBA_4.xy));
    It might be a good idea to not erroneously truncate your values (i.e. you assign a vector4 to a vector3 and so on.)
     
    PutridEx likes this.
  3. nikofon007

    nikofon007

    Joined:
    Sep 10, 2020
    Posts:
    38
    Thank you so much for your answer, but I'm afraid it didn't work. It still says the same thing.
    About the includes, I just copypasted them cause I think some of them contain functions like lerp, saturate, etc that are being used by functions in the file.
    I updated the code on pastebin, maybe you could have another look if you have some spare time.
    I'm sorry that I ask this stupid question its just so hard to get into shaders.
    Thank you.
     
  4. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    It says the same thing about exactly what? Please check the debug logs and fix the errors until you have none left.

    I did manage to get your code working and some kind of sensible results out of it, too.

    But you don't need most of the includes I think. (EDIT, well, you might as I don't know what that ifdef is that wraps your whole shader.)
     
  5. nikofon007

    nikofon007

    Joined:
    Sep 10, 2020
    Posts:
    38
    It turns out I just don't need the includes.
    Thank you for your help!
     
    Last edited: Mar 4, 2021
    Olmi likes this.