# \#onbeforecompile

**URL:** https://discourse.threejs.org/tag/onbeforecompile/657.md

[Latest](https://discourse.threejs.org/latest.md) · [Categories](https://discourse.threejs.org/categories.md) · [Tags](https://discourse.threejs.org/tags.md)

---

## [Digital Serenity](https://discourse.threejs.org/t/digital-serenity/93722)

<div class="topic-metadata">

**Author:** [@prisoner849](https://discourse.threejs.org/u/prisoner849)\
**Replies:** 6\
**Last updated:** [August 25, 2026, 2:49am UTC](https://discourse.threejs.org/t/digital-serenity/93722 "2026-08-25T02:49:04Z")

</div>

Hi community! A fantasy from scratch. The initial thought was “I want a tree of points” :slight\_smile: Picture: Demo: Sketch

---

## [Moving normalMap on InstancedMesh with onBeforeCompile](https://discourse.threejs.org/t/moving-normalmap-on-instancedmesh-with-onbeforecompile/85500)

<div class="topic-metadata">

**Author:** [@Ahlecss](https://discourse.threejs.org/u/Ahlecss)\
**Replies:** 2\
**Last updated:** [July 26, 2025, 12:24am UTC](https://discourse.threejs.org/t/moving-normalmap-on-instancedmesh-with-onbeforecompile/85500 "2025-07-26T00:24:16Z")

</div>

Hey ! Hope you are doing well. I’ve currently a 3D Model, with an atlas texture (3 textures side by side), that I offset in my onBeforeCompile accordingly to what I want. The problem is : I see the normalMap still in …

---

## [Beer-o-mancer \[glitch\]](https://discourse.threejs.org/t/beer-o-mancer-glitch/64676)

<div class="topic-metadata">

**Author:** [@prisoner849](https://discourse.threejs.org/u/prisoner849)\
**Replies:** 3\
**Last updated:** [April 27, 2024, 6:43am UTC](https://discourse.threejs.org/t/beer-o-mancer-glitch/64676 "2024-04-27T06:43:10Z")

</div>

Hi community! Video: Demo: https://codepen.io/prisoner849/full/LYvqWaZ An attempt to write the glitch effect from srcatch (lines 205 - 229 in the JS section)

---

## [OnBeforeCompile fires only after first render](https://discourse.threejs.org/t/onbeforecompile-fires-only-after-first-render/64098)

<div class="topic-metadata">

**Author:** [@Rus-Abd](https://discourse.threejs.org/u/Rus-Abd)\
**Replies:** 4\
**Last updated:** [April 15, 2024, 6:54pm UTC](https://discourse.threejs.org/t/onbeforecompile-fires-only-after-first-render/64098 "2024-04-15T18:54:39Z")

</div>

Hey Everyone! I create my material before running render, but for some reason I can’t update it in the render function directly, the userData.shader is undefined at first render call, and I need to use an if statement t…

---

## [Bimetallic Ring \[LatheGeometry, modified MeshStandardMaterial\]](https://discourse.threejs.org/t/bimetallic-ring-lathegeometry-modified-meshstandardmaterial/57578)

<div class="topic-metadata">

**Author:** [@prisoner849](https://discourse.threejs.org/u/prisoner849)\
**Replies:** 2\
**Last updated:** [October 31, 2023, 8:56pm UTC](https://discourse.threejs.org/t/bimetallic-ring-lathegeometry-modified-meshstandardmaterial/57578 "2023-10-31T20:56:13Z")

</div>

Hi community! Video: Demo: https://codepen.io/prisoner849/full/VwgazZX A small sketch, as an example of how much fun you can have with LatheGeometry and modified materials, inspired with this forum topic: Extrud…

---

## [Chainable onBeforeCompile + Uniforms per Mesh](https://discourse.threejs.org/t/chainable-onbeforecompile-uniforms-per-mesh/8905)

<div class="topic-metadata">

**Author:** [@Fyrestar](https://discourse.threejs.org/u/Fyrestar)\
**Replies:** 18\
**Last updated:** [June 30, 2021, 9:16am UTC](https://discourse.threejs.org/t/chainable-onbeforecompile-uniforms-per-mesh/8905 "2021-06-30T09:16:12Z")

</div>

This little code will patch all material classes to have a chainable onBeforeCompile pattern, so when you assign a callback to onBeforeCompile it will be pushed into a plugins array property on the material instead overr…
