i now have my pretty earth (from space) with its map and fixed pipe bump mapping (my avatar). now, as it should be, the “night” side of the earth is black, but i want it to show the following texture:
that means that diffuse und bump map texture have to be invisible in shadow and the lightsMap has to be invisible in light …
hope you know what i mean.
thats how its done until now:
// get the heightmap that is used for bumpmapping
Texture tex =
TextureCache.getInstance().getTexture(
getClass().getClassLoader().getResource("themes/startheme/earthBump4096.dds"), game, true).getTexture();
Hi, you need to interpolate the night texture to the day texture using the result from the DOT3 (lighting) operation in the previous unit. Use the INTERPOLATE Combine function.
hey, thank you so far, but i dont seem to get it right …
thats the relevant code for the creation of the earth:
// create a FloatBuffer and set it up
FloatBuffer tBuf = earth.getTextureBuffer(0, 0);
tBuf.clear();
tBuf.put(0).put(5);
tBuf.put(0).put(0);
tBuf.put(5).put(0);
tBuf.put(5).put(5);
// create a Material State and set the color
MaterialState ms = TaskQueueUtil.getMaterialState(game);
ms.setAmbient(ColorRGBA.white);
ms.setDiffuse(ColorRGBA.white);
// create the BumpMapController that manages the bumpmapping effect
c = new BumpMapColorController(earth);
earth.addController(c);
earth.setRenderState(ms);
// create the TextureState for the texture we use for the earths landmasses
TextureState ts = TaskQueueUtil.getTextureState(game);
// get the heightmap that is used for bumpmapping
Texture tex =
TextureCache.getInstance().getTexture(
getClass().getClassLoader().getResource("themes/startheme/earthBump4096.dds"), game, true, true).getTexture();
// get the texture that shows the surface
Texture tex2 =
TextureCache.getInstance().getTexture(
getClass().getClassLoader().getResource("themes/startheme/earthMap4096.dds"), game, true, true).getTexture();
tex2.setApply(Texture.AM_COMBINE);
tex2.setWrap(Texture.WM_WRAP_S_WRAP_T);
tex2.setCombineFuncRGB(Texture.ACF_MODULATE);
tex2.setCombineSrc0RGB(Texture.ACS_PREVIOUS);
tex2.setCombineSrc1RGB(Texture.ACS_TEXTURE);
ts.setTexture(tex2, 1);
// get the texture that shows city lights
Texture tex3 =
TextureCache.getInstance().getTexture(getClass().getClassLoader().getResource("themes/startheme/lightsMap2048.dds"),
game, true, true).getTexture();
tex3.setApply(Texture.AM_COMBINE);
tex3.setWrap(Texture.WM_WRAP_S_WRAP_T);
tex3.setCombineFuncRGB(Texture.ACF_INTERPOLATE);
tex2.setCombineSrc0RGB(Texture.ACS_PREVIOUS);
tex2.setCombineSrc1RGB(Texture.ACS_TEXTURE);
ts.setTexture(tex3, 2);
// edit the texturecoordinates accordingly
earth.copyTextureCoords(0, 0, 1);
// set up the renderstate
earth.setRenderState(ts);
// create the ZBufferState
ZBufferState buf = TaskQueueUtil.getZBufferState(game);
buf.setEnabled(true);
buf.setFunction(ZBufferState.CF_LEQUAL);
// set render state
earth.setRenderState(buf);
and the light:
// detach everything from the lightState
lightState.detachAll();
lightState.setSeparateSpecular(true);
// create and set up a DirectionalLight
DirectionalLight dl = new DirectionalLight();
dl.setEnabled(true);
dl.setDiffuse(ColorRGBA.white);
dl.setAmbient(ColorRGBA.black);
dl.setDirection(new Vector3f(0, 0, 1));
// create a new LightNode ...
lightNode = new LightNode("light", lightState);
lightNode.setCullMode(SceneElement.CULL_NEVER);
lightNode.setLight(dl);
// ... and set the rootNode as target, so everything is influenced by the light
lightNode.setTarget(rootNode);
lightNode.setLocalTranslation(new Vector3f(-180f, 60f, -50f));
now that the ambient light is black, i cant see anything on the dark side of the earth, if i make it another color, the normal surface texture appears in some form, but not the city lights. how would i have to set the material colors and light colors? do i apply the city lights texture correctly?
You interpolate the nightmap toward the lit colormap using the colormap's intensity (which is premultiplied with the lighting)
Ideally you would want to interpolate using the unmodified lighting but this might be difficult (or even impossible) to do in fixed-function multitexturing.