Quadmesh Billboard Shader not working with instanced foliage.

I had tried that before with no results, though on the old mesh, so there were no results to be seen anyway.

sort of makes sense logically though, because of instancing and local space.

@Erlandys Hey! That seems to have done the job. It apparently works both with CameraSpace -> LocalSpace and CameraSpace -> WorldSpace. Such a simple fix. Thank you very much.

@Sorai

Can you see if you have this issue
https://cdn.discordapp.com/attachmen…62/unknown.png
https://cdn.discordapp.com/attachmen…18/unknown.png
Here im showing how all the billboards are shifting position(not just rotation) when i look left and right
You can see how the branch travels through the foliage mass, the branch isnt moving the foliage is

What i have come to realize is the billboards are not retaining there original center position from the original face
as in there not just simply rotating around the center of the faces original center point
The are being offset based on camera ‘direction’ so this offset changes depending on where your looking

What iv noticed and you can test this your self is if i move my camera left and right using A&D the offset dosnt occur only when i rotate the camera(look around)
https://cdn.discordapp.com/attachmen…81/unknown.png
here you can see the left lower branch should be in the middle of the foliage but due to the offset the branch appears infront of the foliage

I made a test by taking this tree mesh in blender and turning each quad into its own separate mesh/object then exporting that to ue4 then making a simple/traditional billboard material and added to all the now individual meshes

This gave me the same looking tree setup only this was now over 1000 meshes(an actor per billboard), this was so i could test how the tree billboards would look/behave if there were proper billboards. This tree did not have the shifting problem all billboards were locked to the center point of the original face and all billboards sat correctly infront of meshes like the branch

So my conclusion is that the quad to billboard effect defiantly dose not retain each billboards center point and seems to shift around the billboards center position based on camera direction/rotation which is more noticeable the closer you are to the tree/foliage

Can you confirm this is the case for you

@Erlandys Maybe you can check too?

That’s strange - my effect doesn’t move position. It only shifts when I rotate the camera.

@Sorai so what i mean is the foliage is offsetting as i look left to right so the foliage will start to not line up with the the branches
Its hard so explain but if you have discord i can show you it in motion

But you can test my mesh and alpha if you want to see
https://cdn.discordapp.com/attachmen…rchTree_1a.fbx
https://cdn.discordapp.com/attachmen…eaves_02_d.TGA

If you look at the branch in my shots you can quickly see the issue
As i say moving the camera with wasd dosnt casue the effect but when rotating the camera around you see the foliage shift with the camera direction

As i say this issue dosnt happen with the proper billboard test
https://cdn.discordapp.com/attachmen…d_of_faces.fbx
this is the mesh you can also test, just make a simple traditional billboard material and parameter to scale the faces up so you can get both trees to look routhly the same and you can see how there different billboards behave

I tried your tree mesh and for me the shifting is really minimal when rotating the camera. It’s still lined up with the branches and certainly not as extreme as in your screenshots. It might be something in your material. Erlandys said that multiplying the UV by 1, -1 gives a more disturbed billboard effect. For me, I am multiplying by -1, 1. Maybe you can try to check that and see if it helps.

@Sorai
I already am
https://cdn.discordapp.com/attachmen…84/unknown.png
My mat this is what i have plugged into world position offset

My offset is really bad, unusable bad
You as close to the tree as i am in my shot

In my mat instance i have size set to 25 and inflate set to 0(im essentially not using it atm)

Looking straight on tree in middle of camera

I look left putting the tree on the right side of the screen

Now looking right putting tree on the left side of the screen

This shifting is too noticeable, in motion it looks like the branch randomly pops out from the foliage and is moving around

I’m really not sure :confused: It’s not so bad on my end. It moves a bit, but maybe it’s not a big deal to me. My billboard size is at 40, so maybe the larger faces make it much less noticeable. but that may change the look that you want. I also find it better having the alpha take up most of the square. That’s how mine is and it probably hides the shifting better.

That’s kind of what I was initially saying guys.
you really need a Rotate About Axis with a Pivot Point defined for this to work right.

The center point of each face is always .5 .5 of the original UV.
you could try a transform local to world on it and use as the pivot.

The rest of the calculations no longer apply.
you have to get a 2pi rotation angle to feed the rotate about axis.
Most calculations do this out of an atan2 with swapped x/y input (r g of the UV).

See if you can give it a shot - if any of this makes sense to you.

As always, the problem is getting the localized .5,.5 or Pivot of the face from the mesh into an x,y,z world unit.
So you probably need to add wpo to it. Or at least a Z value that makes sense

@Sorai
Regardless it dosnt change the fact that these billboards do not work the way an actual billboard works
(face the camera but not move at all from its center anchor point)

