Showing posts with label Stage3D. Show all posts
Showing posts with label Stage3D. Show all posts

Friday, October 19, 2012

Stage3D compressed textures – Introducing the ATF SDK

We introduced Stage3D last year and the momentum behind has never stopped growing but there is one area we did not give all the details. The ATF file format, it is mentioned here and there, so what's up with this? Some of you may have seen it in the documentation for Stage3D referred as the compressed texture file format, but we never shared any tools to create those famous ATF textures.
Before we package the ATF tools with the AIR SDK, I am happy to share here in advance the ATF tools so that you guys can start leveraging the ATF format now!
So what is it?
First, let's start by talking about what compressed textures are.
When doing GPU programming with any technology, you have two options for how you handle your textures. You can go compressed or uncompressed, very simple. So, what is the difference?
  1. When using uncompressed textures, a good old uncompressed file format like PNG is used and uploaded to the GPU.
  2. Because GPUs don't support such a file format natively, your texture is actually stored in CPU memory, when it could actually be stored on the GPU memory!
  3. Same thing applies for JPEG images, make no mistake, graphics chipsets don't know anything about JPEG which would also be decoded on CPU memory.
  4. Of course, each platform has different support for compressed textures depending on the hardware chipset being used.
Now get ready for the fun! Here is below a little table to illustrate it:

PlatformFormat
ImgTech (iOS)PVRTC
Qualcom (Android)ETC1
Mali (Android)ETC1
NVidia (Android)ETC1/DXT1/DXT5
Android (PowerVR)PVRTC/ETC1
WindowsDXT1/DXT5
MacOSDXT1/DXT5


Why ATF?
As you can imagine, if you would develop a game targeting iOS, Android and desktop, you would need to supply your textures compressed to each format for each platform. Which would look like this:
  1. leaf.png encoded to DXT for Windows and MacOS
  2. leaf.png encoded to ETC1 or DXT for Android (Nvidia)
  3. leaf.png encoded to PVRTC for iOS (ImgTech)
Of course it is a pain to provide all the different versions of the textures, detect at runtime which platform you are running on and upload the corresponding texture. Wouldn't it be cool if you could just rely on one single container, that would wrap all the textures for each platform and Flash Player or AIR would extract automatically the texture required depending on the platform? So here comes ATF.
The ATF internals
Really, think about the ATF format as a container for lossy images. Here is below a little figure showing very sinply the structure of a default compressed ATF file:
Read more: Stage3D compressed textures – Introducing the ATF SDK

Tuesday, October 9, 2012

Create a Glowing, Flowing Lava River Using Bézier Curves and Shaders

Most of the time, using conventional graphic techniques is the right way to go. Sometimes, though, experimentation and creativity at the fundamental levels of an effect can be beneficial to the style of the game, making it stand out more. In this tutorial I’m going to show you how to create an animated 2D lava river using Bézier curves, custom textured geometry and vertex shaders. Note: Although this tutorial is written using AS3 and Flash, you should be able to use the same techniques and concepts in almost any game development environment.

Final Result Preview

Click the Plus sign to open more options: you can adjust the thickness and speed of the river, and drag the control points and position points around. No Flash? Check out the YouTube video instead:
The actual demo runs at a much higher framerate.

Setup

The demo implementation above uses AS3 and Flash with Starling Framework for GPU accelerated rendering and the Feathers library for UI elements. In our initial scene we are going to place a ground image and a foreground rock image. Later we are going to add a river, inserting it between those two layers.

Geometry

Rivers are formed by complex natural processes of interaction between a fluid mass and the ground beneath it. It would be impractical to do a physically correct simulation for a game. We just want go get the right visual representation, and to do so we are going to use a simplified model of a river. Modeling the river as a curve is one of the solutions we can use, enabling us to have a good control and achieve a meandering look. I chose to use quadratic Bézier curves to keep things simple. Bézier curves parametric curves often used in computer graphics; in quadratic Bézier curves, the curve passes through two specified points, and its shape is determined by the third point, which is usually called a control point.
Read more: Create a Glowing, Flowing Lava River Using Bézier Curves and Shaders

