浏览代码

Update the sky code using the Adam demo source

/main
Evgenii Golubev 8 年前
当前提交
2f7b3af3
共有 4 个文件被更改,包括 44 次插入25 次删除
  1. 12
      Assets/ScriptableRenderLoop/HDRenderLoop/Sky/ProceduralSky/ProceduralSkyParameters.cs
  2. 4
      Assets/ScriptableRenderLoop/HDRenderLoop/Sky/ProceduralSky/ProceduralSkyRenderer.cs
  3. 48
      Assets/ScriptableRenderLoop/HDRenderLoop/Sky/ProceduralSky/Resources/AtmosphericScattering.hlsl
  4. 5
      Assets/ScriptableRenderLoop/HDRenderLoop/Sky/ProceduralSky/Resources/SkyProcedural.shader

12
Assets/ScriptableRenderLoop/HDRenderLoop/Sky/ProceduralSky/ProceduralSkyParameters.cs


/*
[Header("Scatter Occlusion")]
public bool useOcclusion = false;
public bool occlusionFullSky = false;
public bool occlusionDepthFixup = true;
public float occlusionBiasIndirect = 0.6f;
public float occlusionBiasIndirect = 0.6f;
public float occlusionBiasSkyMie = 0.4f;
public float occlusionBiasSkyRayleigh = 0.2f;
public float occlusionDepthThreshold = 25f;
public bool occlusionDepthFixup = true;
public float occlusionDepthThreshold = 25f;
public bool occlusionFullSky = false;
public float occlusionBiasSkyRayleigh = 0.2f;
public float occlusionBiasSkyMie = 0.4f;
*/
[Header("Other")]

4
Assets/ScriptableRenderLoop/HDRenderLoop/Sky/ProceduralSky/ProceduralSkyRenderer.cs


