Cannot cast from larger type float3 to smaller type float2

Ive been trying to create a skybox texture but an error keeps occuring

This is the error:

[SM5] (Node TextureSample) Cannot cast from larger type LWCVector3 to smaller type LWCVector2.

[SM5] (Node TextureSample) Cannot cast from larger type float3 to smaller type float2.

Absolute World Position outputs a 3D Vector (float3) but UVs is expecting a 2D Vector (float2).

Here’s how it’s done in the M_SkyBox material that comes with the engine :

Your example is also a float3…
Cubemaps usually expect float3 UVWs. But if OPs texture isn’t authored as a cubemap then the engine won’t know what to do with the W/Z/B component. There are nodes to convert between 2D coords and cubemaps, like “UV to LongLat”.

1 Like

I did what you showed here but this error still persists

[SM5] (Node TextureSample) Cannot cast from larger type float3 to smaller type float2.

Hey

What you need in general for this case is Component Mask to extract the Vector2 from the World Position or any other Vector3 output, marking only R, G channels, that would be X, Y.
image

1 Like

While this will prevent the error, there is more to correctly mapping skybox and cubemaps textures specifically, and if you simply mask out the blue channel it may not look correct. As I mentioned in my previous comment, the UV to LongLat and LongLat to UV material functions are designed to deal with this situation.

1 Like

Alright this is what i have now

image

but when I try to scale up the sphere for the skybox my character can’t spawn inside of it