浏览代码

Merge branch 'master' into HDLightExplorerExtension

/main
sebastienlagarde 6 年前
当前提交
b5fa681b
共有 12 个文件被更改,包括 165 次插入144 次删除
  1. 14
      com.unity.render-pipelines.high-definition/CHANGELOG.md
  2. 4
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/HDLightEditor.cs
  3. 2
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Volumetric/DensityVolumeTextureTool.cs.meta
  4. 3
      com.unity.render-pipelines.high-definition/HDRP/Editor/RenderPipeline/Settings/FrameSettingsUI.cs
  5. 2
      com.unity.render-pipelines.high-definition/HDRP/Lighting/GlobalIlluminationUtils.cs
  6. 4
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Light/HDAdditionalLightData.cs
  7. 3
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Volumetrics/DensityVolume.cs
  8. 2
      com.unity.render-pipelines.high-definition/HDRP/Lighting/Volumetrics/DensityVolumeManager.cs
  9. 4
      com.unity.render-pipelines.lightweight/LWRP/Editor/LightweightLightEditor.cs
  10. 142
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Volumetric/DensityVolumeTextureTool.cs
  11. 129
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Volumetric/Texture3DCreationEditor.cs
  12. 0
      /com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Volumetric/DensityVolumeTextureTool.cs.meta

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


- Fix decals getting into a state where they could not be removed or disabled.
- Fix lux meter mode - The lux meter isn't affected by the sky anymore
- Fix area light size reset when multi-selected
- Fixed filter pass number in HDUtils.BlitQuad
- Fixed Lux meter mode that was applying SSS
- Fixed planar reflections that were not working with tile/cluster (olbique matrix)
- Fixed debug menu at runtime not working after nested prefab PR come to trunk
- Fix filter pass number in HDUtils.BlitQuad
- Fix Lux meter mode that was applying SSS
- Fix planar reflections that were not working with tile/cluster (olbique matrix)
- Fix debug menu at runtime not working after nested prefab PR come to trunk
- Fix scrolling issue in density volume
### Changed
- Shader code refactor: Split MaterialUtilities file in two parts BuiltinUtilities (independent of FragInputs) and MaterialUtilities (Dependent of FragInputs)
## [3.1.0-preview]

- Replace the sampler used for density volumes for correct wrap mode handling
### Changed
- Movde Render Pipeline Debug "Windows from Windows->General-> Render Pipeline debug windows" to "Windows from Windows->Analysis-> Render Pipeline debug windows"
- Move Render Pipeline Debug "Windows from Windows->General-> Render Pipeline debug windows" to "Windows from Windows->Analysis-> Render Pipeline debug windows"
- Update detail map formula for smoothness and albedo, goal it to bright and dark perceptually and scale factor is use to control gradient speed
- Refactor the Upgrade material system. Now a material can be update from older version at any time. Call Edit/Render Pipeline/Upgrade all Materials to newer version
- Change name EnableDBuffer to EnableDecals at several place (shader, hdrp asset...), this require a call to Edit/Render Pipeline/Upgrade all Materials to newer version to have up to date material.

4
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/HDLightEditor.cs


case LightShape.Rectangle:
// TODO: Currently if we use Area type as it is offline light in legacy, the light will not exist at runtime
//m_BaseData.type.enumValueIndex = (int)LightType.Area;
//m_BaseData.type.enumValueIndex = (int)LightType.Rectangle;
// In case of change, think to update InitDefaultHDAdditionalLightData()
settings.lightType.enumValueIndex = (int)LightType.Point;
m_AdditionalLightData.lightTypeExtent.enumValueIndex = (int)LightTypeExtent.Rectangle;

case LightShape.Line:
// TODO: Currently if we use Area type as it is offline light in legacy, the light will not exist at runtime
//m_BaseData.type.enumValueIndex = (int)LightType.Area;
//m_BaseData.type.enumValueIndex = (int)LightType.Rectangle;
settings.lightType.enumValueIndex = (int)LightType.Point;
m_AdditionalLightData.lightTypeExtent.enumValueIndex = (int)LightTypeExtent.Line;
EditorGUI.BeginChangeCheck();

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


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

