How do I project an image texture onto the surface of a model using a shader?

WebGL Shader to fix image disortion (fisheye)
Simple vertex shader
Hello, dear community!
Forgive me if I don’t know anything about shaders, in this question @Evgeni_Popov has created an example where the image texture is projected on the surface of the cube and it looks like the effect of a projector shining on a wall.
Also, in this example, the image texture moves as the ArcRotateCamera is panned left, it seems that the texture is always in the center of the ArcRotateCamera’s view and black space appears after the panning.
How can this example be modified so that the image texture stays projected on the surface of the cube while not moving with the ArcRotateCamera’s left and right panning?

Hello @saki , how are you doing?

Is this the effect you are trying to achieve?

Simple vertex shader | Babylon.js Playground (babylonjs.com)

2 Likes

@srzerbetto Hello, thank you for your prompt response and professional answer.
Currently the texture does not move with the camera panning anymore, which is great.
I have observed that the texture rotates with the camera as it rotates, the position of the texture is related to the height and angle of the camera.
I really like the effect of this image texture projection, is it possible to do a texture projection after I set the position and angle of the camera and subsequently make sure that the position of the image texture doesn’t change no matter how much the camera rotates and pans.
Thanks again for your kind answers and have a great day! :smiling_face_with_three_hearts: