Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Shader graph position question.

Discussion in 'Graphics Experimental Previews' started by screenname_taken, Dec 9, 2018.

  1. screenname_taken

    screenname_taken

    Joined:
    Apr 8, 2013
    Posts:
    663
    Hi, i seem to be having trouble connecting anything to the "position" tab of a PBR shader.
    I thought i could connect the output from an "Add" node to the input of position.
    upload_2018-12-9_17-57-51.png
     
  2. Jick87

    Jick87

    Joined:
    Oct 21, 2015
    Posts:
    124
    I just read a post somewhere recently with a similar issue (can't remember where I saw it). It seems it is to do with the Sample Texture 2D node. Anything you plug into the Position slot basically happens in the vertex function stage of the compiled shader and the normal texture sampling function that the Sample Texture 2D node uses can't work in that stage.

    My understanding is you need to replace any use of the Sample Texture 2D node with a Sample Texture 2D LOD node when you intend to plug it into the Position slot.
     
  3. screenname_taken

    screenname_taken

    Joined:
    Apr 8, 2013
    Posts:
    663
    I see. :/ well damn.
    Edit: Indeed it was. Thank you so much, from my understanding, it should have worked with sample texture 2d.
     
  4. Fallc

    Fallc

    Joined:
    Mar 13, 2015
    Posts:
    48
    If theres a texture2D lod node available it should work. The only reason textures don't work out of the box in vertex stage, is that theres no way the gpu can tell which mipmap to choose.
     
  5. screenname_taken

    screenname_taken

    Joined:
    Apr 8, 2013
    Posts:
    663
    Ah. Now it makes more sense. These kind of notes are what the documentation should include.
     
  6. Andy-Touch

    Andy-Touch

    A Moon Shaped Bool Unity Legend

    Joined:
    May 5, 2014
    Posts:
    1,479
    The Shader Graph team already added these notes in the Documentation for the Sample Texture 2D Node :)

    "Samples a Texture 2D and returns a Vector 4 color value for use in the shader. You can override the UV coordinates using the UV input and define a custom Sampler State using the Sampler input.

    To use the Sample Texture 2D Node to sample a normal map, set the Type dropdown parameter to Normal.

    NOTE: This Node can only be used in the Fragment Shader Stage. To sample a Texture 2D in the Vertex Shader Stage use a Sample Texture 2D LOD Node instead."



    https://github.com/Unity-Technologi...raph/Documentation~/Sample-Texture-2D-Node.md
     
    Last edited: Dec 12, 2018
  7. screenname_taken

    screenname_taken

    Joined:
    Apr 8, 2013
    Posts:
    663
    Ah. was trying to find stuff in docs.unity