Projecting a texture in one direction

Hi,
I’m trying to apply a texture to a diamond in one direction. I have a diamond in 3D and I would like to project an image in the mesh following a plane. Do you think it make sense?

Do you think it can be an approach? I saw some examples in shaders, but it is too complicated for me!

Thanks

If I understand your question correctly and you have a 3d model you load I guess my approach would be to simply uv map it in Blender.
Just looking down on the diamond and project the uv map from view.
(Reference: Mapping Types — Blender Manual)

I guess this would be way easier as altering the shader for that one case :slight_smile:

Thanks for your answer!

Texture mapping is a good approach but agree with you about shader.

About the shader, are you proposing do the image projection using shaders. Do you know any hint I can follow? I’m lost! :slight_smile:

Thanks

You might be interested in this thread from the old forum:

here is a PG by @nasimiasl and @sebavan:
https://www.babylonjs-playground.com/#1F17BQ#56

Thanks Adam,
Yes, I saw it in the past, but the diamond is not too realistic! I found a shader and it is really good!

https://www.shadertoy.com/view/XdtGDj

I have it running in babylonjs, but I need to apply a transformation matrix, because now it is always in the 0,0,0. Do you know where I can find help with that? I have 0 experience in shaders. Do you know if there is a forum I can ask for that?

thanks,

1 Like

Hi @mechuvos,

I guess I understand now.
For the effect you are going for you can use refraction.
I made a small sample playground:

https://www.babylonjs-playground.com/#WJXYP9

Just note that I was not able to get the dynamic refraction rendering the top part of the skybox correctly. Maybe someone can help?

If you do not have other objects in the scene you could just use the reflection texture for the refraction i guess. That would save processing power and solve the problem with the skybox.

The clearcoat is not necessary and maybe some parameters are not set coorectly (IOR for the diamond). It just adds a more visible reflection.

I hope this helps :slight_smile:

// more info on refraction:
https://doc.babylonjs.com/how_to/reflect#refraction

1 Like