Billboard Characters


#1

Hey guys,

I’ve started a mini project for a tutorial for heaps and I’m stuck on something stupid.

The idea is that I’ll be teaching 2D and 3D together and I wanted to do billboard NPC’s in a 3D world. Looking at the source, it looks like I should probably use the Polygon, but I wanted to double check in case there’s a more logical route.

Cheers,
Lee


#2

While I’ll leave the proper answer to other people, in my case I did custom primitive quad to render s2d objects in s3d space. My solution does not support interaction, but in general should work. Also keep in mind that it works via rendering to POT texture. :​)
If that solution suits your needs, feel free to utilize it: https://gist.github.com/Yanrishatum/625a10921b8ed269bbb06cd5a7b7774e
(It’s from my not yet publicly released engine I will utilize for upcoming Ludum Dares, and rendering s2d objects in 3d space has been one of the thing we wanted in last ludum)


#3

Hi. I did exactly the same to draw 2d graphics and animations to a texture attached to a 3D Plane. I used the Plane class that extends the Polygon class, and it was not very hard to do. But you can of course extend the Polygon class (or Plane class) to make your own kind of Plane or Quad Primitive.

It was even simple to draw 2D Objects to 3D Context, like the 2D Animation class.


#4

Thanks guys,

I’ll continue on my path, in that case :slight_smile:

Regards,
Lee


#5

Hey Marcus,

Do you have an example? I’m just not seeing it work. Not sure if I’m just dumb or missing something silly. Anything simple is fine :slight_smile:

Thanks in advance,
Lee


#6

Maybe I was a little bit fast and did not get what you really want.
I use the SpriteBatch Class to draw many 2D Sprites onto a texture that is attached to a 3D Plane. This 3D Plane fills the entire screen and it is a little in the background, so I can draw 3D Elements in the foreground.

This is not what you want, because you want 2D Sprites with individual z-positions and have the sprites always face the camera. My sprites are all at the same z-position. And the BatchElement Class does not have a z-position at all.

So what you want to do is draw multiple 3D Planes, one for each sprite. Maybe they use the same texture but different UVs. But nevertheless drawing this Quads without batching them is a bad idea, because every billboard NPC would be a drawcall. If this sprites stay on there positions you could merge them to one Mesh and it would be just one drawcall. But if they should move, then you can’t merge them.

But maybe it’s no problem for you because you don’t want to draw very much billboard NPCs, like 20 or 50 or 100. Then it would be ok, but still not a very efficient way.

So how can you achieve this? Maybe using Particles?

I have made 2D Billboards in the openfl away3D engine. There I can drawbatch tenthousands of Sprites with individual z-positions. But I did not try this with the heaps engine.

I hope I did not make you dissapointed now. And yesterday was a long night, so it could be that I wrote to much nonsense. But I will try to figure it out too and will come back, because it is an interesting task.


#7

It would indeed but nice to be able to have a whole h2d.Object (and its decendents) rendered in 3D space easily, if possible without using a temporary texture.


#8

Absolutely agree.

I’m going to do the tutorial / project entirely in 2d for now, as this is giving me a headache, but I will revisit in the future.