turning off texture smoothing alternativa3d 8

Posted by davidejones

Now that alternativa3d has been released as opensource and is available online at github, this opens up the opportunities for developers to try some great things with the technology and hopefully contribute to its development.

The first thing that bugged me with version 8 is that I couldn’t turn off the smoothing of images. In version 7 you could easily do this by setting material.smooth to false and get that pixelated look. So I thought now the source is released I’d put together a little example of how to get this same effect.

To create this I duplicated the TextureMaterial class from the alternativa source code and made my own PixelTextureMaterial.

In this class there are 2 constants that contain AGAL code that is for the diffuse and diffuse with alpha rendering. If you aren’t familar with AGAL, I guess it can be described as sort of gpu assembly code. Anyway there is a line in the AGAL code that begins with “tex” and then has some various registers and flag options.

Here is an example of code

tex t0, v0, s0 <2d, linear,linear,miplinear>

The flag options between the arrows are what we are interested in, these options represent this data


The texture dimension can be : 2d, cube
The texture mipmapping can be : nomip, mipnone, mipnearest, miplinear
The texture filtering can be : nearest, linear
The texture repeat can be : repeat, wrap, clamp

The texture filtering is responsible for the way our image is sampled and the current TextureMaterial is set to use linear filtering, if we change this to say nearest we can get that pixelated look we want.

Here is what my changed code looks like, you can of course alter the other flag options to remove mipmapping or change the repeat etc if you desire. The full source code is available here or see the demo here.

static alternativa3d const getDiffuseProcedure:Procedure = new Procedure([
	"tex t0, v0, s0 <2d, linear,nearest, miplinear>",
	"mul t0.w, t0.w, c0.w",
	"mov o0, t0"
], "getDiffuseProcedure");

static alternativa3d const getDiffuseOpacityProcedure:Procedure = new Procedure([
	"tex t0, v0, s0 <2d, linear,nearest, miplinear>",
	"tex t1, v0, s1 <2d, linear,nearest, miplinear>",
	"mul t0.w, t1.x, c0.w",
	"mov o0, t0"
], "getDiffuseOpacityProcedure");

Trackback URL for this post: http://davidejones.com/blog/1376-turning-texture-smoothing-alternativa3d-8/trackback/

Being Sociable...

  • If you like this article then please share it on your favourite social network and follow me on twitter for the latest updates

17 Responses to turning off texture smoothing alternativa3d 8


Hmm I hadn’t noticed that but you are right. Its doing 2 draw calls when showing pixelated. It might be the way I wrote the material, at the time i used some outProcedure.compileFromArray method to change things depending on the smoothing option. Perhaps its causing it to call the agal twice?

Basically if you take the texturematerial source code from github and replace 2d, linear,nearest, miplinear with 2d,nearest,clip,mipnone it should do the same and perhaps without doubling the faces.

Maybe i can post an updated version, i’ve learnt alot since i first made this minor change

    @davidejones yeah, you’re right, i did that replacement and it removes the smoothness without redrawing triangles.
    Hey, you know what would be cool? A “Fog” tutorial. I’m trying to create fog and so far, the only solution i could find (i dont know almost anything about coding shaders…) is to create several semi-transparent planes in front of the camera in layers… like an old Playstation game.

    Im guessing that a shader could do that much better?


Hi, I’m just getting started with flash and using alternativa3d for iOS games. How did you get you lines/edges in the box to be so smooth? Mine are really jagged and drawing primitives from alternative for dummies part 1


    do you mean the edges of the box? the primitive box?
    It just works like that for me. It could be some of your settings like the flash player you are targeting and maybe the stage quality setting


Not really sure what you mean the quality works great for me and as good as away3d.
Email me your code you are working with and i’ll see if i can see anything wrong with it.


I get an incompatable override error on both canDrawInShadowMap and collectDraws in PixelTextureMaterial.as. I am using the exact sources you provided and used them in a flashdevelop project. Very frustrating, any idea what could be the problem? The override on fillResources seems to work fine for some reason, very strange.

  • Pingback: Alternativa platform : fog, pixel material and more | Kim TASKER webgrafiks

  • Leave a Reply

    Your email address will not be published. Required fields are marked *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>