Search Issue Tracker

Fixed in 5.2.0

Votes

25

Found in

4.6.0f3

Issue ID

652220

Regression

No

[UI] Image using materials with custom shaders does not render in the game view

UI

-

To reproduce this issue:

1. Open the attached project
2. Open 'test' scene
3. Notice in the scene view that there is an image in the scene
4. Observe game view
5. Image is not seen in the game view
6. Select image in the hierarchy ( Canvas -> Image)
7. Change Material to 'None'
8. Now image is rendered in the game view

It seems that using custom shaders do not work on UI Images. The same materials with custom shaders work fine in the game view when using sprites/other gameobjects.

Captured repro: http://screencast.com/t/ihqglIj9V

Comments (17)

  1. gneissler

    Mar 29, 2023 22:35

    set the canvas to screen space camera
    then add the cam you wanna use to canvas -> Renderer camera

  2. FunRobDev

    Apr 12, 2018 15:00

    Default UI Material.RenderQueue = 3000
    Your new Material.RenderQueue = ?
    Maybe that's the difference...

  3. Voxel-Busters

    Jul 23, 2016 06:37

    Try writing a Cg unlit shader instead of using surface shader as a workaround.
    Cheers,
    VB Team

  4. Voxel-Busters

    Jul 22, 2016 22:27

    This issue still exists in 5.3.3 :|

  5. mwk888

    Oct 02, 2015 19:34

    I tried TC's suggestions above but could not make a shader that rendered in a 5.1 Canvas set to Screen Space - Overlay. The closest I came was getting black (but at least it rendered!) when I had "LightMode" = "Always" set. Even when the shader was unlit and previewed correctly it would be black when drawn through the canvas.

    Fix: I built a shader starting from Unity's DefaultResources/Internal-GUITexture.shader source. This in the older vertex/frag style and it worked with Screen Space - Overlay

  6. Chiefmofo123

    Aug 20, 2015 18:01

    NVM, just saw the status fixed for 5.2. Sorry about that.

  7. Chiefmofo123

    Aug 20, 2015 17:40

    Just curious if this was still be worked on. I'm seeing the same issue as Radetic, where a custom shader works perfectly with a MeshRenderer or Sprite component, but not with an Image UI component.

  8. Tim-C

    Jul 13, 2015 13:52

    Hi,

    This issue is caused by something we did to not confuse users, but it looks like it causes more confusion.

    Let me explain:

    When you have a canvas set to screen space overlay it renders through a 'fast' path that has no lighting. If you have a material configured with only lighting passes we are skipping it for rendering. In this case the material has this property. What you can do to currently work around this is provide a material that has a 'no lighting' pathway (like the builtin unlit shaders) or turn the canvas into screen space camera and specify a render camera.

    What I have done now (for 5.2) is removed this 'check'. This means that if you have a shader that expects lighting it may render black, but it will render.

    -TC

  9. chasepettit

    Jul 06, 2015 22:31

    Not sure about the current status of this because I modified my approach to some things to get around this. If you're still having this issue, I'd suggest taking a look at the LightMode in your shader. I was able to resolve most of my issues by making sure I specified "LightMode"="Always". Obviously this isn't an option if you need lighting on your UI, but if that's not you situation, see if it works for you.

  10. Lermy KefSensei

    Jun 26, 2015 21:07

    I am having the same issue here!

    I am also having a different problem, and it consist in if you want to animate the properties of a material written in a custom shader you cannot animate them from the Image component!! Even when having the same public values that the Image component needs (_Color, _MainTex) and the image can be seen.

    This is happening because the material properties are not been exposed! I don get the reason for this, right now making a component proxy for Every image that needs an effect in my game :(

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.