当前位置 : 主页 > 手机开发 > 其它 >

cocos中lua使用shader实例

来源:互联网 收集:自由互联 发布时间:2021-06-13
local prog = cc.GLProgram:create( " res/shader/light2d.vsh " , " res/shader/light2d.fsh " )prog:link()prog:updateUniforms()local progStat = cc.GLProgramState:create(prog)progStat:setUniformVec2( " u_lightPosition " ,cc.p(GVar.halfWinW,GVar.
local prog = cc.GLProgram:create("res/shader/light2d.vsh","res/shader/light2d.fsh")
prog:link()
prog:updateUniforms()
local progStat= cc.GLProgramState:create(prog)

progStat:setUniformVec2("u_lightPosition",cc.p(GVar.halfWinW,GVar.halfWinH))
progStat:setUniformVec4("u_lightColor",cc.vec4(1,1,1,1))
progStat:setUniformFloat("u_lightRange",100)


playerImg:setGLProgram(prog)
playerImg:setGLProgramState(progStat)
网友评论