Skybox spherical projection on surfaces

Good afternoon everyone,

Is there any way to do a Spherical projection of an skybox on other objects?
Let me explain:

I have a model of a room and a sphere skybox with a realistic image of this room. Now i need to project the skybox texture/image on the room like the image blow shows.

Someone has an idea of how to do this?

I did that for screen mapping (exactly like on the second image)

Do you want me to share this code or meaningless?

Please share. I was trying to do the camera as well as you might have noticed from my old posts, but I just realized that I would need the spherical projection and I got discouraged, but it will be of great help to see your running.


So, In a nutshell, you have to calculate screen-space coords for each vertex in Vertex Shader.

varying vec2 vVertex_screenCoords; 

uniform mat4 matrix_projection;

vec2 getScreenCoords(vec3 position) {
    vec4 world_position = matrix_model * vec4(position, 1.0);
    vec4 view_position = matrix_viewProjection * world_position;    
    return vec2((view_position.x + 10.0 ) / 20.0 , (view_position.y + 10.5) / 20.0);

I have to say that this function isn’t correct. I don’t know why and how to fix it.
Probably you’re more lucky and somebody would help you.

Then, bypass it to Fragment one and texel from texture by these coords.

I did that via shader chunk system, so


In my case there is also a power param, but you don’t need that. So either texel right from texture or replace shader’s chunk just like me, if you need shadows and etc.

Thanks, i’ll try this, but i need to learn about shaders first kkkk

I’m breaking my head here to understand these shaders. 1 question, how do you pass to the shader that ‘varying vec2 vVertex_screenCoords’? You calculate first via javascript and then how do you pass each vertex information to vertex shader?

Nope, screen position is the same for whole draw call.
So just by setting additional parameter, just like in a tutorial.