浏览代码

Merge HDRP/staging

/main
Antoine Lelievre 6 年前
当前提交
c5cac258
共有 10 个文件被更改,包括 172 次插入144 次删除
  1. 6
      com.unity.render-pipelines.core/CoreRP/Textures/TextureCache.cs
  2. 13
      com.unity.render-pipelines.high-definition/CHANGELOG.md
  3. 2
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Gizmos.cs
  4. 2
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Volumetric/volumeTextureTool.cs.meta
  5. 18
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDAdditionalReflectionData.cs
  6. 3
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Volumetrics/DensityVolume.cs
  7. 2
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Volumetrics/DensityVolumeManager.cs
  8. 141
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Volumetric/volumeTextureTool.cs
  9. 129
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Volumetric/Texture3DCreationEditor.cs
  10. 0
      /com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Volumetric/volumeTextureTool.cs.meta

6
com.unity.render-pipelines.core/CoreRP/Textures/TextureCache.cs


bool TextureHasMipmaps(Texture texture)
{
var crt = texture as CustomRenderTexture;
else if (crt is CustomRenderTexture)
return ((CustomRenderTexture)texture).useMipMap;
else if (texture is RenderTexture)
return ((RenderTexture)texture).useMipMap;
return false;
}

13
com.unity.render-pipelines.high-definition/CHANGELOG.md


### Fixed
- Fixed package upgrade crashing the editor
- Fix HDReflectionProbe offset displayed in gizmo different than what is affected.
## [3.1.0-preview]

- Split EmissiveColor and bakeDiffuseLighting in forward avoiding the emissiveColor to be affect by SSAO
- Added a volume to control indirect light intensity
- Added EV 100 intensity unit for area lights
- Added support for RendererPriority on Renderer. This allow to control order of transparent rendering manually. HDRP have now two stage of sorting for transparent in addition to bact to front. Material have a priority then Renderer have a priority.
- Add Coupling of (HD)Camera and HDAdditionalCameraData for reset and remove in inspector contextual menu of Camera
- Add Coupling of (HD)ReflectionProbe and HDAdditionalReflectionData for reset and remove in inspector contextual menu of ReflectoinProbe
- Add macro to forbid unity_ObjectToWorld/unity_WorldToObject to be use as it doesn't handle camera relative rendering
- Add opacity control on contact shadow
### Fixed
- Fixed an issue with PreIntegratedFGD texture being sometimes destroyed and not regenerated causing rendering to break

- Refactor shader code: GetBakedDiffuseLighting is not call anymore in GBuffer or forward pass, including the ConvertSurfaceDataToBSDFData and GetPreLightData, this is done in ModifyBakedDiffuseLighting now
- Refactor shader code: Added a backBakeDiffuseLighting to BuiltinData to handle lighting for transmission
- Refactor shader code: Material must now call InitBuiltinData (Init all to zero + init bakeDiffuseLighting and backBakeDiffuseLighting ) and PostInitBuiltinData
### Added
- Added support for RendererPriority on Renderer. This allow to control order of transparent rendering manually. HDRP have now two stage of sorting for transparent in addition to bact to front. Material have a priority then Renderer have a priority.
- Add Coupling of (HD)Camera and HDAdditionalCameraData for reset and remove in inspector contextual menu of Camera
- Add Coupling of (HD)ReflectionProbe and HDAdditionalReflectionData for reset and remove in inspector contextual menu of ReflectoinProbe
- Add macro to forbid unity_ObjectToWorld/unity_WorldToObject to be use as it doesn't handle camera relative rendering
- Add opacity control on contact shadow
## [3.0.0-preview]

2
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditor.Gizmos.cs


