MeshBaker
DigitalOpus.MB.Core.TextureBlender Interface Reference

A TextureBlender will attempt to blend non-texture properties with textures so that the result material looks the same as source material. More...

Inheritance diagram for DigitalOpus.MB.Core.TextureBlender:
DigitalOpus.MB.Core.TextureBlenderFallback DigitalOpus.MB.Core.TextureBlenderLegacyBumpDiffuse DigitalOpus.MB.Core.TextureBlenderLegacyDiffuse DigitalOpus.MB.Core.TextureBlenderStandardMetallic DigitalOpus.MB.Core.TextureBlenderStandardSpecular

Public Member Functions

bool DoesShaderNameMatch (string shaderName)
 The shader name that must be matched on the result material in order for this TextureBlender to be used. More...
 
void OnBeforeTintTexture (Material sourceMat, string shaderTexturePropertyName)
 This is called to prepare the TextureBlender before any calls to OnBlendTexturePixel Use this to grab the non-texture property values from the material that will be used to alter the Pixel color in the texture. More...
 
Color OnBlendTexturePixel (string shaderPropertyName, Color pixelColor)
 Called once for each pixel in the texture to alter the pixel color. More...
 
bool NonTexturePropertiesAreEqual (Material a, Material b)
 Material a & b may have the same set of textures but different non-texture properties (colorTint etc...) If so then they need to be put into separate rectangels in the atlas. More...
 
void SetNonTexturePropertyValuesOnResultMaterial (Material resultMaterial)
 Sets the non texture properties on the result materail after textures have been baked. More...
 
Color GetColorIfNoTexture (Material m, ShaderTextureProperty texPropertyName)
 Some textures may not be assigned for a material. More...
 

Detailed Description

A TextureBlender will attempt to blend non-texture properties with textures so that the result material looks the same as source material.

Member Function Documentation

§ DoesShaderNameMatch()

bool DigitalOpus.MB.Core.TextureBlender.DoesShaderNameMatch ( string  shaderName)

The shader name that must be matched on the result material in order for this TextureBlender to be used.

This should return something like "Legacy/Bumped Difuse"

Implemented in DigitalOpus.MB.Core.TextureBlenderStandardSpecular, DigitalOpus.MB.Core.TextureBlenderStandardMetallic, DigitalOpus.MB.Core.TextureBlenderFallback, DigitalOpus.MB.Core.TextureBlenderLegacyBumpDiffuse, and DigitalOpus.MB.Core.TextureBlenderLegacyDiffuse.

§ GetColorIfNoTexture()

Color DigitalOpus.MB.Core.TextureBlender.GetColorIfNoTexture ( Material  m,
ShaderTextureProperty  texPropertyName 
)

Some textures may not be assigned for a material.

This method should return a color that will used to create a small solid color texture to be used in these cases.

Implemented in DigitalOpus.MB.Core.TextureBlenderStandardSpecular, DigitalOpus.MB.Core.TextureBlenderStandardMetallic, DigitalOpus.MB.Core.TextureBlenderFallback, DigitalOpus.MB.Core.TextureBlenderLegacyBumpDiffuse, and DigitalOpus.MB.Core.TextureBlenderLegacyDiffuse.

§ NonTexturePropertiesAreEqual()

bool DigitalOpus.MB.Core.TextureBlender.NonTexturePropertiesAreEqual ( Material  a,
Material  b 
)

Material a & b may have the same set of textures but different non-texture properties (colorTint etc...) If so then they need to be put into separate rectangels in the atlas.

This method should check the non-texture properties and return false if they are different. Note that material a and b may use a different shader than GetShaderName so your code should handle the case where properties do not exist.

Implemented in DigitalOpus.MB.Core.TextureBlenderStandardSpecular, DigitalOpus.MB.Core.TextureBlenderStandardMetallic, DigitalOpus.MB.Core.TextureBlenderFallback, DigitalOpus.MB.Core.TextureBlenderLegacyBumpDiffuse, and DigitalOpus.MB.Core.TextureBlenderLegacyDiffuse.

§ OnBeforeTintTexture()

void DigitalOpus.MB.Core.TextureBlender.OnBeforeTintTexture ( Material  sourceMat,
string  shaderTexturePropertyName 
)

This is called to prepare the TextureBlender before any calls to OnBlendTexturePixel Use this to grab the non-texture property values from the material that will be used to alter the Pixel color in the texture.

Note that the sourceMat may not use a shader matching ShaderName. It may not have expected properties. Check that properties exist before grabing them.

Implemented in DigitalOpus.MB.Core.TextureBlenderStandardSpecular, DigitalOpus.MB.Core.TextureBlenderStandardMetallic, DigitalOpus.MB.Core.TextureBlenderLegacyBumpDiffuse, DigitalOpus.MB.Core.TextureBlenderLegacyDiffuse, and DigitalOpus.MB.Core.TextureBlenderFallback.

§ OnBlendTexturePixel()

Color DigitalOpus.MB.Core.TextureBlender.OnBlendTexturePixel ( string  shaderPropertyName,
Color  pixelColor 
)

Called once for each pixel in the texture to alter the pixel color.

For efficiency don't check shaderPropertyName every call. Instead use OnBeforeTintTexture to prepare this textrure blender for a batch of OnBlendTexturePixel calls.

Implemented in DigitalOpus.MB.Core.TextureBlenderStandardSpecular, DigitalOpus.MB.Core.TextureBlenderStandardMetallic, DigitalOpus.MB.Core.TextureBlenderFallback, DigitalOpus.MB.Core.TextureBlenderLegacyBumpDiffuse, and DigitalOpus.MB.Core.TextureBlenderLegacyDiffuse.

§ SetNonTexturePropertyValuesOnResultMaterial()

void DigitalOpus.MB.Core.TextureBlender.SetNonTexturePropertyValuesOnResultMaterial ( Material  resultMaterial)

Sets the non texture properties on the result materail after textures have been baked.

If for example _Color has been blended with the _Albedo textures then the _Color property on the result material should probably be set to white.

Implemented in DigitalOpus.MB.Core.TextureBlenderStandardSpecular, DigitalOpus.MB.Core.TextureBlenderStandardMetallic, DigitalOpus.MB.Core.TextureBlenderFallback, DigitalOpus.MB.Core.TextureBlenderLegacyBumpDiffuse, and DigitalOpus.MB.Core.TextureBlenderLegacyDiffuse.


The documentation for this interface was generated from the following file: