Author Topic: Custom shader parameters reset every frame  (Read 3080 times)

peaj

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Custom shader parameters reset every frame
« on: August 26, 2014, 03:48:24 AM »
Hi,

I try to set 2 colors in my custom shader on a UITexture via script. The shader is nearly identical to the "Unlit - Transparent Color" shader except there are 2 additional
color properties and small changes in the fragment shader to make use of those.
In another thread I read it is recommended to change custom shader parameters via "widget.drawCall.dynamicMaterial".
I tried this but now I got the problem that the set parameters are reset every frame.
Even if I set the colors in Update it seems like every second frame is rendered without colors set.
So how can I persistently set custom shader parameters via script?

Best regards,
Pascal

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile

peaj

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: Custom shader parameters reset every frame
« Reply #2 on: August 26, 2014, 04:13:00 AM »
Thx for your fast reply, but I could not find onRender anywhere.
Autocomplete does not show it and even in the documentation of UIWidget
I could not find it. Neither in UIWidget nor in UITexture.
Maybe sth. changed?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Custom shader parameters reset every frame
« Reply #3 on: August 27, 2014, 03:45:38 AM »
Sounds like your version of NGUI is not up to date.

peaj

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: Custom shader parameters reset every frame
« Reply #4 on: August 27, 2014, 06:38:25 AM »
Yeah thx I just read it in the other thread, too.
I was a little bit confused because the NGUI documentation wasnt up to date either.
I'll try it out as soon as we are able to update NGUI.