Monday, October 8, 2012

Use Any Sprite As a Stage3D Texture

Textures are usually simple bitmaps, but what if you wanted to use something more dynamic? How about a SWF you’ve created in Flash Professional? How about a Sprite or MovieClip you’ve created in code? Today’s article will show you how to do just that. First of all, there’s no magic Flash API that accepts a [...]

Read more: Use Any Sprite As a Stage3D Texture

Wednesday, September 5, 2012

Constrained mode support

FlashPlayer 11.4 was released recently and now many more users will be able to use  hardware  3D-rendering in Flash. Earlier versions of FlashPlayer 11 support hardware rendering for devices   manufactured after 2008. The constrained mode extends this support to all devices released since 2005. For example, almost one third  of TankiOnline players will be able to use GPU rendering thanks to the constrained mode support. (Around two third of the players already have GPU support and less than ten percent still use the old version of the Flash player that doesn’t support hardware rendering at all) Incidentally, your application should be ready to work in constrained mode as well as FlashPlayer on the user side. This is easy to achieve with Alternativa3D 8.32.

How does it work?

In order to make your application work in constrained mode you just should set the second parameter of stage3D.requestContext3D() when requesting the context, in the following way:
stage3D.requestContext3D(Context3DRenderMode.AUTO, Context3DProfile.BASELINE_CONSTRAINED);
Context3DProfile class appears with API of the 11.4 version of FlashPlayer so you need to update your playerglobal.swc (or use hardcoded string constant – "baselineConstrained"); If you wish to enable constrained mode only if normal hardware rendering is unavailable, you can request the context as usual then check which mode is set and, if after you receive it, the software rendering mode is set, you should request the context again, this time in constrained mode.

What do you get with Alternativa3D in Constrained mode?

[...]
Read more: Constrained mode support

Wednesday, March 28, 2012

Quick comments about Unity and premium features

I’m sitting at the Seattle airport at the moment but I just wanted to clarify a couple of things about the announcements we made last night. Firstly we announced that we now have a partnership in place with Unity. Our teams working together will make their Flash export feature even better in the future. Big shout out to Ralph and the Unity for their awesome work on it!
The second thing we announced is a new premium feature model for the desktop browser runtime. This model is there to allow Adobe to make revenue from large, web-based Flash games like the ones that we expect to come out of Unity and other tools. Building a real game platform means that we have to be able to make revenue to fund its development. When talking with game companies at GDC, most prefer this model because they are much more confident about deploying to a platform that we are actively making money from.
So in a nutshell this is what the premium features mean. If you create a game that uses Stage3D GPU AND uses the Alchemy opcodes then you will need to get a license key from Adobe. Then if your game makes over $50,000 in revenue, your game will subject to a 9% revenue share that you will pay to Adobe. This does not apply at all to Adobe AIR. So you can use Stage3D and the opcodes as much as you want with no license. I have seen a lot of chatter online basically saying that people will have to pay a cut to Adobe in addition to the cut Apple and Google take. This is completely false. There is NO licensing needed when deploying to mobile.
I know there are a tons of edge cases here surrounding the use of the opcodes and I will be writing more in-depth about them very soon. Read through the two links below to get more details.
Premium features overview
Premium features FAQ
Read more: Quick comments about Unity and premium features

Monday, March 26, 2012

AIR 3.2 – Making an Endless Runner with Stage3D (Part 1)

With the introduction of AIR 3.2, Adobe has brought Stage3d to mobile devices. This means that flash developers can now leverage direct GPU Acceleration on Mobile Platforms (Android and iOS specifically). While this obviously enables 3d games, it’s also totally a huge boon for 2d games! There are already several 2d frameworks you can choose from which make the gpu quite easy to work with:
My personal favorite right now is ND2D.  So I thought it would be cool to take a look at how you might build an Endless Runner style game with this framework!

Files & Demo

Before we get started here’s some downloads to help you follow along:

Overview

