ray-tracing-renderer
ray-tracing-renderer copied to clipboard
Add support for texture .repeat and .offset
If you set the texture to repeat over a surface, the texture does not repeat while doing ray tracing and resorts to 1 large texture over the entire surface.
Here is the webgl2 renderer version :
And here is the raytraced version :
This happens even when you upload a GLTF file with a repeat pattern . Here is the file for you to test: https://drive.google.com/file/d/1idu7p_C36dxsTNpcNE4vFQXfsP7IpAbi/view?usp=sharing
Thanks !
Thanks for your contribution! The renderer doesn't implement Texture.repeat, so it doesn't do anything at the moment. It's been on my plate to add but it has been pushed away to higher priority tasks, so unfortunately I won't be able to get to it in the next few months.
If you're able to use this workaround, you can get texture tiling by modifying the geometry's UV values directly, before passing it to the renderer. e.g., from the GLTF model you loaded, the following works:
model.traverse(child => {
if (child.name === 'Plane') { // select and modify only the ground plane
const tex = child.material.map;
const uv = child.geometry.getAttribute('uv').array;
for (let i = 0; i < uv.length; i += 2) {
uv[i] *= tex.repeat.x; // u coord
uv[i + 1] *= tex.repeat.y; // v coord
}
}
});
And wa-la.
It's a messy workaround, but I hope it's okay for now.
Thankyou for your answer :)