Strange behaviour of sperical gradient texture (creating eyeball)

Hi,

I try to create an procedural eyeball. I know there are a lot of tutorials about that, but I noticed a problem I don´t understand. Geometry is pretty basic and I added two shaders so far. Shader 1 for most of the eyeball and a spherical map to make the center (where the iris is) transparent. Shader 2 is basically the same setup, but should show a pupil by using a sperical gradient. The result is not what I expected. The gradient creates a ring instad of a point. I would expect a ring if I use another color in the gradient (blue, black, blue), but not with this setup. Ontop of that problem it shows another ring made from small squares with soft edges around the first one and i really don´t know where the problem came from.
The shader setup is very basic and I dont know why this happens.

Hi, @Hello_World! I tried recreating your scene to figure out what was going on, and I think I might have figured out a couple of contributing issues. One might be the scale. At smaller scales - like the size of the human iris, the way you have your material setup may be introducing some sort of precision error. You have to have your two gradient stops so close together that there may be some weird rounding or precision error:

The second one is the use of the Object coordinates - I had a bit more success using Generated coordinates. You will have to adjust your coordinate center by the Vector Math node as seen here:

Hope this helps!

1 Like

In addition to what @Hunkadoodle said, make sure to apply the scale of your objects.
Further, you can add a multiply node before the color ramp to make the adjustment easier, if the object scale is small:

1 Like

Thanks for the reply and the effort you put in. Unfortunately now the circle disappears completely. I know that I may not copy just your values, but moving the sliders up and down doesn´t change much. I may find a value where I can see part of a black area, but can not adjust it the way I want. This time I attached a screenshot and the blend file.

eye_problem.blend (1.2 MB)

I had only included the multiply node for the case of a small scale of the eyeball (as @Hunkadoodle had implied). This here seems to work:

eye_problem_2.blend (1.2 MB)

2 Likes

Now I got it to work with both setups. The first one is my initial setup and the second one is the setup with the sutract node. The only thing realy changed to the first setup is the “Location Y” value in the mapping node from -1.5m to -1m. I used the value you came up with, but would like to know why it changes the result so drastically. I tought the location defines…hmmm…the location, and will not turn a spherical gradient to a ring. I just don´t get why that happened.

And thanks for the help so far.

The location determines the origin of the sphere. The intersection of that sphere with the surface of your mesh then gives you the gradient pattern (and this intersection may be a ring in certain cases).

Thanks again.

1 Like