Can't light a simple cube

Hi,

I’m really struggling to light a cube so that it is bright on one side and dark on the other,

In the Hello Assets demo, the ninja is lit correctly (dark on far side), but the brick wall is lit uniformly in all directions,

How can I create the right material/light setup so that it’s dark on one side of the wall?



I’ve tired applying lighting material, and importing my own cube model to light, but either there is no difference, or the whole thing crashes,



I have a MacBook and as far I can tell from its graphics card it supports opengl 2.



Can someone suggest the simple code amendment to the Hello Asset file so that the brick wall is lit properly?

Thanks.

if you import your own models (.obj) you need to make sure you export with Normals on (default is off in blender).

Then you need to add:



[java]TangentBinormalGenerator.generate(yourModel);[/java]



Hello Materials explains it pretty well (apart from the export business).

You can use Lighting.jm3d and just not set m_NormalMap and m_SpecularMap or m_Shiness to see it shaded.

ok it seems to be half working, the wall in the demo scene I made a simple grey material with the above additions - but it seems inside out or something, I’m getting these errors when it runs - seems like the normals aren’t right,



Nov 4, 2010 6:38:07 PM com.jme3.asset.DesktopAssetManager

INFO: DesktopAssetManager created.

Nov 4, 2010 6:38:10 PM com.jme3.system.JmeSystem initialize

INFO: Running on jMonkey Engine 3 Alpha 0.6

Nov 4, 2010 6:38:10 PM com.jme3.system.Natives extractNativeLibs

INFO: Extraction Directory #1: file:/Applications/jmonkeyplatform.app/Contents/Resources/jmonkeyplatform/jmonkeyplatform/libs/

Nov 4, 2010 6:38:10 PM com.jme3.system.Natives extractNativeLibs

INFO: Extraction Directory #2: /Volumes/Jackup/JME/lightest3

Nov 4, 2010 6:38:10 PM com.jme3.system.Natives extractNativeLibs

INFO: Extraction Directory #3: /Volumes/Jackup/JME/lightest3

Nov 4, 2010 6:38:10 PM com.jme3.system.lwjgl.LwjglAbstractDisplay run

INFO: Using LWJGL 2.5

Nov 4, 2010 6:38:10 PM com.jme3.system.lwjgl.LwjglDisplay createContext

INFO: Selected display mode: 640 x 480 x 0 @0Hz

Nov 4, 2010 6:38:10 PM com.jme3.system.lwjgl.LwjglAbstractDisplay initInThread

INFO: Display created.

Nov 4, 2010 6:38:10 PM com.jme3.system.lwjgl.LwjglAbstractDisplay initInThread

INFO: Adapter: null

Nov 4, 2010 6:38:10 PM com.jme3.system.lwjgl.LwjglAbstractDisplay initInThread

INFO: Driver Version: null

Nov 4, 2010 6:38:10 PM com.jme3.system.lwjgl.LwjglAbstractDisplay initInThread

INFO: Vendor: NVIDIA Corporation

Nov 4, 2010 6:38:10 PM com.jme3.system.lwjgl.LwjglAbstractDisplay initInThread

INFO: OpenGL Version: 2.1 NVIDIA-1.6.18

Nov 4, 2010 6:38:10 PM com.jme3.system.lwjgl.LwjglAbstractDisplay initInThread

INFO: Renderer: NVIDIA GeForce 9400M OpenGL Engine

Nov 4, 2010 6:38:10 PM com.jme3.system.lwjgl.LwjglAbstractDisplay initInThread

INFO: GLSL Ver: 1.20

Nov 4, 2010 6:38:10 PM com.jme3.system.lwjgl.LwjglTimer

INFO: Timer resolution: 1000 ticks per second

Nov 4, 2010 6:38:10 PM com.jme3.renderer.lwjgl.LwjglRenderer initialize

INFO: Caps: [FrameBuffer, FrameBufferMRT, FrameBufferMultisample, OpenGL20, OpenGL21, ARBprogram, GLSL100, GLSL110, GLSL120, VertexTextureFetch, TextureArray, FloatTexture, FloatColorBuffer, FloatDepthBuffer, PackedFloatTexture, SharedExponentTexture, PackedFloatColorBuffer]

Nov 4, 2010 6:38:10 PM com.jme3.renderer.Camera

INFO: Camera created (W: 640, H: 480)

Nov 4, 2010 6:38:10 PM com.jme3.renderer.Camera

INFO: Camera created (W: 640, H: 480)

Nov 4, 2010 6:38:10 PM com.jme3.input.lwjgl.LwjglMouseInput initialize

INFO: Mouse created.

Nov 4, 2010 6:38:10 PM com.jme3.input.lwjgl.LwjglKeyInput initialize

INFO: Keyboard created.

Nov 4, 2010 6:38:11 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Gui Node)

Nov 4, 2010 6:38:11 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

Nov 4, 2010 6:38:11 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

Nov 4, 2010 6:38:11 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

Nov 4, 2010 6:38:11 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

Nov 4, 2010 6:38:11 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

Nov 4, 2010 6:38:11 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

Nov 4, 2010 6:38:11 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

Nov 4, 2010 6:38:11 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

Nov 4, 2010 6:38:11 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

Nov 4, 2010 6:38:11 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

Nov 4, 2010 6:38:11 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

Nov 4, 2010 6:38:11 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

Nov 4, 2010 6:38:11 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

Nov 4, 2010 6:38:11 PM com.jme3.scene.Node attachChild

INFO: Child (Statistics View) attached to this node (Gui Node)

Nov 4, 2010 6:38:12 PM com.jme3.scene.Node attachChild

INFO: Child (Teapot-geom-0) attached to this node (Teapot-objnode)

Nov 4, 2010 6:38:12 PM com.jme3.scene.Node attachChild

