Skip to content

Commit

Permalink
#6 - Sample skybox from lighting setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Looooong committed May 30, 2019
1 parent 48e4192 commit 2f4bce1
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 12 deletions.
5 changes: 2 additions & 3 deletions Runtime/CGIncludes/Radiances/Pixel.cginc
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,10 @@
radiance += (1.0 - radiance.a) * SampleRadiance(coordinate, size);
}

#ifdef REFLECT_SKYBOX
if (radiance.a < 1.0) {
radiance += (1 - radiance.a) * texCUBElod(Skybox, float4(data.vecR, mad(-40.0, data.glossiness * data.glossiness, 40.0)));
half4 skyData = UNITY_SAMPLE_TEXCUBE_LOD(unity_SpecCube0, data.vecR, 6.0 * data.perceptualRoughness);
radiance += (1 - radiance.a) * half4(DecodeHDR(skyData, unity_SpecCube0_HDR), 1.0);
}
#endif

return data.specularColor * radiance.rgb * data.NdotR;
}
Expand Down
2 changes: 2 additions & 0 deletions Runtime/CGIncludes/Structs/LightingData.cginc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// Physical properties
float glossiness;
float metallic;
float perceptualRoughness;
float roughness;

// Vectors
Expand All @@ -40,6 +41,7 @@
diffuseColor = (1.0 - metallic) * baseColor;
specularColor = metallic * baseColor;

perceptualRoughness = 1.0 - glossiness;
roughness = 1.0 - glossiness * glossiness;
roughness *= roughness;

Expand Down
1 change: 0 additions & 1 deletion Runtime/Scripts/Graphics/VXGI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public enum AntiAliasing { X1 = 1, X2 = 2, X4 = 4, X8 = 8 }
public enum Resolution { Low = 33, Medium = 65, High = 129, VeryHigh = 257 }

public Vector3 center;
public Cubemap skybox;
public Light sun;
public AntiAliasing antiAliasing = AntiAliasing.X1;
public Resolution resolution = Resolution.Medium;
Expand Down
8 changes: 1 addition & 7 deletions Runtime/Scripts/SRP/VXGIRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public void RenderDeferred(ScriptableRenderContext renderContext, Camera camera,
_command.Clear();

var drawSettings = new DrawRendererSettings(camera, new ShaderPassName("Deferred"));
drawSettings.rendererConfiguration |= RendererConfiguration.PerObjectReflectionProbes;
drawSettings.sorting.flags = SortFlags.CommonOpaque;

renderContext.DrawRenderers(_cullResults.visibleRenderers, ref drawSettings, _filterSettings);
Expand All @@ -130,13 +131,6 @@ public void RenderDeferred(ScriptableRenderContext renderContext, Camera camera,
_coneType = vxgi.coneType;
}

if (vxgi.skybox == null) {
_command.DisableShaderKeyword("REFLECT_SKYBOX");
} else {
_command.EnableShaderKeyword("REFLECT_SKYBOX");
_command.SetGlobalTexture("Skybox", vxgi.skybox);
}

Matrix4x4 clipToWorld = camera.cameraToWorldMatrix * GL.GetGPUProjectionMatrix(camera.projectionMatrix, false).inverse;

_command.SetGlobalVector("CameraPosition", camera.transform.position);
Expand Down
1 change: 0 additions & 1 deletion Runtime/Shaders/VXGI.shader
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Shader "Hidden/VXGI"
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile __ REFLECT_SKYBOX
#pragma multi_compile __ TRACE_SUN
#pragma multi_compile __ TRACE_DIFFUSE TRACE_REFLECTANCE TRACE_TRANSMITTANCE

Expand Down

0 comments on commit 2f4bce1

Please sign in to comment.