void SetKeywords(BuiltinSkyParameters builtinParams, ProceduralSkyParameters param)
{
// Ensure that all preprocessor symbols are initially undefined.
m_ProceduralSkyMaterial.DisableKeyword("ATMOSPHERICS");
m_ProceduralSkyMaterial.DisableKeyword("ATMOSPHERICS_PER_PIXEL");
m_ProceduralSkyMaterial.DisableKeyword("ATMOSPHERICS_DEBUG");
m_ProceduralSkyMaterial.DisableKeyword("ATMOSPHERICS_OCCLUSION");
m_ProceduralSkyMaterial.DisableKeyword("ATMOSPHERICS_OCCLUSION_EDGE_FIXUP");

m_ProceduralSkyMaterial.EnableKeyword("ATMOSPHERICS_PER_PIXEL");
/*
if (useOcclusion)

48
Assets/ScriptableRenderLoop/HDRenderLoop/Sky/ProceduralSky/Resources/AtmosphericScattering.hlsl


coords2.a = mieScatter;
}
void VolundTransferScatter(float3 scaledWorldPos, out float4 coords1) {
float4 c1, c2, c3;
VolundTransferScatter(scaledWorldPos, c1, c2, c3);
void VolundTransferScatter(float3 worldPos, out float4 coords1) {
float4 c1, c2, c3;
VolundTransferScatter(worldPos, c1, c2, c3);
#ifdef IS_RENDERING_SKY
coords1.rgb = c3.rgb;

}
float2 UVFromPos(float2 pos) {
#if defined(UNITY_PASS_FORWARDBASE)
return pos;
#else
#endif
}
float3 VolundApplyScatter(float4 coords1, float2 pos, float3 color) {

return color * coords1;
}
void VolundTransferScatterOcclusion(float3 scaledWorldPos, out float4 coords1, out float3 coords2) {
float4 c1, c2, c3;
VolundTransferScatter(scaledWorldPos, c1, c2, c3);
void VolundTransferScatterOcclusion(float3 worldPos, out float4 coords1, out float3 coords2) {
float4 c1, c2, c3;
VolundTransferScatter(worldPos, c1, c2, c3);
coords1.rgb = c1.rgb * _RayleighInScatterPct.x;
coords1.a = max(0.f, 1.f - c1.a * _RayleighExtinctionFactor - c3.a * _HeightExtinctionFactor);

float4 mfWeights = float4(fWeights.z * fWeights.y, fWeights.x * fWeights.y, fWeights.x * fWeights.w, fWeights.z * fWeights.w);
return dot(occ, mfWeights * maskDepth) / dot(mfWeights, maskDepth);
}
#endif //defined(ATMOSPHERICS_OCCLUSION_EDGE_FIXUP)
#else
return SAMPLE_TEXTURE2D(_OcclusionTexture, SRL_BilinearSampler, uv).r;
#endif
#else //defined(ATMOSPHERICS_OCCLUSION)
return 1.f;
#endif //defined(ATMOSPHERICS_OCCLUSION)

// Original vert/frag macros
#if defined(ATMOSPHERICS_OCCLUSION)
#define VOLUND_SCATTER_COORDS(idx1, idx2) float4 scatterCoords1 : TEXCOORD##idx1; float3 scatterCoords2 : TEXCOORD##idx2;
#define VOLUND_TRANSFER_SCATTER(pos, o) o.scatterCoords1 = pos.xyzz; o.scatterCoords2 = pos.xyz;
#define VOLUND_APPLY_SCATTER(i, color) VolundTransferScatterOcclusion(i.scatterCoords1.xyz, i.scatterCoords1, i.scatterCoords2); color = VolundApplyScatterOcclusion(i.scatterCoords1, i.scatterCoords2, i.pos.xy, color)
#define VOLUND_CLOUD_SCATTER(i, color) VolundTransferScatterOcclusion(i.scatterCoords1.xyz, i.scatterCoords1, i.scatterCoords2); color = VolundApplyCloudScatterOcclusion(i.scatterCoords1, i.scatterCoords2, i.pos.xy, color)
#if defined(ATMOSPHERICS_PER_PIXEL)
#define VOLUND_TRANSFER_SCATTER(pos, o) o.scatterCoords1 = pos.xyzz; o.scatterCoords2 = pos.xyz;
#define VOLUND_APPLY_SCATTER(i, color) VolundTransferScatterOcclusion(i.scatterCoords1.xyz, i.scatterCoords1, i.scatterCoords2); color = VolundApplyScatterOcclusion(i.scatterCoords1, i.scatterCoords2, i.pos.xy, color)
#define VOLUND_CLOUD_SCATTER(i, color) VolundTransferScatterOcclusion(i.scatterCoords1.xyz, i.scatterCoords1, i.scatterCoords2); color = VolundApplyCloudScatterOcclusion(i.scatterCoords1, i.scatterCoords2, i.pos.xy, color)
#else
#define VOLUND_TRANSFER_SCATTER(pos, o) VolundTransferScatterOcclusion(pos, o.scatterCoords1, o.scatterCoords2)
#define VOLUND_APPLY_SCATTER(i, color) color = VolundApplyScatterOcclusion(i.scatterCoords1, i.scatterCoords2, i.pos.xy, color)
#define VOLUND_CLOUD_SCATTER(i, color) color = VolundApplyCloudScatterOcclusion(i.scatterCoords1, i.scatterCoords2, i.pos.xy, color)
#endif
#define VOLUND_TRANSFER_SCATTER(pos, o) o.scatterCoords1 = pos.xyzz;
#define VOLUND_APPLY_SCATTER(i, color) VolundTransferScatter(i.scatterCoords1.xyz, i.scatterCoords1); color = VolundApplyScatter(i.scatterCoords1, i.pos.xy, color);
#define VOLUND_CLOUD_SCATTER(i, color) VolundTransferScatter(i.scatterCoords1.xyz, i.scatterCoords1); color = VolundApplyCloudScatter(i.scatterCoords1, color);
#if defined(ATMOSPHERICS_PER_PIXEL)
#define VOLUND_TRANSFER_SCATTER(pos, o) o.scatterCoords1 = pos.xyzz;
#define VOLUND_APPLY_SCATTER(i, color) VolundTransferScatter(i.scatterCoords1.xyz, i.scatterCoords1); color = VolundApplyScatter(i.scatterCoords1, i.pos.xy, color);
#define VOLUND_CLOUD_SCATTER(i, color) VolundTransferScatter(i.scatterCoords1.xyz, i.scatterCoords1); color = VolundApplyCloudScatter(i.scatterCoords1, color);
#else
#define VOLUND_TRANSFER_SCATTER(pos, o) VolundTransferScatter(pos, o.scatterCoords1)
#define VOLUND_APPLY_SCATTER(i, color) color = VolundApplyScatter(i.scatterCoords1, i.pos.xy, color)
#define VOLUND_CLOUD_SCATTER(i, color) color = VolundApplyCloudScatter(i.scatterCoords1, color)
#endif
#define SURFACE_SCATTER_COORDS float3 scaledWorldPos; float4 scatterCoords1; float3 scatterCoords2;
#define SURFACE_SCATTER_COORDS float3 worldPos; float4 scatterCoords1; float3 scatterCoords2;
#define SURFACE_SCATTER_APPLY(i, color) color += (i.scaledWorldPos + i.scatterCoords1.xyz + i.scatterCoords2.xyz) * 0.000001f
#define SURFACE_SCATTER_APPLY(i, color) color += (i.worldPos + i.scatterCoords1.xyz + i.scatterCoords2.xyz) * 0.000001f
#endif
#endif //FILE_ATMOSPHERICSCATTERING

5
Assets/ScriptableRenderLoop/HDRenderLoop/Sky/ProceduralSky/Resources/SkyProcedural.shader


#pragma multi_compile _ ATMOSPHERICS_DEBUG
#pragma multi_compile _ PERFORM_SKY_OCCLUSION_TEST
#ifndef PERFORM_SKY_OCCLUSION_TEST
#define IS_RENDERING_SKY
#endif
#define IS_RENDERING_SKY
#include "AtmosphericScattering.hlsl"
TEXTURECUBE(_Cubemap);

正在加载...
取消
保存