var reflectionData = reflectionProbe.GetComponent<HDAdditionalReflectionData>();
Gizmos_CapturePoint(reflectionProbe, reflectionData, e);
var mat = reflectionProbe.transform.localToWorldMatrix;
InfluenceVolumeUI.DrawGizmos(e.m_UIState.influenceVolume, reflectionData.influenceVolume, mat, InfluenceVolumeUI.HandleType.None, InfluenceVolumeUI.HandleType.Base);
if (!e.sceneViewEditing)
return;

2
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Volumetric/volumeTextureTool.cs.meta


fileFormatVersion: 2
guid: 9723a65f374db464a8a4f39c94ca7f54
guid: 6fac8c32212b2374ba031d6c1cc3d128
MonoImporter:
externalObjects: {}
serializedVersion: 2

18
com.unity.render-pipelines.high-definition/HDRP/Lighting/Reflection/HDAdditionalReflectionData.cs


int m_Version;
ReflectionProbe m_LegacyProbe;
ReflectionProbe legacyProbe { get { return m_LegacyProbe ?? (m_LegacyProbe = GetComponent<ReflectionProbe>()); } }
ReflectionProbe legacyProbe
{
get
{
if (m_LegacyProbe == null || m_LegacyProbe.Equals(null))
{
m_LegacyProbe = GetComponent<ReflectionProbe>();
return m_LegacyProbe;
}
else
{
return m_LegacyProbe;
}
}
}
#pragma warning disable 649 //never assigned
//data only kept for migration, to be removed in future version

internal override void UpdatedInfluenceVolumeShape(Vector3 size, Vector3 offset)
{
legacyProbe.size = size;
legacyProbe.center = offset;
legacyProbe.center = transform.rotation*offset;
}
}
}

3
com.unity.render-pipelines.high-definition/HDRP/Lighting/Volumetrics/DensityVolume.cs


{
float animationTime = animate ? time : 0.0f;
volumeScrollingAmount = (textureScrollingSpeed * animationTime);
// Switch from right-handed to left-handed coordinate system.
volumeScrollingAmount.x = -volumeScrollingAmount.x;
volumeScrollingAmount.y = -volumeScrollingAmount.y;
}
}

2
com.unity.render-pipelines.high-definition/HDRP/Lighting/Volumetrics/DensityVolumeManager.cs


}
}
private void TriggerVolumeAtlasRefresh()
public void TriggerVolumeAtlasRefresh()
{
atlasNeedsRefresh = true;
}

141
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Volumetric/volumeTextureTool.cs


using System;
using UnityEngine;
using UnityEditor;
using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering {
public class VolumeTextureTool : EditorWindow
{
private Texture2D sourceTexture = null;
private string assetPath;
private string assetDirectory;
private int tileSize = 0;
private static GUIContent windowTitle = new GUIContent("Create Volume Texture");
private static GUIContent textureLabel = new GUIContent("Slice Texture");
private static GUIContent tileSizeLabel = new GUIContent("Texture Slice Size", "Dimensions of the created 3D Texture in pixels. Width, Height and Depth are all the same size");
private static GUIContent createLabel = new GUIContent("Create 3D Texture");
[MenuItem("Window/Render Pipeline/Create Volume Texture")]
static void Init()
{
VolumeTextureTool window = (VolumeTextureTool)EditorWindow.GetWindow(typeof(VolumeTextureTool));
window.titleContent = windowTitle;
window.Show();
}
private bool IsTileSizeValid()
{
int textureWidth = sourceTexture.width;
int textureHeight = sourceTexture.height;
return (tileSize > 0 && (textureWidth * textureHeight >= (tileSize*tileSize*tileSize)));
}
void OnGUI()
{
EditorGUILayout.LabelField(textureLabel, null);
EditorGUI.indentLevel++;
sourceTexture = ( EditorGUILayout.ObjectField((UnityEngine.Object)sourceTexture, typeof(Texture2D), false, null) as Texture2D);
EditorGUI.indentLevel--;
tileSize = EditorGUILayout.IntField(tileSizeLabel, tileSize, null);
bool validData = (sourceTexture != null && IsTileSizeValid());
bool create = false;
if (!validData)
{
if (tileSize > 0)
{
EditorGUILayout.HelpBox(String.Format("Source Texture too small to generate a volume Texture of {0}x{0}x{0} size", tileSize), MessageType.Warning);
}
else
{
EditorGUILayout.HelpBox("Tile size must be larger than 0", MessageType.Warning);
}
}
using (new EditorGUI.DisabledScope(!validData))
{
create = GUILayout.Button(createLabel, null);
}
if (create)
{
assetPath = AssetDatabase.GetAssetPath(sourceTexture);
assetDirectory = System.IO.Directory.GetParent(assetPath).ToString();
//Check if the texture is set to read write.
//Only need to do this since CopyTexture is currently broken on D3D11
//So need to make sure there is a CPU copy ready to copy to the 3D Texture
//The fix for this is coming soon. Need to revist once it's in.
TextureImporter importer = TextureImporter.GetAtPath(assetPath) as TextureImporter;
if (importer && !importer.isReadable)
{
importer.isReadable = true;
importer.SaveAndReimport();
}
BuildVolumeTexture();
}
}
private void BuildVolumeTexture()
{
//Check if the object we want to create is already in the AssetDatabase
string volumeTextureAssetPath = assetDirectory + "/" + sourceTexture.name + "_Texture3D.asset";
bool createNewAsset = false;
Texture3D volumeTexture = AssetDatabase.LoadAssetAtPath(volumeTextureAssetPath, typeof(Texture3D)) as Texture3D;
//If we already have the asset then we are just updating it. make sure it's the right size.
if (!volumeTexture || volumeTexture.width != tileSize || volumeTexture.height != tileSize || volumeTexture.depth != tileSize)
{
volumeTexture = new Texture3D(tileSize, tileSize, tileSize, sourceTexture.format, false);
volumeTexture.filterMode = sourceTexture.filterMode;
volumeTexture.mipMapBias = 0;
volumeTexture.anisoLevel = 0;
volumeTexture.wrapMode = sourceTexture.wrapMode;
volumeTexture.wrapModeU = sourceTexture.wrapModeU;
volumeTexture.wrapModeV = sourceTexture.wrapModeV;
volumeTexture.wrapModeW = sourceTexture.wrapModeW;
createNewAsset = true;
}
//Only need to do this since CopyTexture is currently broken on D3D11
//Proper fix on it's way for 18.3 or 19.1
Color [] colorArray = new Color[0];
int yTiles = sourceTexture.height / tileSize;
int xTiles = sourceTexture.width / tileSize;
for (int i = yTiles - 1; i >= 0; i--)
{
for (int j = 0; j < xTiles; j++)
{
Color [] sourceTile = sourceTexture.GetPixels(j * tileSize, i * tileSize, tileSize, tileSize);
Array.Resize(ref colorArray, colorArray.Length + sourceTile.Length);
Array.Copy(sourceTile, 0, colorArray, colorArray.Length - sourceTile.Length, sourceTile.Length);
}
}
volumeTexture.SetPixels(colorArray);
volumeTexture.Apply();
if (createNewAsset)
{
AssetDatabase.CreateAsset(volumeTexture, volumeTextureAssetPath);
}
else
{
AssetDatabase.SaveAssets();
//Asset can be currently used by Density Volume Manager so trigger refresh
DensityVolumeManager.manager.TriggerVolumeAtlasRefresh();
}
}
}
}

