Disable antialias on Render to texture
Disable antialias on Render to texture
This must be a dumb question, but how on earth can antialias be disabled on a render to texture?
I have a render target, deviceex was used with antialias disabled, but as soon as I render to the texture the antialias is being done!
I set a material with alias disabled, no change.
I stepped through drawall and turned off alias in the materials... no change.
I must have missed something really dumb, but what?
I have a render target, deviceex was used with antialias disabled, but as soon as I render to the texture the antialias is being done!
I set a material with alias disabled, no change.
I stepped through drawall and turned off alias in the materials... no change.
I must have missed something really dumb, but what?
Re: Disable antialias on Render to texture
Stepped through the Irrlicht driver and antialias is off, I guess there is aa for the 3D drawing, and for textures.
Stepped through AddRenderTarget and it calls D3D9 CreateTexture, but no params to disable multisampling.
Any idea what I missed...so that rendering to a texture has no antialias?
Ideally I´d like to do multiple renders to the same texture, some with, some without antialias.
Any help much appreciated
Stepped through AddRenderTarget and it calls D3D9 CreateTexture, but no params to disable multisampling.
Any idea what I missed...so that rendering to a texture has no antialias?
Ideally I´d like to do multiple renders to the same texture, some with, some without antialias.
Any help much appreciated
Re: Disable antialias on Render to texture
Could it be this?
by BlindSide » Sat Jun 13, 2009 6:10 pm
We're still not turning off AA for 2D drawing? All that's needed is to add "pID3DDevice->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, FALSE);" to setRenderStates2DMode() (Preferably inside the "if (CurrentRenderMode != ERM_2D)" condition).
Its not in setRenderStates2DMode() yet...
Can´t be???
by BlindSide » Sat Jun 13, 2009 6:10 pm
We're still not turning off AA for 2D drawing? All that's needed is to add "pID3DDevice->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, FALSE);" to setRenderStates2DMode() (Preferably inside the "if (CurrentRenderMode != ERM_2D)" condition).
Its not in setRenderStates2DMode() yet...
Can´t be???
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Re: Disable antialias on Render to texture
So how do you render the textures, and are you sure that it's AA and not just bilinear filters? For 2D drawing, you could disable AA with the 2d override material, in case it is enabled by default.
Re: Disable antialias on Render to texture
I create a texture using AddRenderTargetTexture, then setrender, and call drawAll as per the code below.
Would bilinear on 2D (the default) cause the 3-level AA I´m getting in the texture?, and if so, with the same settings it doesn´t AA when the target is the FB.
I thought maybe I am missing some step with the texture setup....???
I must be missing something real simple....
Would bilinear on 2D (the default) cause the 3-level AA I´m getting in the texture?, and if so, with the same settings it doesn´t AA when the target is the FB.
I thought maybe I am missing some step with the texture setup....???
Code: Select all
// Alias in createdeviceex is off
m_pDriver->setViewPort( topright );
video:SMaterial material;
material.AntiAliasing = EAAM_OFF;
m_pSmgr->setMaterial(material);
m_pSmgr->enableMaterial2D();
m_pSmgr->drawAll( 0x01 | 0x010 ); // TOP-RIGHT QUADRANT : DRAW scene to our texture
m_pDriver->setViewPort( botright );
m_pSmgr->drawAll( 0x01 | 0x010 ); // BOTTOM-RIGHT QUADRANT : DRAW scene to our texture
// Scene has now been rendered to the texture, but although AA is off on the main FB, now the scene has been aliased!!! (how to disable???)
{
m_pDriver->setRenderTarget( 0, false, true ); // Now render quad to framebuffer using texture containing scene
scene::SMeshBuffer mb;
mb.Indices.set_used (6);
mb.Indices[0] = 0;
mb.Indices[1] = 1;
mb.Indices[2] = 2;
mb.Indices[3] = 0;
mb.Indices[4] = 2;
mb.Indices[5] = 3;
const video::SColor white(255, 255, 255, 255);
mb.Vertices.set_used (4);
mb.Vertices[0].Pos.set (-1.f, -1.f, 1.f);
mb.Vertices[0].TCoords.set(0.0f, 1.0f);
mb.Vertices[0].Color = white;
mb.Vertices[1].Pos.set (-1.f, 1.f, 1.f);
mb.Vertices[1].TCoords.set(0.0f, 0.0f);
mb.Vertices[1].Color = white;
mb.Vertices[2].Pos.set (1.f, 1.f, 1.f);
mb.Vertices[2].TCoords.set(1.0f, 0.0f);
mb.Vertices[2].Color = white;
mb.Vertices[3].Pos.set (1.f, -1.f, 1.f);
mb.Vertices[3].TCoords.set(1.0f, 1.0f);
mb.Vertices[3].Color = white;
const core::matrix4 identity;
video::SMaterial material;
material.setTexture(0, m_pPlusTexture);
material.Lighting = false;
material.MaterialType = EMT_SOLID;
m_pDriver->setTransform(video::ETS_WORLD, identity);
m_pDriver->setTransform(video::ETS_VIEW, identity);
m_pDriver->setTransform(video::ETS_PROJECTION, identity);
m_pDriver->setMaterial(material);
m_pDriver->drawMeshBuffer(&mb); // Render Quad
}
Last edited by robmar on Wed Jul 02, 2014 10:52 am, edited 1 time in total.
Re: Disable antialias on Render to texture
I just tried with enableMaterial2D(false) after the drawAll, and set the quad texture´s shader to EMT_SOLID, and the AA was then disabled, but also the cube was culled and the setViewPort did not work anymore!
I disabled BackfaceCulling, but the cube stayed culled when using enablematerial2D().
But if I enable my shader the AA comes back along with correct culling and setviewport works again.
Why is this happening?
I´m using 1.7.3.
I disabled BackfaceCulling, but the cube stayed culled when using enablematerial2D().
But if I enable my shader the AA comes back along with correct culling and setviewport works again.
Why is this happening?
I´m using 1.7.3.
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Re: Disable antialias on Render to texture
drawAll without beginScene and endScene could be problematic. 2d Material does not affect drawAll calls, which are all 3d (at least from setup point of view). 1.7.x is quite outdated and hard to assess which things have been fixed already.
Re: Disable antialias on Render to texture
There is a beginscene and endscene before and after this code, I just didn´t show it.
I´ve found that by clearing the bilinear flag and calling setMaterial just before drawing the quad´s mesh buffer, the "antialising" becomes disabled on the previous drawAll´s done to each viewport, which is very strange.
I draw the scenes to each viewpoint (4 of them) with the bilinear filtering re-enabled prior to two of the draws, bilinear is then disabled for the other two viewports.
What I don´t understand is that once I turn bilinear off for the quad mesh draw, it can´t be re-enabled for the drawall´s to the quad´s texture.
Bilinear seems to get permanently disabled on 3D drawing.
I´ve found that by clearing the bilinear flag and calling setMaterial just before drawing the quad´s mesh buffer, the "antialising" becomes disabled on the previous drawAll´s done to each viewport, which is very strange.
I draw the scenes to each viewpoint (4 of them) with the bilinear filtering re-enabled prior to two of the draws, bilinear is then disabled for the other two viewports.
What I don´t understand is that once I turn bilinear off for the quad mesh draw, it can´t be re-enabled for the drawall´s to the quad´s texture.
Bilinear seems to get permanently disabled on 3D drawing.
Re: Disable antialias on Render to texture
What I´m trying to achieve is:-
1. Render the scene to one texture 4 times, top-left, right, bottom viewports.
2. On the top two viewport areas, render with aliasing, on the lower two without.
3. Display the texture fullscreen using the quad.
RT textures don´t support aliasing, but the bilinear filter seems to work, the problem is that I can´t seem to enable it selectively.
1. Render the scene to one texture 4 times, top-left, right, bottom viewports.
2. On the top two viewport areas, render with aliasing, on the lower two without.
3. Display the texture fullscreen using the quad.
RT textures don´t support aliasing, but the bilinear filter seems to work, the problem is that I can´t seem to enable it selectively.
Re: Disable antialias on Render to texture
So.... the bilinear filter set on a texture, it affects the sampling of that texture by the shader?
So that if the texture had no antialiasing, the sampling process (tex2d etc) would then filter the pixels read using the bilinear filter?
I had thought that the material filters worked on writing to the texture, not reading from it...
I mean I know that Linear, Point etc can be specified for the shader sampler, and effect sampling,.... its all so complicated for my small brain!
So that if the texture had no antialiasing, the sampling process (tex2d etc) would then filter the pixels read using the bilinear filter?
I had thought that the material filters worked on writing to the texture, not reading from it...
I mean I know that Linear, Point etc can be specified for the shader sampler, and effect sampling,.... its all so complicated for my small brain!
Re: Disable antialias on Render to texture
Okay I have this problem corned now!
The rendering to the texture is correct and without aliasing or bilinear filtering.
However, when the texture gets rendered to the full-screen quad, if I didn´t call driver->setMaterial(material) with EMF_BILINEAR_FILTER set to false, the texture renders with bilinear filtering.
I don´t understand why this happens because my shader sets :-
texture qtex;
sampler2D tex = sampler_state
{
MinFilter = Point;
MagFilter = Point;
}
Its as if the texture sampler state gets ignored, cos if I disable bilinear with the setMaterial call, then I can´t use it in the shader.
I have to use two textures to shade the quad, one needs no filtering, the other needs bilinear, but at the moment, I´m unable to control the filter usage.
Is Irrlicht overriding this with a call to SetSamplerState somewhere?
Any ideas?
The rendering to the texture is correct and without aliasing or bilinear filtering.
However, when the texture gets rendered to the full-screen quad, if I didn´t call driver->setMaterial(material) with EMF_BILINEAR_FILTER set to false, the texture renders with bilinear filtering.
I don´t understand why this happens because my shader sets :-
texture qtex;
sampler2D tex = sampler_state
{
MinFilter = Point;
MagFilter = Point;
}
Its as if the texture sampler state gets ignored, cos if I disable bilinear with the setMaterial call, then I can´t use it in the shader.
I have to use two textures to shade the quad, one needs no filtering, the other needs bilinear, but at the moment, I´m unable to control the filter usage.
Is Irrlicht overriding this with a call to SetSamplerState somewhere?
Any ideas?