Click or drag to resize
Ab4d.SharpEngine logo

StandardMaterialBase Class

StandardMaterialBase is a bases class for StandardMaterial and SolidColorMaterial and provides common functionality for diffuse material and diffuse texture loading.
Inheritance Hierarchy

Namespace: Ab4d.SharpEngine.Materials
Assembly: Ab4d.SharpEngine (in Ab4d.SharpEngine.dll) Version: 2.0.8956+4c7684e186ca1be74e7a284fbe739d9a1b843d3c
Syntax
C#
public abstract class StandardMaterialBase : Material, 
	ITransparentMaterial, IDiffuseMaterial, IDiffuseTextureMaterial

The StandardMaterialBase type exposes the following members.

Constructors
 NameDescription
Protected methodStandardMaterialBase Constructor
Top
Properties
 NameDescription
Public propertyAlphaClipThreshold Pixels with alpha color values below this value will be clipped (not rendered and their depth will not be written to depth buffer). Expected values are between 0 and 1. When 0 (by default) then alpha clipping is disabled - this means that also pixels with alpha value 0 are fully processed (they are not visible but its depth value is still written so objects that are rendered afterwards and are behind the pixel will not be visible).
Public propertyDiffuseColor Gets or sets a Color3 that specifies the diffuse color of this material. Default value is Black. But when the DiffuseTexture is set and the user does not set the DiffuseColor, then the DiffuseColor is automatically set to White color to preserve the colors in the texture.
Public propertyDiffuseTexture Gets or sets a GpuImage objects that define the texture. When rendering texture, the colors from texture are multiplied by the DiffuseColor (White color is used when a texture is set and DiffuseColor is not changed by the user). When user does not set the DiffuseColor but sets the DiffuseTexture, then the DiffuseColor is automatically set to White color to preserve the colors in the texture. The GpuImage is not disposed when disposing this Material (except when calling DisposeWithTexture method).
Public propertyDiffuseTextureSampler Gets the GpuSampler that defines how the diffuse texture is read by the graphics card. The sampler can be set by DiffuseTextureSamplerType or by calling the SetDiffuseTextureSampler(GpuSampler) method.
Public propertyDiffuseTextureSamplerType Gets or sets the sampler type for the diffuse texture. Sampler type defines how the texture is read by the graphics card. Default value is Mirror. Setting this property sets the DiffuseTextureSampler with the actual GpuSampler when the material is initialized. It is also possible to set the DiffuseTextureSampler by calling the SetDiffuseTextureSampler(GpuSampler) method.
Public propertyHasTransparency Gets or sets a boolean that specifies if this material is semi-transparent and needs to be alpha blended with the scene. This value is automatically set to true when Opacity is set to a value smaller than 1. When using DiffuseTextures, user need to manually set the HasTransparency value based on the texture format and content.
Public propertyIsPreMultipliedAlphaColor When IsPreMultipliedAlphaColor is true (false by default) and Opacity is less then 1, then the color components of the DiffuseColor are already multiplied with alpha value to produce pre-multiplied colors. When false, then non-premultiplied color is converted in pre-multiplied color when this is required by the shader. Default value is false.
Public propertyOpacity Gets or sets a float value that defines the opacity for the material, for example 1 means fully opaque and 0 means fully transparent. When HasTransparency was not manually set, then changing Opacity value also updates HasTransparency value. Default value is 1;
Public propertyTextureSource Gets a source string that can contain file name or other string that defines the source of this GpuImage (TextureSource is read from GpuImage object and can be null even when DiffuseTexture is set).
Top
Methods
 NameDescription
