away3d / away3d-core-openfl

Away3D engine for OpenFL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Height BumpMap?

ramsestom opened this issue · comments

I need to perform some bump mapping on a plane using a greyscale map that encode the simulated height of each point/pixel of this plane. I don't know if there is some solution out of the box I could use. In older away3D versions, I see there was a NormalBumpMaker class with a convertToNormalMap() function that allowed to convert these greyscale regular bumpmaps into normal maps (that then could be applied to any material). However, this class do no seems to exist anymore on fp11 and openfl versions. So is there a function that could allow me to apply these height bumpmaps to a material directly (without mesh displacment, just a regular bump mapping that affect the surface normals but do not alter the shape of the object like I could do with extrusion.Elevation...) or is there a built in function that would allow to convert these maps into normal maps?
Thanks

EDIT: I tried
material.normalMethod = new HeightMapNormalMethod(new BitmapTexture(heightmap),width,height,depth);

where heightmap is a bitmapData of my greyscale height bumpmap but it failed with error:

Invalid Cast Called from openfl._legacy.display.Stage.__pollTimers (openfl/_legacy/display/Stage.hx line 1084) Called from openfl._legacy.display.Stage.__checkRender (openfl/_legacy/display/Stage.hx line 351) Called from openfl._legacy.display.Stage.__render (openfl/_legacy/display/Stage.hx line 1103) Called from openfl._legacy.display.DisplayObjectContainer.__broadcast (openfl/_legacy/display/DisplayObjectContainer.hx line 286) Called from openfl._legacy.display.DisplayObject.__broadcast (openfl/_legacy/display/DisplayObject.hx line 161) Called from openfl._legacy.display.DisplayObject.__dispatchEvent (openfl/_legacy/display/DisplayObject.hx line 182) Called from openfl._legacy.events.EventDispatcher.dispatchEvent (openfl/_legacy/events/EventDispatcher.hx line 98) Called from flixel.FlxGame.onEnterFrame (flixel/FlxGame.hx line 523) Called from flixel.FlxGame.step (flixel/FlxGame.hx line 681) Called from flixel.FlxGame.update (flixel/FlxGame.hx line 701) Called from flixel.FlxGame.switchState (flixel/FlxGame.hx line 616) Called from gui.states.PlayState3D.create (gui/states/PlayState3D.hx line 193) Called from gui.states.PlayState3D.createCube3DView (gui/states/PlayState3D.hx line 284) Called from gui.utils.Cube3D.createCube3D (gui/utils/Cube3D.hx line 76) Called from away3d.materials.SinglePassMaterialBase.set_normalMethod (away3d/materials/SinglePassMaterialBase.hx line 205) Called from away3d.materials.passes.CompiledPass.set_normalMethod (away3d/materials/passes/CompiledPass.hx line 336) Called from away3d.materials.methods.ShaderMethodSetup.set_normalMethod (away3d/materials/methods/ShaderMethodSetup.hx line 79) Called from away3d.materials.methods.HeightMapNormalMethod.copyFrom (away3d/materials/methods/HeightMapNormalMethod.hx line 57)

There is no NormalMapGenerator class in Away3D 4.x which is what the OpenFL version is ported from.

I've managed to re-create your error with the HeightMapNormalMethod and I'm looking into a fix for it.

Thanks for reporting.