Strange issue with Lighting/LightBlow based materials

The scene is based of 5 clones of the same tree a torch in the middle with added point light and ambient light.

The materials of the leaf is a simple Lighting/LightBlow based material with a DiffuseMap (Issue is the same for Lighting/LightBlow)

All 4 trees, the torch and the pointlight are added to the root node.



Material file:

[java]

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

MaterialParameters {

DiffuseMap : Trees/Definitions/Textures/BlackTupelo/Leaf/tile_0.png

}

AdditionalRenderState {

}

}[/java]



And here is a video of the issue.

http://www.youtube.com/watch?v=Hw8GCdXN29w



What could cause this issue? (If neccesary i can upload the project, but it's due textures and audiofiles quite a big project)

Are those trees billboards?

@pspeed said:
Are those trees billboards?


No, they are generated with the treegenerator

Another interesting thing, no mather how many tree’s i add, the lighting of one is always ‘frogotten’ (depending on the viewdirection the forgotten one is selected)

@zzuegg , you will need to switch tangentBinormalGenerator on for your models.



This is an issue:

http://www.youtube.com/watch?v=GTM_W4XTCjA&feature=channel_video_title





[java]TangentBinormalGenerator.generate(Spatial/Node/Geometry);

[/java]

@mifth said:
@zzuegg , you will need to switch tangentBinormalGenerator on for your models.
[java]TangentBinormalGenerator.generate(Spatial/Node/Geometry);
[/java]

@zzuegg Are your trees normal mapped?
If they are mifth is right you should generate tangents
If there are not there is no point in generating tangents.

Since i do not apply a normal map in the material i assue they are not normal mapped

Normals are needed for lighting still no?

Arent normals distinct to a normal map though? I always thought a normal map was a high poly render of a model used to produce a texture for a lower poly render of that model.

Idk, I was just thinking how does the shader know about the normal of the triangle else? But I think you’re right, the issues only start when a normal maps actually being used…

Wouldnt normals be automatically generated based on which way the triangle was facing? I mean, if they didnt have normals, I dont think they would be lit at all…

Thats what I mean. some normal has to be there, but I guess mapped normals and the normal used when no map is available are two different things.

If you want to use lighting… your vertexes will need normals. No exceptions.



If you want to use normal maps or bump maps, you will also need tangents… no exceptions.



So, if you don’t have normal maps then you just need normals on your vertexes. These can’t be determined correctly automatically because a) the shader doesn’t know anything about triangles, b) it wouldn’t know what should be smooth and what shouldn’t, etc. anyway.

1 Like

What differences are between rendering in the SceneComposer and renderering Ingame?



I am asking because in the scene composer everything works fine while the same scene rendered ‘Ingame’ causes the issues.



This is all i do to load the scene:

[java] public void simpleInitApp() {

this.rootNode.detachAllChildren();



AmbientLight ambient = new AmbientLight();

ambient.setColor(new ColorRGBA(1f, 1f, 1f, 0.001f));

rootNode.addLight(ambient);



this.flyCam.setMoveSpeed(100f);



Spatial scene = assetManager.loadModel(“Scenes/TestScene/TestScene.j3o”);



rootNode.attachChild(scene);



}[/java]

try this:



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

@mifth said:
try this:

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


And note: if this does fix it then you _are_ using normal maps and you just don't know it.

Tangents are 100% ignored without normal maps and bump maps as the sole purpose is to define "tangent space" for those textures.

Thank you for the reply’s. The code above will affect only the terrain because all the objects are loaded and attached at runtime trough custom controls.



Once i find some free time i will make some trees with blender to check if there is something wrong with the generated models.



Unfortunately i have a new different issue. (I am really sorry to bother you with all my issues)



I have implemented another control which replaces the 3d model with a simple plane (which is following the camera and is texturized with a picture of the same tree as the model). Currently its only a very simple kind of LOD management, but i have already ideas how to extend it).



As you can see on the screenshots on the border of the visible part of the texture a greenish border gets drawn. How can i get rid of that?



I am using the Lighting material:

[java]Material My Material : Common/MatDefs/Light/Lighting.j3md {

MaterialParameters {

DiffuseMap : Models/Objects/Common/Trees/Objects/DarkTupelo1_billboardPic.png

UseAlpha : true

AlphaDiscardThreshold : 0.0

}

AdditionalRenderState {

Blend Alpha

FaceCull Off

}

}[/java]







I am using this texture:



@pspeed said:
And note: if this does fix it then you _are_ using normal maps and you just don't know it.

Tangents are 100% ignored without normal maps and bump maps as the sole purpose is to define "tangent space" for those textures.


If i have made the materials i use myself how can normal maps be used? Can the be stored in the model?
(If the objects are cloned, do i need to call TangentBinormalGenerator.generate(spatial); on every clone or only on the original?)
@zzuegg said:
If i have made the materials i use myself how can normal maps be used? Can the be stored in the model?


They would be part of the material. The material could be stored on the model, I suppose.

My point was that it keeps getting suggested to generate tangents and if you don't have normal maps then it's not at all even slightly relevant. And if it _does_ fix your issues then something else is going on... because tangents only matter if you have normal or bump maps. If you don't then tangents aren't used... a little dance and a pat on your head would be as effective a solution as calling TangentBinormalGenerator.

@zzuegg said:
(If the objects are cloned, do i need to call TangentBinormalGenerator.generate(spatial); on every clone or only on the original?)


No... once before cloning should be enough.
@zzuegg said:
As you can see on the screenshots on the border of the visible part of the texture a greenish border gets drawn. How can i get rid of that?


You might be able to mess with some settings on the materials additional render state.

If you use AA then you can try the "alpha to coverage". Otherwise, try playing with the alpha falloff and threshold.

Usually these borders are caused by partially transparent pixels being rendered and filling the Z-buffer before the parts of the scene behind it are drawn. Though in this case that also implies that your ground is in the transparent bucket with the trees. You'll still need to deal with the border or your edges will render through other trees, too.