Page 1 of 1
OGLES1 branch - Antialiasing not working
Posted: Fri Apr 22, 2011 2:38 pm
by [ghost]
Hi ,
can anybody help me to make antialising work on OGLES1 branch,
I render few 2D images usoing rotation and scale and seems that the antialising doesn't work even I set the required flags. Tha
Code: Select all
getVideoDriver()->getMaterial2D().AntiAliasing = video::EAAM_FULL_BASIC;
getVideoDriver()->getMaterial2D().TextureLayer[0].BilinearFilter = true;
[/code]
Posted: Fri Apr 22, 2011 2:39 pm
by ChaiRuiPeng
what is the surrounding code?
for some reason i experienced similar problem setting built in material flags

seems like i needed to do it in a certain order when building custom meshes or else the flags wouldn't "reigster"
Posted: Fri Apr 22, 2011 3:13 pm
by [ghost]
This is the code that render the scaled image
Code: Select all
getVideoDriver()->enableMaterial2D();
getVideoDriver()->getMaterial2D().AntiAliasing = video::EAAM_FULL_BASIC;
getVideoDriver()->getMaterial2D().TextureLayer[0].BilinearFilter = true;
matrix4 newTransform(getVideoDriver()->getTransform(ETS_WORLD));
newTransform.setScale(0.7f);
newTransf.setRotationDegrees(45);
newTransf.setRotationCenter(center,irr::core::vector3df(0,0,0));
getVideoDriver()->setTransform(ETS_WORLD,newTransform);
getVideoDriver()->draw2DImage(m_texture,dest,src,NULL,col,true);
.....
Posted: Fri Apr 22, 2011 3:16 pm
by ChaiRuiPeng
is m_texture on the correct layer?
Posted: Fri Apr 22, 2011 3:23 pm
by [ghost]
I suppose it is, m_texture renderes fine with antialising on PC with opengl.
Posted: Fri Apr 22, 2011 3:27 pm
by ChaiRuiPeng
hm...
got any screenshots?
Posted: Fri Apr 22, 2011 7:42 pm
by [ghost]
I don't have any screenshots ,I'll make few monday, but I'm sure that the antialising is the problem and think this issue is only for 2D rendering,I saw they reset many settings when switching to 2D render mode.tha
Posted: Fri Apr 22, 2011 9:51 pm
by hybrid
You seem to use an altered Irrlicht verson. At least we usually reset the transformation matrix in 2d rendering, so it wouldn't help anything here. Moreover, using anti-aliasing requires the device to support anti-aliasing upon creation already. Make sure you use the proper flags and check if anti-aliasing is enabled. Not sure if 2d material is supported in ogl-es. Try to check those settings in 3d rendering with usualy materials first.
Posted: Sat Apr 23, 2011 5:19 pm
by [ghost]
- I use a irrlicht ogles version altered just a bit to allow matrix transforms on 2D(I post on forum those small changes also)
- Iphone/ipad supports anti-aliasing and also I set Antialising true when create the IrrlichtDevice
- if 2D material is not supported for ogles then I made a very bad choice using irrlicht as start point for my application,but I can't believe that is true.
- I'll try to see if it works for 3d rendering,thanks
Posted: Sun Apr 24, 2011 1:12 pm
by hybrid
The thing is that changes to the OpenGL driver will only slowly merge into the ogl-es driver. Since the two drivers are closely related, but don't derive from each other, some code mergaing has to happen. And since the branch has only low priority, these merges are only happening very seldomly. So you won't see all new features of Irrlicht in the branches (i.e. ogl-es) immediately. Which does not mean that they won't appear in the future. You can even submit patches to get a faster update of the branch. But hey, that's up to you.
Posted: Mon Apr 25, 2011 12:48 pm
by darkphoenix16
Hey, I'm using the ogles branch (stock) and AA works using the GLES1 driver.
Posted: Thu Apr 28, 2011 12:28 pm
by [ghost]
Definitely not for 2D rendering.
AntiAliasing for 2D image render fix
Posted: Sun May 22, 2011 2:13 pm
by [ghost]
Below the updated code for setRenderStatesMode() to have AA functional on 2d image rendering, this is a copy/paste sample from opengl driver that works fine for opengles.
Code: Select all
void COGLES1Driver::setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel)
{
if (CurrentRenderMode != ERM_2D || Transformation3DChanged)
{
// unset last 3d material
if (CurrentRenderMode == ERM_3D)
{
if (static_cast<u32>(LastMaterial.MaterialType) < MaterialRenderers.size())
MaterialRenderers[LastMaterial.MaterialType].Renderer->OnUnsetMaterial();
}
if (Transformation3DChanged)
{
glMatrixMode(GL_PROJECTION);
const core::dimension2d<u32>& renderTargetSize = getCurrentRenderTargetSize();
core::matrix4 m;
m.buildProjectionMatrixOrthoLH(f32(renderTargetSize.Width), f32(-(s32)(renderTargetSize.Height)), -1.0, 1.0);
m.setTranslation(core::vector3df(-1,1,0));
glLoadMatrixf(m.pointer());
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.375, 0.375, 0.0);
glLoadMatrixf(Matrices[ETS_WORLD].pointer());
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
Transformation3DChanged = false;
}
if (!OverrideMaterial2DEnabled)
{
setBasicRenderStates(InitMaterial2D, LastMaterial, true);
LastMaterial = InitMaterial2D;
}
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
if (OverrideMaterial2DEnabled)
{
OverrideMaterial2D.Lighting=false;
OverrideMaterial2D.ZBuffer=ECFN_NEVER;
OverrideMaterial2D.ZWriteEnable=false;
setBasicRenderStates(OverrideMaterial2D, LastMaterial, false);
LastMaterial = OverrideMaterial2D;
}
if (alphaChannel || alpha)
{
glEnable(GL_BLEND);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.f);
}
else
{
glDisable(GL_BLEND);
glDisable(GL_ALPHA_TEST);
}
if (texture)
{
if (!OverrideMaterial2DEnabled)
{
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
}
if (alphaChannel)
{
// if alpha and alpha texture just modulate, otherwise use only the alpha channel
if (alpha)
................
Posted: Sun May 22, 2011 8:29 pm
by hybrid
Ok, applied a patch. Hope it works now, else report here.