Nez.Portable/Graphics/Textures/TextureUtils.cs
/// <summary>
/// processes each pixel of the passed in Texture and in the output texture transparent pixels will be transparentColor and opaque pixels
/// will be opaqueColor. This is useful for creating normal maps for rim lighting by applying a grayscale blur then using createNormalMap*
/// by doing something like the following. The first step is used only for making rim lighting normal maps:
/// - var maskTex = createFlatHeightmap( tex, Color.White, Color.Black )
/// - var blurredTex = createBlurredGrayscaleTexture( maskTex, 1 )
/// - createNormalMap( blurredTex, 50f )
/// </summary>
/// <returns>The flat heightmap.</returns>
/// <param name="image">Image.</param>
/// <param name="opaqueColor">Opaque color.</param>
/// <param name="transparentColor">Transparent color.</param>
processes each pixel of the passed in Texture and in the output texture transparent pixels will be transparentColor and opaque pixels
will be opaqueColor. This is useful for creating normal maps for rim lighting by applying a grayscale blur then using createNormalMap
by doing something like the following. The first step is used only for making rim lighting normal maps:
var maskTex = createFlatHeightmap( tex, Color.White, Color.Black )
var blurredTex = createBlurredGrayscaleTexture( maskTex, 1 )
createNormalMap( blurredTex, 50f )
processes each pixel of the passed in Texture and in the output texture transparent pixels will be transparentColor and opaque pixels will be opaqueColor . This is useful for creating normal maps for rim lighting by applying a grayscale blur then using createNormalMap by doing something like the following . The first step is used only for making rim lighting normal maps : var maskTex = createFlatHeightmap ( tex Color . White Color . Black ) var blurredTex = createBlurredGrayscaleTexture ( maskTex 1 ) createNormalMap ( blurredTex 50f )
public static Texture2D createFlatHeightmap(Texture2D image, Color opaqueColor, Color transparentColor)
        {
            var resultTex = new Texture2D(Core.graphicsDevice, image.Width, image.Height, false, SurfaceFormat.Color);
            var srcData = new Color[image.Width * image.Height];
            image.GetData<Color>(srcData);
            var destData = createFlatHeightmap(srcData, opaqueColor, transparentColor);
            resultTex.SetData(destData);
            return resultTex;
        }
public static Texture2D createFlatHeightmap ( Texture2D image , Color opaqueColor , Color transparentColor ) { var resultTex = new Texture2D ( Core . graphicsDevice , image . Width , image . Height , false , SurfaceFormat . Color ) ; var srcData = new Color [ image . Width * image . Height ] ; image . GetData < Color > ( srcData ) ; var destData = createFlatHeightmap ( srcData , opaqueColor , transparentColor ) ; resultTex . SetData ( destData ) ; return resultTex ; }
processes each pixel of the passed in Texture and in the output texture transparent pixels will be transparentColor and opaque pixels
will be opaqueColor.
processes each pixel of the passed in Texture and in the output texture transparent pixels will be transparentColor and opaque pixels will be opaqueColor .
The flat heightmap.
The flat heightmap .
image
Texture2D
None
opaqueColor
Color
None
transparentColor
Color
None