About Store Forum Documentation Contact



Post Reply 
Stacked Object Draw Priority
Author Message
SamNainocard Offline
Member

Post: #1
Stacked Object Draw Priority
I have a problem of stacking blend/blend light object which tend to draw on top of each other on certain angle.

As seen on this video.





I would like to have Crystal to always draw inside Barrier, but when changing angle (yaw or pitch) sometimes Crystal will draw on top of Barrier.
Crystal and Barrier are different object but same position.
Also, is there a way to blend/blend light draw underwater when look from above water?
09-17-2015 04:51 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Stacked Object Draw Priority
Hi,

You could use 'BlendObject' and its method 'scheduleDrawBlend', depending on the 'pos' that you specify there, if will affect the object depth sorting.
09-19-2015 09:08 AM
Find all posts by this user Quote this message in a reply
SamNainocard Offline
Member

Post: #3
RE: Stacked Object Draw Priority
Sorry, but I extended object with 'BlendObject' and called 'scheduleDrawBlend(pos())' inside my drawPrepare(), with or without specified to one object but this doesn't seem to work, am I missing something?

Code:
virtual uint drawPrepare () {scheduleDrawBlend(pos()); super.drawPrepare(); return 0;}
virtual uint drawPrepare ()
{
   if(id()==BarrierObjectID) scheduleDrawBlend(pos());
   super.drawPrepare(); return 0;
}

virtual void drawBlend   () {particles.draw();}

Thank you in advanced. smile
09-19-2015 01:36 PM
Find all posts by this user Quote this message in a reply
Tottel Offline
Member

Post: #4
RE: Stacked Object Draw Priority
Not sure about the actual issue, but you should probably return super.drawPrepare()
09-19-2015 02:14 PM
Find all posts by this user Quote this message in a reply
SamNainocard Offline
Member

Post: #5
RE: Stacked Object Draw Priority
Changed my code to return super.drawPrepare(), still not working, however I'll do this from now on. smile
09-20-2015 02:18 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: Stacked Object Draw Priority
Hi,

Can you verify that:
1) scheduleDrawBlend(pos()); actually gets called?
2) 'drawBlend' actually gets called?
3) Are your particles created in blend or palette mode?
you can check particles.renderMode()==RM_BLEND

Maybe this is an issue of name conflicts, because both Game.Obj and BlendObject have
virtual void drawBlend() {}

so if you're overriding this, maybe only Game.Obj.drawBlend is overriden, but not BlendObject.drawBlend, not sure how C++ works in this case.
09-21-2015 10:20 AM
Find all posts by this user Quote this message in a reply
SamNainocard Offline
Member

Post: #7
RE: Stacked Object Draw Priority
Particles are blend mode.
I think 'scheduleDrawBlend(pos());' actually get called, as I added Log() into drawBlend() and check log output.
Code:
class OBJ: Game::Kinematic,  BlendObject
{
   virtual uint drawPrepare () {scheduleDrawBlend(pos()); return super.drawPrepare();}
   virtual void drawBlend   () {Log("SDFSDF"); particles.draw();}
}

I also test a bit with particles.renderMode()==RM_BLEND for possible palette particle mode.

Code:
virtual uint drawPrepare()
{
   if(inter.particles.renderMode()==RM_BLEND) scheduleDrawBlend(pos());
   return super::drawPrepare() | (inter.particles.renderMode()==RM_BLEND ? 0 : IndexToFlag(inter.particles.renderMode()));
}
also test drawBlend() with 'Game.Kinematic.drawBlend();' just in case
Code:
virtual void drawBlend() {Log("SDFSDF"); Game.Kinematic.drawBlend(); particles.draw();}

However nothing seems to work, Barrier object still sometimes draw over Crystal or vice versa, not sure about particle has to do with this but I temporary remove it from code it's still same.

By the way, I think I forget to mention that, these 2 objects are extended from Kinematic, create exactly at same position and are using only blend or blend light material mode. smile
(This post was last modified: 09-23-2015 03:10 AM by SamNainocard.)
09-23-2015 03:10 AM
Find all posts by this user Quote this message in a reply
SamNainocard Offline
Member

Post: #8
RE: Stacked Object Draw Priority
I able to solve this by removing 'super::drawPrepare()' and instead only use scheduleDrawBlend() with specified position based on camera matrix, which I force Barrier to always draw first.

Something like...
Code:
virtual uint drawPrepare()
{
   if('Barrier') scheduleDrawBlend(pos()-Cam.matrix.z*Dist(pos(), Cam.matrix.pos));
   else          scheduleDrawBlend(pos());
   return (particles.renderMode()==RM_BLEND ? 0 : IndexToFlag(particles.renderMode()));
}
10-26-2015 11:57 AM
Find all posts by this user Quote this message in a reply
Post Reply