Nez.Portable/Graphics/Textures/TextureUtils.cs
/// <summary>
/// generates a normal map from a height map calculating it with a sobel filter
/// </summary>
/// <returns>The sobel filter.</returns>
/// <param name="image">Image.</param>
/// <param name="normalStrength">Normal strength.</param>
generates a normal map from a height map calculating it with a sobel filter
generates a normal map from a height map calculating it with a sobel filter
public static Texture2D createNormalMap(
            Texture2D image,
            EdgeDetectionFilter filter,
            float normalStrength = 1f,
            bool invertX = false,
            bool invertY = false)
        {
            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 = createNormalMap(
                srcData,
                filter,
                image.Width,
                image.Height,
                normalStrength,
                invertX,
                invertY);
            resultTex.SetData(destData);
            return resultTex;
        }
public static Texture2D createNormalMap ( Texture2D image , EdgeDetectionFilter filter , float normalStrength = 1f , bool invertX = false , bool invertY = false ) { 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 = createNormalMap ( srcData , filter , image . Width , image . Height , normalStrength , invertX , invertY ) ; resultTex . SetData ( destData ) ; return resultTex ; }
generates a normal map from a height map calculating it with a sobel filter
generates a normal map from a height map calculating it with a sobel filter
The sobel filter.
The sobel filter .
image
Texture2D
None
filter
EdgeDetectionFilter
normalStrength
float
None
invertX
bool
invertY
bool