I saw the official volume rendering example, but its proxy geometry is BOX and the in-shader sampling method is also cube intersection.

How can I bend the volume into a sphere cube? Like in the following example：

WedgeGeometry (aka spherical cube)

```
let geometry = new THREE.BoxGeometry(1,1,1,10,10,10);
let pa = geometry.attributes.position.array;
let v= new Vector3();
for(let i=0;i<pa.length;i+=3){
v.set(pa[i],pa[i+1],pa[i+2]);
v.normalize();
pa[i]=v.x;
pa[i+1]=v.y;
pa[i+2]=v.z;
}
geometry.computeVertexNormals();
geometry.attributes.position.needsUpdate = true;
```

1 Like

thanks, but nothing happened, what does the code do?

I updated the code… try it again?

I realized your cube geometry wasn’t subdivided, so there weren’t enough vertices to sphereize.

Now I pass 10 subdivisions for x,y,z, and you should see a sphere.

It worked!

For this case, I want to use my own RawShaderMaterial, and after applying your code, it shows a weird result compared with offical example:

3 Likes