mirror of https://github.com/axmolengine/axmol.git
[lua tests] MaterialSystemTest update u_Time uniform (#20083)
This commit is contained in:
parent
dcf7baf8c0
commit
eed319938d
|
@ -3348,7 +3348,7 @@ bool luaval_to_uniformLocation(lua_State* L, int pos, cocos2d::backend::UniformL
|
|||
return false;
|
||||
|
||||
lua_pushstring(L, "location");
|
||||
lua_gettable(L, pos);
|
||||
lua_gettable(L, pos - 1);
|
||||
if (lua_isnil(L, -1)) {
|
||||
CCASSERT(false, "invalidate UniformLocation value");
|
||||
}
|
||||
|
@ -3362,7 +3362,7 @@ bool luaval_to_uniformLocation(lua_State* L, int pos, cocos2d::backend::UniformL
|
|||
lua_pop(L, 1);
|
||||
|
||||
lua_pushstring(L, "shaderStage");
|
||||
lua_gettable(L, pos);
|
||||
lua_gettable(L, pos -1);
|
||||
if (lua_isnil(L, -1)) {
|
||||
CCASSERT(false, "invalidate UniformLocation value");
|
||||
}
|
||||
|
|
|
@ -133,6 +133,7 @@ function Material_2DEffects:subtitle()
|
|||
return "Testing effects on Sprite"
|
||||
end
|
||||
|
||||
|
||||
function Material_2DEffects:onEnter()
|
||||
local properties = cc.Properties:createNonRefCounted("Materials/2d_effects.material#sample")
|
||||
|
||||
|
@ -161,6 +162,19 @@ function Material_2DEffects:onEnter()
|
|||
spriteEdgeDetect:setNormalizedPosition(cc.p(0.8, 0.5))
|
||||
self:addChild(spriteEdgeDetect)
|
||||
spriteEdgeDetect:setProgramState(mat1:getTechniqueByName("edge_detect"):getPassByIndex(0):getProgramState())
|
||||
|
||||
local scheduler = cc.Director:getInstance():getScheduler()
|
||||
local uTimeLoc = spriteNoise:getProgramState():getUniformLocation("u_Time")
|
||||
self._schedulerEntry = scheduler:scheduleScriptFunc(function(dt)
|
||||
local time = cc.Director:getInstance():getTotalFrames() * cc.Director:getInstance():getAnimationInterval()
|
||||
local random = cc.vec4(time / 10., time, time * 2, time * 4)
|
||||
spriteNoise:getProgramState():setUniform(uTimeLoc, cc.bytearray.from_vec4(random));
|
||||
end, 0, false)
|
||||
end
|
||||
|
||||
function Material_2DEffects:onExit()
|
||||
local scheduler = cc.Director:getInstance():getScheduler()
|
||||
scheduler:unscheduleScriptEntry(self._schedulerEntry)
|
||||
end
|
||||
|
||||
----------------------------------------
|
||||
|
|
Loading…
Reference in New Issue