UE4: Working with linear textures, good idea?

Hi there,

I’m doing a lil project on the side, cartoony/fantasy and I’ve created an ubershader somewhat similar to the Diablo 3 one, though with some neat extra features. I’m working mainly with grayscale textures (shapes, gradients and noises) and only applying color towards the end of the material, as a solid tint, with particle color or gradient maps.

Saving my textures as dxt1 makes them look like garbage, since they’re very soft looking and I need those nice gradients. So I’m saving them as grayscale, but I noticed that if I store them as linear, they take much less space than storing them as sRGB (saved as G8 instead of R8G8B8).

So right now I’m sampling all of my textures as Linear inside of my ubershader, doing all the shader math, and multiplying the result by itself (as a cheap approximation of a 2.2 power function) to convert to sRGB, and then applying the particle/tint color as the last step.

I was wondering if there’s any downsides to this that I might be overlooking? I’d rather find out sooner than later since the game will be very VFX heavy. Cheers!

1 Like

This is how the shader looks like if you’re curious:

Also, shout out to Keith who taught me a bunch of those tricks :slight_smile:

1 Like

Nicely organized! Definitely the sort of thing that makes it easy for another person to collaborate.
I can’t quite tell, do you have any camera angle offset for your bulge to make it 3d-ish?

There’s no downside to how you’re doing it. Depending on what the gradients look like you can also just sample UVs and bias them around to get spherical, diamond, box, and linear ramps that are nice and clean and scalable.

I work in linear a lot depending on whether I’m blending UV ramps in, so the math between the two is more compatible.


Wonderful, thanks a lot guys!

The bulge is just a -1 to +1 gradient on both axes, masked by a circle gradient, added on top of the regular UVs. I end up using very low numbers (0.1, 0.2) and it does give a more natural look to some particles.

That’s how I imagined you were using it.
If you work in VR, you might consider making your bulge more like a Bumpoffset. It doesn’t help flat particles as much, but if you add a little screen space fudge it can add some dimensionality.

1 Like

That’s a pretty good idea actually :slight_smile: I’ll write that down so I don’t forget. Thanks!

For your sRGB conversion approximation you might want to consider:

UE3 had the concept of custom function expressions, which I assume UE4 still has. I would use those so you can reuse these elsewhere in your project.


Nice link, thanks a lot!