This is kleinerm's git repository for development of Psychtoolbox-3. Regular end users should stay away from it, unless instructed by him otherwise, and use the official Psychtoolbox-3 GitHub page or distribution system for production releases.
104
stars
307
forks
source link
Update the SineGratingSmoothedApertureShader fragment #208
This shader smooths the edge of a grating. By default useAlpha is turned OFF and smoothing uses the background color directly (alpha channel untouched). In this case no change will be seen by this fix.
However when useAlpha is turned on, the shader should use the edge modifier (Mod)on the alpha channel directly. Previously the fragment shader combined the global and local alpha ((rawAlpha * Mod) + Offset.a) causing an undesired effect (as I originally contributed this it was my bug), and the edge is not smoothed. To fix this we use the Modifier value directly (Offset.a * Mod), which allows the edge to blend properly with the underlying color while leaving the rest unaffected. When the background colour and offset are the same (as is normally the case, e.g. [0.5 0.5 0.5 1]), then useAlpha ON/OFF now looks the same. If the background colour is different to the offset, now with useAlpha=ON the edge properly smooths.
I added an optional value = 2 to Method which copies what is done in the SmoothedDiscShader.frag (option to invert the smoothing mask). Previously it accepted 0 or 1, and so there will be no change unless you explicitly set this to 2.
In addition I added the .vscode folder to .gitignore, this folder gets generated if you use VS Code or VS Codium and shouldn't be tracked in git.
This shader smooths the edge of a grating. By default
useAlpha
is turned OFF and smoothing uses the background color directly (alpha channel untouched). In this case no change will be seen by this fix.However when
useAlpha
is turned on, the shader should use the edge modifier (Mod
)on the alpha channel directly. Previously the fragment shader combined the global and local alpha ((rawAlpha * Mod) + Offset.a
) causing an undesired effect (as I originally contributed this it was my bug), and the edge is not smoothed. To fix this we use the Modifier value directly (Offset.a * Mod
), which allows the edge to blend properly with the underlying color while leaving the rest unaffected. When the background colour and offset are the same (as is normally the case, e.g. [0.5 0.5 0.5 1]), thenuseAlpha
ON/OFF now looks the same. If the background colour is different to the offset, now withuseAlpha
=ON the edge properly smooths.I added an optional value = 2 to
Method
which copies what is done in the SmoothedDiscShader.frag (option to invert the smoothing mask). Previously it accepted 0 or 1, and so there will be no change unless you explicitly set this to 2.In addition I added the
.vscode
folder to .gitignore, this folder gets generated if you use VS Code or VS Codium and shouldn't be tracked in git.