# Vertex painting pixelated textures

**URL:** <https://forums.unrealengine.com/t/vertex-painting-pixelated-textures/458502>\
**Category:** Asset Creation\
**Tags:** vertex-paint, unreal-engine, question\
**Created:** [November 16, 2019, 3:48pm UTC](https://forums.unrealengine.com/t/vertex-painting-pixelated-textures/458502 "2019-11-16T15:48:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marcis](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/marcis/32/1103070_2.png) [@Marcis](https://forums.unrealengine.com/u/Marcis)\
**Post date:** [November 16, 2019, 3:48pm UTC](https://forums.unrealengine.com/t/vertex-painting-pixelated-textures/458502/1 "2019-11-16T15:48:40Z")

</div>

Hi,

How to vertex paint pixelated textures without having the gradient visible? Adjusting the contrast doesn’t help it just creates artifacts.

This example was achieved with height lerp. Ideally I would only want the edges of the painted areas to be pixelated without any gradient whatsoever.

This plane is 400 units in size and I can not increase polygon count.

Thanks in advance

 ![292478-paintedpixels.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/a/4/5a499538e2895106ded90d094e95a5a58f9e1314.png)

 ![292479-heightlerp.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/d/b/cdb771f61f649e4737a2347c38eaac4d6b33b15d.png)

 ![292480-vertexpaint.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/7/5/d75e75d2384189c1be042c305d65abe87d804019.png)

 ![292481-wireframe.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/2/f/82f23a61c138c2da46d31e8ecca476cc416572ab.png)

---

<div class="post-metadata">

**Author:** ![shadow242425](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@shadow242425](https://forums.unrealengine.com/u/shadow242425)\
**Post date:** [December 23, 2022, 12:35am UTC](https://forums.unrealengine.com/t/vertex-painting-pixelated-textures/458502/2 "2022-12-23T00:35:19Z")

</div>

Hi, I know this is really old but maybe someone will find this useful.

I found this post: [unity - Cutout fragment shader pixels arent square - Game Development Stack Exchange](https://gamedev.stackexchange.com/questions/159305/cutout-fragment-shader-pixels-arent-square) (someone had similar problem in unity)

and I basically just copied code in that post and pasted it into custom node, here is the result:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/d/5/1d541fb3076efbe57d258be3932b9dc95ddc5777.jpeg)

It isn’t perfect but still better than nothing.

For anyone interested, this is the code, you just need to create 3 inputs: UVMap,VertexCol and TextureRes;

```
float2 texelPos = UVMap*TextureRes;
float2 texelCenter = floor(texelPos) + 0.5f;
float2 delta = (texelCenter - texelPos) * (1.0f/TextureRes);
float2 gradient = float2(ddx(VertexCol), ddy(VertexCol));
float2x2 uvToScreen;
uvToScreen[0]=ddx(UVMap);
uvToScreen[1]=ddy(UVMap);
float determinant = uvToScreen[0][0] * uvToScreen[1][1] - uvToScreen[0][1] *uvToScreen[1][0];
float2x2 result = {uvToScreen[1][1], -uvToScreen[0][1], -uvToScreen[1][0],uvToScreen[0][0]};
float2x2 ScreenToUV;
ScreenToUV = result * 1.0f/determinant;
gradient = mul(ScreenToUV, gradient);
return VertexCol+dot(gradient,delta);

```

Here is the setup:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/c/e/dce769da2c0cb437c5ba0e6dfeae9fe52f906475.png)

Hope this helps!
