PuckiSilver / NoShadow

Remove various shadows from text
MIT License
40 stars 1 forks source link

Using texelFetch() #2

Closed mihannnik closed 1 year ago

mihannnik commented 1 year ago

Hi, I have been researching your shader and have a number of questions. Why do you use texelFetch(Sampler2, UV2 / 16, 0).rgb on line 29? From the implementation I can understand that this way you replace the color back to white but... why not just use vertexColor.argb = vec4(1,1,1,1,1,1)? I tried it and didn't notice any difference, maybe I just don't know something? I also have a question about Position.z == 0.03 || Position.z == 0.06 || Position.z == 0.12. You are checking that the text is displayed at a certain level of the screen (title, actionbar and subtitle), but where did you get these numbers? Did you just calculate them or is there a list of text levels somewhere?

And I just like the way you did the color check. I used a separate function for bit operations, but it looks nicer this way (although I don't know which is faster).

PuckiSilver commented 1 year ago

Hey, sorry for reacting late!

The texelFetch(Sampler2, UV2 / 16, 0).rgb is just taken from the vanilla shader, it samples light (Sampler2) for the text, it is used to display text darker in caves for example, maybe it is not used for gui text, but I like keeping it consistent.

The position values are "how far back" the text is, all items have a "z order" or how far back they are, and for gui elements it is always the same so this is a good way to only select certain text and not everything. I got these numbers by simply playing around with > and < until I had the number.

Not sure how "a separate function for bit operations" would work for a color check but there are many ways, I recently used a different color check that I like best, especiall when doing checks for multiple colors:

ivec3 iColor = ivec3(Color.xyz * 255.1);
if (iColor == ivec3(78, 92, 36)) { ... } else
if (iColor == ivec3(59, 43,  6)) { ... } else
if (iColor == ivec3(33, 25,  5)) { ... } else
if (iColor == ivec3(64, 51,  3)) { ... }

I really like how readable this approach is.

~PuckiSilver