129
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Volumetric/Texture3DCreationEditor.cs


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ///
/// MIT License ///
/// ///
/// Copyright (c) 2016 Rapha�l Ernaelsten (@RaphErnaelsten) ///
/// ///
/// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), ///
/// to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, ///
/// and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: ///
/// ///
/// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. ///
/// ///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ///
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ///
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS ///
/// IN THE SOFTWARE. ///
/// ///
/// PLEASE CONSIDER CREDITING AURA IN YOUR PROJECTS. IF RELEVANT, USE THE UNMODIFIED LOGO PROVIDED IN THE "LICENSE" FOLDER. ///
/// ///
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using System;
using UnityEngine;
using System.Collections.Generic;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
//This Editor window is a quick way to generate 3D Textures for the Volumetric system.
//It will take a sourceTexture and slice it up into tiles that will fill a 3D Texture
//The volumetric system has a hardcoded size of 32x32x32 volume texture atlas so this tool makes sure it fits that size.
public class Texture3DCreationEditor : EditorWindow
{
private Texture2D sourceTexture = null;
private string sourcePath = null;
private int tileSize = DensityVolumeManager.volumeTextureSize;
private int numXTiles
{
get { return sourceTexture != null ? sourceTexture.width / tileSize : 0; }
set {}
}
private int numYTiles
{
get { return sourceTexture != null ? sourceTexture.height / tileSize : 0; }
set {}
}
private bool validData
{
get { return numXTiles * numYTiles >= tileSize; }
set {}
}
[MenuItem("Window/Render Pipeline/Create 3D Texture")]
private static void Init()
{
Texture3DCreationEditor window = (Texture3DCreationEditor)EditorWindow.GetWindow(typeof(Texture3DCreationEditor));
window.titleContent.text = "Create Texture3D Asset";
window.Show();
}
private void OnGUI()
{
EditorGUILayout.BeginVertical(EditorStyles.miniButton);
GUILayout.Button(new GUIContent(" Create Texture3D Asset", ""), EditorStyles.centeredGreyMiniLabel);
EditorGUILayout.Separator();
EditorGUILayout.LabelField("Source Texture");
sourceTexture = (Texture2D)EditorGUILayout.ObjectField(sourceTexture, typeof(Texture2D), false);
EditorGUILayout.HelpBox(String.Format("Volumetric system requires textures of size {0}x{0}x{0} so please ensure the source texture is at least this many pixels.", tileSize), MessageType.Info);
EditorGUILayout.Separator();
if (sourceTexture != null)
{
sourcePath = AssetDatabase.GetAssetPath(sourceTexture);
if (validData)
{
if (GUILayout.Button(new GUIContent("Generate 3D Texture", ""), EditorStyles.toolbarButton))
{
Generate3DTexture();
}
}
else
{
EditorGUILayout.HelpBox("Invalid Source Texture: Source texture size is not enough to create " + tileSize + " depthSlices.", MessageType.Error);
}
}
EditorGUILayout.EndVertical();
}
private void Generate3DTexture()
{
Texture3D texture = new Texture3D(tileSize, tileSize, tileSize, sourceTexture.format, false);
texture.wrapMode = sourceTexture.wrapMode;
texture.wrapModeU = sourceTexture.wrapModeU;
texture.wrapModeV = sourceTexture.wrapModeV;
texture.wrapModeW = sourceTexture.wrapModeW;
texture.filterMode = sourceTexture.filterMode;
texture.mipMapBias = 0;
texture.anisoLevel = 0;
Color[] colorArray = new Color[0];
for (int i = numYTiles - 1; i >= 0; --i)
{
for (int j = 0; j < numXTiles; ++j)
{
Color[] texColor = sourceTexture.GetPixels(j * tileSize, i * tileSize, tileSize, tileSize);
Array.Resize(ref colorArray, texColor.Length + colorArray.Length);
Array.Copy(texColor, 0, colorArray, colorArray.Length - texColor.Length, texColor.Length);
}
}
texture.SetPixels(colorArray);
texture.Apply();
AssetDatabase.CreateAsset(texture, System.IO.Directory.GetParent(sourcePath) + "\\" + sourceTexture.name + "_Texture3D.asset");
}
}
}

/com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Volumetric/Texture3DCreationEditor.cs.meta → /com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Volumetric/volumeTextureTool.cs.meta

正在加载...
取消
保存