Sep 12, 2017

Unity: Sprite Packer enabling problem 2017.1.1f1

PROBLEM:
 I have completed all the process, Project setting: Packer Always enabled and When I clicked PAck button nothing happens. Also I have all my images tagged. When I create a new project and try this action even if I used the same images, the packer works, then I turn back to my old project and try to pack my images with the same working images but nothing has changed.

My icon folder (that I try to pack) path: Assets/Resources/icons

SOLUTION:

  1. Move the assets outside the resource folder.Use path: Assets/icons
  2. Disable and re-enable the sprite packer from the Project Settings > Editor
  3. Close the project and reopen it

Apr 30, 2013

Generating Normal Maps

Normal maps can turn boring smooth shaded models into detailed and realistic looking ones. Generating normal maps are as easy. You just need a normal map generator( or write on yourself). here is tools:

NDO

This is a powerful photoshop plugin for creating normal maps. This was free then became a commercial project. The free one can be found here, but i think the commercial project was taken down. The author’s website is here and a tutorial is here.

NormalMapper

This application find the dfference between hi-res and low-res models and output the difference in normal maps. Link here.

NormalMapper(AMD)

AMD seems to have a normal map generator with the same name. It’s not in development anymore, but its still available for download.
link

SSBump Generator

This is a free tool for making self shadowed bump maps for valve’s source game engine
link

Normal Map Generator

Another free tool for making normal maps. Made by the same person who made the SSBump Generator. This one makes it easier to batch normal map coversions
download page

ShaderMap

This is a commercial software. It makes professional looking nomal, displacement, specular and ambient occlusion maps. You can visualize your normal maps on models in it as well. It also comes with an SDK for some reason :/. You can download the demo for free.
download page

xNormal

another software for baking normals from hi-res models to low-res ones in to normal maps
link
download page

MindTex

Commercial, but you can try it free for thirty days
link

CrazyBump

This is a popular one, and my personal favorite :D . It’s commercial, but comes with a 30 day trial but for its beta version. It generates normal, displacement, specular and AO maps like ShaderMap.

Gimp Normal Map Plugin

This one has free written all over it. You can generate normal maps right after drawing them and preview them on models. link

Resource:  http://nickthecoder.wordpress.com/2012/08/23/generating-normal-maps/









Apr 5, 2013

Useful IntelliJ Resources for dummies

Links on the IntelliJ site:

  1. 1. The main documentation page
  2. 2. Demos and tutorials including a couple of new Groovy support demonstrations
  3. 3. 25 things you can do with IntelliJ 8 you can’t do with 7
  4. 4. Mac Keymap reference
  5. 5. Windows/Linux keymap reference
  6. 6. The Jetbrains IntelliJ blog. A great way of getting tips from the guys that wrote it, and keeping up to date with improvements.

DZone: Intellij in 7 pages

  1. 7. The DZone refcard for Intellij

My personal faves

  1. 8. Command Shift-A to bring up a search window for actions. This one I think of as Quicksilver for my IDE.
  2. 9. Alt-Enter to trigger intentions. Problem with your code? Let the IDE suggest a refactor to correct it.
  3. 10. Ctrl-n for auto-generation of Java code. Getter and setter boilerplate getting you down(and you can’t switch from Java to Groovy)? Want a nice compact toString() on a class with 20 member variables? Let the IDE do the heavy lifting.
  4. 11. The Javadoc Sync plugin. This goes well with #10 to javadoc all those getters and setters auto-magically.

Add logging using the debugger

  1. 12. Printing to the console is a basic tool for debugging code. Everybody’s done it – because it’s easy and it works. But you often come across scenarios that disallow this quick and satisfying hackish behaviour. Namely when you are debugging into code in a library, this is not necessarily an easy option. Fortunately IntelliJ provides a nice easy way to add console logging through the debugger. You can access the breakpoint configuration dialog either by right clicking on an existing line breakpoint and selecting ‘Properties’ or by pressing Command Shift-F8 from the Debug view. From there you configure your line or Exception breakpoint with a ‘Suspend policy’ of ‘None’ and check the boxes under ‘Actions’ to enable logging. A full description of the features can be found here. I find this especially handy when there’s a problem iterating over a Collection and only one or some of the items in that Collection lead to an error condition during processing. Using this strategy I can provide context as to which cases passed and which failed without having to stop at a bunch of breakpoints and inspect the variables on the stack; I can just concentrate on the failure point and look back at the console output to compare against previous invocations.
    Here’s a couple of screencaps to show configuration for logging the size of a list on a line breakpoint. Note that the Groovy requires a little bit of extra magic, since the debugger gets passed a Reference object instead of the raw List.

    Resource: http://www.kellyrob99.com/blog/2009/08/18/my-favorite-intellij-resources-tips-and-tricks/

    http://www.jetbrains.com/idea/docs/IntelliJIDEA8_ReferenceCard.pdf

