AR Test

This is the first assignment for the class XR Studio

Using AR Foundation in Unity I’ve created a window to a space scene. The planets are shaded using a custom simplex noise based shader for which the main code is below.

The window is created by placing four planes with a VR/Occulsion materal around the model of the window. These planes block the scene behind (and in AR show the camera’s video feed instead). The result is that everything “behind” the window is only visible through the window, and occluded outside of the window.

Planet code below:

half oct_noise(fixed3 pos, half scl, int oct, half lac, half per) {

	half noise_val = 0;
	half amp = 1;
	for (int i = 0; i < oct; i++) {
		noise_val += snoise(pos * scl) * amp;
		scl *= lac;
		amp *= per;

	noise_val /= oct;
	noise_val = (noise_val + 1) / 2;
	return noise_val;

void surf(Input IN, inout SurfaceOutputStandard o)
                //This line is what creates the "cloud bands" on the gas giants 
		fixed3 sample_pos = IN.localPos * fixed3(0, 1, 0);

		half turbulence = oct_noise(IN.localPos, 10, 4, 1.5, 0.9);
		sample_pos += pow(turbulence, 2) * 0.01;

		half noise_val = oct_noise(sample_pos, _NoiseScale, _Octaves, _Lacunarity, _Persistence);

		fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color * noise_val;
		o.Albedo = c.rgb;
		o.Metallic = _Metallic;
		o.Smoothness = _Glossiness;
		o.Alpha = c.a;