snapshot of the result of normalMapWith1PointLight question

(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]

In the newer daily builds, shader effects that take in two textures are defined in the format of “composite.”

I believe the following update will fix the issue you’re seeing.

object.fill.effect = “composite.normalMapWith1PointLight”

Tried this with build 20 and composite instead of filter. Still same result. (Normal map filter works fine, but compositing another image or snapshot over it doesn’t).

Maybe a quick video will help explain what I’m seeing.

In the first part, it’s just the composite/normal multitexture with a light moving around over it, and a second image put on top (no effect, no alpha).

The second part shows the image on top using a composite mode (secondObject.fill.effect = “composite.overlay”). It seems to be compositing over the normal map itself (the rgb normal map image), not the composite result of the composite.normalMapWith1PointLight. It’s also not updating- or at least the light effect isn’t showing.

The third part is the composited image with no filter, but alpha set to .5 (we can see the normal map properly through it).

http://www.screencast.com/t/02FmZQuJF

Are you seeing the same issue with using “composite.” in the newer build?

Sorry Bryan, I mistyped in the last post.  

Tried this in build 2013.120. This is how I set up the color/normal:

[lua]

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 = “composite.normalMapWith1PointLight”

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 }

[/lua]

I also tried inserting ‘object’ into a snapshot, and compositing the second image over that (thinking the snapshot would in effect flatten what the multi texture/composite is doing), but get the same effect: composite (overlay, screen, whatever) appearing to happen over gravel_01_norm.jpg, not the multitexture-composite itself. 

In the newer daily builds, shader effects that take in two textures are defined in the format of “composite.”

I believe the following update will fix the issue you’re seeing.

object.fill.effect = “composite.normalMapWith1PointLight”

Tried this with build 20 and composite instead of filter. Still same result. (Normal map filter works fine, but compositing another image or snapshot over it doesn’t).

Maybe a quick video will help explain what I’m seeing.

In the first part, it’s just the composite/normal multitexture with a light moving around over it, and a second image put on top (no effect, no alpha).

The second part shows the image on top using a composite mode (secondObject.fill.effect = “composite.overlay”). It seems to be compositing over the normal map itself (the rgb normal map image), not the composite result of the composite.normalMapWith1PointLight. It’s also not updating- or at least the light effect isn’t showing.

The third part is the composited image with no filter, but alpha set to .5 (we can see the normal map properly through it).

http://www.screencast.com/t/02FmZQuJF

Are you seeing the same issue with using “composite.” in the newer build?

Sorry Bryan, I mistyped in the last post.  

Tried this in build 2013.120. This is how I set up the color/normal:

[lua]

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 = “composite.normalMapWith1PointLight”

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 }

[/lua]

I also tried inserting ‘object’ into a snapshot, and compositing the second image over that (thinking the snapshot would in effect flatten what the multi texture/composite is doing), but get the same effect: composite (overlay, screen, whatever) appearing to happen over gravel_01_norm.jpg, not the multitexture-composite itself.