Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Resolved Same Shader, Same Input, Diffrent Output

Discussion in 'Shader Graph' started by beneQ_04, Aug 16, 2023.

  1. beneQ_04

    beneQ_04

    Joined:
    Mar 1, 2020
    Posts:
    21
    So I made a simple sprite lit snow shader for my 2d Pixel Art game.

    The problem is I made it in my test project.
    When I moved it over to my main project it gave me a diffrent output that in my test project.
    The shader got the exact same input all the values and textures yet it somehow produced a diffrent output.

    I took a closer look at it and even some simple operations like inverting colors give diffrent outputs between projects which shouldnt be the case.

    Test Project
    upload_2023-8-16_17-48-56.png

    Main Project
    upload_2023-8-16_17-49-44.png

    Could any body please tell me what is going on here???

    I should add that both projects are made on the same version of unity
     
  2. BenCloward

    BenCloward

    Unity Technologies

    Joined:
    Jul 15, 2021
    Posts:
    145
    My first suspicion is that maybe the settings on the texture are different between the two projects. Could you check to see if the texture in your first project matches the one in your second project? Specifically, if the first one has an alpha channel, does the other one also have it? And then check the settings in Unity for the texture between the two projects in the Inspector:

    upload_2023-8-16_12-1-38.png

    Not saying that yours have to match mine, but compare them between the two projects and make sure they're the same.
     
  3. beneQ_04

    beneQ_04

    Joined:
    Mar 1, 2020
    Posts:
    21
    Nope they are the same

    Main Project:
    upload_2023-8-17_22-47-4.png

    Test Project:
    upload_2023-8-17_22-48-22.png

    Only diffrence I can find between the projects is that in my main project I have a texture asset importer preset but it's only made to import my textures with the correct PPU and filter mode where as I set those by hand in the test project.
    So I don't think that is the issue, unless unity does something here tham I'm not aware of.

    (Edit)
    Well just checked and it's not the importers fault.
     
    Last edited: Aug 17, 2023
  4. BenCloward

    BenCloward

    Unity Technologies

    Joined:
    Jul 15, 2021
    Posts:
    145
    Do the actual image files have the same number of channels? Is one of them missing an alpha channel or have one where it shouldn't?
     
  5. beneQ_04

    beneQ_04

    Joined:
    Mar 1, 2020
    Posts:
    21
    I am not excatly sure what you mean by that and how to check that.

    I think this is what you mean upload_2023-8-17_23-53-5.png
    and if I'm right about that than yes they are the same in both projects and they are both correct
     
  6. BenCloward

    BenCloward

    Unity Technologies

    Joined:
    Jul 15, 2021
    Posts:
    145
    Like if you were to open the texture file in Photoshop (or other image editing software) and look at the channels, does one of them have an alpha channel and the other not have it?

    Another thing you could do is, in your graph, insert a swizzle node in between the RGBA output of the Sample Texture 2D node and the Invert Colors node, and set the Swizzle node's mask to XYZ - so it's just giving you 3 channels instead of four. After doing that, does the Invert Colors node output match, or is it still different?
     
  7. beneQ_04

    beneQ_04

    Joined:
    Mar 1, 2020
    Posts:
    21
    So I tried the second method and the output of the invert colors node is still diffrent

    Also I don't really think that the textures are the problem here as I made sure they are the same texture by copying the file over from on project to another.
     
  8. beneQ_04

    beneQ_04

    Joined:
    Mar 1, 2020
    Posts:
    21
    Is there any other reason this might be happening?
     
  9. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,340
    Do you have the same color space linear/gamma in both projects?
     
    Last edited: Aug 20, 2023
    halley likes this.
  10. beneQ_04

    beneQ_04

    Joined:
    Mar 1, 2020
    Posts:
    21
    Yes! that's it thank you.

    But I did not change the color space in any of my projects so why in one gamma was set by default and linear in the other?

    Also what is the diffrence between them?
     
  11. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,500
    In a nutshell, both Linear and Gamma-Corrected modes assume that 0 is black/empty and 1 is white/full, but they change the emphasis along the way for values in between. This is supposed to be useful for having a good tonal balance on varying hardware, and for how light falloff behaves, but in my experience it just makes for constant surprises like this when different assets or projects have a mismatch.

    https://docs.unity3d.com/Manual/LinearRendering-LinearOrGammaWorkflow.html
     
  12. beneQ_04

    beneQ_04

    Joined:
    Mar 1, 2020
    Posts:
    21
    Alright, Thank you!