It should be pretty straight forward.
I don't use comic and never plan to (otherwise I'd just post the finished code), but it'd go something like this for it to cut off if the lum value for the pixel is above a specific value (between 0 and 1):
1) create a uniform or #define for a float value (let's call it CUTOFF_LUM_VALUE).
2) calculate the lum_value of the current pixel: this formula is fine: (0.2126*RED + 0.7152*GREEN + 0.0722*BLUE)
3) find the line of code near the end of the shader that returns the new rgb color value and do the lum test there. If it's less than CUTOFF_LUM_VALUE then it just operates normally, otherwise it returns the original pixel color.
If you don't want it to simply cutoff, you can experiment with lerping the original and new pixel color based on the difference between lum_value and CUTOFF_LUM_VALUE (or a function that takes both as an argument and does something a little more complicated).
In the end it'll just be like 5 lines of code added total (unless you want to do some complicated calculation based on lum_value and CUTOFF_LUM_VALUE).
The above is the same for ANY shader, really (like ambient occlusion, debanding, antialiasing, whatever) -- and can be further generalized for adding anything new to any shader:
a) create a test
b) test it against current pixel
c) finally based on the result of that test either return the original color, the modified color, or a completely new color from an interpolation (lerp or whatever) between the original color and the modified color
Last edit: 2 years 9 months ago by Daemonjax.
Please Log in or Create an account to join the conversation.