Back to Filament

setParameter

docs/android/dokka/filament-android/com.google.android.filament/-material-instance/set-parameter.md

1.75.016.4 KB
Original Source

//filament-android/com.google.android.filament/MaterialInstance/setParameter

setParameter

[main]
open fun setParameter(name: String, x: Boolean)

Sets the value of a bool parameter.

Parameters

main

namethe name of the material parameter
xthe value of the material parameter

Throws

RuntimeExceptionif name doesn't exist or no-op if exceptions are disabled.

[main]
open fun setParameter(name: String, x: Float)

Sets the value of a float parameter.

Parameters

main

namethe name of the material parameter
xthe value of the material parameter

Throws

RuntimeExceptionif name doesn't exist or no-op if exceptions are disabled.

[main]
open fun setParameter(name: String, x: Int)

Sets the value of an int parameter.

Parameters

main

namethe name of the material parameter
xthe value of the material parameter

Throws

RuntimeExceptionif name doesn't exist or no-op if exceptions are disabled.

[main]
open fun setParameter(name: String, x: Boolean, y: Boolean)

Sets the value of a bool2 parameter.

Parameters

main

namethe name of the material parameter
xthe value of the first component
ythe value of the second component

Throws

RuntimeExceptionif name doesn't exist or no-op if exceptions are disabled.

[main]
open fun setParameter(name: String, x: Float, y: Float)

Sets the value of a float2 parameter.

Parameters

main

namethe name of the material parameter
xthe value of the first component
ythe value of the second component

Throws

RuntimeExceptionif name doesn't exist or no-op if exceptions are disabled.

[main]
open fun setParameter(name: String, x: Int, y: Int)

Sets the value of an int2 parameter.

Parameters

main

namethe name of the material parameter
xthe value of the first component
ythe value of the second component

Throws

RuntimeExceptionif name doesn't exist or no-op if exceptions are disabled.

[main]
open fun setParameter(name: String, x: Boolean, y: Boolean, z: Boolean)

Sets the value of a bool3 parameter.

Parameters

main

namethe name of the material parameter
xthe value of the first component
ythe value of the second component
zthe value of the third component

Throws

RuntimeExceptionif name doesn't exist or no-op if exceptions are disabled.

[main]
open fun setParameter(name: String, x: Float, y: Float, z: Float)

Sets the value of a float3 parameter.

Parameters

main

namethe name of the material parameter
xthe value of the first component
ythe value of the second component
zthe value of the third component

Throws

RuntimeExceptionif name doesn't exist or no-op if exceptions are disabled.

[main]
open fun setParameter(name: String, x: Int, y: Int, z: Int)

Sets the value of a int3 parameter.

Parameters

main

namethe name of the material parameter
xthe value of the first component
ythe value of the second component
zthe value of the third component

Throws

RuntimeExceptionif name doesn't exist or no-op if exceptions are disabled.

[main]
open fun setParameter(name: String, x: Boolean, y: Boolean, z: Boolean, w: Boolean)

Sets the value of a bool4 parameter.

Parameters

main

namethe name of the material parameter
xthe value of the first component
ythe value of the second component
zthe value of the third component
wthe value of the fourth component

Throws

RuntimeExceptionif name doesn't exist or no-op if exceptions are disabled.

[main]
open fun setParameter(name: String, x: Float, y: Float, z: Float, w: Float)

Sets the value of a float4 parameter.

Parameters

main

namethe name of the material parameter
xthe value of the first component
ythe value of the second component
zthe value of the third component
wthe value of the fourth component

Throws

RuntimeExceptionif name doesn't exist or no-op if exceptions are disabled.

[main]
open fun setParameter(name: String, x: Int, y: Int, z: Int, w: Int)

Sets the value of a int4 parameter.

Parameters

main

namethe name of the material parameter
xthe value of the first component
ythe value of the second component
zthe value of the third component
wthe value of the fourth component

Throws

RuntimeExceptionif name doesn't exist or no-op if exceptions are disabled.

[main]
open fun setParameter(name: String, texture: Texture, sampler: TextureSampler)

Sets a texture and sampler parameter on this material's default instance.

Note: Depth textures can't be sampled with a linear filter unless the comparison mode is set to COMPARE_TO_TEXTURE.

Parameters

main

nameThe name of the material texture parameter
textureThe texture to set as parameter
samplerThe sampler to be used with this texture

Throws

RuntimeExceptionif name doesn't exist or no-op if exceptions are disabled.

[main]
open fun setParameter(name: String, type: MaterialInstance.BooleanElement, v: Array<Boolean>, offset: Int, count: Int)

Set a bool parameter array by name.

Parameters

main

