Best way for tree leaves


#1

Hello.

recently i started making some tree assets that contains leaves.

got a question. when its about tree leaves.

already made planes 2-sided (i never needed use this) so i thought it will be fine.

but in second screenshot black leaves is backface.

so i wonder, if i should do this doublesided quads or use something else.

i seen to fix backface lighting need to setup:

renderManager.setPreferredLightMode(TechniqueDef.LightMode.SinglePass);

but should i use it? i hope there is some better way to do tree leaves.

Maybe i should make leaves not as quads, but as some cubes? or dupplicate them somehow in blender with opposite normal direction?

how are you making trees look nice in JME?

thanks for any suggestions :slight_smile:

here is test-tree i made:

in Blender(2.8):
v111111111111

in JME
v2222222222


#2

I think you read this already?


#3

thanks for link.

nope i dont red it, but it say same as what i red.

it is: use single-pass or dupplicate model and reverse normals.

while someone in this topic just added:

wvNormal = -faceforward(wvNormal, viewDir, wvNormal);

and i cant belive it trully helped…

anyway i ask here if someone have experience and know what is the best way to solve this.

or maybe explain me if Single-pass is better or worse, what would be better.


#4

also had fps issue, but merged all particles from blender into one mesh.

also i replaced .gltf material generated via blender that was looking like above screenshots in sdk, but ingame was issues. so replaced with j3m created file, so it look nice ingame too.

what do you think? (i think there will will be issue with things like flashlight but now its not visible)


#5

anyway as i see there are some issue:


#6

Would be helpful to see your .j3m.

Else, random shots in the dark are “alphaDiscard”, etc.


#7

.j3m could not help much. below is what i use:

i just set there normalMap and colorMap for PBR material.

but i use:

public static void transparencyFixer(Geometry geom){
    for (String name : Arrays.asList(new String[] { "ColorMap", "DiffuseMap", "BaseColorMap" })) {
        MatParam tex = geom.getMaterial().getParam(name);
        String texName = tex != null ? tex.getValueAsString() : "";
        if(texName.contains("Transparent")){
            geom.getMaterial().setFloat("AlphaDiscardThreshold", 0.5f);
            geom.setQueueBucket(RenderQueue.Bucket.Transparent);
            geom.getMaterial().getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
        }
    }
}

because i was lazy everytime set it for each model / etc. it worked great for me so far


#8

switched from PBR to phong (still in same Node so is lit by probelight of green color - same issue as i had in early with terrain painting ;p)

but no this issue… ???

bbbbbbbbbbbbbbbbbbbbbbbbbbbb


#9

To be honest, I’m kind of guessing at the issues each time because you just show a picture but don’t mention what’s wrong. So I try to guess by what looks wrong to me… but I don’t know what it’s supposed to look like.

So I’m guessing you are complaining about the shadows of the early tree being quad shaped? I’ve never tried semi-transparent textures with PBR and shadows so maybe it’s broken.


#10

overall this topic is about how to best do leaves in JME.

i explained i did double-faced quads. so i had issue in SDK preview that backfaces were Black.

so next i checked this ingame, but had fps issues anyway, so like said i merged all quads into one mesh to optimize and i re-applied default blender .gltf imported material with created one(first it was PBR and was dark, for some reason, but i dont complain about it, but about “shadows” on mountain - arround tree, that should not be there ):

Material My Material : Common/MatDefs/Light/Lighting.j3md {
     MaterialParameters {
        NormalMap : Repeat "Models/common/nature/trees/3/leafs1Normal.png"
        DiffuseMap : Repeat "Models/common/nature/trees/3/leafs1BaseColorTransparent.png"
     }
    AdditionalRenderState {
    }
}

so once i used lighting material, the issue with shadows on mountain no more exist.

please note this shadows that were arround tree looks like some PBR transparency issue? because its not default light shadow there.

anyway still this topic is about same. it is: what is the best way to achieve nice looking optimized tree with leaves in JME :slight_smile:


#11

I may be the wrong person to ask… since when I was confronted with that question, I wrote my own tree generator. :slight_smile:


#12

anyway i ask :smiley:

  1. is your tree generator using PBR material, or Phong? :slight_smile:
    Also you use double-sized quads there? or dupplicated quads with opposite normals(or maybe its some very low-poly tree)

as i remember mythruna had a nice trees (dont remember now if blocky leaves)

  1. how many tris you think one tree should have? (for better(not best) video cards) .
    1500?

#13

My generator does not yet use PBR so it may have the same shadow issues.

It uses camera-oriented quads for the leafs… so they are basically large camera-facing particles that adjust their lighting as they rotate around.

It has LOD:

Animated wind:

…supports instancing, etc.

I used it in this demo:

I’m not saying it’s the best way… but it’s the way I did it and I thought I’d pre-answer any other questions. :slight_smile:


#14

hmmm. i thought about billboard-style-leaves

but i thought it will look odd. Your videos proved me that it can look really good.

once it always look in camera, there even dont need to be many of this quads.

also its much easier to animate them.

i think your solution is very good :slight_smile:

why i did my solution this way, is that as you can notice. i got one branch that i dupplicate using tree normals of particles in blender (so root of branch always start from tree)

zzzzzzzzzzzzzzzzzzzzzzzzzzz

so trees look really nice.

but your solution without using branches, just a leaves, looks really nice too, and can be dynamic, animated easly.

so now i have headache what to choose :smiley:

edit:

haha, i used “leafs” in every post thinking its proper word, while i should use leaves :smiley:


#15

There is an updated PBR shader that you can get if you use JmonkeyBuilder with the Simarboreal plugin, I use it for my trees and am happy with the results.

Just to quickly share my input, using Simarboreal for my trees has definitely been the best way I could find - and I’ve even reused the simarboreal shaders on some of my other foilage models for the nice wind effects :slightly_smiling_face:


#16

isnt Simarboreal made by pspeed himself?

telling author to use his own shaders to fix his issue? :smiley: hehe.

sometimes something we create we dont even know.


#17

Thanks! That’s really nice to hear.


#18

I just watched a video on trees that basically explains how to generate them procedurally. If you haven’t already subscribed to this guy you probably should.

He draws them in 2D. In my head it starts with a cylinder of n vertices and you work your way up, reducing the radius with each recursion. A bit of noise here and there and you’ve got yourself a tree generator.


#19

You just described SimArboreal, actually. But I based my code on stuff I read about fractals and L-systems in the 90s so it’s probably no surprise.

I also separated SimArboreal into two layers. There is the simple L-system that generates the branch structure and then there is the layer that turns that into a mesh. So anyone wanting to write a more complicated full-feature L-system could feed the output into the mesh generator.

(Which also lets one specify a very specific tree structure if they want to.)


#20

I’ve used your tree editor quite a few times. With some careful tweaking it can create some really nice trees with reasonable vert count. The LOD control is really cool. Often times, though, I find myself wanting to know “how it works” and end up writing my own just to understand it more than anything. It’s an annoying trait.