Depth sorting + Blending Mode issues

danielmorena's picture

Dear friends at the forum,

I just create a plugin which upload/renders textures directly by sharing it's name. The ideia is to speed up the render, and the results so far has been promising. But now, i'm stucked in what i thought it will be simple: the blending (replace,over,add,alpha) / depth (none,read/write,read only) implementation. My goal is to implement the same behaviour as the native Sprite, and as the attached project can show, the behaviours i'm getting are very strange and inconsistent...

Any help will be appreciated :)

PreviewAttachmentSize
MTTexture.zip2.49 MB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

gtoledo3's picture
Re: Depth sorting + Blending Mode issues

I don't know if it's the only reason the depth testing looks wrong (didn't compile the plugin), but the depth testing code is just a little mixed up. It should be something like

if(self.inputDepthMode == 0)
         glDisable(GL_DEPTH_TEST);
      else if(self.inputDepthMode == 1)
      {
         glEnable(GL_DEPTH_TEST);
         glDepthFunc(GL_LEQUAL);
         glDepthMask(GL_TRUE);
      }
      else
      {
         glEnable(GL_DEPTH_TEST);
         glDepthMask(GL_FALSE);
      }  
 

gtoledo3's picture
Re: Depth sorting + Blending Mode issues

It looks like you're probably going to want to put in something to control face culling as well.

Cool idea.

danielmorena's picture
Re: Depth sorting + Blending Mode issues

hmmm.... i just tried it... didn't work... i really don't know what's seems to be the problem, i know it's possible because the native Sprite renders all combinations perfectly. I don't know if this helps but, everything looks worst when i try different combinations of blend + depth.... sometimes, everything just slowly erases overtime....

thanks for the help anyway!

gtoledo3's picture
Re: Depth sorting + Blending Mode issues

My point is, that's what it's supposed to be. Keep it like that and look for errors elsewhere...I notice it looks like you aren't unlocking the context you setup earlier in that patch. Maybe there needs to be glDeleteTextures going on in your stop execution method on the one patch, or maybe on the sprite patch... it looks like you're binding textures after popping the matrix, but they never get deleted. Not sure, haven't really looked through the full project line per line or anything. Sorry to give a bunch of "maybe it's this", but it does look like going through it with a fine tooth comb will get it working how you expect.

danielmorena's picture
Re: Depth sorting + Blending Mode issues

Sure, i got that. And i think it's a line, or an order of commands it's wrong, but i'm really new in the openGL world. But let me clarify one thing, and (i don't know) maybe that's the problem. The texture will not be deallocated at the end of MTTextureSprite. The main point of the plugin, is to load an image or a image with string in the other patches (MTTexture, MTTextureType) classes and then hold it as long as the composition is running (or when the purge port is true). In that way the sprite does not pull the image buffer from a input port, it just reference the texture name directly, as told by inputTextureName port, speeding the rendering process (as my tests has proved so far). What do you think?

Anyway, I will post the plugin here, when finished (and working!), MIT licensed.