<p>The effect I'm trying to achieve is to have it so that the texture is pixilated/quantized, but the &quot;grid,&quot; stays aligned to world coordinates even as the object with it's own UV coordinates moves around.</p>
<p>The closest I've gotten is the following psuedocode, which at least should give kind of an idea of what I'm after (though I can't get the grid to actually stay still like I want).</p>
<pre><code>float DIVISIONS = 16.0;
vec3 coords = UV + world_position;

//quantize
coords = floor(coords * DIV) / DIV;

OUT_COLOR = coords - world_position;
</code></pre>
<p>In my own head it's scratching the area right between &quot;this likely isn't possible,&quot; and &quot;this feels like it should be solvable with some math,&quot; but I just can't seem to get the right equation down.</p>
<p>EDIT: Here is a video demonstration made using some compositing effects of roughly what I'm trying to acheive (though not perfect) <a href="https://youtu.be/eFJIG47Wp_E" rel="nofollow noreferrer">https://youtu.be/eFJIG47Wp_E</a></p>

CC BY-SA 4.0
2023-12-07T17:42:14.700Z
I think you need to discribe it in more detail... Maybe you can provide some images to see how it should be? Also it is helpful to tell for what you need this effect...
Thomas
CC BY-SA 4.0
2023-12-09T22:27:03.243Z
Ok, just make a video and provided a link since it's something you kind of have to see in motion to be able to understand. The purpose of this is so that I can render pixilated objects that align with the global pixel grid in the same render pass that I render non-pixilated objects. The standard way would be to do this in two passes and composite them together, but I was curious if I could do this in just one. I'm only concerned with UVs being pixilated, not the object outlines (which I couldn't do in compositing).
zachThePerson
<shader><mathematics><fragment-shader>
Pixilate/Quantize UV coordinates in world space?
zachThePerson
# Pixilate/Quantize UV coordinates in world space?

(Asked by: username_0 on 2023-12-05)

The effect I'm trying to achieve is to have it so that the texture is pixilated/quantized, but the "grid," stays aligned to world coordinates even as the object with it's own UV coordinates moves around.

The closest I've gotten is the following psuedocode, which at least should give kind of an idea of what I'm after (though I can't get the grid to actually stay still like I want).

```
float DIVISIONS = 16.0;
vec3 coords = UV + world_position;

//quantize
coords = floor(coords * DIV) / DIV;

OUT_COLOR = coords - world_position;

```

In my own head it's scratching the area right between "this likely isn't possible," and "this feels like it should be solvable with some math," but I just can't seem to get the right equation down.

EDIT: Here is a video demonstration made using some compositing effects of roughly what I'm trying to acheive (though not perfect) <https://youtu.be/eFJIG47Wp_E>

**Tags:** shader, mathematics, fragment-shader

> **Comments:**
> **username_1**: I think you need to discribe it in more detail... Maybe you can provide some images to see how it should be? Also it is helpful to tell for what you need this effect...  
> **username_0**: Ok, just make a video and provided a link since it's something you kind of have to see in motion to be able to understand. The purpose of this is so that I can render pixilated objects that align with the global pixel grid in the same render pass that I render non-pixilated objects. The standard way would be to do this in two passes and composite them together, but I was curious if I could do this in just one. I'm only concerned with UVs being pixilated, not the object outlines (which I couldn't do in compositing).  

---

## 0 answers