Public methodCreateDiffuseTexture(RawImageData, CommonSamplerTypes, String, Single) CreateDiffuseTexture creates a GpuImage object from the specified rawImageData. If this material was already initialized ([!:Material.Scene] is set), then this method sets the DiffuseTexture, DiffuseTextureSamplerType and DiffuseTextureSampler properties. If this material was not yet initialized, then the creation of the texture is postponed until the InitializeResources method is called. To immediately create the texture call this method and pass a VulkanDevice as the first parameter. The created GpuImage is disposed when this Material is disposed.
Public methodCreateDiffuseTexture(VulkanDevice, RawImageData, CommonSamplerTypes, String, Single) CreateDiffuseTexture creates a GpuImage object from the specified rawImageData. The method sets the DiffuseTexture, DiffuseTextureSamplerType and DiffuseTextureSampler properties. Calling this method requires a valid gpuDevice objects. If you want to lazily create a diffuse texture before the device is known, call the method without the gpuDevice parameter. The created GpuImage is disposed when this Material is disposed.
Protected methodDispose Releases unmanaged and managed resources (when disposing is true). This method may be called only from the CheckAndDispose(Boolean) method and must not be called manually by the user.
(Overrides MaterialDispose(Boolean))
Public methodDisposeWithTexture DisposeWithTexture disposes this Material and also disposes the GpuImage that is assigned to the DiffuseTexture (if it is not cached by the Scene) even if the textures were created by the user and then set to the DiffuseTexture property (in this case the standard Dispose method does not dispose the DiffuseTexture).
Public methodGetDetailsText GetDetailsText adds string that writes details about this Material into the specified StringBuilder.
(Overrides MaterialGetDetailsText(StringBuilder, Boolean, Boolean, Boolean))
Public methodLoadDiffuseTexture(String, IBitmapIO, CommonSamplerTypes, Single, Boolean, Boolean) LoadDiffuseTexture lazily loads the specified textureFileName, creates a GpuImage object from the file and sets it to the DiffuseTexture property. The method also sets DiffuseTextureSamplerType and DiffuseTextureSampler properties. If this material was not yet initialized when this method is called ([!:Material.Scene] is not yet set), then the creation of the texture is postponed until the InitializeSceneResources method is called. To immediately create the texture, call this method and pass a VulkanDevice as the first parameter. When the created GpuImage is not cached by the Scene (useSceneCache is false by default) or GpuDevice (useGpuDeviceCache is true by default), then it is disposed when this Material is disposed.
Public methodLoadDiffuseTexture(VulkanDevice, String, IBitmapIO, CommonSamplerTypes, Single, Boolean) LoadDiffuseTexture immediately loads the specified textureFileName, creates a GpuImage object from the file and sets it to the DiffuseTexture property. The method also sets DiffuseTexture, DiffuseTextureSamplerType and DiffuseTextureSampler properties. Calling this method requires a valid gpuDevice objects. When useGpuDeviceCache is true (by default), then before loading the image the GpuDevice's cache is checked if this file was already loaded. Also, the create GpuImage is cached by the GpuDevice's cache. If you want to use Scene case, use the method override that takes Scene objects as parameter. If you want to lazily create a diffuse texture before the device is known, call the method without the gpuDevice parameter. When the created GpuImage is not cached by the GpuDevice (useGpuDeviceCache is true by default), then it is disposed when this Material is disposed.
Public methodLoadDiffuseTexture(Scene, String, IBitmapIO, CommonSamplerTypes, Single, Boolean, Boolean) LoadDiffuseTexture immediately loads the specified textureFileName, creates a GpuImage object from the file and sets it to the DiffuseTexture property. The method also sets DiffuseTexture, DiffuseTextureSamplerType and DiffuseTextureSampler properties. Calling this method requires a valid Scene object that has initialized GpuDevice set. When useGpuDeviceCache is true (by default), then before loading the image the Scene's cache is checked if this file was already loaded. Also, the create GpuImage is cached by the Scene's cache. If you want to use GpuDevice case, use the method override that takes GpuDevice objects as parameter. If you want to lazily create a diffuse texture before the device is known, call the method without the Scene parameter. When the created GpuImage is not cached by the Scene (useSceneCache is false by default) or GpuDevice (useGpuDeviceCache is true by default), then it is disposed when this Material is disposed.
Public methodLoadDiffuseTexture(Stream, String, IBitmapIO, CommonSamplerTypes, Single, Boolean, Boolean) LoadDiffuseTexture lazily loads the texture from the specified file steam, creates a GpuImage object from the file and sets it to the DiffuseTexture property. The method also sets DiffuseTextureSamplerType and DiffuseTextureSampler properties. If this material was not yet initialized when this method is called ([!:Material.Scene] is not yet set), then the creation of the texture is postponed until the InitializeSceneResources method is called. To immediately create the texture, call this method and pass a VulkanDevice as the first parameter. When the created GpuImage is not cached by the Scene (useSceneCache is false by default) or GpuDevice (useGpuDeviceCache is true by default), then it is disposed when this Material is disposed.
Public methodLoadDiffuseTexture(VulkanDevice, Stream, String, IBitmapIO, CommonSamplerTypes, Single, Boolean) LoadDiffuseTexture immediately loads the texture from the specified file steam, creates a GpuImage object from the file and sets it to the DiffuseTexture property. The method also sets DiffuseTexture, DiffuseTextureSamplerType and DiffuseTextureSampler properties. Calling this method requires a valid gpuDevice objects. When useGpuDeviceCache is true (by default), then before loading the image the GpuDevice's cache is checked if this file was already loaded. Also, the create GpuImage is cached by the GpuDevice's cache. If you want to use Scene case, use the method override that takes Scene objects as parameter. If you want to lazily create a diffuse texture before the device is known, call the method without the gpuDevice parameter. When the created GpuImage is not cached by the GpuDevice (useGpuDeviceCache is true by default), then it is disposed when this Material is disposed.
Public methodLoadDiffuseTexture(Scene, Stream, String, IBitmapIO, CommonSamplerTypes, Single, Boolean, Boolean) LoadDiffuseTexture immediately loads the texture from the specified file steam, creates a GpuImage object from the file and sets it to the DiffuseTexture property. The method also sets DiffuseTexture, DiffuseTextureSamplerType and DiffuseTextureSampler properties. Calling this method requires a valid Scene object that has initialized GpuDevice set. When useGpuDeviceCache is true (by default), then before loading the image the Scene's cache is checked if this file was already loaded. Also, the create GpuImage is cached by the Scene's cache. If you want to use GpuDevice case, use the method override that takes GpuDevice objects as parameter. If you want to lazily create a diffuse texture before the device is known, call the method without the Scene parameter. When the created GpuImage is not cached by the Scene (useSceneCache is false by default) or GpuDevice (useGpuDeviceCache is true by default), then it is disposed when this Material is disposed.
Protected methodOnDiffuseTextureDisposing OnDiffuseTextureDisposing
Protected methodOnInitializeSceneResources Initializes resources with the specified Scene and GpuDevice. This method can be override and is called from InitializeSceneResources(Scene) method.
(Overrides MaterialOnInitializeSceneResources(Scene, VulkanDevice))
Protected methodResetMaterialBase ResetMaterialBase
Public methodSetDiffuseTextureSampler SetDiffuseTextureSampler method sets the DiffuseTextureSampler to the specified sampler. It also sets the DiffuseTextureSamplerType to Other. It is also possible to set the DiffuseTextureSampler to a common sampler by setting the DiffuseTextureSamplerType.
Protected methodSetWhiteDiffuseColor SetWhiteDiffuseColor sets DiffuseColor to white behind the scenes so that the DiffuseColor is not marked to be changed by the user. This is used when setting texture so that texture is not masked by any other color.
Top
Fields
 NameDescription
Public fieldStatic memberUseGpuDeviceCacheForTextures Static UseGpuDeviceCacheForTextures specifies if by default the texture that are loaded by providing the file name are cached by the GpuDevice (so future request for the same file will use cached GpuImage). This does not affect textures that are loaded by manually calling LoadDiffuseTexture method. Default value is true. Note that when UseSceneCacheForTextures is true, then this value is not used.
Public fieldStatic memberUseSceneCacheForTextures Static UseSceneCacheForTextures specifies if by default the texture that are loaded by providing the file name are cached by the Scene object (so future request for the same file will use cached GpuImage). This does not affect textures that are loaded by manually calling LoadDiffuseTexture method. Default value is false. See also UseGpuDeviceCacheForTextures.
Top
See Also