Honktown wrote: Sun Nov 10, 2019 12:39 am
Re: unemployed. I know that feeling. EE and a programming job that stopped paying (literally), which forced me to go on unemployment unless the state could've made them pay in time. I was kinda hoping you were using some tutorials or even a book... the shadertoy website looks very interesting. Much easier than coding a desktop application. I forked a mod after the author was rude and ended up banging out a more thorough version, spending up to 10+ hours a day coding. Should add it to my resume, as well as "Lua scripting". Back to colors, IPS/PLS and IPS-like panels came down in cost so much in recent years, with better response times. Once I had one I had trouble dealing with TN panels (especially the garbage view angles/off-contrast).
I just have an AAS degree in 'computer programming' from a community college.. And it took me a really long time to get because of mental disorders I only got help with starting when I was 24 or so. So I don't have much when it comes to credentials on paper, and with no prior actual job experience in the field I basically have a very short resume that most of the time gets filtered out automatically, so never gets seen by an actual human being. Now I'm 29 and still living with parents.
The first link I provide (labeled with the text 'this one'; which doesn't really do it justice, as it is a great article) is the closest I've ever seen to a 'tutorial' for this sort of thing. The thing is, most of the material talking about this talks about it in terms of the math and physics sides, and most things talking about the code either talk about 'good enough' approximations and how to make code that cheats and doesn't do most of the math, or instead are documentation files for existing libraries - and for open source ones, that means the 'tutorial' would be 'read the code'.
The first link I gave is a rarity. It walks through the math in theoretical terms, then walks through an example, and then at the end gives actual code one could use to implement it all. It even gives the code in chunks, explaining what each part does - relating it to the more math-oriented stuff at the beginning of the article.
I will note, however, that the things in the article turn out to be easier than their code portrays, if you use GLSL. GLSL has built-in vector and matrix types, and also has built-in support for matrix multiplication and even matrix inversion. The only thing it really lacks that is used in that article is an easy way to make a diagonal square matrix out of a vector - so that's something I fill in with a preprocessor directive (so that I can use it to create 'const' variables whose values are calculated ahead of time, so aren't being recalculated every frame for every pixel).
I end up using another preprocessor directive to generate an RGB→XYZ conversion matrix (that way they too can be generated once when the shader gets compiled by the GPU driver):
Code: Select all
#define rgbToXyz(space)\
(space.primaries*diag(inverse((space).primaries)*(space).white))
And for xyzToRgb():
Code: Select all
#define xyzToRgb(space)\
inverse(rgbToXyz(space))
And to actually use them to perform a conversion:
Code: Select all
// Rough approximation of the linear-light version of the 'dull red' from the other post; values are on a scale of 0 to 1
vec3 color = vec3(0.43415, 0.10224, 0.057805);
color = conversionMatrix*color;
I have a barebones version that
doesn't use preprocessor directives (as they're sorta hacky)
here if you want a simple example. More complex examples are actually my color blindness stuff, and speaking of that...
I wouldn't use that example. There's no gamma correction, so you won't get accurate results. Furthermore, they don't show how they derive those matrices, and they don't even use matrices at all for some reason. The main thing that GLSL does to make life easier for this, they reinvent themselves for no reason. And just now I tested their code with some color blindness test images I have, and predictably, those filters don't even work for the purpose they exist for.
I have two main color blindness shaders.
The first one is similar to the one you linked to, except it provides only 4 views. The other views, however, can be simulated by clicking and dragging to change how strong the color blindness is. Clicking in the middle should give normal vision, clicking to the left simulates varying degrees of color blindness (and the furthest left column of pixels gives you full dichromacy simulation), and clicking to the right attempts to help 'correct' color blindness for people with anomalous trichromacy (as opposed to full dichromacy). Though I'll warn you, the method I use for this 'correction' is dubious. Don't trust it.
The other one is
an interactive spectral simulation of color blindness. It uses approximated curves for the spectral sensitivities of the 3 types of cones in the human eye, and gives a rough estimation of how those spectral sensitivities shift for people with anomalous trichromacy, and full dichromacy. It cycles through an animation of the 3 main types (prota, deuta, and trita), though if you pause the shader as it's animating a certain type, you can then click and drag the mouse to see a specific weighting. Click again on the far left column to let it go back to its animated cycle, and unpause for it to actually animate again. You could click without pausing, but then it'll every once in a while switch color blindness types on you without any indication it's going to.
Those two shaders showcase a number of more advanced techniques I use. The second one, in particular, I made sure to document as much as possible - with lots of code comments and whatnot for everything. I often open it up in another tab just so I can get bits and pieces of it for other shaders.
Oh, and you can use
this Chrome extension or
this Firefox extension to test your own images on Shadertoy. You can't save shaders with them (you can only use the preset textures, or generate your own custom texture in a buffer), but I find it useful for things like testing color blindness filters.