Dec 19, 2012

Toshiba laptop disassembly

Disassemble, repair and upgrade Toshiba laptop yourself. Step by step instructions. Great work!
 
http://www.irisvista.com/tech/

Stage3D Blogs and References

http://www.saltgames.com/
http://blog.onebyonedesign.com
http://flashdaily.net/tagged/stage3d

Stage3D Shader Cheatsheet

A quick reference for working with AGAL, the new shader language for use with Stage3D introduced with Flash Player 11.


Registers:
Each register consists of four components, which are floating point values. These components are accessed by registerName.x, registerName.y, registerName.z, registerName.w. They’re named for dealing with 3D positions – with the ‘w’ for rotation in the style of quaternions – but they can just as well be used to hold a colour (in fact you can also access the components with .r .g. b. a) or any other values you want to use.
There are several registers of each type available. For instance you might have va0 giving the 3D position of a vertex in space, and va1 giving the uv mapping coordinate for that vertex. The nice thing about having registers made up of components is you can do things like perform a basic addition operation va0 and vc0, and the addition will be performed correctly on each component.


Registers for Vertex Shaders
  • va[0 to 7] Vertex Attribute. The contents of the vertex buffer, as set with context3D.setVertexBufferAt. Each vertex has its own space in the vertex buffer which only it can access.
  • vc[0 to 127] Vertex Constant. Passed into the shader with context3D.setProgramConstantsFromVector or context3D.setProgramConstantsFromMatrix. These registers can be read by all vertices, but cannot be written to by the shader.
  • vt[0 to 7] Vertex Temporary. A handy temporary register where you can put values during a calculation.
  • op Vertex Output or “Output Position”. The output: op.x and op.y is where in the 2D space of the screen this vertex will be drawn. The op.z value is used for depth checking and writing to the depth buffer if you have those enabled. So far as I know the op.w value is not actually used.
  • v[0 to 7] Varying. A magical (not actually magical) register that allows you to pass values from the vertex shader to the fragment shader. The value that arrives in the fragment shader will be interpolated between the value of the three v registers of the vertices which make up the triangle in which the fragment falls.
    Note!  The fragment shader cannot directly access the vertex buffer, so anything it needs from there has to be passed through the v registers. For instance if you’re using texture mapping this register will need to pass the uv coordinates to the fragment shader.
Registers for Fragment Shaders
  • fc[0 to 27] Fragment Constant. Much like vc for the vertex shader, this register is set by context.setProgramConstantsFromVector or context.setProgramConstantsFromMatrix, can be read by each fragment, and not written to by the shader.
  • ft[0 to 7] Fragment Temporary. Again just like vt for the vertex shader, this is a temporary store useful for performing calculations.
  • fs[0 to 7] Texture Sampler. This is where the fragment shader is able to access whatever texture(s) were bound using context3D.setTextureAt.
  • oc Fragment Output or “Output Colour”. The output: oc.x oc.y oc.z oc.w are the red, green, blue and alpha values respectively for the fragment to be drawn.

Operations:
Shaders are made up of a series of operations, with one operation on each line. First the operation to perform is identified by a three letter opcode such as “add”, then the parameters for that operation are given. The parameters are (almost) always specified as registers. If you want to use a number in your shader, it should be supplied through the vc or fc registers.

In the parameters the target register is always specified first. The target register is where the result of the operation is placed. No change is made to a register other than the target register. Some operations require two further parameters, others just one. The tex operation used for texture sampling is a special case that has six parameters, three of which are given as strings rather than registers. tex is a pretty wild guy.

At first look the mess of opcodes and registers names that make up the AGAL code for a shader can look intimidating but they’re actually quite simple. Just remember that each operation does exactly one thing, and writes to exactly one register. AGAL doesn’t allow for conditional statements like if then or any form of looping, so following along with what a shader is doing is extremely easy: it always just proceeds to the next operation.

