Raymond Graham
7 年前
当前提交
667f9ee7
共有 12 个文件被更改,包括 265 次插入 和 21 次删除
-
6ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/DensityVolumeManager.cs
-
48ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/HomogeneousDensityVolume.cs
-
4ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/VolumeVoxelization.compute
-
5ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/VolumetricLighting.cs
-
10ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/VolumetricLighting.cs.hlsl
-
8ScriptableRenderPipeline/HDRenderPipeline/HDRP/Sky/AtmosphericScattering/VolumetricFog.cs
-
8ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volumetric.meta
-
67ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volumetric/HomogeneousDensityVolumeEditor.cs
-
11ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volumetric/HomogeneousDensityVolumeEditor.cs.meta
-
108ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volumetric/Texture3DCreationEditor.cs
-
11ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Volumetric/Texture3DCreationEditor.cs.meta
|
|||
fileFormatVersion: 2 |
|||
guid: fd873482d8bcf8049b02cd828184e831 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering; |
|||
using UnityEngine.Experimental.Rendering.HDPipeline; |
|||
|
|||
namespace UnityEditor.Experimental.Rendering.HDPipeline |
|||
{ |
|||
[CanEditMultipleObjects] |
|||
[CustomEditor(typeof(HomogeneousDensityVolume))] |
|||
class HomogeneousDensityVolumeEditor : Editor |
|||
{ |
|||
private static GUIContent albedoLabel = new GUIContent("Scattering Color"); |
|||
private static GUIContent meanFreePathLabel = new GUIContent("Mean Free Path"); |
|||
private static GUIContent asymmetryLabel = new GUIContent("Asymmetry"); |
|||
private static GUIContent volumeTextureLabel = new GUIContent("Volume Texture Mask"); |
|||
private static GUIContent textureScrollLabel = new GUIContent("Texture Scroll Speed"); |
|||
private static GUIContent textureTileLabel = new GUIContent("Texture Tiling Amount"); |
|||
private static GUIContent textureSettingsTitle = new GUIContent("Volume Texture Settings"); |
|||
|
|||
private bool showTextureParams = false; |
|||
|
|||
SerializedProperty densityParams; |
|||
SerializedProperty albedo; |
|||
SerializedProperty meanFreePath; |
|||
SerializedProperty asymmetry; |
|||
|
|||
SerializedProperty volumeTexture; |
|||
SerializedProperty textureScroll; |
|||
SerializedProperty textureTile; |
|||
|
|||
void OnEnable() |
|||
{ |
|||
densityParams = serializedObject.FindProperty("parameters"); |
|||
albedo = densityParams.FindPropertyRelative("albedo"); |
|||
meanFreePath = densityParams.FindPropertyRelative("meanFreePath"); |
|||
asymmetry = densityParams.FindPropertyRelative("asymmetry"); |
|||
|
|||
volumeTexture = densityParams.FindPropertyRelative("volumeMask"); |
|||
textureScroll = densityParams.FindPropertyRelative("textureScrollingSpeed"); |
|||
textureTile = densityParams.FindPropertyRelative("textureTiling"); |
|||
|
|||
if (volumeTexture != null && volumeTexture.objectReferenceValue != null) |
|||
{ |
|||
showTextureParams = true; |
|||
} |
|||
} |
|||
|
|||
public override void OnInspectorGUI() |
|||
{ |
|||
albedo.colorValue = EditorGUILayout.ColorField(albedoLabel, albedo.colorValue, true, false, false); |
|||
EditorGUILayout.PropertyField(meanFreePath, meanFreePathLabel); |
|||
EditorGUILayout.PropertyField(asymmetry, asymmetryLabel); |
|||
EditorGUILayout.Space(); |
|||
|
|||
showTextureParams = EditorGUILayout.Foldout(showTextureParams, textureSettingsTitle, true); |
|||
if (showTextureParams) |
|||
{ |
|||
EditorGUI.indentLevel++; |
|||
EditorGUILayout.PropertyField(volumeTexture, volumeTextureLabel); |
|||
EditorGUILayout.PropertyField(textureScroll, textureScrollLabel); |
|||
EditorGUILayout.PropertyField(textureTile, textureTileLabel); |
|||
EditorGUI.indentLevel--; |
|||
} |
|||
|
|||
serializedObject.ApplyModifiedProperties (); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 7ffb0e1717cab7a40ad62507bc855683 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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 = 0; i < numXTiles; ++i) |
|||
{ |
|||
for(int j = 0; j < numYTiles; ++j) |
|||
{ |
|||
Color[] texColor = sourceTexture.GetPixels(i*tileSize, j*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"); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 9723a65f374db464a8a4f39c94ca7f54 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue