Sprites renderer again...
Sprites renderer again...
Hello for all! I'm writing client for online game and have a problem.
As it is on screenshot ONE frame consists of many images. If i at first render images to texture and then do billboard->setTexture(), then it have very, very poor perfomance. Because it's also need to rescale/rotate "basic" images. What can i do? I think there is way with matrixes when i set it, then draw basic image and so on.
As it is on screenshot ONE frame consists of many images. If i at first render images to texture and then do billboard->setTexture(), then it have very, very poor perfomance. Because it's also need to rescale/rotate "basic" images. What can i do? I think there is way with matrixes when i set it, then draw basic image and so on.
Last edited by Randajad on Mon Sep 10, 2012 12:44 pm, edited 1 time in total.
Sorry for my English, i'm from Russia.
If i makes mistakes in phrases you can correct me btw. ^_^
If i makes mistakes in phrases you can correct me btw. ^_^
Re: Sprites renderer again...
Oh, i forgot main question. Is it possible to disable z-buffer when one is rendering to draw one pixcure on another?
Sorry for my English, i'm from Russia.
If i makes mistakes in phrases you can correct me btw. ^_^
If i makes mistakes in phrases you can correct me btw. ^_^
Re: Sprites renderer again...
Maybe use a url for your image tag - seems the forum doesn't like the redirection on that server (or use imgur that usually works well).
You can affect z-buffer by setting a material. Values to affect it are SMaterial::ZBuffer and SMaterial:: ZWriteEnable. See http://irrlicht.sourceforge.net/docu/cl ... erial.html
Not sure if I got the other part of your question. The part of the texture used is affected by uv-coordinates for each vertex. Rotation can be done by setting a texture-matrix for the corresponding TextureLayer in your material: http://irrlicht.sourceforge.net/docu/cl ... layer.html
Hope that helps, otherwise just ask again :-)
You can affect z-buffer by setting a material. Values to affect it are SMaterial::ZBuffer and SMaterial:: ZWriteEnable. See http://irrlicht.sourceforge.net/docu/cl ... erial.html
Not sure if I got the other part of your question. The part of the texture used is affected by uv-coordinates for each vertex. Rotation can be done by setting a texture-matrix for the corresponding TextureLayer in your material: http://irrlicht.sourceforge.net/docu/cl ... layer.html
Hope that helps, otherwise just ask again :-)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Sprites renderer again...
Sorry, too many mistakes in my post above. I don't know how i wrote it.
I'm reupload image.
So. I had animation which consists of many frames. Each frame consists of "basic" images. Basic image have position, scale and rotate. I need to show frames. How i can render it better?
I try to make final frame by drawing basic images on iimage and creting itexture, then set this texture to billboard. But it's have poor perfomance. I think there is way to draw right basics images on screen and when node is rendering, disable zbuffer to draw one picture on another. Is there?
I'm reupload image.
So. I had animation which consists of many frames. Each frame consists of "basic" images. Basic image have position, scale and rotate. I need to show frames. How i can render it better?
I try to make final frame by drawing basic images on iimage and creting itexture, then set this texture to billboard. But it's have poor perfomance. I think there is way to draw right basics images on screen and when node is rendering, disable zbuffer to draw one picture on another. Is there?
Last edited by Randajad on Mon Sep 10, 2012 1:44 pm, edited 1 time in total.
Sorry for my English, i'm from Russia.
If i makes mistakes in phrases you can correct me btw. ^_^
If i makes mistakes in phrases you can correct me btw. ^_^
Re: Sprites renderer again...
Hm, first question - do you really need a billboard? Billboard is for putting an image in 3D ... this looks on first view like something you could do with 2d.
And if that would be sufficient you could use IVideoDriver 2d drawing functions. For rotation - please search around the forum for image rotation, I think there had been some solutions. I'm not certain on how I would do that myself, I guess I would try setting the world-matrix to some rotation matrix before using 2d drawing functions, but don't know if this works as I didn't try. Disabling zbuffer can be done as mentioned above by setting an SMaterial with ZBuffer and ZWriteEnable to whatever you need. And then use IVideoDriver::setMaterial before calling your draw functions.
And if that would be sufficient you could use IVideoDriver 2d drawing functions. For rotation - please search around the forum for image rotation, I think there had been some solutions. I'm not certain on how I would do that myself, I guess I would try setting the world-matrix to some rotation matrix before using 2d drawing functions, but don't know if this works as I didn't try. Disabling zbuffer can be done as mentioned above by setting an SMaterial with ZBuffer and ZWriteEnable to whatever you need. And then use IVideoDriver::setMaterial before calling your draw functions.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Sprites renderer again...
Yes, i have 3d world with 2d sprites.
I think ZWriteEnable used only to render transparent objects, isn't it? I only need to avoid z-fightering.
I think ZWriteEnable used only to render transparent objects, isn't it? I only need to avoid z-fightering.
Sorry for my English, i'm from Russia.
If i makes mistakes in phrases you can correct me btw. ^_^
If i makes mistakes in phrases you can correct me btw. ^_^
Re: Sprites renderer again...
maybe a draw3DSpriteBatch could be a nice addition to the video driver? or anything that did something similar to drawing a large amount of billboards, each of them with a custom texture fragment that could change on a per call basis.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Re: Sprites renderer again...
@ Randajad, no those flags are not only for transparency, transparency just also needs them. But you probably need to set ZBuffer and not ZWriteEnable in your case. And I suspect you have to set it to irr::video::ECFN_ALWAYS which sounds like write always to me.
@Mel: Yeah, I had hoped spritebanks would be extended to have more sprite functions one day. But not sure right now if Bitplane will ever get back to working on those... he's been a little quite lately :-(
@Mel: Yeah, I had hoped spritebanks would be extended to have more sprite functions one day. But not sure right now if Bitplane will ever get back to working on those... he's been a little quite lately :-(
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Sprites renderer again...
You may also try combining the sprites into a large image and changing the texture matrix of the billboard instead.
Regards,
smso
Code: Select all
while (device->run())
if (device->isWindowActive())
{
core::matrix4 mat;
//buildTextureTransform(f32 rotateRad, const core::vector2df &rotatecenter, const core::vector2df &translate, const core::vector2df &scale)
mat.buildTextureTransform(...);
billboard->getMaterial(0).setTextureMatrix(0, mat);
driver->beginScene(true, true, 0);
smgr->drawAll();
driver->endScene();
}
else { device->yield(); }
smso
Re: Sprites renderer again...
Thanks very mush for this help, guys! It works, but i have another problem.
I'm only disable ZWriteEnable on the material and it's have effect that i expected.
But then i have trouble with object overlap.
Two screens:
I'm only disable ZWriteEnable on the material and it's have effect that i expected.
But then i have trouble with object overlap.
Two screens:
Sorry for my English, i'm from Russia.
If i makes mistakes in phrases you can correct me btw. ^_^
If i makes mistakes in phrases you can correct me btw. ^_^
Re: Sprites renderer again...
Bump!
Sorry for my English, i'm from Russia.
If i makes mistakes in phrases you can correct me btw. ^_^
If i makes mistakes in phrases you can correct me btw. ^_^
Re: Sprites renderer again...
I'm not certain from this shots what the problem is. Should there be a full person above the shoes which is overlapped by the castle? Is the castle 3d or another sprite? If it is another sprite - what about the gras - is that the same sprite as the castle?
You must be a little more talkative - we don't see/know what's going on except for what you describe :-)
You must be a little more talkative - we don't see/know what's going on except for what you describe :-)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Sprites renderer again...
That's what's supposed to happen if you disable the Z buffer...
By doing that you're saying "I will handle the draw order myself".
By doing that you're saying "I will handle the draw order myself".
Re: Sprites renderer again...
All world is 3d. Characters are sprites.
So, i think, then there is no way to resolve zbuffer trouble. Okay, i will try to find another way to do what i need.
So, i think, then there is no way to resolve zbuffer trouble. Okay, i will try to find another way to do what i need.
Sorry for my English, i'm from Russia.
If i makes mistakes in phrases you can correct me btw. ^_^
If i makes mistakes in phrases you can correct me btw. ^_^
Re: Sprites renderer again...
Just don't disable the ZWrite, and use the Alpha Channel Ref. for Sprites, it can be the best solution.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt