woensdag 17 april 2013

Distorting pixels

Hello everyone!

Today I want to talk about refraction, what it is and how you can use it to enhance special effects in your games. 



In the image above, you can clearly see that the pixels are distorted, they are not rendered at the place you'd expect them to be. The light seems to bend around something in the 3D world. This is what we call a refraction effect, gamewise. In the real world refraction works a bit more complicated than just pixels being distorted on the screen, but that doesn't matter for now. I think you can clearly see the point of what I'm trying to explain from the image.

There is a shader involved which renders this effect using simple geometry ( billboarding plane). The shader renders the object as of its 100% transparent. It also renders the object after the first 'transparent object render pass', this is important. In Unity you use the tag ' Tags { "Queue"="Transparent+1"} ' to achieve this in the shader. 
However, it also transforms the already rendered pixels behind this piece of geometry according to a normalmap. This all sounds quite complicated just from plain text, maybe some pictures can make it a bit more clear.



The above image shows you schemetically what normally happens during rendering without any refraction effect applied. As you can see every geometry is being rendered using its material onto the screen, nothing fancy. 



The second image shows you what the refraction shader is doing to the already rendered pixels using the simple billboarding plane geometry and it's normalmap texture.

This render techinique can be used to enhance your special effects. For example to visualize a shockwave moving through the world coming from a big explosion. Or a heat effect, wich makes the light 'ripple' in front of the viewer's eyes.


One big issue with this technique is that you can't fade the refraction effect by default. In the non-refracted shockwave particles I created, I made the particles fade out by altering their alpha values. However this doesn't doesn't affect the normal distortion off course. I fixed this problem by taking the vertex alpha's into the normals calculation of the effect. 



During the lifetime of a shockwave particle, it's alpha decreases from 1.0 to 0.0. I multiply this value by the normals I get from the refraciton normalmap. Less alpha means less distortion, which makes the effect able to fade in/out.


When taking this technique several steps further you could combine it with reflection to create realistic looking water reflections and distortions.. the possibilities are endless :) !

Greetings,
Joep



donderdag 11 april 2013

Recycle for a better game environment!


Hi!
Today some news about a new game! Just like Eugene im working on a new project as well!
And I am going to tell you a technique to reduce the memory usage by recycling objects.

In this game we are re-using a lot of objects during the game. Like in every other game but this time we are re-using it at the time we are not using it any more. So when we are following a path, we pass numerous objects. Once we pass them we will recycle it and not destroying it. We set it to the next possible spot. This way we won't need to delete it and create it again.
Just a quick reset of its variables and visuals and then set it again for another use! A very nice way of recycling!
Level unmodified

Well this sounds very promising but we need to cooperate with the artist for this. Normally u want to place all these objects in Max and export it the normal way. But since we are recycling all of those objects we don't want a normal export. The export we want, to save some memory and size, has to be modified.




Their are some things we need to know of that model, name, position, scale and rotation. So its name and transform. This can be done in several ways without actually exporting the models. Write all of its data to a text file or replace the model with a dummy and give it the same properties. There are several other ways but we are going to use the dummies. To do this we are using a max script that will search through the scene and replace all the models with dummies.
Models replaced by dummies

We can then search for the specific dummies and add their transform to a array.
So let's say we want to create different sets of objects we now know the type, position, rotation and scale of that specific object. The next part to make it all work, we need a pool of those object types. For each object type we need an original model so we can clone that and put it in a object pool.
So when we need to create a set of objects we can get it from the pool, get its transform we listed before.

This can sound a bit weird but it's very useful.
This can actually increase your game's performance if you use the same objects over and over again. Instead of destroying them on the end and allocating new ones later we are now recycling them. So stop wasting the garbage collector with the same stuff over and over again!

In game
Greetings,

Michael

donderdag 4 april 2013

The Art of Looping


The Art of looping
 
Hi everybody!

Melvin here, senior audio designer and animator at Xform for just about two months now and this my first Xform blog ever.

Well kids, today I'm going to tell you a story about a thing called "looping". The reason why I'm going to discuss this is that I want to show you the relation between sound and movement. And also because this is something you have to deal with, whether as an audio designer or an animator.  In music and sound we use the word loop where in animation we often use the term cycle.

They key thought when creating a seamless loop in audio and animation is that the loop should roughly be like a sine in a graphical approach. I mentioned roughly because it's not necessary to be as curvy as a sine. You could see a sine as a drawn circle, cycle or better yet, a loop in a certain time. We could say we have come full circle!

A sine starts at y=0 and ends at y=0, the origin. The audio example below consists of two sinuses, thus two loops or cycles.The red markers indicate where the loop starts and ends.


Avoiding this story to sound as your monday morning mathclass, I'll just say the more your visual representation of your audio file or animation resembles a sine, the better your loop will be. Thus, if you want a flawless loop, your start and end should have the same y-coordinates and the same angle. The y-coordinate doesn't necessarily need to be 0.  If you do not do this, your animation loop will stutter and in case of your audio loop, it will pop and click.

There are some exceptions in animation where you actually want mirrored angles. A bouncing ball is an example of that.
Here is an examples of bad a loop. (the loop is indicated in blue)



Although the loop start and ends at the same y-value, the loop will pop because the angles are mirrored.
3ds Max users know that if you open the Track View - Curve Editor you will see the graphic representation of your animation.



Here is an example of the movement of a biped pelvis in the animation above. Notice the similarities between this graph and that of the sine audio example.


Of course in real life sound isn’t just one sine and neither do all of we have the same walk cycle. Otherwise everything would be monotonous and boring.  If we look at a more complex audio loop such as this lava audio loop, we can see all of different sorts of sinuses. This gives the sound authenticity.


Importing files

I always save my sounds as wav files, and consider them as my master source files, which I can encode to other formats such as ogg, wma or mp3. I try to avoid saving to mp3 because of the problem, that mp3 encoding places several frames of silence at the start and end of the waveform, which makes looping impossible. The way Unity3d handles audio files is actually quite nice. You can import wav files and choose in Unity3d how it handles its audio files. It also ogg-vorbis compression to keep your final file small.

So this is a small portion of what I do at Xform, I hope haven't dozed you off  to sleep and you can use this in your own work.  
Lets's say goodbye with a seamless loopable track from the forthcoming smash hit
Burnin' Rubber 5.
Enjoy!
 

 
Cheers,

Melvin

 

 

 

 

maandag 18 maart 2013

Hammer!!!


Hey everyone!

This week I’m going to talk about the character I've been working on the last couple of days.
I’m not going to tell much about the project that I’m working on.  One thing I can tell, it has nothing to do with cars or what so ever.

I had to make a character with the same looks as the main character of the game called “The Hammer”. This is one of the first games Xform made!


 So with that game as my main reference. I started to begin on my character.


I always make one half of an object. I do this with almost everything I make, cars, props, weapons and in this case a character.


During modelling an object you always want to know how the model will look like in total. For this, there are several easy methods in 3Ds Max to get that. Personally I always make an instance of my model.  This allows me to work on one model while the other one also get the same changes. There is also another tool in 3Ds Max what you can use, called symmetry.



When I’m satisfied with my model, I begin to unwrap. After unwrapping is done I attach the model to the other to get it complete. I do this after unwrapping so I won’t have to unwrap everything. Now I just have to separate the unwraps of each other and weld them together.  

After that I added the biped to my character and used skin to rig him.



When the rig is done, I always make an test animation to check if the character is rigged well.

Here is an example


As you can see, there is one vertex that is sticking out. Apparently that vertex was also attached to the Left Upper Arm.
So I select the vertexes that are attached to the wrong bones and reattach them to the correct bones.
This is easily done in the skin modifier.


So after the Rig is completed I started with my texture.  I’m not going into this. That is for another time.

 A nice end pose, added some random weapons. And the deed is done for now!


Hails!

Eugène 

vrijdag 22 februari 2013

Start your weekend with a smile!

Hi all,


As much as we like to work hard, we also like to have a good laugh.
This laugh can be brought to us by listening silly songs, telling stupid stories or making wacky sounds ourselves.
But there's another thing that can put a smile on our face: the game comments players add to our games!


What do players think while playing our games?



Players just say the funniest things. And we made a small selection for you!
So sit back... and enjoy!

Cheers,
Shirley








 And can you guess the games of these comments?

woensdag 20 februari 2013

Lightmapped tinting

Dear readers,

Today I'd like to explain a technique we're using in our new game considering lighting. It involves using the lightmap to shade models like bullet impacts and characters. A lightmap is actually just another texture applied to a model in combination with the second texture coordinates. The lightmap is blended with the primary texture to obtain a model that is shaded without there being any (hardware) light in the scene. The reason this is done is because it is much faster to render than real-time lighting/shadows. The downside is that it is computed beforehand and so is static (i.e. not real-time). Below you see an example of a scene that uses a lightmap for shading and below that an example of what a lightmap texture looks like.

An example of a lightmapped scene, notice the shadows of the trees and hills.

An example of a lightmap texture. You can see the shadows of trees and buildings in this texture.

Now what we'd like is that when a character walks through the scene and walk into a shaded area, the character also becomes darker (because it's walking in the shade). To do this we cast a ray from the character onto the ground and get the second texture coordinate of the point on the ground. We then use this color on the character material and in this way it'll shade appropriately.

A character in light on the left and in shadow on the right.
This also works for other objects such as bullet holes, but care should be taken. As bullet holes share the same material, adjusting the color on that material changes the appearence of all bullet holes which is not what we want (as some are in light, others in shadow). Creating a separate material for each bullet hole is possible, but not desirable: it slows down rendering. Instead we create just two materials: one for in light, the other for in shadow and assign one of the two materials to the bullet hole depending on whether it is in light or shadow.
 
Bullet holes in light on the left and in shadow on the right.
-- Stijn

maandag 18 februari 2013

Designing and building an interface

Hi guys,

Today I'm going to show you some tips and tricks on how we design and build our interfaces here at Xform.
Always start with a good game and interface design document before starting the interface design in Photoshop. You need to have a good idea of all the elements that need to be displayed on screen and also when an interface element is displayed.

When I setup a file I always start by creating layer folders and sub folders in Photoshop. As you can see in the right column in the image below, I've created an Interface folder which contains all the elements of the interface in sub folders. This makes it easy to turn separate or unique interface elements on and off. This also prevents me from cloning a lot of graphic elements which are used in multiple screens, like the speedometer.

When all screens are done I setup layer compositions (left column of the image below) to make it even easier to switch between all the possible interface screens. Setting a layer compositions doesn't actually change anything in your Photoshop file, it only remembers which layers have to be turned on or off when it's selected. Don't forget to use this tool, it can save you a lot of time!

Interface mock-up in Photoshop 

When the mock-up is approved it's time to turn the interface elements into a compact texture. Here I've chosen to work with an 512x512px texture. All the elements I need are placed in a grid of 16x16 pixels. It's very important for me to work inside this grid since we'll use the same mesh grid in 3ds Max.

512x512 px texture. Photoshop grid size 16x16px
 
The final textures will be imported in 3ds Max and placed on a plane of the same dimensions: 512x512 units. To "recreate" the Photoshop grid we set the length and width segments to 32x32, which creates squares of 16x16 units. This makes it easy for me to cut-up the plane into separate interface elements.

512x512 px texture on a 512x512 units 3D plane divided in 32x32 segments

The elements are set into place in an orthographic view using the original Photoshop image as a template. Although the interface is created in a 3D software program it'll still be displayed as an 2D interface. Therefore we use an orthographic view instead of an perspective view.
As you can see in the lower part of the image below the elements are ordered in 3D space, but will be rendered in game as seen in the top area of the image below. The white boxes on top of the interface are used to display dynamic text, like weapon and enemy names.

Interface in 3ds Max. Top orthographic view. Bottom Perspective view.
 
When the max file is done our programmers will have to make the interface work in game. And there you have it... a working interface!
 
Final in-game interface

Cheers,
Matt