(alpha 2013.103)
Using multitexture and normalMapWith1PointLight:
Simply creating the multitexture with a map and normal map, adding the normalMapWith1PointLight filter, and moving the pointLightPos, I get what we expect.
If I snapshot the result, then try to composite that snapshot- it seems only the normal map itself is being composited- not the result.
Also, if I try to composite something else on top of the normalmap filter result (composite.add, mult, etc.), it again seems to be only working with the normal map itself (from slot 2 of the multi texture), not the result of the filter.normalMapwith1PointLight.
Is this expected behavior?
On reason to do this operation might be to generate cast shadows/lights, then composite a snapshot of that over a normal mapped base.
Below is a simple test with a color/normal setup, and a simple image composited over it. (I’ll try to get the images used uploaded, but any normal/color maps should do )
[lua]
----NORMAL MAP COMPOSITE TEST
_w = display.contentWidth
_h = display.contentHeight
–********set up normal map multitexture*******
local multitexture =
{
type=“composite”,
paint1={ type=“image”, filename=“gravel_01_col.jpg” },
paint2={ type=“image”, filename=“gravel_01_norm.jpg” }
}
local object = display.newRect( 0, 0, _w , _h )
object.fill = multitexture
object.fill.effect = “filter.normalMapWith1PointLight”
object.x = _w * .5
object.y = _h * .5
local effect = object.fill.effect
effect.pointLightColor = { .2, .2, .2, 20 }
effect.pointLightPos = { 0, 0, 20}
effect.ambientLightIntensity = 0 – value from 0 to 1
effect.attenuationFactors = { 5, 5, 10 }
–Put an image rect on screen, which we’ll attempt to composite over the results
–of the normal map above. Only covering part of the screen here.
test = display.newImageRect(“wall_01.png”, _w , _h * .5)
test.x = _w * .5
test.y = _w * .5
test.fill.effect = “composite.overlay”
–A Rect which can controll the location of the pointLightPos
local lightObject = display.newRect (_w * .5,_h * .5,50,50)
Runtime:addEventListener( “enterFrame”, function( event )
--map screen space onto object space
lightLocX = lightObject.x / (object.width )
lightLocY = lightObject.y / (object.height )
effect.pointLightPos = { lightLocX, lightLocY , .1 }
end )
local function drag (event)
local t = event.target --event.target
local phase = event.phase
if “began” == phase then
display.getCurrentStage():setFocus( t, event.id )
t.isFocus = true
t.x0 = event.x - t.x --store innitial positions
t.y0 = event.y - t.y
elseif t.isFocus then
if “moved” == phase then
t.x = event.x - t.x0
t.y = event.y - t.y0
elseif “ended” == phase or “cancelled” == phase then
display.getCurrentStage():setFocus( nil )
t.isFocus = false
end
end
return true
end
lightObject:addEventListener( “touch”, drag )
[/lua]