I am trying to scale and repeat a Cubemap with Latitude-Longitude mapping layout just as you would do with classical UV mapping but without any interesting result. This should be used as a skybox.

This comes from the fact that the coordinates are in 3D space and we can't apply this simple formula texcoord.xy * scale.xy + offset.xy

How would you handle such features : scaling which involves tiling and offsetting.

samplerCUBE _TexCube;
texCUBE(_TexCube, float3);

1 Answer 1


This doesn't really answer the question but is a workaround. Beware it's hack time :)

Instead of using the texCUBE and samplerCube I'll be using the tex2D method and a simple sampler to sample the texture.

As I am using a sphere mesh, I generate 2D UVs like this.

float x = atan2(vertex.x, vertex.z) / PI;
x = x / 2.0 + 0.5; // To remap from 0 to 1
float y = vertex.y / 2.0 + 0.5; // Also remap from 0 to 1
float3 color = tex2D(sampler, float2(x, y) * scale.xy + offset.xy);

It's a bit hacky but using this I have 2D texture coordinates for my texture.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.