浏览代码

Merge pull request #1035 from Unity-Technologies/Fix-Sky-shader-resources

Fix sky shader resources
/2018.1
GitHub 7 年前
当前提交
dc6ad122
共有 17 个文件被更改,包括 43 次插入40 次删除
  1. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDAssetFactory.cs
  2. 6
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Sky/HDRISky/HDRISkyEditor.cs
  3. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/HDRenderPipelineResources.asset
  4. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/RenderPipelineResources.cs
  5. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/HDRISky/HDRISky.cs
  6. 7
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/HDRISky/HDRISkyRenderer.cs
  7. 29
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/ProceduralSky/ProceduralSkyRenderer.cs
  8. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/HDRISky/HDRISky.shader
  9. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/ProceduralSky/ProceduralSky.shader
  10. 9
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/HDRISky/HDRISky.shader.meta
  11. 9
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/HDRISky/Resources.meta
  12. 9
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/ProceduralSky/Resources.meta
  13. 0
      /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/HDRISky/HDRISky.shader
  14. 0
      /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/ProceduralSky/ProceduralSky.shader.meta
  15. 0
      /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/ProceduralSky/ProceduralSky.shader

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDAssetFactory.cs


newAsset.computeGgxIblSampleData = Load<ComputeShader>(HDRenderPipelinePath + "Material/GGXConvolution/ComputeGgxIblSampleData.compute");
newAsset.GGXConvolve = Load<Shader>(HDRenderPipelinePath + "Material/GGXConvolution/GGXConvolve.shader");
newAsset.opaqueAtmosphericScattering = Load<Shader>(HDRenderPipelinePath + "Sky/OpaqueAtmosphericScattering.shader");
newAsset.hdriSky = Load<Shader>(HDRenderPipelinePath + "Sky/HDRISky/HDRISky.shader");
newAsset.proceduralSky = Load<Shader>(HDRenderPipelinePath + "Sky/ProceduralSky/ProceduralSky.shader");
// Utilities / Core
newAsset.encodeBC6HCS = Load<ComputeShader>(CorePath + "CoreResources/EncodeBC6H.compute");

6
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Sky/HDRISky/HDRISkyEditor.cs


public class HDRISkyEditor
: SkySettingsEditor
{
SerializedDataParameter m_SkyHDRI;
SerializedDataParameter m_hdriSky;
public override void OnEnable()
{

m_SkyHDRI = Unpack(o.Find(x => x.skyHDRI));
m_hdriSky = Unpack(o.Find(x => x.hdriSky));
PropertyField(m_SkyHDRI);
PropertyField(m_hdriSky);
EditorGUILayout.Space();

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/HDRenderPipelineResources.asset


GGXConvolve: {fileID: 4800000, guid: 123ed592ad5c2494b8aed301fd609e7b, type: 3}
opaqueAtmosphericScattering: {fileID: 4800000, guid: 326059e48e5735e46a98047eff4f0295,
type: 3}
hdriSky: {fileID: 4800000, guid: 9bd32a6ece529fd4f9408b8d7e00c10d, type: 3}
proceduralSky: {fileID: 4800000, guid: ec63f47fd265df243a7b1d40f9ef7fe7, type: 3}
skyboxCubemap: {fileID: 103, guid: 0000000000000000f000000000000000, type: 0}
encodeBC6HCS: {fileID: 7200000, guid: aa922d239de60304f964e24488559eeb, type: 3}
cubeToPanoShader: {fileID: 4800000, guid: 595434cc3b6405246b6cd3086d0b6f7d, type: 3}

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/RenderPipelineResources.cs


public ComputeShader computeGgxIblSampleData;
public Shader GGXConvolve;
public Shader opaqueAtmosphericScattering;
public Shader hdriSky;
public Shader proceduralSky;
public Shader skyboxCubemap;

4
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/HDRISky/HDRISky.cs


public class HDRISky : SkySettings
{
[Tooltip("Cubemap used to render the sky.")]
public CubemapParameter skyHDRI = new CubemapParameter(null);
public CubemapParameter hdriSky = new CubemapParameter(null);
public override SkyRenderer CreateRenderer()
{

unchecked
{
hash = skyHDRI.value != null ? hash * 23 + skyHDRI.GetHashCode() : hash;
hash = hdriSky.value != null ? hash * 23 + hdriSky.GetHashCode() : hash;
}
return hash;

7
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/HDRISky/HDRISkyRenderer.cs


using UnityEngine.Rendering;
namespace UnityEngine.Experimental.Rendering.HDPipeline
{
public class HDRISkyRenderer : SkyRenderer

public override void Build()
{
m_SkyHDRIMaterial = CoreUtils.CreateEngineMaterial("Hidden/HDRenderPipeline/Sky/SkyHDRI");
var hdrp = GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset;
m_SkyHDRIMaterial = CoreUtils.CreateEngineMaterial(hdrp.renderPipelineResources.hdriSky);
}
public override void Cleanup()

public override void RenderSky(BuiltinSkyParameters builtinParams, bool renderForCubemap)
{
m_SkyHDRIMaterial.SetTexture(HDShaderIDs._Cubemap, m_HdriSkyParams.skyHDRI);
m_SkyHDRIMaterial.SetTexture(HDShaderIDs._Cubemap, m_HdriSkyParams.hdriSky);
m_SkyHDRIMaterial.SetVector(HDShaderIDs._SkyParam, new Vector4(m_HdriSkyParams.exposure, m_HdriSkyParams.multiplier, -m_HdriSkyParams.rotation, 0.0f)); // -rotation to match Legacy...
// This matrix needs to be updated at the draw call frequency.

29
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/ProceduralSky/ProceduralSkyRenderer.cs


using UnityEngine.Rendering;
Material m_SkyProceduralMaterial;
Material m_ProceduralSkyMaterial;
MaterialPropertyBlock m_PropertyBlock;
ProceduralSky m_ProceduralSkyParams;

public override void Build()
{
m_SkyProceduralMaterial = CoreUtils.CreateEngineMaterial("Hidden/HDRenderPipeline/Sky/SkyProcedural");
var hdrp = GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset;
m_ProceduralSkyMaterial = CoreUtils.CreateEngineMaterial(hdrp.renderPipelineResources.proceduralSky);
CoreUtils.Destroy(m_SkyProceduralMaterial);
CoreUtils.Destroy(m_ProceduralSkyMaterial);
}
public override void SetRenderTargets(BuiltinSkyParameters builtinParams)

public override void RenderSky(BuiltinSkyParameters builtinParams, bool renderForCubemap)
{
CoreUtils.SetKeyword(m_SkyProceduralMaterial, "_ENABLE_SUN_DISK", m_ProceduralSkyParams.enableSunDisk);
CoreUtils.SetKeyword(m_ProceduralSkyMaterial, "_ENABLE_SUN_DISK", m_ProceduralSkyParams.enableSunDisk);
Color sunColor = Color.white;
Vector3 sunDirection = Vector3.zero;

sunDirection = -builtinParams.sunLight.transform.forward;
}
m_SkyProceduralMaterial.SetVector(HDShaderIDs._SkyParam, new Vector4(m_ProceduralSkyParams.exposure, m_ProceduralSkyParams.multiplier, 0.0f, 0.0f));
m_SkyProceduralMaterial.SetFloat(_SunSizeParam, m_ProceduralSkyParams.sunSize);
m_SkyProceduralMaterial.SetFloat(_SunSizeConvergenceParam, m_ProceduralSkyParams.sunSizeConvergence);
m_SkyProceduralMaterial.SetFloat(_AtmoshpereThicknessParam, m_ProceduralSkyParams.atmosphereThickness);
m_SkyProceduralMaterial.SetColor(_SkyTintParam, m_ProceduralSkyParams.skyTint);
m_SkyProceduralMaterial.SetColor(_GroundColorParam, m_ProceduralSkyParams.groundColor);
m_SkyProceduralMaterial.SetColor(_SunColorParam, sunColor);
m_SkyProceduralMaterial.SetVector(_SunDirectionParam, sunDirection);
m_ProceduralSkyMaterial.SetVector(HDShaderIDs._SkyParam, new Vector4(m_ProceduralSkyParams.exposure, m_ProceduralSkyParams.multiplier, 0.0f, 0.0f));
m_ProceduralSkyMaterial.SetFloat(_SunSizeParam, m_ProceduralSkyParams.sunSize);
m_ProceduralSkyMaterial.SetFloat(_SunSizeConvergenceParam, m_ProceduralSkyParams.sunSizeConvergence);
m_ProceduralSkyMaterial.SetFloat(_AtmoshpereThicknessParam, m_ProceduralSkyParams.atmosphereThickness);
m_ProceduralSkyMaterial.SetColor(_SkyTintParam, m_ProceduralSkyParams.skyTint);
m_ProceduralSkyMaterial.SetColor(_GroundColorParam, m_ProceduralSkyParams.groundColor);
m_ProceduralSkyMaterial.SetColor(_SunColorParam, sunColor);
m_ProceduralSkyMaterial.SetVector(_SunDirectionParam, sunDirection);
CoreUtils.DrawFullScreen(builtinParams.commandBuffer, m_SkyProceduralMaterial, m_PropertyBlock, renderForCubemap ? 0 : 1);
CoreUtils.DrawFullScreen(builtinParams.commandBuffer, m_ProceduralSkyMaterial, m_PropertyBlock, renderForCubemap ? 0 : 1);
}
public override bool IsValid()

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/HDRISky/HDRISky.shader


Shader "Hidden/HDRenderPipeline/Sky/SkyHDRI"
Shader "Hidden/HDRenderPipeline/Sky/HDRISky"
{
HLSLINCLUDE

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/ProceduralSky/ProceduralSky.shader


// It's been ported to HDRP in order to have a basic procedural sky
// It has been left mostly untouched but has been adapted to run per-pixel instead of per vertex
// ==================================================================================================
Shader "Hidden/HDRenderPipeline/Sky/SkyProcedural"
Shader "Hidden/HDRenderPipeline/Sky/ProceduralSky"
{
HLSLINCLUDE

9
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/HDRISky/HDRISky.shader.meta


fileFormatVersion: 2
guid: 9bd32a6ece529fd4f9408b8d7e00c10d
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

9
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/HDRISky/Resources.meta


fileFormatVersion: 2
guid: 45faf85c8e652e744a3ce8ead527369d
folderAsset: yes
timeCreated: 1481636169
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

9
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/ProceduralSky/Resources.meta


fileFormatVersion: 2
guid: 3c4549341d53b5e479e9514d5b0e2a3b
folderAsset: yes
timeCreated: 1481636169
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/HDRISky/Resources/SkyHDRI.shader → /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/HDRISky/HDRISky.shader

/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/ProceduralSky/Resources/ProceduralSky.shader.meta → /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/ProceduralSky/ProceduralSky.shader.meta

/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/ProceduralSky/Resources/ProceduralSky.shader → /ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/ProceduralSky/ProceduralSky.shader

正在加载...
取消
保存