3
com.unity.render-pipelines.high-definition/HDRP/Editor/RenderPipeline/Settings/FrameSettingsUI.cs


EditorGUILayout.PropertyField(p.enableOpaqueObjects, _.GetContent("Enable Opaque Objects"));
EditorGUILayout.PropertyField(p.enableTransparentObjects, _.GetContent("Enable Transparent Objects"));
EditorGUILayout.PropertyField(p.enableMSAA, _.GetContent("Enable MSAA"));
// Hide for now as not supported
//EditorGUILayout.PropertyField(p.enableMSAA, _.GetContent("Enable MSAA"));
}
static void Drawer_FieldStereoEnabled(FrameSettingsUI s, SerializedFrameSettings p, Editor owner)

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


break;
// Note: We don't support this type in HDRP, but ini just in case
case LightType.Area:
case LightType.Rectangle:
ld.orientation = l.transform.rotation;
ld.position = l.transform.position;
ld.range = l.range;

4
com.unity.render-pipelines.high-definition/HDRP/Lighting/Light/HDAdditionalLightData.cs


lightData.lightUnit = LightUnit.Lux;
lightData.intensity = k_DefaultDirectionalLightIntensity;
break;
case LightType.Area: // Rectangle by default when light is created
case LightType.Rectangle: // Rectangle by default when light is created
lightData.lightUnit = LightUnit.Lumen;
lightData.intensity = k_DefaultAreaLightIntensity;
break;

}
// Sanity check: lightData.lightTypeExtent is init to LightTypeExtent.Punctual (in case for unknow reasons we recreate additional data on an existing line)
if (light.type == LightType.Area && lightData.lightTypeExtent == LightTypeExtent.Punctual)
if (light.type == LightType.Rectangle && lightData.lightTypeExtent == LightTypeExtent.Punctual)
{
lightData.lightTypeExtent = LightTypeExtent.Rectangle;
light.type = LightType.Point; // Same as in HDLightEditor

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;
}

4
com.unity.render-pipelines.lightweight/LWRP/Editor/LightweightLightEditor.cs


public bool spotOptionsValue { get { return typeIsSame && lightProperty.type == LightType.Spot; } }
public bool pointOptionsValue { get { return typeIsSame && lightProperty.type == LightType.Point; } }
public bool dirOptionsValue { get { return typeIsSame && lightProperty.type == LightType.Directional; } }
public bool areaOptionsValue { get { return typeIsSame && lightProperty.type == LightType.Area; } }
public bool areaOptionsValue { get { return typeIsSame && lightProperty.type == LightType.Rectangle; } }
public bool runtimeOptionsValue { get { return typeIsSame && (lightProperty.type != LightType.Area && lightProperty.type != LightType.Point && !settings.isCompletelyBaked); } }
public bool runtimeOptionsValue { get { return typeIsSame && (lightProperty.type != LightType.Rectangle && lightProperty.type != LightType.Point && !settings.isCompletelyBaked); } }
public bool bakedShadowRadius { get { return typeIsSame && (lightProperty.type == LightType.Point || lightProperty.type == LightType.Spot) && settings.isBakedOrMixed; } }
public bool bakedShadowAngle { get { return typeIsSame && lightProperty.type == LightType.Directional && settings.isBakedOrMixed; } }
public bool shadowOptionsValue { get { return shadowTypeIsSame && lightProperty.shadows != LightShadows.None; } }

142
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/Volumetric/DensityVolumeTextureTool.cs


using System;
using UnityEngine;
using UnityEditor;
using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering.HDPipeline;
namespace UnityEditor.Experimental.Rendering
{
public class DensityVolumeTextureTool : EditorWindow
{
private Texture2D sourceTexture = null;
private string assetPath;
private string assetDirectory;
private int tileSize = 0;
private static GUIContent windowTitle = new GUIContent("Create Density 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/Rendering/Density Volume Texture Tool")]
static void Init()
{
DensityVolumeTextureTool window = (DensityVolumeTextureTool)EditorWindow.GetWindow(typeof(DensityVolumeTextureTool));
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/DensityVolumeTextureTool.cs.meta

正在加载...
取消
保存