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

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

<p>As I am using a sphere mesh, I generate 2D UVs like this.</p>

<pre><code>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);
</code></pre>

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

CC BY-SA 3.0
2018-02-16T12:53:17.267Z
2018-02-16T12:53:17.267Z
MaT
<p>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.</p>

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

<p>How would you handle such features : scaling which involves tiling and offsetting.</p>

<pre><code>samplerCUBE _TexCube;
texCUBE(_TexCube, float3);
</code></pre>

<texture><shader><glsl><hlsl><uv-mapping>
How to scale and offset a cubemap using sphere mapping
MaT
# How to scale and offset a cubemap using sphere mapping

(Asked by: username_0 on 2018-02-16)

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);

```

**Tags:** texture, shader, glsl, hlsl, uv-mapping


---

## 1 answers

### Answer by username_0 on 2018-02-16. Score: 0 | Accepted answer

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.


---

