Eyeon Talk:Script/Reference/Applications/Fuse/Classes/ScriptOperator/DoMultiProcess

From VFXPedia

Jump to: navigation, search

Checking the example, I'm pretty sure that

	local p = Pixel()
	for x=0,In.Width-1 do
		In:GetPixel(x,y, p)
		p.R = p.R * Gain
		p.G = p.G * Gain
		p.B = p.B * Gain
		Out:SetPixel(x,y, p)
	end

should be

	local p = Pixel()
	for x=0,img.Width-1 do
		img:GetPixel(x,y, p)
		p.R = p.R * gain
		p.G = p.G * gain
		p.B = p.B * gain
		out:SetPixel(x,y, p)
	end

--Chad

The call to DoMultiProcess sets up 'In' and 'Out' when it does '{ In = img, Out = out, Gain = gain }' --Stuart 02:06, 21 April 2010 (EDT)

Oh neat, missed that. That's what you get copying and pasting various examples together. --Chad 14:20, 21 April 2010 (EDT)



Are there any examples of what the threadinitfunc should be? All the examples I've found are nil. I'm currently trying to multithread some operations where the result from the thread/chunk is compared to the results of the previous threads. --Chad 10:07, 18 October 2010 (EDT)

The threadinitfunc happens once on each of the threads before they do any chunk processing. When processing a particular chunk, you can't use results from any previous chunk, because you don't know if any previous chunk has been completed. A thread could only know that results exist for any chunk it previously processed, but that could be any indeterminate previous chunks. If a thread is processing chunk 10, it can't know or assume that chunks 0..9 are complete as there could be 10 other threads still processing those chunks. --Stuart 20:33, 18 October 2010 (EDT)
Yeah, that's why I'm asking. :) If it's nil, you can't use the results from another chunk. So what would a threadinitfunc look like that actually did something? --Chad 10:09, 19 October 2010 (EDT)
If it's non-nil, you can't use the results from another chunk either. I believe it's a function that takes no arguments. Each thread will call it before it starts doing chunk processing (you could use it to, for example, pre-calculate something, that you then want to re-use over and over for each chunk). But, just like the chunk processing, there's no defined order in which each thread will end up calling the initfunc, and there's no guarantee that each thread will have called the initfunc before any of the other threads start doing chunk processing. --Stuart 18:48, 19 October 2010 (EDT)
I did a test and it seems like the threadinitfunc will only get called once, not once for each thread. Consider this code:
 function threadinit()
    print("threadinit")
 end
 function processingfunc(n)
    print(n)
 end
This will print "threadinit" once, followed by 0,1,2... --Tilt 03:27, 21 November 2010 (EST)