Minecaft-style crosshair that inverts color

Hello. I was working on a new game idea when I noticed that my white crosshair is barely visible on the background of snowy mountains (a place where 90% of the game happens) and, while thinking of resolving this problem, I remembered Minecraft’s crosshair, which would invert colors (It doesn’t exactly invert the color as it’s still white most of the time, but does display the world trough some kind of shader, but I’m not sure how to better describe it) of whatever you looked at. I tried finding out how did Minecraft’s developers created it, but trying to google anything about the crosshair only results in tutorials about customizing its textures in-game. Here are some examples of how it looks in game.

image
Crosshair while looking at dark green grass

image
Crosshair while looking at white clouds


Crosshair looking at white snow.


Crosshair looking at both white snow and black coal

image
Crosshair looking at a red-white mushroom

EDIT: Now I realized, UE’s editor crosshair looks and behaves exactly the same :thinking:

Hey there @V_vix! You might be able to get this effect using a PostProcessMaterial, but the harder part is getting it to only be for the crosshair. You’d have to set up it’s shape and size in the PPM. I know you can invert anything visually with the MinusOne node, but masking it to only your cross is going to take shaping.

Presumably you’d map a texture across the display, and read this texture in the post-process material.
You’d probably want to clamp the texture and only map it across the center 128x128 pixels or so.
Make the texture black where there’s no crosshair, and white where there’s crosshair, and make this value linear interpolate between the “normal” value and the “inverted” value.

Note that gray backgrounds (rock walls, concrete, …) have problems with one-minus inversion, because inverser of gray is gray. There are a few ways to fix this. One is to use subtraction-with-wrap instead of invert. Another is to only invert some color channels (say, green and blue) and instead just overlay red on there. A third is to calculate the color space distance between the texture and the framebuffer, and only invert if the distance is smallish.