# division in materials custom node (HLSL) is bad

**URL:** <https://forums.unrealengine.com/t/division-in-materials-custom-node-hlsl-is-bad/2712103>\
**Category:** Asset Creation\
**Tags:** math, unreal-engine, hlsl, question\
**Created:** [April 7, 2026, 2:48pm UTC](https://forums.unrealengine.com/t/division-in-materials-custom-node-hlsl-is-bad/2712103 "2026-04-07T14:48:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![BOBtheROSS](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BOBtheROSS](https://forums.unrealengine.com/u/BOBtheROSS)\
**Post date:** [April 7, 2026, 2:48pm UTC](https://forums.unrealengine.com/t/division-in-materials-custom-node-hlsl-is-bad/2712103/1 "2026-04-07T14:48:55Z")

</div>

The custom node seems to be worse than the build in division node.  
Is this expected behaviour?

problem:

- for var1 = 3.0 the HLSL code `return var1/trunc(var1);` does not return 1.0, but ~0.99999995 (the next lower value to 1.0 in a 32bit float)

important factors:

- affects **division** in **custom node** (HLSL)
- the **divisor** a.k.a. denominator must be fed by a material **parameter** , not a constant
- affected float values: 3, 6, 7, 12, 13, 14, 15, 24, 26, 28, 30, 37, 41, 45, 47, 48, … (same with negative values)

 ![Bug_Mat_customDividePrameter](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/6/6/966cd5d25d963e9bdb37c8615890177e4186f187.png)
