synthsin75 wrote:For using layerscripts in ASP7, which introduced the multi-core render bug that wasn't fixed in the version it was introduced in, and to utilize layerscripts with multi-thread rendering in 8, could you explain what needs to be done to make layerscripts work with that bug?
Sorry, I don't believe I can in a generalized, concise way. Maybe there should be some discussion in the scripting forum.
It really depends on the script in question. Here's one simple example (in pseudo-code). Suppose you have a script that moves a layer upwards by a small amount every frame, and it uses a global variable:
Code: Select all
layerHeight = 0
function RunScript()
if (currentFrame == 0) then
layerHeight = 0
else
layerHeight = layerHeight + 4
end
layer:SetHeight(layerHeight)
end
In a single-threaded environment, it's very simple: the layer will be 4 units higher every frame. However, in a multithreaded environment where the frames may be rendered in any order it gets tricky. Suppose the left column below is the current frame being rendered, the middle column is the expected height and the right column is the actual layer height:
Code: Select all
frame expected height actual height
-----------------
0 0 0
1 4 4
3 12 8
2 8 12
This is a very simple example, but here's the right way to code it for multithreaded rendering (ideally, you would get rid of the global variable altogether, but here's a simple example):
Code: Select all
layerHeight = 0
function RunScript()
layerHeight = currentFrame * 4
layer:SetHeight(layerHeight)
end
This may be getting a little technical for this thread. I suspect most Anime users aren't into scripting, so I'd like to not get too deep into that topic right here.