# DeFragCoord - FragCoord to Defold migration guide

**URL:** <https://forum.defold.com/t/defragcoord-fragcoord-to-defold-migration-guide/82518>\
**Category:** The Defoldmine\
**Created:** [March 11, 2026, 10:39pm UTC](https://forum.defold.com/t/defragcoord-fragcoord-to-defold-migration-guide/82518 "2026-03-11T22:39:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pawel](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pawel/32/24623_2.png) [@Pawel](https://forum.defold.com/u/Pawel)\
**Post date:** [March 11, 2026, 10:39pm UTC](https://forum.defold.com/t/defragcoord-fragcoord-to-defold-migration-guide/82518/1 "2026-03-11T22:39:39Z")

</div>

![defragcoord](https://forum-defold-uploads.b-cdn.net/original/3X/6/e/6ebca1ac315c84b3db71397db6a4edb2ffec0189.jpeg)

# DeFragCoord

This is a simple FragCoord - Defold migration guide.

You can test your shaders in [FragCoord.xyz](https://fragcoord.xyz/) online tool by XorDev and then use them in Defold!

## Guide

The whole migration is only based on adjusting to the different naming used in FragCoord shaders (hence defines). It’s not perfect, but should work with most of the shaders from there. You need to:

1. Paste this fragment on top of your Defold fragment program:

```glsl
#version 140

in mediump vec2 var_texcoord0;
out vec4 out_fragColor;
uniform mediump sampler2D texture_sampler;

uniform fs_uniforms
{
    mediump vec4 time_res_scroll;
};

#define u_time time_res_scroll.x
#define u_resolution time_res_scroll.yz
#define u_scroll time_res_scroll.w
#define fragColor out_fragColor

// ------------------------------------------------------
// Put your FragCoord.xyz shader below:
// ------------------------------------------------------

```

1. And below paste the content of the `Main` pass from FragCoord. e.g. this is a blank project:

```glsl
void main()
{
//Normalized screen uvs [0, 1]
vec2 uv = gl_FragCoord.xy / u_resolution;

//Centered, fit screen coordinates
vec2 fit = 0.5 + (gl_FragCoord.xy - 0.5 * u_resolution) / min(u_resolution.x, u_resolution.y);

//Output for demo
fragColor = vec4(fit, 0, 1);
}

```

1. Then, you need to provide the used uniforms to the shader. Most of the shaders need time and resolution, sometimes mouse input. If the shader from FragCoord provides custom uniforms, you would need to either provide them, or define default values (e.g. like in `the_card_game.fp` example).

Example script that provides time, resolution, mouse scroll and position is provided in `main/uniforms.script` in the repository.

## Examples

This example comes with few shaders already ported. Those are added to the sprite component. You can run it from Defold and change the material to any other one, save and Hot Reload (Ctrl+R) to quickly preview the others.

## License

MIT (shaders have their own licenses)

* * *

## Repository:

> **[GitHub - paweljarosz/defragcoord: FragCoord to Defold migration guide](https://github.com/paweljarosz/defragcoord)**
>
> FragCoord to Defold migration guide

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [March 12, 2026, 5:10am UTC](https://forum.defold.com/t/defragcoord-fragcoord-to-defold-migration-guide/82518/2 "2026-03-12T05:10:32Z")

</div>

Cool! Thanks for sharing. Note that we will soon provide time to shaders out of the box: [Expose engine time to shaders by Jhonnyg · Pull Request #11993 · defold/defold · GitHub](https://github.com/defold/defold/pull/11993)

---

<div class="post-metadata">

**Author:** ![Pawel](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pawel/32/24623_2.png) [@Pawel](https://forum.defold.com/u/Pawel)\
**Post date:** [March 12, 2026, 5:17am UTC](https://forum.defold.com/t/defragcoord-fragcoord-to-defold-migration-guide/82518/3 "2026-03-12T05:17:33Z")

</div>

Yes, and this would be very useful! ❤

---

<div class="post-metadata">

**Author:** ![Pawel](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pawel/32/24623_2.png) [@Pawel](https://forum.defold.com/u/Pawel)\
**Post date:** [April 9, 2026, 6:45am UTC](https://forum.defold.com/t/defragcoord-fragcoord-to-defold-migration-guide/82518/4 "2026-04-09T06:45:54Z")

</div>

I’ve updated the repository to Defold 1.12.3 to use the time that is now exposed directly to shaders via Fragment Constant of type “Time” ⌚ 😉
