Hello, I’m working on a small project, and im trying to figure out how to create multiple smaller “Enviroments” in a Unity map.
I have the basic skyrender(Skybox), and I have inverted cube objects that will be the mini enviroments.
inside these Cubes will be the mini enviroments.
I don’t know how to create a entire sky inside these cubes, as I don’t believe anyone uses proper sky “boxes” anymore.
is there any options or advice you all can give me, to render multiple different sky enviroments in one map?
Why not just change the RenderSettings.skybox depending on where the player is?
You can add a Skybox component to a camera and it overrides the Env skybox. Maybe use it on the player’s camera and change it at runtime. Or switch cameras.
I figured I would reopen this thread as I’m still having this issue.
any old dev’s remember the old sky"boxes" we used to make with inverted cubes, and simply apply 6 seamless textures in them? what i need is a mini “world bubble” that has terriain and stuff in it, and then when a player goes throught a portal, they find themselves in a completely new world, with its own seperate skybox.
Im seeing that “actual” skyboxes, and skyspheres are apparently a lost art lol.
there are some assets on the store that allow you to use “sky domes” or Hemisphere meshes.
or this
Sky Domes - High Performance Skybox Alternative | 3D Environments | Unity Asset Store
Does anyone have any options I can use to achieve similar results? can i invert a cube and map the textures from a cubemap simply onto the 6 sides like “in the old days”?
I think you are over complicating this. Your question basically boils down to: Can I draw a cube? Yes. Yes you can
First make your cube. Then invert the faces. You know that already of course. Now to texture it. I’ve honestly never written a shader that had to sample a cubemap but I don’t see why it would be any different from sampling a normal texture. You’ll probably have to setup the UVs appropriately but if you can handle inverting the cube faces then I’m sure you can handle that too. If it really turns out to be a hassle then just use six regular textures and create a texture atlas in photoshop that can easily be UV mapped as needed. It’s a skybox so you don’t need anything fancy for shaders. You can probably get away with a regular unlit one. If you do need something more dynamic then you’ll have to dive in to that for yourself.
Once you have your cube, pop it in your scene, scale it appropriately, and write a script to center it around your camera. Or if you want to be fancier with it, use a second camera that never moves position but matches the rotation of the main camera every frame and use layers to cull everything but the skybox. Then layer that camera’s output so that it is always rendered behind the contents of the main camera (how you do this depends on the pipeline you are using but it shouldn’t be hard to look up how to layer multiple cameras for whichever one you need).
here’s a shader you can apply to a built in unity cube to make it an inverted skybox cube
Shader "Custom/_Skybox"
{
Properties
{
[HDR] _Color("Tint Color", Color) = (.5, .5, .5, 1)
[NoScaleOffset] _MainTex("Cubemap", Cube) = "grey" {}
}
SubShader
{
Tags { "Queue" = "Background" "RenderType" = "Background" "PreviewType" = "Skybox" }
Pass
{
Name "Skybox"
CULL FRONT
ZWRITE OFF
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
samplerCUBE _MainTex;
half3 _Color;
struct appdata
{
float4 vertex : POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos : SV_POSITION;
float3 cubeUV : TEXCOORD0;
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert(appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
o.cubeUV = v.vertex.xyz;
return o;
}
fixed4 frag(v2f i) : SV_Target
{
return fixed4(texCUBE(_MainTex, i.cubeUV).rgb *_Color.rgb, 1);
}
ENDCG
}
}
}
remove the [NoScaleOffset] if you want to be able to change the size of the skybox without resizing the cube