@piinthesky darrrrrrrrrrrrrrn.
It works for the figure models but it doesn’t work for the others.
See attached project.
@piinthesky darrrrrrrrrrrrrrn.
It works for the figure models but it doesn’t work for the others.
See attached project.
@UberGoober, those models have multiple materials, so you have to loop over them all.
-- bloom effect2
viewer.mode=STANDARD
function setup()
bloomScale=5
tab={}
scene = craft.scene()
scene.sun.rotation=quat.eulerAngles(30,45,30)
v=scene.camera:add(OrbitViewer, vec3(0,0,0), 200, 0, 1000)
v.ry=180
cameraComponent = scene.camera:get(craft.camera)
cameraComponent.hdr = true
cameraComponent.colorTextureEnabled = true
bloom = craft.bloomEffect()
cameraComponent:addPostEffect(bloom)
bloom.threshold = 2
bloom.intensity = 0.65
bloom.softThreshold = 0.2
bloom.iterations = 8
models = {asset.builtin.Blocky_Characters.Robot, asset.builtin.Blocky_Characters.WomanAlternative, asset.builtin.Watercraft.watercraftPack_005_obj, asset.builtin.CastleKit.siegeBallista_obj, asset.builtin.Watercraft.watercraftPack_007_obj,asset.builtin.SpaceKit.spaceCraft3_obj}
for i=1,6 do
local ground = scene:entity()
-- ground.model= craft.model(models[math.random(#models)])
ground.model= craft.model(models[i])
x=math.random(-50,50)
y=math.random(-50,50)
z=math.random(-50,50)
ground.position = vec3(x,y,z)
table.insert(tab,{gr=ground,x=x,y=y,z=z,r=0,a=false})
end
parameter.integer("pos",1,#tab,position)
parameter.integer("Rotate",-180,180,0,rotate)
parameter.boolean("int",false,intensity)
end
function update(dt)
scene:update(dt)
end
function rotate()
tab[pos].r=Rotate
end
function draw()
update(DeltaTime)
tab[pos].gr.eulerAngles = vec3(0,tab[pos].r, 0)
scene:draw()
end
function position()
Rotate=tab[pos].r
int=tab[pos].a
end
function intensity()
thisModel=tab[pos].gr
nMat=thisModel.model.submeshCount
-- print(nMat)
for i=0,nMat-1 do
thisMat=thisModel.model:getMaterial(i)
-- print(thisMat.diffuse)
if int then
thisMat.diffuse=thisMat.diffuse*bloomScale
else
thisMat.diffuse=thisMat.diffuse/bloomScale
end
end
tab[pos].a=int
end
@piinthesky I made a zip of your project, and gave it a nice icon, in case anyone wants to get it that way.
Personally I like having icons, because otherwise I quickly end up with tons of little green squares that I can’t remember the purpose of.
I also fixed the bug where the first entity had their skin made darker, which required abstracting your process into a stand-alone function, which was good to do anyway because it makes it easier to use for anyone who wants to cut and paste it.
I also gave some of the variables verbose names, partly to help other coders grasp the code quicker, partly because that’s just me.
[edit: project wasn’t working, but should work now]