With that said, AGAL code is not nearly as intuitive to glance at and understand what it does as (well written) AS3 code is. Taking a minute to type out some comments for the AGAL code you write is a very good idea.

You are limited to 200 operations in a single AGAL shader.

Operations available to shaders:
  • mov t a - Copy the contents of a into t.
  • add t a b - Add a and b, put result in t.
  • sub t a b – Subtract b from a, put result in t.
  • mul t a b – Multiple a and b, put result in t.
    When working component-wise this operation doesn’t always do as I’d expect. Specifically performing the operation:
    mul vt0.xy va0.xy vc0.xy
    Gives a different result from performing the two operations:
    mul vt0.x va0.x vc0.x
    mul vt0.y va0.y vc0.y
    Whereas they would give the same result if it were an add operation in both instances instead of mul. I’ve yet to work out exactly what the mul operation does with multiple components.
  • div t a b – Divide a by b, put result in t.
    The same behaviour as outlined above for the mul operation applies to div too.
  • rcp t a – Divide 1 by a, put result in t.
  • min t a b – Copy whichever of a or b is smaller into t.
  • max t a b – Copy whichever of a or b is larger into t.
  • frc t a – Copy just the fractional part of a into t.
    e.g. if a has the value 5.86 then 0.86 is placed in t.
  • sqt t a - Find the square root of a, put result in t.
  • rsq t a – Find 1 divided by the square root of a, put result in t.
  • pow t a b – Raise a to the power of b, put result in t.
  • log t a – Find the binary logarithm of a, put result in t.
  • exp t a – Raise 2 to the power of a, put result in t.
  • nrm t a – Normalise the vector given in a (keep same direction, but make it length 1), put result in t.
  • sin t a – Find the sine of a, put result in t.
  • cos t a – Find the cosine of a, put result in t.
  • crs t a b – Find the cross product of the vectors a and b, put result in t.
  • dp3 t a b – Find the dot product of the three-dimensional vectors a and b, put result in t.
  • dp4 t a b – Find the dot product of the four-dimensional vectors a and b, put result in t.
  • abs t a – Find the absolute value of a, put result in t.
  • neg t a – Multiply a by -1, put result in t.
  • sat t a – Clamp a between 1 and 0, put result in t.
    e.g. if a is -4.6, 0 will be placed in t.
    If a is 0.6, 0.6 will be placed in t.
    If a is 8.2, 1 will be placed in t.
  • m33 t a b – Perform a 3×3 matrix multiply on a and b, put result in t.
  • m44 t a b – Perform a 4×4 matrix multiply on a and b, put result in t.
  • m34 t a b – Perform a 3×4 matrix multiply on a and b, put result in t.
  • m43 t a b – Perform a 4×3 matrix multiply on a and b, put result in t.
    I need to write a decent explanation of what matrix operations do.
    In all of these, b is the first register that makes up a matrix. For instance if you perform m44 with b as vc0 then the contents of registers vc0 vc1 vc2 vc3 will be used. a is a single register that gets multiplied through by the matrix specified in b.
  • sge t a b - If a is greater or equal to b put 1 in t, otherwise put 0 in t.
  • slt t a b – If a is less than b put 1 in t, otherwise put 0 in t.
    sge and slt are the closest we have to conditional flow control in AGAL so look out for ways to use multiplication of their 1 or 0 result in place of traditional conditionals.

Operations only available to fragment shaders:
  • kil a - a must be a single scalar value rather than a vector, for instance: ft0.x. If the value given is less than zero then execution on this fragment is halted and it is not drawn.
  • tex t a b  - Samples the texture in b (which should be one of the fs registers) at the coordinates in a, putting the resulting colour in t.
    • type determines what kind of texture you’re sampling from, and should be either: “2d” for standard texturing or “cube” for using a cubemap.
    • wrap determines how to deal with sampling beyond the bounds of the texture, either: “clamp” or “repeat”.
    • filter determines how to interpolate between texels, either “mipnearest”, “miplinear” (both of those require mipmaps to have been uploaded for the texture), “nearest”, or “linear”. Use nearest if you want your texture to have crisp pixel edges, use linear if you want them smoothed out.
Reference:  http://www.saltgames.com/2011/stage-3d-shader-cheatsheet/

Visual Studio Keyboard Shortcuts

Playing with keyboard shortcuts is very interesting and reduce the headache of using the mouse again and again while programming with visu...