Replacing Textures with Material Colors

 
< previous page next page >

In this tutorial we will learn how to replace textures with material colors. This procedure can help generating very light weight 3D models (if paired with decimation usually only two or three figure Kilobytes in file size) which can for example be used in an app to act as preview placeholders while the full quality asset is loading in the background.

Let us start with downloading the source model here.

Table of Contents

Settings

 back to top

We will use the following pool of settings to replace textures with material colors according to a certain threshold between 0 and 255:

Flat Texture Treshold

Name Type Default Valid Range Quick Description
compact:baseColorFlatTexThreshold Int 0 {0 .. 255} per channel maximum distance threshold below which this texture will be replaced with material value
compact:displacementFlatTexThreshold Int 0 {0 .. 255} per channel maximum distance threshold below which this texture will be replaced with material value
compact:emissiveFlatTexThreshold Int 0 {0 .. 255} per channel maximum distance threshold below which this texture will be replaced with material value
compact:metallicFlatTexThreshold Int 0 {0 .. 255} per channel maximum distance threshold below which this texture will be replaced with material value
compact:normalsFlatTexThreshold Int 0 {0 .. 255} per channel maximum distance threshold below which this texture will be replaced with material value
compact:occlusionFlatTexThreshold Int 0 {0 .. 255} per channel maximum distance threshold below which this texture will be replaced with material value
compact:roughnessFlatTexThreshold Int 0 {0 .. 255} per channel maximum distance threshold below which this texture will be replaced with material value
compact:specularFlatTexThreshold Int 0 {0 .. 255} per channel maximum distance threshold below which this texture will be replaced with material value


Examples

 back to top

Example 1

For this example we will demonstrate the flat texture threshold of 255 with the base color map; This means that all base color textures will be considered flat and thus replaced by material colors no matter how much the pixels in the texture are deviating from the average pixel:

	rpdx -s compact:baseColorFlatTexThreshold 255 -i Shelf-Plant.glb -c f:100% -e Shelf-Plant_bc-255.glb
	

Input Model using textures on the left; After dropping the textures with a flat texture threshold setting of 255 for each map, right.

Example 2

Now we will use a flat texture threshold of 125 and after that 75 with the base color map; This means that base color textures will only be considered flat and thus replaced by material colors if the pixels in the texture(s) differ in RGB values in the range of +- 125 or +- 75 respectively from the average pixel color of the whole texture:

	rpdx -s compact:baseColorFlatTexThreshold 125 -i Shelf-Plant.glb -c f:100% -e Shelf-Plant_bc-125.glb
	
	rpdx -s compact:baseColorFlatTexThreshold 75 -i Shelf-Plant.glb -c f:100% -e Shelf-Plant_bc-75.glb
	

Base Color flat texture threshold of 125 on the left; Base Color flat texture threshold of 75 on the right.

As you can see the value of 125 allowed enough of a threshold between RGB values to consider some textures, such as the ones of the plant pot, as flat and thus got replaced by material colors.

In the other case, the threshold of 75 was exceeded for all pixels of all textures (compared to the respective average pixel color of each texture) and thus the textures were considered not flat and therefore no replacement with material colors.



< previous page next page >