About Store Forum Documentation Contact



Post Reply 
[SOLVED] Billboard draw3D rendering order
Author Message
Mardok Offline
Member

Post: #1
[SOLVED] Billboard draw3D rendering order
Hi guys i need some advice,

Example: I need to draw 3D sphere mesh and billboard image with some blue aura effect but i dunno how to achieve correct rendering order. Billboard should be in the foreground, mesh in the background (billboard pos = mesh pos). I'm experimenting with D.depthLock and D.depthUnlock and in one case achieved effect on PC is exactly what i need but on mobile isn't. I dunno if i'm using depthLock and depthUnlock correctly, it's just experiment. Is another way to achieve this? All advice welcome.

Unwanted effect - mobile
[Image: mobile.jpg]

Expected effect - pc
[Image: image.jpg]

For test i modified Rendering/01 tutorial:
Code:
ImagePtr billboard;

void Render() // Rendering Function
{
   switch(Renderer())
   {
      case RM_BLEND:
      {
         D.depthLock(false);
         billboard->draw3D(Color(), 1.35, 0, MatrixIdentity.pos);
         D.depthLock(true);  
              
      }break;
      
      case RM_PREPARE:
      {
         if(Frustum(mesh.box))mesh.draw(MatrixIdentity);
      }break;
   }
}
(This post was last modified: 09-20-2016 04:44 AM by Mardok.)
09-17-2016 02:09 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Billboard draw3D rendering order
Can you attach a zipped esenthelproject of this app?
I will test what's wrong.

Also: why are you setting an invalid color parameter?
"Color()"
Try using WHITE, maybe that's the problem
09-17-2016 02:28 AM
Find all posts by this user Quote this message in a reply
Mardok Offline
Member

Post: #3
RE: Billboard draw3D rendering order
OK, check this.

Color WHITE == just BLACK square on mobile, on PC is OK.


Attached File(s)
.7z  Billboard.7z (Size: 640.53 KB / Downloads: 10)
(This post was last modified: 09-17-2016 02:41 AM by Mardok.)
09-17-2016 02:40 AM
Find all posts by this user Quote this message in a reply
Tottel Offline
Member

Post: #4
RE: Billboard draw3D rendering order
Just an idea, but your billboard texture is not a power of two. I don't know how much that would matter, but you can try enabling "power of 2" in the texture.
09-17-2016 08:37 AM
Find all posts by this user Quote this message in a reply
Mardok Offline
Member

Post: #5
RE: Billboard draw3D rendering order
Yes you are right Tottel. The image should be 64x64. I made a mistake when exporting frame to png. It wasnt a problem for PC GPU and i was sure that evrything is ok with texture.

TY guys for your time. Have a nice day
09-17-2016 12:50 PM
Find all posts by this user Quote this message in a reply
Mardok Offline
Member

Post: #6
RE: [FIXED] Billboard draw3D rendering order
UPDATE

Hello Guys, i need some help, tips or explanation one more time.

Is there some depth sorting method for rendering billboards via Image::draw3D? Something like BlendObject::scheduleDrawBlend(Vec &pos) for mesh parts or something like D.textDepth but for Image::draw3D?

Im experimenting with 3D objects + 2D sprite animations and i have no idea how i can get better control what and when is rendered.

The following pictures shows the problem.
Is there any solution to render billboard (RM_BLEND) with position same as mesh in the background but covered by mesh in the foreground?

[Image: image.jpg]

[Image: image.jpg]
09-18-2016 07:51 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #7
RE: [OPEN] Billboard draw3D rendering order
well you're disabling depth buffer usage, so you need to remove your lines:
D.depthLock(false);
D.depthLock(true);
09-19-2016 12:01 AM
Find all posts by this user Quote this message in a reply
Mardok Offline
Member

Post: #8
RE: [OPEN] Billboard draw3D rendering order
(09-19-2016 12:01 AM)Esenthel Wrote:  well you're disabling depth buffer usage, so you need to remove your lines:
D.depthLock(false);
D.depthLock(true);
Hmm i try better visualise the problem.

Try imagine if we have game where we control 3D sphere mesh + sometimes we want render effects based on sprites rendered as billboards in RM_BLEND mode. So we expecting our billboard cover our BALL mesh but other 3D buildings shoud cover our billboard, how achieve this?
[Image: image.jpg]
[Image: image.jpg]



Without any depthBuffer lock operations rendering look like this, i know its correct but im asking about situation when sprite cover only our ball not other 3D objects.
[Image: image.jpg]

Im expecting result like this below:
[Image: image.jpg]
09-19-2016 01:39 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #9
RE: [OPEN] Billboard draw3D rendering order
You can draw sprite moved towards the camera by distance equal to "radius" of the mesh sphere.
09-20-2016 12:14 AM
Find all posts by this user Quote this message in a reply
Mardok Offline
Member

Post: #10
RE: [OPEN] Billboard draw3D rendering order
Yes i'm using this method to achieve expected result. I made this thread cuz i thought there is some different method. Ty for clarification.
09-20-2016 04:43 AM
Find all posts by this user Quote this message in a reply
Post Reply