namename of the parameter array as defined by this Material
typethe number of components for each individual parameter
varray of values to set to the named parameter array
offsetthe number of elements in v to skip
countthe number of elements in the parameter array to set
For example, to set a parameter array of 4 bool4s:
kotlin
    boolean[] a = new boolean[4 * 4];     instance.setParameter("param", MaterialInstance.BooleanElement.BOOL4, a, 0, 4);
``` |

#### Throws

| | |
|---|---|
| [RuntimeException](https://developer.android.com/reference/kotlin/java/lang/RuntimeException.html) | if name doesn't exist or no-op if exceptions are disabled. |

[main]\
open fun [setParameter](set-parameter.md)(name: [String](https://developer.android.com/reference/kotlin/java/lang/String.html), type: [MaterialInstance.IntElement](-int-element/index.md), v: [Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin-stdlib/kotlin/-array/index.html)&lt;[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin-stdlib/kotlin/-int/index.html)&gt;, offset: [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin-stdlib/kotlin/-int/index.html), count: [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin-stdlib/kotlin/-int/index.html))

Set an int parameter array by name.

#### Parameters

main

| | |
|---|---|
| name | name of the parameter array as defined by this Material |
| type | the number of components for each individual parameter |
| v | array of values to set to the named parameter array |
| offset | the number of elements in `v` to skip |
| count | the number of elements in the parameter array to set 
For example, to set a parameter array of 4 int4s: 
```kotlin
    int[] a = new int[4 * 4];     instance.setParameter("param", MaterialInstance.IntElement.INT4, a, 0, 4);
``` |

#### Throws

| | |
|---|---|
| [RuntimeException](https://developer.android.com/reference/kotlin/java/lang/RuntimeException.html) | if name doesn't exist or no-op if exceptions are disabled. |

[main]\
open fun [setParameter](set-parameter.md)(name: [String](https://developer.android.com/reference/kotlin/java/lang/String.html), type: [MaterialInstance.FloatElement](-float-element/index.md), v: [Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin-stdlib/kotlin/-array/index.html)&lt;[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin-stdlib/kotlin/-float/index.html)&gt;, offset: [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin-stdlib/kotlin/-int/index.html), count: [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin-stdlib/kotlin/-int/index.html))

Set a float parameter array by name.

#### Parameters

main

| | |
|---|---|
| name | name of the parameter array as defined by this Material |
| type | the number of components for each individual parameter |
| v | array of values to set to the named parameter array |
| offset | the number of elements in `v` to skip |
| count | the number of elements in the parameter array to set 
For example, to set a parameter array of 4 float4s: 
```kotlin
    float[] a = new float[4 * 4];     material.setDefaultParameter("param", MaterialInstance.FloatElement.FLOAT4, a, 0, 4);
``` |

#### Throws

| | |
|---|---|
| [RuntimeException](https://developer.android.com/reference/kotlin/java/lang/RuntimeException.html) | if name doesn't exist or no-op if exceptions are disabled. |

[main]\
open fun [setParameter](set-parameter.md)(name: [String](https://developer.android.com/reference/kotlin/java/lang/String.html), type: [Colors.RgbType](../-colors/-rgb-type/index.md), r: [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin-stdlib/kotlin/-float/index.html), g: [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin-stdlib/kotlin/-float/index.html), b: [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin-stdlib/kotlin/-float/index.html))

Sets the color of the given parameter on this material's default instance.

#### Parameters

main

| | |
|---|---|
| name | the name of the material color parameter |
| type | whether the color is specified in the linear or sRGB space |
| r | red component |
| g | green component |
| b | blue component |

#### Throws

| | |
|---|---|
| [RuntimeException](https://developer.android.com/reference/kotlin/java/lang/RuntimeException.html) | if name doesn't exist or no-op if exceptions are disabled. |

[main]\
open fun [setParameter](set-parameter.md)(name: [String](https://developer.android.com/reference/kotlin/java/lang/String.html), type: [Colors.RgbaType](../-colors/-rgba-type/index.md), r: [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin-stdlib/kotlin/-float/index.html), g: [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin-stdlib/kotlin/-float/index.html), b: [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin-stdlib/kotlin/-float/index.html), a: [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin-stdlib/kotlin/-float/index.html))

Sets the color of the given parameter on this material's default instance.

#### Parameters

main

| | |
|---|---|
| name | the name of the material color parameter |
| type | whether the color is specified in the linear or sRGB space |
| r | red component |
| g | green component |
| b | blue component |
| a | alpha component |

#### Throws

| | |
|---|---|
| [RuntimeException](https://developer.android.com/reference/kotlin/java/lang/RuntimeException.html) | if name doesn't exist or no-op if exceptions are disabled. |