# Local variables in the "material graph" shader editor

**URL:** <https://forums.unrealengine.com/t/local-variables-in-the-material-graph-shader-editor/2615076>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, shader, question\
**Created:** [July 23, 2025, 3:18am UTC](https://forums.unrealengine.com/t/local-variables-in-the-material-graph-shader-editor/2615076 "2025-07-23T03:18:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JR\_Miller](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jr_miller/32/768643_2.png) [@JR\_Miller](https://forums.unrealengine.com/u/JR_Miller)\
**Post date:** [July 23, 2025, 3:18am UTC](https://forums.unrealengine.com/t/local-variables-in-the-material-graph-shader-editor/2615076/1 "2025-07-23T03:18:40Z")

</div>

In the material graph, how do you do create and assign values to local variables?

pseudo code:

var a = some\_texture;  
a = some\_different\_texture;

It seems absurd that there would be a scripting language, visual or not, that forbid the creation of local variables. It just seems terrible. This super fundamental feature has existed since the beginning of programming. But after spending a while searching, I could not find out how to do this in the material editor.

I think I am going insane. How do you do this?

---

<div class="post-metadata">

**Author:** ![rokenrock](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rokenrock/32/1040844_2.png) [@rokenrock](https://forums.unrealengine.com/u/rokenrock)\
**Post date:** [July 23, 2025, 3:33am UTC](https://forums.unrealengine.com/t/local-variables-in-the-material-graph-shader-editor/2615076/2 "2025-07-23T03:33:56Z")

</div>

Hi there,

You can absolutely create local variables if you use a “custom hlsl” node, as in that pseudo code.  
The closest you’ll get in the material editor graph, however, is a named reroute- though these can only be assigned once, they can be accessed however many times you need. Think const variable.
