---
title: "CustomRenderMethodInput | JavaScript maps SDK"
description: "Documentation for MapTiler SDK"
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# Type Alias CustomRenderMethodInput

Input arguments exposed by custom render function.

type CustomRenderMethodInput \= {  
    [defaultProjectionData](#defaultprojectiondata): [ProjectionData](https://docs.maptiler.com/sdk-js/api-reference/types/ProjectionData/);  
    [farZ](#farz): number;  
    [fov](#fov): number;  
    [modelViewProjectionMatrix](#modelviewprojectionmatrix): [mat4](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.mat4/);  
    [nearZ](#nearz): number;  
    [projectionMatrix](#projectionmatrix): [mat4](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.mat4/);  
    [shaderData](#shaderdata): {  
        define: string;  
        variantName: string;  
        vertexShaderPrelude: string;  
    };  
}

##### Index

### Properties[](#properties)

[defaultProjectionData](#defaultprojectiondata) [farZ](#farz) [fov](#fov) [modelViewProjectionMatrix](#modelviewprojectionmatrix) [nearZ](#nearz) [projectionMatrix](#projectionmatrix) [shaderData](#shaderdata)

## Properties[](#properties-1)

### defaultProjectionData[](#defaultprojectiondata)

defaultProjectionData: [ProjectionData](https://docs.maptiler.com/sdk-js/api-reference/types/ProjectionData/)

Uniforms that should be passed to the vertex shader, if MapLibre's projection code is used. For more details of this object's internals, see its doc comments in `src/geo/projection/projection_data.ts`.

These uniforms are set so that `projectTile` in shader accepts a vec2 in range 0..1 in web mercator coordinates. Use `map.transform.getProjectionData({overscaledTileID: tileID})` to get uniforms for a given tile and pass vec2 in tile-local range 0..EXTENT instead.

For projection 3D features, use `projectTileFor3D` in the shader.

If you just need a projection matrix, use `defaultProjectionData.projectionMatrix`. A projection matrix is sufficient for simple custom layers that also only support mercator projection.

Under mercator projection, when these uniforms are used, the shader's `projectTile` function projects spherical mercator coordinates to gl clip space coordinates. The spherical mercator coordinate `[0, 0]` represents the top left corner of the mercator world and `[1, 1]` represents the bottom right corner. When the `renderingMode` is `"3d"`, the z coordinate is conformal. A box with identical x, y, and z lengths in mercator units would be rendered as a cube. [MercatorCoordinate.fromLngLat](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.MercatorCoordinate/#fromlnglat) can be used to project a `LngLat` to a mercator coordinate.

Under globe projection, when these uniforms are used, the `elevation` parameter passed to `projectTileFor3D` in the shader is elevation in meters above "sea level", or more accurately for globe, elevation above the surface of the perfect sphere used to render the planet.

### farZ[](#farz)

farZ: number

This value represents the distance from the camera to the far clipping plane. It is used in the calculation of the projection matrix to determine which objects are visible. farZ should be larger than nearZ.

### fov[](#fov)

fov: number

Vertical field of view in radians.

### modelViewProjectionMatrix[](#modelviewprojectionmatrix)

modelViewProjectionMatrix: [mat4](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.mat4/)

model view projection matrix represents the matrix converting from world space to clip space [https://learnopengl.com/Getting-started/Coordinate-Systems](https://learnopengl.com/Getting-started/Coordinate-Systems) \*

### nearZ[](#nearz)

nearZ: number

This value represents the distance from the camera to the near clipping plane. It is used in the calculation of the projection matrix to determine which objects are visible. nearZ should be smaller than farZ.

### projectionMatrix[](#projectionmatrix)

projectionMatrix: [mat4](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.mat4/)

projection matrix represents the matrix converting from view space to clip space [https://learnopengl.com/Getting-started/Coordinate-Systems](https://learnopengl.com/Getting-started/Coordinate-Systems)

### shaderData[](#shaderdata)

shaderData: { define: string; variantName: string; vertexShaderPrelude: string }

Data required for picking and compiling a custom shader for the current projection.

#### Type Declaration

-   ##### define: string
    
    Defines to add to the shader code. Depends on current projection.
    
    #### Example[](#example)
    
    ```typescript
    const vertexSource = `#version 300 es
    ${shaderData.vertexShaderPrelude}
    ${shaderData.define}
    in vec2 a_pos;
    void main() {
        gl_Position = projectTile(a_pos);
        #ifdef GLOBE
        // Do globe-specific things
        #endif
    }`;
    ```
    
-   ##### variantName: string
    
    Name of the shader variant that should be used. Depends on current projection. Whenever the other shader properties change, this string changes as well, and can be used as a key with which to cache compiled shaders.
    
-   ##### vertexShaderPrelude: string
    
    The prelude code to add to the vertex shader to access MapLibre's `projectTile` projection function. Depends on current projection.
    
    #### Example[](#example-1)
    
    ```typescript
    const vertexSource = `#version 300 es
    ${shaderData.vertexShaderPrelude}
    ${shaderData.define}
    in vec2 a_pos;
    void main() {
        gl_Position = projectTile(a_pos);
    }`;
    ```