INFO: Child (Teapot-geom-0) attached to this node (Root Node)

Nov 4, 2010 6:38:12 PM com.jme3.util.TangentBinormalGenerator processTriangleData

WARNING: Normal and tangent are parallel for vertex 0.

Nov 4, 2010 6:38:12 PM com.jme3.util.TangentBinormalGenerator processTriangleData

WARNING: Normal and tangent are parallel for vertex 1.

Nov 4, 2010 6:38:12 PM com.jme3.util.TangentBinormalGenerator processTriangleData

WARNING: Normal and tangent are parallel for vertex 2.

Nov 4, 2010 6:38:12 PM com.jme3.util.TangentBinormalGenerator processTriangleData

WARNING: Normal and tangent are parallel for vertex 3.

Nov 4, 2010 6:38:12 PM com.jme3.util.TangentBinormalGenerator processTriangleData

WARNING: Normal and tangent are parallel for vertex 8.

Nov 4, 2010 6:38:12 PM com.jme3.util.TangentBinormalGenerator processTriangleData

WARNING: Normal and tangent are parallel for vertex 9.

Nov 4, 2010 6:38:12 PM com.jme3.util.TangentBinormalGenerator processTriangleData

WARNING: Normal and tangent are parallel for vertex 10.

Nov 4, 2010 6:38:12 PM com.jme3.util.TangentBinormalGenerator processTriangleData

WARNING: Normal and tangent are parallel for vertex 11.

Nov 4, 2010 6:38:12 PM com.jme3.util.TangentBinormalGenerator processTriangleData

WARNING: Binormal is flipped for vertex 16.

Nov 4, 2010 6:38:12 PM com.jme3.util.TangentBinormalGenerator processTriangleData

WARNING: Binormal is flipped for vertex 17.

Nov 4, 2010 6:38:12 PM com.jme3.util.TangentBinormalGenerator processTriangleData

WARNING: Binormal is flipped for vertex 18.

Nov 4, 2010 6:38:12 PM com.jme3.util.TangentBinormalGenerator processTriangleData

WARNING: Binormal is flipped for vertex 19.

Nov 4, 2010 6:38:12 PM com.jme3.scene.Node attachChild

INFO: Child (Box) attached to this node (Root Node)

Nov 4, 2010 6:38:12 PM com.jme3.scene.Node detachChildAt

INFO: Child removed.

Nov 4, 2010 6:38:12 PM com.jme3.scene.Node detachChildAt

INFO: Child removed.

Nov 4, 2010 6:38:12 PM com.jme3.scene.Node detachAllChildren

INFO: All children removed.

Nov 4, 2010 6:38:12 PM com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Gui Node)

Ninja: emissive

Unsupported texture_unit directive: tex_coord_set

Nov 4, 2010 6:38:13 PM com.jme3.asset.DesktopAssetManager loadAsset

WARNING: Cannot locate resource: Models/Ninja/Ninja.skeleton.xml

Nov 4, 2010 6:38:13 PM com.jme3.scene.Node attachChild

INFO: Child (Ninja-geom-1) attached to this node (Ninja-ogremesh)

Nov 4, 2010 6:38:13 PM com.jme3.scene.Node attachChild

INFO: Child (Ninja-geom-2) attached to this node (Ninja-ogremesh)

Nov 4, 2010 6:38:13 PM com.jme3.scene.Node attachChild

INFO: Child (Ninja-ogremesh) attached to this node (Root Node)

Nov 4, 2010 6:38:13 PM com.jme3.renderer.lwjgl.LwjglRenderer updateUniformLocation

WARNING: Uniform m_UseMaterialColors is not declared in shader.

Nov 4, 2010 6:38:13 PM com.jme3.renderer.lwjgl.LwjglRenderer updateUniformLocation

WARNING: Uniform m_UseMaterialColors is not declared in shader.

Nov 4, 2010 6:38:13 PM com.jme3.renderer.lwjgl.LwjglRenderer updateUniformLocation

WARNING: Uniform m_VertexColor is not declared in shader.

Nov 4, 2010 6:38:16 PM com.jme3.input.lwjgl.LwjglMouseInput destroy

INFO: Mouse destroyed.

Nov 4, 2010 6:38:16 PM com.jme3.input.lwjgl.LwjglKeyInput destroy

INFO: Keyboard destroyed.

Nov 4, 2010 6:38:16 PM com.jme3.system.lwjgl.LwjglAbstractDisplay deinitInThread

INFO: Display destroyed.

“Flip” the normals in blender, or “recalculate outside”.

I’ve just been using the ‘wall’ already inside the demo scene - nothing imported,

can i flip the normals inside the code?

Perhaps you can provide a screenshot? “Inside out” could mean many things.

finally finally got it working,

by playing around a lot with the hello material demo



not enough comprehensive tutorials/docs on materials and lighting…

xp61 said:
not enough comprehensive tutorials/docs on materials and lighting..

So wheres your tutorial?

Apologies if I sounded offensive.

Lol normen ^^ take it easy pal.

Creating and using materials is definitely not easy, as you need to set parameters and such and that requires understanding what each one does and how it works. A tutorial about the Lighting material would be very useful indeed.

In the issue tracker I already added an issue about this a while ago:

http://code.google.com/p/jmonkeyengine/issues/detail?id=204

:smiley: Sorry, I just think that our level of documentation is just marvelous compared to any other oss game engine. :stuck_out_tongue: Also, it would be nice if @xp61 would describe how he achieved what he wanted for the others on the forum and maybe for zathras, who scans the forums for good content to add to the wiki.

ok I got to the heart of it,

once you have your light and lighting material set up, if you don’t have an m_Shininess value defined, then everything looks wrong…



there’s my tutorial!