Game Development Community

High contrast text render effect. I need advice [DONE]

by Francisco Montanes · in Torque 3D Professional · 03/04/2013 (2:49 am) · 8 replies

Hey all, I've been working on a text rendering effect, witch consist on testing the background on each pixel, and if the background is dark then it's rendered using white color ink, and vice versa. I've not finished yet, because I want to know if there is a better ways to accomplish that. What I'm doing is using a pixel shader in the text render method, passing a texture of the backbuffer copy (which I get from REFLECTMGR->getRefractTex()), locating the text pixel on the backbuffer texture. Here is my question: there is a easier way to do that? Thank you very much!

#1
03/04/2013 (10:41 am)
Done! But I till wonder if it could be done easier, because I feel like I'm using a sledgehammer to crack nuts...

https://www.evernote.com/shard/s174/sh/5bb1daad-032a-42bf-ada1-5683d82ad6ee/7923dd9d8f00bbf17129bb9f7b52512d/res/a2ee5839-9ba4-4e41-9995-38a490db4ae3.png?resizeSmall&width=832
#2
03/04/2013 (4:28 pm)
Would you be willing to turn your shader into a resource and document the heck out of it? I am in the process of learning shaders and any examples would be helpful.

When I read your post I basically thought "this is over my head". The results look very nice BTW. For me I would just cheat and draw a black font slightly larger, then draw a white font centered on top. That way the text always has a black vs white background to foreground. Similar to the way the FPS indicator is done.
#3
03/04/2013 (5:34 pm)
Francisco,

Is this replicating a specific effect? I have just never seen an image from a camera or anything where the text was multi-toned. It's pretty cool though. Just wondering about application is all. The reason I ask is I don't find it particularly more readable than if it was all white....

Ron
#4
03/05/2013 (1:22 am)
Frank,
I'll make a resource, I promise. But now, I'm too busy. It looks better on live, with the background changing.

Ron,
Yes, I'm replicating a specific effect in a thermal camera that I'm willing to simulate. This way makes text more readable on any background. White text on white background is unreadable. The picture doesn't show pure white areas, but there are alot. ;)
#5
03/05/2013 (6:13 am)
It looks like a monochrome XOR effect

INPUT
A B OUTPUT
A XOR B
0 0 0
0 1 1
1 0 1
1 1 0

A represents your character font bit
B represents the black and white screen

XOR's where used a lot in old 8 bit games
#6
03/05/2013 (7:57 am)
Yes, you are right. The problem here was implementing the effect in Torque3D. In old days, I used to program in 8 bit machines (Spectrum), where all those kind of 'effects' were trivial.
#7
03/05/2013 (8:52 am)
And the same effect in GuiBitmapCtrl too:
#8
03/05/2013 (4:05 pm)
I did a search and I saw one way, that would probably cause flicker is to XOR the resulting bitmap after it is rendered. Pretty much everyone is using shaders for this now so I think your approach of using shaders is the better method.

It is funny that a feature that used to be so simple is not much more complex due to architecture and tech changes. Go figure. :)