Per-Pixel lighting?

Hello!



I was fooling around with the real-deal Alpha 3 GDE and starting to make the migration from Eclipse to the GDE/Netbeans and I ran into something that I’ve ran into before, but I didn’t know what to make of it. In the attached screenshot is just a piece of a sample level I’d made to mess around with as a testbed, but I was wondering what causes the banding in the light on low-polygon surfaces like this? I thought this was an artifact of vertex lighting, but I’m pretty sure I’ve got that set to false in the lighting.j3md material I’m using:



[java]

Material My Material : Common/MatDefs/Light/Lighting.j3md {

MaterialParameters {

m_Shininess : 1

m_UseMaterialColors : true

m_Diffuse : 0 0 0 1

m_Specular : 1 1 1 1

m_Ambient : 0.05 0.05 0.05 1

m_VTangent : false

m_HighQuality : true

m_LATC : false

m_Minnaert : false

m_WardIso : false

m_UseVertexColor : false

m_NormalMap : Textures/images.jpeg

m_DiffuseMap : Textures/instantcarpet.jpg

m_VertexLighting : false

}

}

[/java]







Is per-pixel lighting still on the way? Or am I doing something obviously wrong? Would a texture help? ~ Which I sorta tried, but I couldn’t get diffuse maps or normal maps to apply to the model using the material only. I’m guessing it has something to do with UV coordinates, though I thought I could just slam a texture at it with no care as to how it’s aligned?



Thanks! And the tool is awesome from what I can tell, I just need to spend some more time with it.

~FlaH

Not sure if it will help, but try removing the statement “m_VertexLighting : false” completely.

If not, then the issue is probably in your model’s normals.

What tool are you using to create your models?

Hello again!



I pulled out the m_VertexLighting as you said, and I double checked my normals in blender + recalculated. I couldn’t just swap in the new model so it’s a little different, but the issue still remains. I use the standard “Make model in blender → export as ogre meshes” path for getting models into JME (v2.49 or whatever, none of that new 2.5 business). The model itself is more or less a shell, with no thickness to the walls/floors. Probably not really good for real use, but it was never meant for that.



Two images this time: One of just the model, another with the model + wireframe so you can see the low polygon lines. One thing that’s sorta disturbing is the weird way it falls off to the right so quickly - It’s just a flat wall! The light itself is about 2 units away, with a falloff radius of 10.0 units. The banding/whatever is much less noticeable at greater distances (probably expected).











Thanks!

~FlaH

Can you make a screenshot of the scene with vertex normals displayed? Here’s how to do it in blender

I am guessing the issue might be that you have smooth normals enabled, whereas the wall should have flat normals

Hello again!



Sure thing. Every edge/vert was hand placed with surface smoothing off if that’s what you’re looking for. I thought for a moment I actually needed to turn it on but then I saw how it made the smoothing groups and went “No… Not at all like I thought” :stuck_out_tongue:







EDIT: Uploaded version was sorta tiny. Here’s the full URL I think: http://i55.tinypic.com/2hdy2dh.jpg



EDIT2: Oh yeah, and I keep forgetting to mention I’ve already checked for outlying double verticles. The whole thing is one big mesh, no overlapping verts.



~FlaH

Are you using attenuation? e.g. PointLight.setRadius()

Also, try rendering with this material:

[java]

Material My Material : Common/MatDefs/Light/Lighting.j3md {

MaterialParameters {

m_Shininess : 16

m_UseMaterialColors : true

m_Diffuse : 1 1 1 1

m_HighQuality : true

}

}

[/java]

I didnt notice it in your material file before, but it seems you’re relying on specular lighting rather than diffuse lighting. Also your shininess parameter is too low to be useful.

Hello!



Yep, I’m using setRadius. The shininess attribute confuses the hell out of me. 0 makes it all weird and a high value makes it like you’re looking into the sun. It’s as if there’s no real middle ground with it. Is it 0-100 or something? Anyhoo, attached is the spot with your material. The banding is still there, just subdued a bit by the lower shininess I’m guessing… Or higher shininess… Ugh XD







Big Version: http://i52.tinypic.com/v8pys8.jpg



Is there a way I could attach the model to this post or something? XD



~FlaH

12 is a good shininess value for semi-shiny stuff, did you try creating the tangents for your models geometries (button in SceneComposer)?

Just tried it normen. No change :frowning:



And on the side: So if you want a matte/flat colored object is a high shininess good or a low shininess?



~FlaH

You will need a specular map and/or play with specular etc. colors to achieve that

I think I might have the same problem as @tehflah. I also have walls made of more vertexes and it can be clearly seen that the lightning break on wall stitches (at least specular one). :smiley:

That’s really strange, because mathematically it should be the same.

If you use a DirectionalLight instead of PointLight, what happens?

Hello again!



I just tried the directionalLight and the issue persists. I’ve noticed that it is a lot less noticeable when the light is bright. I was just about to say the directionalLight was fine until I barely noticed the breaks, so I turned the light down a little and it was more obvious.







Full Size: http://i54.tinypic.com/5v7u4x.jpg



~FlaH

I already noticed this on some models, I think it comes from the normals and how they are interpreted in the lighting shader…

If this is how it looks like with directional light then its 100% the normals.

Make sure the vertex normals (NOT face normals) are all facing the same direction

Hello!



mmmm. I did a bit of experimenting. I used the article here: HowTo:Bevel - VsWiki ~ Which explains smooth shading vs flat shading and smoothing groups on flat objects. I took a bunch of screenshots of what I saw.



This screenshot is the OLD vertex normals, averaged at the corners which I’m guessing is bad for a flat surface.





Full: http://i53.tinypic.com/2s9auqd.jpg



The below screenshot are the new vertex normals for that wall, flattened as requested. The rest of the model is smoothed so that’s why the stairs look funny.





Full: http://i53.tinypic.com/28jz81u.jpg



The below screenshots are of directional light and point light respectively. The issue persists… :<







Full: http://i52.tinypic.com/2zf95vq.jpg







Full: http://i54.tinypic.com/9kzcx3.jpg



Did I do something wrong with the normals pointing the same direction? Basically the wall is another object now as well…



~FlaH

I see now, the part of the wall that connects with the stair step, the normal on that vertex is not facing away from the wall but to the top/side a bit.

In general it seems like you have smooth shading enabled, which is probably not a good idea, I think just enabling flat shading should fix it

Hello!



Nononono… Now the wall is it’s own object, that’s why there’s two vert normals there, one is the corner of the step coming outward at an angle and the other is the wall vert facing straight out. I enabled smoothing to see if that helped with the flat wall surface only, that’s why smoothing is on in the latest. I would actually PREFER not having smoothing, as it would be a real pain in the butt to keep the smoothing groups straight. Been in that hell before :stuck_out_tongue:



Here, I detached it, two light sources, smoothing off again for the wall, verts all facing Y direction:







Full: http://i52.tinypic.com/20f5jxs.jpg



~FlaH

Sorry but I can’t reproduce this, I created a test model in blender and did a similar thing to your wall and it works just fine:

Ah well, it’s obviously me using the ol “doin’ it wrong” again I guess and at least it’s not the engine XD… I’m sure I’ll figure out what I’m doing wrong eventually. I’ll give it a whirl on my home machine when I’m able. Thanks for checking it out.



~FlaH