Fix T40692, Checker Texture derivation on very large scales (1k).

It might still have a derivation on larger scales (10k or more), but we need some offset to avoid precision issues on unit coordinates.
This commit is contained in:
Thomas Dinges 2014-06-20 09:03:00 +02:00
parent 84e8cabac6
commit ead83a48f1
Notes: blender-bot 2023-02-14 10:28:22 +01:00
Referenced by issue #40800, If Viewport shading is 'Rendered', B3D crashes after browsing to file for texture node and connecting to any shader node.
Referenced by issue #40726, "Use Nodes" must be clicked before Volume section appears in menu
Referenced by issue #40692, Checker Texture Creep
2 changed files with 6 additions and 6 deletions

View File

@ -21,9 +21,9 @@
float checker(point p)
{
p[0] = (p[0] + 0.00001) * 0.9999;
p[1] = (p[1] + 0.00001) * 0.9999;
p[2] = (p[2] + 0.00001) * 0.9999;
p[0] = (p[0] + 0.000001) * 0.999999;
p[1] = (p[1] + 0.000001) * 0.999999;
p[2] = (p[2] + 0.000001) * 0.999999;
int xi = (int)fabs(floor(p[0]));
int yi = (int)fabs(floor(p[1]));

View File

@ -21,9 +21,9 @@ CCL_NAMESPACE_BEGIN
ccl_device_noinline float svm_checker(float3 p)
{
/* avoid precision issues on unit coordinates */
p.x = (p.x + 0.00001f)*0.9999f;
p.y = (p.y + 0.00001f)*0.9999f;
p.z = (p.z + 0.00001f)*0.9999f;
p.x = (p.x + 0.000001f)*0.999999f;
p.y = (p.y + 0.000001f)*0.999999f;
p.z = (p.z + 0.000001f)*0.999999f;
int xi = float_to_int(fabsf(floorf(p.x)));
int yi = float_to_int(fabsf(floorf(p.y)));