Game Development Reference
In-Depth Information
Lines 106-107 : Finally, the destination pixels are pushed back to the
destination texture buffer, and the Apply function is called to confirm the
operation. Unity also supports a SetPixel function (singular) as opposed to
SetPixels (plural). However, SetPixels results in better performance as it
repeats the calling of SetPixel .
Lines 111-114 : The GetPixelFromArray function accepts an array of pixel
data as well as the x and y coordinates of a pixel and the pixel width of the
texture data. On the basis of this, it returns a linear index into the pixel array
where you can find the pixel color value.
Lines 117-131 : The SetPixelInArray function changes the color of a pixel
in a linear array. The method of change is determined by the argument
Blending . If Blending is set to false , the source pixel would simply replace
the destination pixel. If Blending is true , the source pixel would be blended
or layered onto the destination pixel that preserves the alpha transparency.
Blending should be set to true when painting alpha-transparent brushes onto
the target texture to allow for the accumulation and blending of color values.
Step 3 - setting up texture painting
Now that we have a working shader, texture-painting script, and configured
textures, we'll take a step-by-step run-through of configuring texture painting in
Unity. Start from an empty project, including only our shader, texture painting
script, and two configured textures: a background texture and a brush texture,
as shown here:
Starting a texture-painting project
 
Search WWH ::




Custom Search