[LayaAir 1.0]自定义渲染后,customRender里设置uniform值在ui节点下不生效

1.自定义一个精灵类,里面重写了渲染方法
        // 重写渲染函数
        public customRender(context:Laya.RenderContext,x:number,y:number):void{
            if(this.shader._program)
            {
                let u_lightTime = gl.getUniformLocation(this.shader._program, "u_lightTime")
                gl.uniform1f(u_lightTime, this.timerCount)
                this.timerCount += Laya.timer.delta/1000
            }
            context.ctx.setIBVB(x, y,this.iBuffer, this.vBuffer,this.iNum,null,this.shader,this.shaderValue, 0, 0);
        }
 
2.我将自定义的精灵类添加到ui根节点下,能达到我想要的效果gl.uniform1f(u_lightTime, this.timerCount)生效
3.我将自定义的精灵类添加到imgBg节点下,gl.uniform1f(u_lightTime, this.timerCount)不生效
 
1.添加到imgBg节点下gl.uniform1f(u_lightTime, this.timerCount)感觉没有生效, 图1的发光线没有呼吸效果
2.添加到ui根节点下,图2是我想要的效果
 
QQ截图20181121120740.png QQ截图20181121120154.png QQ截图20181121120031.png
已邀请:

chasel

赞同来自:

发现如果添加到UI节点内的一个image类型节点下,当前使用的并不是 this.shader._program ,而是其他的。
 
有解决方法吗?

chasel

赞同来自:

有没有接口是:获取旧的shader program, 设置新的program,   更新uniform值后,  再设置成旧的shader program??

Aar0n

赞同来自:

感谢对laya的支持与信任,您的问题属于底层了,我们引擎开放了自定义接口,但是写自定义shader的开发者很少,所以官方不提供底层问题服务的。 很抱歉,这个问题超出服务范围,希望您别太失望,或者选择一些折中的办法,或者继续深入钻研。

要回复问题请先

商务合作
商务合作