#Unity Skybox Moon UV coordinates

42 messages · Page 1 of 1 (latest)

edgy fjord
#

Hello, I'm modifying the built in procedural skybox to fill my needs, however for some reason I cannot find anyone online about how to map a 2D image (Like the moon) unto the skybox. Can anyone help?

#

How it is on the left, on the right is how I want it

tight summit
#

maybe, download the skybox you wanna use , get it into 6-side split of images in photshop , then add a moon texture and use 6-side skybox material

edgy fjord
#

That wouldn't work

#

I also realize I failed to provide the code that makes this all work- Apologies

#

OK, I did manage to do it, but there's something wrong. Whenever I go towards the edge of the image, it does stretches the projection, see right. How can I fix this? Here's how I calculated the UVs
half2 _moonUV = (((_WorldSpaceLightPos0.xyz - ray) / _MoonSize) * float2(-0.5, 0.5)) - float2(0.5, 0.5);

#

This is from the built-procedural skybox

crystal elm
#

if your attempt is to make the moon move why dont you rotate the skybox

edgy fjord
#

Because that would make everything else move and I'd prefer to not do that?

visual kettle
#

At certain positions, the moon will span three faces (at corners)

edgy fjord
#

Yeah

#

I tried to use that method where it would wrap around instead but I have no idea how to make the offsets work for it

#

It either didn't work or was off one way or another

visual kettle
#

Do you need to use a skybox

edgy fjord
#

Yes, I do

visual kettle
#

Why

edgy fjord
#

Because I've tried before with quads and it didn't work how I wanted it too

visual kettle
#

...

#

I mean if you really want to use skybox that's fine

edgy fjord
#

Yeah, but this is an issue that can't not be fixed if I want to use the texture

visual kettle
#

Elaborate I don't understand

edgy fjord
#

The outline of the moon is fine but the texture gets stretched. I have no idea how to fix it

visual kettle
#

So you want to keep using a skybox but fix the stretching

edgy fjord
#

Yes

visual kettle
#

That's still going to require projecting/transforming the moon texture onto a cube

#

Possibly across multiple edges

edgy fjord
#

Oh
I mean, if it works it works but I have no idea how to do that...

visual kettle
edgy fjord
#

Hmm can I get back to you in this

visual kettle
#

Which is why I suggested not using a skybox. But I think we could figure it out if we read up on projections and stuff

edgy fjord
#

I already have a projection for the cloud and moon textures

#

I tried using it for the moon but didn't work as I said

#

Maybe I need to develop a formula that will provide the right offset

visual kettle
edgy fjord
#

It uses the same code as the sun, it's probably the angle and my 120 fov

visual kettle
#

fov also shouldn't stretch it like that, if we're talking realism

#

I think

#

Not at this distance

edgy fjord
#

This is with the editor camera

visual kettle
#

Oh

#

Could still look the same in game