The core classes which will make up this demo are*:
  • Game.as – Root display object, instantiates the other classes, and manages property injection
  • Background.as – Handle parrallax scrolling bg
  • Foreground.as – Handles ground tiles
  • PhysicsManager – Simple Physics engine, processes gravity and collisions
  • PlayerManager – Control Player animations and Keyboard controls
* Note: I’ve never actually built this type of game before. So, my approach may have some issues. However, this is about my 3rd iteration, so it should be ok ;)

Hello World2D

The first step to setting up ND2D is to create your World2D, and assign it an active Scene. In this example we’ll have just one Scene, our main Game: [...]
Read more: AIR 3.2 – Making an Endless Runner with Stage3D (Part 1)

Wednesday, March 21, 2012

Build a Stage3D Shoot-’Em-Up: Explosions, Parallax, and Collisions

This entry is part 3 of 3 in the series Build a Stage3D Shoot-'Em-Up
In this tutorial series (part free, part Premium) we’re creating a high-performance 2D shoot-em-up using the new hardware-accelerated Stage3D rendering engine. In this part, we’re adding eye candy with particle systems, a parallax effect, framerate-independent game loop timers, and collision detection.


Final Result Preview

Let’s take a look at the final result we will be working towards: a hardware-accelerated shoot-em-up demo that includes everything from parts one and two of this series, plus an efficient particle system for loads of eye-candy, framerate-independent timers for consistent movement, a subtle background parallax effect, the ability for entities to orbit one another, and a collision detection system capable of handling tons of entities.
Check it out: every explosion is slightly different!

Introduction: Welcome to Level Three!

