Using displacement maps?

I wonder if something like displacement maps is supported by jm3. I have read through and but only uv/bump mapping is described there.
I wonder if i just missed something.
And if not yet supported would it be hard to implement such a thing ? As far as i understand depending on the alpha value of a texture the drawn pixel is moved alon the normal of the current drawn surface. Just don’t know how lighting would play into it then.

…is this the same thing as bump mapping? The lighting material already supports two different kinds of bump mapping and can either pull depth as alpha from the normal map or you can have a separate bump texture.

Maybe i am doing something wrong then, but it does not look like the thing i was thinking about.
When using normal maps it looks like the surface is not flat, but whe viewing it from a flat angel you still see that it still is.

What i meant is something that i have seen in secondlife once, they took a cube and wrapped a texture arround it and produced a perfectly round apple with this, so essentialy it is still a cube, but with the texture the drawn pixels of the surface were displaced so that in 3D view it became a round apple.

Maybe i am doing something wrong tho… i have this as an example:
Texture and Normal map
Using Lighting.j3md i put the texture in DiffuseMap property and the normal map in the NormalMap property.
When looking at it in 3D view it looks like the wall has the pattern from the normal map, but it still is a flat surface and the pattern comes from different lighting on it.

There may be a boolean you have to turn on to have it use alpha as height. Normal maps and bump maps are not the same thing… so be sure you also have height in the alpha channel of your normal map if you want the parallax effect.

Or try some of the JME tests to see if it’s what you are thinking of.

@ryukajiya The TerrainGrid class generates the image via noise function, but in essence it is used like a displacement map. It probably wouldn’t be too difficult to translate that effort into:

A) Shader-based displacement – you could probably find a lot of useful bits in the GPUAnimationFactory shaders I posted here at some point. It has just about everything you could possibly need for different types of mesh displacement/normal calculations via shaders.

B) A utility class that loads the image and deforms a grid, etc and then resaves the j3o…

Anyways… here are some thoughts on displacement maps and how useful they are in real-time rendering:

  • Displacement via shader sucks without transform feedback. Your app knows nothing about the visual shape of the mesh when it is done. Kind hurts if your physics space needs to know.
  • Real-time displacement comes with overhead cost that you probably wouldn’t want if you can avoid it.
  • Uitility class that loads the image, applies the displacement and resaves the j3o would be ideal. imho.

Actually I’m pretty sure you mean tesselation?

Anyway while morphing a cube to a sphere is possible with it, its not the poper use. Usually it should onyl be used to add grafical detail, (while the base model is enough for physic/ray logic)… Only difference is that tesselation looks better in that case.

@Empire Phoenix Yes, the box to apple example was just to give an example of what i mean. I wanted to use it to give walls more detail, so essentialy it just stays a wall and physic space etc. doesn’t need to know about the different display.

@pspeed I think thats my problem, i don’t have alpha in that normal map. Just wonder how i can get it in. Used blender to bake normals and that was the result, will have to tinker with it some more. Also how does a bump map look, if it is a different kind ? Only ever saw those blue/violet normal map things.

@t0neg0d thanks, but what pspeed and ep sounds as if i only missed some part. But i will definitely take a look at that factory, sounds as if it could help me with another thing :wink:

A bump map is just a gray scale image of height. White is highest, black is lowest. You can do it as a separate image (which is the way I usually do it) or you can encode it into the alpha channel of your normal map.

<cite>@pspeed said:</cite> A bump map is just a gray scale image of height. White is highest, black is lowest. You can do it as a separate image (which is the way I usually do it) or you can encode it into the alpha channel of your normal map.

On which parameter do you put the grayscale image ? ParallaxMap ?
And where would be the zero displacement then ? At white, at black or right in the middle ?
Just trying to figure out how i can generate the needed textures then. Think the displacement bake option from blender would fit this, it worked good with the normal map baking so far.

Yes, “ParallaxMap”

White is the surface of the triangle. It cannot be otherwise since things cannot project out past that. It’s also just a visual trick so don’t expect perfection.

There is a way to switch to the other, slower parallax mapping but I don’t see the parameter in a quick scan of that link. You might have to look in the Lighting.j3md file directly.

Yes, i have read through that page, but it only gives the names of the parameters, not what they are used for :wink:

I found this parameter:
//Set to true to activate Steep Parallax mapping
Boolean SteepParallax
But it made the quad look very awkward when viewed from close up.

I know its just a visual trick, but better then a flat surface and it still keeps a kind of retro look i am aiming for (with the nice side effect that geometry stays very very simple because most is just quads with textures drawn on).

Thanks for the help. Have to play arround with what i can get from blender and how it looks in 3D scene and see what i can get. :wink: