jme engine features claims that it can use “Parallax Map”, i didnt see any code / example. How to do that ?
Is there a way to increase the strength/Height of Normal Maps ? My normal maps seem kinda flat, e.g when i apply them to a model it will seem like an additional texture being applied on top of existing texture, no extra height (maybe 0.1 extra height if you look from far away and with a lot of imagination). I tried it increase the image height with extrernal program but i didnt see any improvement.
I dont know if lights is the problem, I have 2 lights (so that everything is more visible).
Just like you set the normal map with NormalMap you can set the parallax map with ParallaxMap. Though I only found out much much later that you can apparently use the alpha channel of the normal map for depth.
And just to make sure there is no confusion, you know that normal maps and parallax maps are only simulating bumps, right. The geometry is still flat. A normal map allows for dynamic shadows on the texture and a bump map displaces the texture coordinates to make things look bumpy as you move around. You probably know all that but we’d go around and around if you didn’t so I like to be sure.
The JME test data includes some textures that have related normal and bump maps. They definitely work and are definitely dramatic if everything is setup right. Testing your code with them may rule out some number of issues.
See the diffrence? mine is completely flat, forget that i said with imagination it has some height, it doesnt have no matter what. Its like i opened photoshop and appended the normal map to the diffusion map.
tralala said:
If i only used 1 light everything would be black (no colors) and only some positions would be really dark with colors.
That's a problem. Perhaps the light is pointing in the wrong direction? I seem to remember something about it working backwards or so.
It's ok to have an ambient light but setting it so high makes the normal map useless, I think. What happens when you set ambient to white * 0.2 or so?
The normal map will _only_ affect the lighting. A normal pointing towards the light will be brighter, pointing away will be darker... and a high ambient will wash it all out by maximize the light.
For bumps that look 3D as you move around you have to use the parallax map.
Your sunlight has no y component and your quad seems to be laying flat in the x,z. If that's true then the sun will provide almost no light at all.
Also, ambient light is applied during the first real light pass... if you only have ambient then I'm surprised it rendered anything at all since Lighting.j3md will require at least one real non-ambient light.
Pretty sure that Quads can have normal maps. DirectionalLights can definitely light things up… the key is that the light must point to the quad and I’m not sure that yours was… but since I haven’t seen the quad setup I don’t know.
Can you upload your texture, normal map, and parallax map to something like imgur.com and link them here?
Also, can we see more of your code to help diagnose what’s wrong? For example, are you using a JME quad or your own mesh? Is it setup right, tangents generated, etc…
You know, trying a box couldn’t hurt… maybe the quad has no normals. At the very least, you’d be able to see which side your light was pointing. So try a Box and a DirectionalLight again.
I just double-checked the source… Quads definitely have normals. But trying a Box will help debug your lighting problems since then you can see which side is lit and adjust accordingly.
In neotexture if i set the parallax map to nothing the lava material will become completely flat like it happens in jme. So that means that either jme has a bug in reading parallex maps or it requires a special flag to activate it.
Here is my complete code :
[java]import com.jme3.app.SimpleApplication;
import com.jme3.light.PointLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.FastMath;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Box;
import com.jme3.scene.shape.Sphere;
import com.jme3.util.TangentBinormalGenerator;
public class TestNormalMapping extends SimpleApplication
{
float angle = FastMath.HALF_PI;
PointLight pl;
Spatial lightMdl;
public static void main(String[] args)
{
TestNormalMapping app = new TestNormalMapping();
app.start();
}
@Override
public void simpleInitApp()
{
flyCam.setMoveSpeed(20);
Box box = new Box(Vector3f.ZERO,2, 2, 2);
TangentBinormalGenerator.generate(box);
Geometry boxGeom = new Geometry(“Lava”, box);
Material mat = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);
Parallax is “working” but it’s backwards in one or more directions. Even the JME test apps exhibit this behavior and it makes the parallax look really odd if you are even able to notice it at all. You can see it distort and stretch the pixels at the edge of the faces… but there are also cases where I see it stretch the wrong lava flow.
I have my own copy of Lighting.j3md that I use and I ended up flipping the sign of some things to make it work right.
If you get adventurous, there is a section in JME’s Lighting.frag that looks like this:
If you make your own lighting material by copying… then you can also mess with the scale if the effect isn’t dramatic enough. Though it’s already dramatic enough to cause really strange distortions for big height changes (when it’s working in the right direction).
Your normal map does not have large details, which is why you aren’t seeing them. Only the variation between the minuscule bumps on the rocks are in the map; I’m not seeing variation in the color between the lava and rocks. A normal map with significant height variation would look like this:
The problem in inverting the y component of the normal map, is as likely to work on any normal map as not inverting it.
There are many softwares that generate normal maps out there and all of them have different convention, 3ds max generate normal maps with inverted red channel compared to blender for example.
We could add some uniforms to toggle invert red, green, blue channels to fit any possible need but that’s 3 more uniform in an already quite bloated shader.
Making your own lighting shader is a fine solution for warriors like Paul, that can merge change with the trunk version, but i wouldn’t recommend it if you are not experienced with glsl.
Another easy solution is to open the normal map in photoshop/Gimp and invert the green channel (in your particular case).
I have no problem converting my normal map with photoshop to match jme format. The problem is that jme has float heightScale = 0.05; and doesnt allow users to set their own height. To fix this i have to create my “own” lighting shader.However making my own lighting shader isnt a solution because:
everytime i update jme, the code will break and i will have to rewrite it.
the solution in this thread no longer works for the current lighting.frag that has spotlights as it looks “flat” even if you change heightScale.
i can use the old lighting.frag that has the heightScale however lights dont work correctly.