gradientMap GLSL is probably not correct?
See original GitHub issueDescription of the problem
Looking at the gradientmap GLSL
this line
vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
this will not actually give a correct gradient. Imagine you have a 2x1 texture.
The correct gradient is here
| |
V V
+-------------+-------------+
| | |
+-------------+-------------+
^ ^
| |
But the code above uses this. That means much of the sampling is outside gradient.
In other words you need to read the gradient from the center of the first texel to the center of the last texel. Past the center on either side is just solid color. The linear interpolation happens between texels which are defined by center points.
The correct code unfortunately requires the width of the gradient texture
float gradientPos = dotNL * 0.5 + 0.5;
float sampleLoc = 0.5 + (gradientWidth - 1) * gradientPos;
vec2 coord = vec2(sampleLoc / gradientWidth, 0.0 );
Does anyone care?
Three.js version
- Dev
- r94
Issue Analytics
- State:
- Created 5 years ago
- Comments:19 (8 by maintainers)
Top Results From Across the Web
OpenGL GLSL: How to implement the concept of gradient map ...
Based on the image and description, it looks like this maps the original grayscale value of the image to the blue-green gradient.
Read more >Gradient map - GDQuest
In this tutorial, you'll learn how to use a shader to change a sprite's colors. This is useful for refining or completely changing...
Read more >Gradient Map Shader in Godot 3.1: shader tutorial - YouTube
Learn to code shaders with Godot: http://bit.ly/intro-to-shaders-godotGonkee's fog shader : https://www.youtube.com/watch?v=QEaTsz_0o44Fire ...
Read more >P: Gradient Map Adjustment Layer PS 23 is not back...
I try again with a new post since the previous one has not been understood. Using in Photoshop 23.0 the "Gradient Map" adjustment...
Read more >[LWRP] Creating a simple gradient map shader - Unity Forum
The outermost colors of the gradient texture are blue and yellow, yet in between the two there seem to be all sorts of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sidenote: Apart from defining the amount of tones you could also allow the definition of the respective thresholds (which define when you switch from one tone to the next one).
@WestLangley Sounds interesting, yes. I mean introducing an alternative API for defining gradients.
However, @greggman seems to have issues with the term
gradientMap
itself. Because in cel shading, you are not rendering real color gradients but single tones.