Jump to content
  • Advertisement
Sign in to follow this  
Laubstein

Billboard issue in front of 3D object

This topic is 2156 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm starting to develop a poc with the main features of a turn-based RPG similar to Breath of Fire 4, a mixture of 3D environment with characters and items such as billboards.

I'm using an orthographic camera with an angle of 30 degrees on the X axis, I did my sprite to act as a billboard with the pivot in the center, the problem occurs when the sprite is nearing a 3D object such as a wall.

 

billboardissue.jpg

I had tried the solution leaving the rotation matrix of the billboard "upright", worked well, but of course, depending on the height and angle of the camera toward the billboard it gets kinda flattened, I also changed the pivot to the bottom of the sprite but this problem appears with objects in front of the sprite too. I was thinking that the solution would be to create a fragment shader that relies on the depth texture of some previous pass, I tried to think in how to do it with shaders but I could not figure it out. Could you help me with some article or anything that puts me in the right direction? Thank you.

Share this post


Link to post
Share on other sites
Advertisement

If you stand somewhere and someone watches you from above, you would not bend down backwards or even lay on the ground right? So you should not let your sprite do that, too.

Just keep the feet on the ground (that may be an easier object origin than the middle) and the head directly above in world space, not view space.

Share this post


Link to post
Share on other sites
I am trying to achieve the same  visual as this video shows:
 
You can see that the player almost lay down on the ground right? Sorry if I am still wrong. Otherwise if I leave the head directly above in world space the sprite  gets kinda flattened. Am I missing something? Thanks :)

Share this post


Link to post
Share on other sites

That's an interesting problem.

 

My first thought would be to not use full camera facing billboards, instead use normal quads that are orthogonal to the ground and put the texture on there. You'd still want them to billboard on the y axis however. The side effect of this would be that the sprites would look shortened vertically when viewing from above, so to compensate for that you'd have to stretch the quads vertically dependent on the camera angle. I can't think of any reasons immediately why this wouldn't work, and it seems preferable to messing with shaders.

 

I will elaborate if it's not clear what I'm saying.

Edited by stevenmarky

Share this post


Link to post
Share on other sites

I guess it is a clever idea, I am gonna try to test it tonight. The good is that I won't plan to change the angle of the camera dynamically in the scene so a good height offset for the billboard to stretch  the quad would do the trick. I read that another solution would be disabling the z-buffer write and draw the objects from the furthest to the nearest, but sort ing the entirely objects in Unity3d would not be so easy as if it was in OpenGL. Just for curiosity do you think in something related to shaders technique to solve it?

Thanks.

Share this post


Link to post
Share on other sites

I tried your solution @stevenmarky and it works great,  the scaling should be about 1.1547. It is (1 / cos30), which makes billboards look like original size from the camera with the angle of 30 degrees.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!