# Passing texture sampler into Custom Block NME

**URL:** <https://forum.babylonjs.com/t/passing-texture-sampler-into-custom-block-nme/41647>\
**Category:** Questions\
**Tags:** material\
**Created:** [June 16, 2023, 6:05am UTC](https://forum.babylonjs.com/t/passing-texture-sampler-into-custom-block-nme/41647 "2023-06-16T06:05:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeterJig](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/peterjig/32/23995_2.png) [@PeterJig](https://forum.babylonjs.com/u/PeterJig)\
**Post date:** [June 16, 2023, 6:05am UTC](https://forum.babylonjs.com/t/passing-texture-sampler-into-custom-block-nme/41647/1 "2023-06-16T06:05:56Z")

</div>

Is there a code example of passing a texture sampler into a Custom Block for the NME? Details I’m looking for are things like the “inParameters” type. If I’m passing this input into a function, what is the parameter type?

eg. “inParameters” type = Vector3 but function type is vec3. but for a texture sampler not a vector 3. 😄

🙏

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [June 16, 2023, 11:21am UTC](https://forum.babylonjs.com/t/passing-texture-sampler-into-custom-block-nme/41647/2 "2023-06-16T11:21:27Z")

</div>

This PR will add support for sampler types to NME custom blocks:

> <https://github.com/BabylonJS/Babylon.js/pull/13974>
>
> See https://forum.babylonjs.com/t/passing-texture-sampler-into-custom-block-nme/…41647

When the PR is merged, this material will work:

> **[Babylon.js Node Material Editor](https://nme.babylonjs.com/#2GWP9U)**
>
> Babylon.js Node material editor - shader-based materials editor for Babylon.js

The corresponding custom block definition is:

```json
{
    "name": "MirrorTexture",
    "comments": "Mirror the texture on the Y axis",
    "target": "Fragment",
    "inParameters": [
        {
            "name": "sourceTexture",
            "type": "sampler2D"
        },
        {
            "name": "uv",
            "type": "Vector2"
        }
    ],
    "outParameters": [
        {
            "name": "rgba",
            "type": "Color4"
        },
        {
            "name": "rgb",
            "type": "Color3"
        }
    ],
    "functionName": "mirrortexture",
    "code": [
        "void mirrortexture(sampler2D sourceTexture, vec2 uv, out vec4 rgba, out vec3 rgb) {", 
        " rgba = texture2D(sourceTexture, vec2(uv.x, 1.0 - uv.y));", 
        " rgb = rgba.rgb;",
        "}"
    ]    
}

```
