Remapping one section of a texture back onto itself

Hello,

I am interested in having a texture that is able to “decal itself” using a specific portion of its UV space. For example, I have one section of the texture that has the numbers “1”, “2”, and “3” on it. I would like to be able to isolate one of those numbers and then blend it back onto another portion of the texture set aside for that purpose. In this case, it is for signage: I want to be able to have variants of the material that have a portion of the texture display “1” “2” or “3”, depending on the UV coords I initially target.

So far I have been able to use UVRemap_0-1_ToRange to isolate “1” and output it into a Texture Sample, but of course that texture sample uses full 0-1 UV coords. What I want to do now is blend (screen) it back onto my texture, but I need to cram it back into a particular set of UV coords.

See these images to help illustrate what I am attempting to do.


Thank you in advance for any help you can give! I am pretty new to building out material networks so please go easy. :slight_smile:

So when I tried to do this by making a separate texture for the numbers, I ran into the same problem you did, not knowing how to move and scale down an image precisely. So I can’t answer that. But I didn’t really like how you were doing things based on UV coordinates (a personal choice), so I did this using a second texture where the numbers masks are already placed in the upper left corner of a texture. It is an incredible waste of pixels, but makes up for itself by avoiding alpha channels (which double your memory usage) and being very customizable. If you don’t know about “channel packing” already, I suggest you get started by reading this
(UDK | TextureOptimizationTechniques Packing and Consolidation) it’s made for UDK, but the principle still applies.

and this

So here’s what I’ve got for you. It looks super complicated, and it is for a beginner, but I want to get you started on this technique early.

&stc=1&d=1423461719

In the R, G, B channels of a texture, I have the numbers 1, 2, 3, as white. They are placed where they need to be in the final material, and will act as masks. The texture will have rainbow colors, but the channels are separated in the material editor.

DanodinNumberMask.png&stc=1&d=1423461800

In a different texture, I used your texture map you already have. Because it is almost 100% grayscale, I put it into a single channel of this new texture file. That way, I have two other channels to play with and I can sneak 3 (or 4) textures into a single map. I randomly chose to paste your texture in the red channel, and I painted a white mask for the orange paint to go into the green channel. The blue channel was empty, so I made a quick (and ugly) tiling scratch effect.

DanodinMainTexture.png&stc=1&d=1423461774

In the editor, I lerped between a Vector3 parameter (customizable color) and white, using the number mask as the alpha. I plugged the number mask texture into a Static Component Mask Parameter. This allows us to change which mask is used in each instance of this material. I then lerped together the normal main texture with the newly created orange paint decal using the custom mask in our green channel as the alpha. So the orange decal is now on top of our main texture.

&stc=1&d=1423461752

**

The rest is extra. **I made the painted masks non-metallic. I made a duplicate texture sampler for our main texture so that I could use a Texture Coordinate to tile the blue channel separately from everything else. I didn’t want to tile our main texture. I then added that blue channel (the scratched stuff) into the main texture to make a roughness map that has some extra variation to it.

I created Material Instances of this material and applied them to different objects. Inside the instance, I changed the color of the painted decal and chose which number mask to use.

I’m not good at explaining this stuff in one big chunk, so feel free to ask questions and clarify this stuff. Maybe this isn’t what you’re looking for, or it’s too limited by only having 3 channels for number masks.

Tl;dr: I’m using an extra texture as a mask for numbers, and I’m taking advantage of using multiple channels inside each texture in order to add variation.

Ah Stephabon, tyvm for the thorough answer! :slight_smile: I suppose the short answer also is “you can’t do what you are trying to do without an extra RGB texture”… and that works for me. A separate texture using RGB is a good backup plan. I’m so new to this stuff that I just assume everything is possible and that I just don’t know how to do it, so this was actually encouraging to know I was trying to do something too clever or maybe even impossible. I overthought it!

Thanks also for the link to the texture packing URL; that was good info for me to read!

There could very well be an easier way to do it. I just haven’t tried to use that UV coordinate system that you are trying to do. And I love to use channel packing wherever I can because it’s fun. Quite often, the extra memory of a second texture is more simple and efficient than complicated math, and there are random material functions here and there that are extra expensive for different reasons.

combine both approaches. have a mask for the specific area and multiply that with another texture that has the numbers on it. use a combination of both channel packing and UV offsetting to get the number to the right place.
you could in theory do it with your initial approach, but it would hardly save you anything and make it a pain to work with. and you’d still need that mask for the area.

textures with alphas use more space on disk but every channel costs the same when loaded into memory as they need to be uncompressed.