Hey,

I just found this codepen which maps a checkerboard coloring on cells of a plane-geometry.

If I want to do same same but to an rounded-cube geometry… ?

Kinda goldfish here

B

Hey,

I just found this codepen which maps a checkerboard coloring on cells of a plane-geometry.

If I want to do same same but to an rounded-cube geometry… ?

Kinda goldfish here

B

Hi!

And how the desired result with a rounded cube has to look like?

So what’s the question?

Three.js has RoundedBoxGeometry `https://cdn.skypack.dev/three@0.132.2/examples/jsm/geometries/RoundedBoxGeometry.js`

, that supports UVs.

@prisoner849 almost yes, but still, at some sides it is not alternating the chequer´s

I´d love to have it alternating it´s chequers on each side?

This is the best I could imagine for the UV based checkered pattern of a rounded box: Edit fiddle - JSFiddle - Code Playground

```
let g = new RoundedBoxGeometry(5, 5, 5, 10, 1);
let m = new THREE.MeshBasicMaterial({
onBeforeCompile: shader => {
shader.fragmentShader = `${shader.fragmentShader}`
.replace(
`vec4 diffuseColor = vec4( diffuse, opacity );`,
`
float chCount = 7.;
float checker = (1. / chCount);
float actualCheckers = 1. - checker;
float halfChecker = checker * 0.5;
vec2 bUv = (vUv * actualCheckers) - halfChecker;
vec2 cUv = fract((bUv) * (chCount * 0.5)) - 0.5;
float checkerVal = clamp(step(cUv.x * cUv.y, 0.), 0.5, 1.);
vec3 col = vec3(checkerVal);
vec4 diffuseColor = vec4( col, opacity );
`
);
console.log(shader.fragmentShader)
}
});
m.defines = {"USE_UV":""};
let o = new THREE.Mesh(g, m);
scene.add(o);
```

`chCount`

must be an odd number.

3 Likes

If segmentation is odd, then yes