Let’s continue to make a side-scrolling shooter inspired by retro arcade titles such as R-Type or Gradius in actionscript.
In the first part of this series, we implemented a basic 2D sprite engine that achieves great performance through the use of Stage3D hardware rendering as well as several optimizations.
In (the second part, we implemented a title screen, the main menu, sound effects and music, and an input system so that the player could control their spaceship using the keyboard.
In this part, we are going to add all the eye-candy: a particle system, complete with sparks, flying debris, shockwaves, engine fire trails and tons of explosions.
In previous versions, our game was framerate-locked and ran slower on old computers. To ensure the same timings for everything no matter what the framerate, we are going to change all movement and animation simulation units to account for the exact number of milliseconds that have passed since the previous frame. This way, whether you are running at 60fps on a modern gaming rig or your grandma’s old netbook, the game experience itself will be identical.
Finally, we’re going to program collision detection, which is required in nearly any game you can imagine. In order to trigger explosions and we need to be able to detect when a bullet has hit an enemy. While we’re at it, we are going to throw in a little bit of additional pizazz, just for fun, including a vertical parallax effect to the starfield background and an R-Type inspired orbiting “power orb” companion that circles the player’s ship.

Step 1: Open Your Existing Project

If you don’t already have it, be sure to download the source code from part two. Open the project file in FlashDevelop and get ready to upgrade your game!
This source code will work in any other AS3 compiler, from CS6 to Flash Builder. If you do use FB, be sure to include “-default-frame-rate 60” in your compiler options to ensure you get the best performance.

Step 2: Get the Party Started!

We are going to take advantage of the well-optimized internals of your entity manager class from last time by adding a simple particle system to it that still uses all the same basic entity and spritesheet functionality.
This way, we are still rendering the entire game’s sprites (ships, bullets and all) in a single geometry batch using a single texture. Therefore, much of the simulation of particles will be handled the same way as we currently handle the movement of the enemies. Most importantly, we are going to keep the number of draw calls to a minimum by inserting particles into our existing sprite batch.
The fist thing we need to do is define a few interesting effects. We’re going to have a little fun and create some cool-looking effects such as an expanding ring of blueish energy (a “shockwave”), a bunch of different fireballs that spin and fade out, some fast moving sparks that stay nice and bright and some metallic spaceship hull debris.
Create a new file in your project called GameParticles.as and implement the basic particle and explosion helper functions [...]

Read more: Build a Stage3D Shoot-’Em-Up: Explosions, Parallax, and Collisions

Wednesday, March 14, 2012

Build a Stage3D Shoot-’Em-Up: Interaction

This entry is part 2 of 2 in the series Build a Stage3D Shoot-'Em-Up
In this tutorial series (part free, part Premium) we’re creating a high-performance 2D shoot-em-up using the new hardware-accelerated Stage3D rendering engine. In this part, we’ll extend our rendering demo by adding an animated title screen and menu, music and sound effects, and a keyboard-controlled ship that can fire bullets.


Final Result Preview

Let’s take a look at the final result we will be working towards: a hardware accelerated shoot-em-up demo in the making that includes an animated title screen and menu, sounds, music, and keyboard controls.
Click the logo to gain keyboard focus, then use the arrow keys to move and space bar to fire. Your shots will be reflected back at you once they reach the edge of the screen.

Introduction: Welcome to Level Two!

We’re going to continue making a side-scrolling shooter inspired by retro arcade titles such as R-Type or Gradius, in AS3, using Flash 11′s Stage3D API and the freeware tool FlashDevelop.
In the first part of this tutorial series, we implemented a basic 2D sprite engine that achieves great performance through the use of Stage3D hardware rendering as well as several optimizations.
These optimizations include the use of a spritesheet (or texture atlas), the creation of an entity object pool which reuses incactive entities instead of creating and destroying objects at runtime, and a batched geometry rendering system which draws all of our game’s sprites in a single pass rather than individually. These optimizations are the perfect foundation upon which we will build our high performance next-gen 3d shooter.
In this part, we are going to work toward evolving what is currently a mere tech demo into something that is more like a videogame. We are going to create a title screen and main menu, add some sound and music, and code an input system that lets the player control their spaceship using the keyboard.

Step 1: Open Your Existing Project

If you don’t already have it, be sure to download the source code from part one (download here). Open the project file in FlashDevelop (info here) and get ready to upgrade your game!

Read more: Build a Stage3D Shoot-’Em-Up: Interaction

Friday, March 9, 2012

Build a Stage3D Shoot-’Em-Up: Sprite Test

In this tutorial series (part free, part Premium) we’ll create a high-performance 2D shoot-em-up using the new hardware-accelerated Stage3D rendering engine. We will be taking advantage of several hardcore optimization techniques to achieve great 2D sprite rendering performance. In this part, we’ll build a high-performance demo that draws hundreds of moving sprites on-screen at once.


Final Result Preview

Let’s take a look at the final result we will be working towards: a high-performance 2D sprite demo that uses Stage3D with optimizations that include a spritesheet and object pooling.

Introduction: Flash 11 Stage3D

If you’re hoping to take your Flash games to the next level and are looking for loads of eye-candy and amazing framerate, Stage3D is going to be your new best friend.
The incredible speed of the new Flash 11 hardware accelerated Stage3D API is just begging to be used for 2D games. Instead of using old-fashioned Flash sprites on the DisplayList or last-gen blitting techniques as popularized by engines such as FlashPunk and Flixel, the new breed of 2D games uses the power of your video card’s GPU to blaze through rendering tasks at up to 1000x the speed of anything Flash 10 could manage.
Although it has 3D in its name, this new API is also great for 2D games. We can render simple geometry in the form of 2D squares (called quads) and draw them on a flat plane. This will enable us to render tons of sprites on screen at a silky-smooth 60fps.
We’ll make a side-scrolling shooter inspired by retro arcade titles such as R-Type or Gradius in ActionScript using Flash 11′s Stage3D API. It isn’t half as hard as some people say it is, and you won’t need to learn assembly language AGAL opcodes.
In this 6-part tutorial series, we are going to program a simple 2D shoot-’em-up that delivers mind-blowing rendering performance. We are going to build it using pure AS3, compiled in FlashDevelop (read more about it here). FlashDevelop is great because it is 100% freeware – no need to buy any expensive tools to get the best AS3 IDE around.

Step 1: Create a New Project

If you don’t already have it, be sure to download and install FlashDevelop. Once you’re all set up (and you’ve allowed it to install the latest version of the Flex compiler automatically), fire it up and start a new “AS3 Project.” [...]

Read more: Build a Stage3D Shoot-’Em-Up: Sprite Test