Impossinle to set PerRendererData for custom UI shaders?

Edit: Damn, title typo…

Hey guys. So I am creating a sheen effect to my UI buttons.

The buttons have a graphical component (UI.Image). I add my component to this gameobject (UISheen).

My component implements IMaterialModifier. This lets me create a new material that uses my Sheen shader. The CanvasRenderer grabs my material and uses that material to render the UI.Image component.

So far so good. My Sheen shader is a copy of the default UI shader, except it applies a white sheen effect that pans across the screen, tinting a portion of the image white as it washes over it. (Giving it a “sheen”). See example image bellow:

Now the problem. My Sheen shader has various parameters to control the sheen effect. For example - Sheen Speed, Sheen Width.

There is no way to set these parameters as PerRendererData, as we have no way of setting PerRendererData. The CanvasRenderer does not have any methods to set the data, like other renderers (SpriteRenderer, MeshRenderer).

Because of this, any element using my Sheen effect has to be its own draw call. This causes a large increase in drawcalls, as the Canvas can no longer batch elements together efficiently. The batching is broken every time it hits a image that uses my Sheen effect. With PerRendererData, I could atleast batch all the sheen elements together. But instead they are one draw all each.

Am i missing Something? Is there some hidden way to set PerRendererData for CanvasRenderer?

Bump

I’m sitting here trying to pack float values into UV1 x and y. Please help me UI Gods :frowning: @Tim-C there appears to be no way to set per renderer data - is this true?

This is too vague of a topic - can’t find any information regarding this issue!

Hi
Same problem here. Have you found a solution or a workaround ?

No, never got a reply.

I was eventually able to pack the data I needed into UV0 and UV1 instead of passing per renderer data.

1 Like