imageApproxRatio function


  • string imageApproxRatio(searchQuery, axisSelector, n )


  1. searchQuerystring
    Search query to apply on list of all files in the workspace. See fileSearch for details about the syntax.
  2. axisSelectorstring
    { xy | xz | yx | yz | zx | zy }—selector which defines which scope axes ratio is used as a reference.
  3. nfloat
    Number (integer >= 1) of textures to consider (one is randomly picked out of the n best textures.


Texture with one of the n best ratio matches (according to axisSelector).


The imageApproxRatio function returns one of the n textures with the best ratio match, from the file list specified in searchQuery, according to the specified combination of axes.


imageApproxRatio(path, axisSelector, 1) = imageBestRatio(path, axisSelector)



Setting up texturing based on the best pixel ratio

The goal is to set up the texturing, depending on the best pixel ratio of the list of desired textures. The following textures all have different resolutions.

Textures with different resolutions

Note the color variations in the next two images by using only the "best ratio" (n = 1) and "choose randomly one of the best three ratios" (n = 3).

n = 1:
Lot --> s('.9,'.9,'.9) center(xz) recursiveSplit(0)
recursiveSplit(n) -->
	case >= 1.5 && >= 1.5:
		split(x){ split(z){ recursiveSplit(n+1)}*}*
	else: doTexturing
doTexturing -->
	set(material.colormap, imageApproxRatio("/myProject/assets/textures/*.jpg", "xz",1))
	setupProjection(0, scope.xz,,
Texture with n =1
n = 3:
	set(material.colormap, imageApproxRatio("/myProject/assets/textures/*.jpg", "xz", 3))
Texture with n = 3

In this topic