Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Height BumpMap? #63

Open
ramsestom opened this issue Oct 6, 2015 · 1 comment
Open

Height BumpMap? #63

ramsestom opened this issue Oct 6, 2015 · 1 comment

Comments

@ramsestom
Copy link

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)

@Greg209
Copy link
Member

Greg209 commented Oct 8, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants