AviUtlの乱数について
C言語のrand()がダメなのは理解した
LuaJITのmath.randはではダメ?
Tausworthe(トーズワース)法というものに置き換えられているはず
と考えたため、追加で確認してみる
ソースコード (スクリプト制御)
code:math.rand.lua
local ffi=require"ffi"
pcall(ffi.cdef,[[
typedef struct Pixel_ {
uint8_t b,g,r,a;
} Pixel;
]])
local data,w,h=obj.getpixeldata()
local cdata=ffi.cast("Pixel*",data)
math.randomseed(obj.frame)
for y=0,h-1 do
for x=0,math.floor(w/2) do
local a=math.floor(math.random(0, 256))
local p=cdata+y*w+x
p.b=a
p.g=a
p.r=a
end
end
for y=0,h-1 do
for x=math.floor(w/2),w-1 do
local ix=y*w+x
local p=cdata+ix
local s=rand(0,255,ix)
p.b,p.g,p.r=s,s,s
end
end
obj.putpixeldata(data)
結果
https://scrapbox.io/files/6657f89ded06a5001d0d23e4.png
別によさそう
余談