C# Class Nez.Textures.TextureUtils

various utilties for creating textures on the fly. These can be pretty heavy on the CPU so it's best to not try to use them every frame.
Afficher le fichier Open project: prime31/Nez

Méthodes publiques

Méthode Description
createBlurredGrayscaleTexture ( Microsoft.Xna.Framework.Color srcData, int width, int height, double deviation = 1 ) : Microsoft.Xna.Framework.Color[]
createBlurredGrayscaleTexture ( Microsoft.Xna.Framework.Graphics.Texture2D image, double deviation = 1 ) : Microsoft.Xna.Framework.Graphics.Texture2D

creates a new texture that is a gaussian blurred version of the original in grayscale

createBlurredTexture ( Microsoft.Xna.Framework.Color srcData, int width, int height, double deviation = 1 ) : Microsoft.Xna.Framework.Color[]
createBlurredTexture ( Microsoft.Xna.Framework.Graphics.Texture2D image, double deviation = 1 ) : Microsoft.Xna.Framework.Graphics.Texture2D

creates a new texture that is a gaussian blurred version of the original

createFlatHeightmap ( Microsoft.Xna.Framework.Color srcData, Microsoft.Xna.Framework.Color opaqueColor, Microsoft.Xna.Framework.Color transparentColor ) : Microsoft.Xna.Framework.Color[]
createFlatHeightmap ( Microsoft.Xna.Framework.Graphics.Texture2D image, Microsoft.Xna.Framework.Color opaqueColor, Microsoft.Xna.Framework.Color transparentColor ) : Microsoft.Xna.Framework.Graphics.Texture2D

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 )

createNormalMap ( Microsoft.Xna.Framework.Color srcData, EdgeDetectionFilter filter, int width, int height, float normalStrength = 1f, bool invertX = false, bool invertY = false ) : Microsoft.Xna.Framework.Color[]
createNormalMap ( Microsoft.Xna.Framework.Graphics.Texture2D image, EdgeDetectionFilter filter, float normalStrength = 1f, bool invertX = false, bool invertY = false ) : Microsoft.Xna.Framework.Graphics.Texture2D

generates a normal map from a height map calculating it with a sobel filter

Method Details

createBlurredGrayscaleTexture() public static méthode

public static createBlurredGrayscaleTexture ( Microsoft.Xna.Framework.Color srcData, int width, int height, double deviation = 1 ) : Microsoft.Xna.Framework.Color[]
srcData Microsoft.Xna.Framework.Color
width int
height int
deviation double
Résultat Microsoft.Xna.Framework.Color[]

createBlurredGrayscaleTexture() public static méthode

creates a new texture that is a gaussian blurred version of the original in grayscale
public static createBlurredGrayscaleTexture ( Microsoft.Xna.Framework.Graphics.Texture2D image, double deviation = 1 ) : Microsoft.Xna.Framework.Graphics.Texture2D
image Microsoft.Xna.Framework.Graphics.Texture2D Image.
deviation double Deviation.
Résultat Microsoft.Xna.Framework.Graphics.Texture2D

createBlurredTexture() public static méthode

public static createBlurredTexture ( Microsoft.Xna.Framework.Color srcData, int width, int height, double deviation = 1 ) : Microsoft.Xna.Framework.Color[]
srcData Microsoft.Xna.Framework.Color
width int
height int
deviation double
Résultat Microsoft.Xna.Framework.Color[]

createBlurredTexture() public static méthode

creates a new texture that is a gaussian blurred version of the original
public static createBlurredTexture ( Microsoft.Xna.Framework.Graphics.Texture2D image, double deviation = 1 ) : Microsoft.Xna.Framework.Graphics.Texture2D
image Microsoft.Xna.Framework.Graphics.Texture2D Image.
deviation double Deviation.
Résultat Microsoft.Xna.Framework.Graphics.Texture2D

createFlatHeightmap() public static méthode

public static createFlatHeightmap ( Microsoft.Xna.Framework.Color srcData, Microsoft.Xna.Framework.Color opaqueColor, Microsoft.Xna.Framework.Color transparentColor ) : Microsoft.Xna.Framework.Color[]
srcData Microsoft.Xna.Framework.Color
opaqueColor Microsoft.Xna.Framework.Color
transparentColor Microsoft.Xna.Framework.Color
Résultat Microsoft.Xna.Framework.Color[]

createFlatHeightmap() public static méthode

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 createFlatHeightmap ( Microsoft.Xna.Framework.Graphics.Texture2D image, Microsoft.Xna.Framework.Color opaqueColor, Microsoft.Xna.Framework.Color transparentColor ) : Microsoft.Xna.Framework.Graphics.Texture2D
image Microsoft.Xna.Framework.Graphics.Texture2D Image.
opaqueColor Microsoft.Xna.Framework.Color Opaque color.
transparentColor Microsoft.Xna.Framework.Color Transparent color.
Résultat Microsoft.Xna.Framework.Graphics.Texture2D

createNormalMap() public static méthode

public static createNormalMap ( Microsoft.Xna.Framework.Color srcData, EdgeDetectionFilter filter, int width, int height, float normalStrength = 1f, bool invertX = false, bool invertY = false ) : Microsoft.Xna.Framework.Color[]
srcData Microsoft.Xna.Framework.Color
filter EdgeDetectionFilter
width int
height int
normalStrength float
invertX bool
invertY bool
Résultat Microsoft.Xna.Framework.Color[]

createNormalMap() public static méthode

generates a normal map from a height map calculating it with a sobel filter
public static createNormalMap ( Microsoft.Xna.Framework.Graphics.Texture2D image, EdgeDetectionFilter filter, float normalStrength = 1f, bool invertX = false, bool invertY = false ) : Microsoft.Xna.Framework.Graphics.Texture2D
image Microsoft.Xna.Framework.Graphics.Texture2D Image.
filter EdgeDetectionFilter
normalStrength float Normal strength.
invertX bool
invertY bool
Résultat Microsoft.Xna.Framework.Graphics.Texture2D