I think the problem is the size and the actual billboard effect are not separate
What is the correct number for the billboard effect to be at 100%
Why is it linked to the size at all

It may work for you for what you need but i need to fix for this
https://drive.google.com/file/d/180P…ew?usp=sharing
You can see how it is on my end and why im unable to use this in its current state

If you dont get it like this then what on earth is different your end as really need to know
Changing size dosnt help the issue is worse larger and any smaller it messes up the billboard effect
different alpha makes no difference at all i turned the alpha off for one test so it was just solid faces it shifts all the same
Nothing suggested so far makes a difference to my issue

[USER=“3140864”]MostHost LA[/USER] I would need to see a screenshot of the material graph to know what you mean, Im quite new unfortianly

I’m really not sure. I’m not much of a material artist so I don’t know the specific math involved. I was just following the tutorial trying to get the look that I’m going for. MostHost has more detailed information on the math so if you can understand it you can try to implement it in a better way.

@Sorai
You can see why the issue is very much an issue for me, If it can be resolved then it should make the effect better overall regardless

[USER=“3140864”]MostHost LA[/USER] When you have the time if you could do a quick screenshot of what you mean it would give me something to go off of

First.
the mesh panes are moving because or the UV itself and the placement in world space of the UV.

Removing the camera to local and Normalize node from the operations is what did this in essence.

Second.
I could share some code, but this is probably much more helpful to work with rotate about axis the first few times.

Start with a regular mesh. Transition back to working this specific one after you understand the base concept. Which should also make what I wrote before a little clearer - hopefully.

I think I’ll be able to get back to testing this mid week.

Had some time to look more into this.
With rotate about axis, the problem is that the Pivot coordinates can’t really be translated off the texture position - Or there is a way I just don’t know yet.

You’d have to days chain 2 rotate about axis nodes.
The first one on the X or Y axis by 90deg. (1.5708 radians, or 2-1.5708 as the value of the rotation angle I think).

The second one, would then rotate on the Z axis to keep in tune with the camera position.

If you know enough to leverage pivot painter, you may be able to.

For the rest of us plebes on Blender, The best possible approach is to sacrifice vertex paint and to color in each face.
Each face has to be it’s own mesh to do this. they all need 4 vertex or more.

You have to get the mesh size,
output each face x/y/z location,
normalize it (dividing by the mesh size, making sure your results are within a 0 to 1 range).

After that’s packed and in engine.
You can extract the values the very opposite way.
mesh size as a V3 variable you edit (or you can use object bounds, BUT those may not work on foliage).
multiply by the scale too, so you can scale up or down.

and set up the daisy chain. (by this, you simply need to ADD the result of 2 rotate about axis nodes together - and use the position of the first node + wp as the position of the second.).

It’s definitely NOT as cheap as the original transform sequence.

if someone know how to be able to pull location data in world space off a texture across Multiple faces that would probably be a better approach.

The problem with using the code above for pivot locations is that the values end up being all very close to 0,0,0 - as if the camera to local is not even being taken into account.

Personally i think it would be better if all the faces used the same angle rather then each looking at the camera individually
So get the angle from the foliage mesh as a whole to the camera then set all faces to use this angle around there individual center points
I did make a crude image to show my thinking

  1. The dot represents the camera and the hex shape is representing faces of a mesh be it a sphere ect in there original pos/angle
  2. Shows the faces in billboard facing the camera
  3. If you make the billboards bigger you can lead to intersections shown in red
  4. Instead if you have all the faces billboards using one angle to face the camera and not per face. Aka the angle from the mesh as a whole to the camera position
  5. So even with there bigger size there less likely to clip and if they do like shown there would be faces in front covering it for the most part

Regardless weather it looks better or not i assume finding the angle from the mesh to the camera is easier then a per face basis

Definitely. Because you can just use the object pivot.

the problem is still the same. Finding an accurate way to define the pivot point for each face.
each face being composed of 2 tris…

If i make each face a different vertex color, you can use that?
I did have a script for blender that automatically dose this

yes, and it works well. But at the same time it’s not as easy to implement as the quad mesh system.

Eventually, I’ll be publishing an update to BoneBreaker that includes a script to do this. Since I use it extensively for grass and foliage meshes.

Would be much nicer to be able to actually get the pivots from where the faces are in 3d space via the position of each UV…

Quick update.

That’s “the best” I got to without leveraging vertex paint.
The rotation is supposedly simulating the camera position, but as you can clearly see, the transform pivot is still not even close to being Localized to each face.

Yer thats errr trippy haha I really hope this can be resolved as it looks perfect if it didnt have that offset issue