- Moved video screen into its own separate movie tent. - Adjusted stable post-processing volume. - Chickens are now at full volume. - Added button to toggle chickens off and on.
72 lines
3.3 KiB
HLSL
72 lines
3.3 KiB
HLSL
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
|
|
|
|
#ifndef UNITY_IMAGE_BASED_LIGHTING_INCLUDED
|
|
#define UNITY_IMAGE_BASED_LIGHTING_INCLUDED
|
|
|
|
#include "UnityStandardUtils.cginc"
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// GlossyEnvironment - Function to integrate the specular lighting with default sky or reflection probes
|
|
// ----------------------------------------------------------------------------
|
|
struct Unity_GlossyEnvironmentData
|
|
{
|
|
// - Deferred case have one cubemap
|
|
// - Forward case can have two blended cubemap (unusual should be deprecated).
|
|
|
|
// Surface properties use for cubemap integration
|
|
half roughness; // CAUTION: This is perceptualRoughness but because of compatibility this name can't be change :(
|
|
half3 reflUVW;
|
|
};
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
Unity_GlossyEnvironmentData UnityGlossyEnvironmentSetup(half Smoothness, half3 worldViewDir, half3 Normal, half3 fresnel0)
|
|
{
|
|
Unity_GlossyEnvironmentData g;
|
|
|
|
g.roughness /* perceptualRoughness */ = SmoothnessToPerceptualRoughness(Smoothness);
|
|
g.reflUVW = reflect(-worldViewDir, Normal);
|
|
|
|
return g;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------------
|
|
half perceptualRoughnessToMipmapLevel(half perceptualRoughness)
|
|
{
|
|
return perceptualRoughness * UNITY_SPECCUBE_LOD_STEPS;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------------
|
|
half mipmapLevelToPerceptualRoughness(half mipmapLevel)
|
|
{
|
|
return mipmapLevel / UNITY_SPECCUBE_LOD_STEPS;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------------
|
|
half3 Unity_GlossyEnvironment (UNITY_ARGS_TEXCUBE(tex), half4 hdr, Unity_GlossyEnvironmentData glossIn)
|
|
{
|
|
half perceptualRoughness = glossIn.roughness /* perceptualRoughness */ ;
|
|
|
|
// TODO: CAUTION: remap from Morten may work only with offline convolution, see impact with runtime convolution!
|
|
// For now disabled
|
|
#if 0
|
|
float m = PerceptualRoughnessToRoughness(perceptualRoughness); // m is the real roughness parameter
|
|
const float fEps = 1.192092896e-07F; // smallest such that 1.0+FLT_EPSILON != 1.0 (+1e-4h is NOT good here. is visibly very wrong)
|
|
float n = (2.0/max(fEps, m*m))-2.0; // remap to spec power. See eq. 21 in --> https://dl.dropboxusercontent.com/u/55891920/papers/mm_brdf.pdf
|
|
|
|
n /= 4; // remap from n_dot_h formulatino to n_dot_r. See section "Pre-convolved Cube Maps vs Path Tracers" --> https://s3.amazonaws.com/docs.knaldtech.com/knald/1.0.0/lys_power_drops.html
|
|
|
|
perceptualRoughness = pow( 2/(n+2), 0.25); // remap back to square root of real roughness (0.25 include both the sqrt root of the conversion and sqrt for going from roughness to perceptualRoughness)
|
|
#else
|
|
// MM: came up with a surprisingly close approximation to what the #if 0'ed out code above does.
|
|
perceptualRoughness = perceptualRoughness*(1.7 - 0.7*perceptualRoughness);
|
|
#endif
|
|
|
|
|
|
half mip = perceptualRoughnessToMipmapLevel(perceptualRoughness);
|
|
half3 R = glossIn.reflUVW;
|
|
half4 rgbm = UNITY_SAMPLE_TEXCUBE_LOD(tex, R, mip);
|
|
|
|
return DecodeHDR(rgbm, hdr);
|
|
}
|
|
#endif // UNITY_IMAGE_BASED_LIGHTING_INCLUDED |