I created an engine which draws 2D planes in the Stage3D API in Actionscript 3. And my question is, how do I turn all anti-aliasing off, because when I scale it all the pixels get really blurry, and I'm trying to use pixel-art for this.
This is the code I use:
protected function setupShaders() {
var vertexShaderAssembler:AGALMiniAssembler = new AGALMiniAssembler();
vertexShaderAssembler.assemble( Context3DProgramType.VERTEX,
"dp4 op.x, va0, vc0 \n"+
"dp4 op.y, va0, vc1 \n"+
"mov op.z, vc2.z \n"+
"mov op.w, vc3.w \n"+
"mov v0, va1.xy \n"+
"mov v0.z, va0.z \n");
var fragmentShaderAssembler:AGALMiniAssembler = new AGALMiniAssembler();
fragmentShaderAssembler.assemble( Context3DProgramType.FRAGMENT,
"tex ft0, v0, fs0 <2d,clamp,linear, nomip>\n"+
"mov oc, ft0 \n");
shader = context3D.createProgram();
shader.upload(vertexShaderAssembler.agalcode, fragmentShaderAssembler.agalcode);
}
public function draw() {
context3D.setProgram(shader);
context3D.setBlendFactors(Context3DBlendFactor.ONE, Context3DBlendFactor.ONE_MINUS_SOURCE_ALPHA);
context3D.setProgramConstantsFromMatrix(Context3DProgramType.VERTEX, 0, parent.modelViewMatrix, true);
context3D.setTextureAt(0, sprites.texture);
if (updateVBOs) {
vertexBuffer = context3D.createVertexBuffer(vertices.length / 3,3);
indexBuffer = context3D.createIndexBuffer(indices.length);
uvBuffer = context3D.createVertexBuffer(UVs.length >> 1, 2);
indexBuffer.uploadFromVector(indices, 0, indices.length);
uvBuffer.uploadFromVector(UVs, 0, UVs.length >>1);
updateVBOs = false;
}
vertexBuffer.uploadFromVector(vertices, 0, vertices.length / 3);
context3D.setVertexBufferAt(0, vertexBuffer, 0, Context3DVertexBufferFormat.FLOAT_3);
context3D.setVertexBufferAt(1, uvBuffer, 0, Context3DVertexBufferFormat.FLOAT_2);
context3D.drawTriangles(indexBuffer, 0, nChildren << 1);
}
public function configureBackBuffer(width:uint, height:uint) {
context3D.configureBackBuffer( width, height, 0, false);
}