This commit is contained in:
2025-11-14 18:44:06 +08:00
parent 10156da245
commit 22e867d077
7013 changed files with 2572882 additions and 1804 deletions

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: c8ddeeb6d84a54443825ff356f7951cc
folderAsset: yes
timeCreated: 1517223126
licenseType: Store
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,440 @@
// Amplify Impostors
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEditor;
using UnityEditor.PackageManager.Requests;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text.RegularExpressions;
namespace AmplifyImpostors
{
public enum AIImportFlags
{
None = 0,
URP = 1 << 0,
HDRP = 1 << 1,
Both = URP | HDRP
}
public enum AISRPBaseline
{
AI_SRP_INVALID = 0,
AI_SRP_10_X = 100000,
AI_SRP_11_X = 110000,
AI_SRP_12_X = 120000,
AI_SRP_13_X = 130000,
AI_SRP_14_X = 140000,
AI_SRP_15_X = 150000,
AI_SRP_16_X = 160000,
AI_SRP_17_0 = 170000,
AI_SRP_17_1 = 170100,
AI_SRP_17_2 = 170200
}
public class AISRPPackageDesc
{
public AISRPBaseline baseline = AISRPBaseline.AI_SRP_INVALID;
public string guidURP = string.Empty;
public string guidHDRP = string.Empty;
public AISRPPackageDesc( AISRPBaseline baseline, string guidURP, string guidHDRP )
{
this.baseline = baseline;
this.guidURP = guidURP;
this.guidHDRP = guidHDRP;
}
}
[Serializable]
[InitializeOnLoad]
public static class AIPackageManagerHelper
{
private static string URPPackageId = "com.unity.render-pipelines.universal";
private static string HDRPPackageId = "com.unity.render-pipelines.high-definition";
private static string NewVersionDetectedFormat = "A new {0} version {1} was detected and compatible shaders are being imported.\nPlease hit the Update button on your ASE canvas to recompile your shader under the newest version.";
private static string PackageBaseFormat = "AI_PkgBase_{0}_{1}";
private static string PackageCRCFormat = "AI_PkgCRC_{0}_{1}";
private static string URPBakeTemplateGUID = "6ee191abcace33c46a5dd52068b074e0";
private static string URPOctahedronGUID = "83dd8de9a5c14874884f9012def4fdcc";
private static string URPSphericalGUID = "da79d698f4bf0164e910ad798d07efdf";
private static string HDRPBakeTemplateGUID = "5b7fbe5f8e132bd40b11a10c99044f79";
private static string HDRPOctahedronGUID = "56236dc63ad9b7949b63a27f0ad180b3";
private static string HDRPSphericalGUID = "175c951fec709c44fa2f26b8ab78b8dd";
private const string ImpostorsGCincGUID = "806d6cc0f22ee994f8cd901b6718f08d";
private static Dictionary<int, AISRPPackageDesc> m_srpPackageSupport = new Dictionary<int, AISRPPackageDesc>()
{
{ ( int )AISRPBaseline.AI_SRP_10_X, new AISRPPackageDesc( AISRPBaseline.AI_SRP_10_X, "06e710174fd46404391092ae9bc5e849", "d7ac8a02737091445aa206cd5bbc7101" ) },
{ ( int )AISRPBaseline.AI_SRP_11_X, new AISRPPackageDesc( AISRPBaseline.AI_SRP_11_X, "06e710174fd46404391092ae9bc5e849", "d7ac8a02737091445aa206cd5bbc7101" ) },
{ ( int )AISRPBaseline.AI_SRP_12_X, new AISRPPackageDesc( AISRPBaseline.AI_SRP_12_X, "a51904d3fea17d942a8935be648c3f0d", "741ca0d5f350e034e84999facc1de789" ) },
{ ( int )AISRPBaseline.AI_SRP_13_X, new AISRPPackageDesc( AISRPBaseline.AI_SRP_13_X, "a51904d3fea17d942a8935be648c3f0d", "741ca0d5f350e034e84999facc1de789" ) },
{ ( int )AISRPBaseline.AI_SRP_14_X, new AISRPPackageDesc( AISRPBaseline.AI_SRP_14_X, "ade3eaef5ceb09e42ade0a2d51d48465", "417c33caa5dee86498451657f089dfba" ) },
{ ( int )AISRPBaseline.AI_SRP_15_X, new AISRPPackageDesc( AISRPBaseline.AI_SRP_15_X, "3ba162bb5fa749244af39891d40a737e", "50089e2e3ccdc9a4185eea86c35460c4" ) },
{ ( int )AISRPBaseline.AI_SRP_16_X, new AISRPPackageDesc( AISRPBaseline.AI_SRP_16_X, "5d2a70fd39a1c484486c3719d8fca5d9", "0488f1df97596c544b1640896e525f9c" ) },
{ ( int )AISRPBaseline.AI_SRP_17_0, new AISRPPackageDesc( AISRPBaseline.AI_SRP_17_0, "8931284b085cd8f46a6e9f2662ff4db9", "081ebeca8cd4ada43b058a4e6c212ff0" ) },
{ ( int )AISRPBaseline.AI_SRP_17_1, new AISRPPackageDesc( AISRPBaseline.AI_SRP_17_1, "f760d13996060f84fbeb2beb11565431", "80fd9acc1fb7dbc4498a2405d1ccfd03" ) },
{ ( int )AISRPBaseline.AI_SRP_17_2, new AISRPPackageDesc( AISRPBaseline.AI_SRP_17_2, "92f8554d40b366447a0fe0a25a7a20ca", "8a63de5da688cba4b9fcf5ee113e69d5" ) },
};
public static bool Supports( AISRPBaseline baseline ) { return m_srpPackageSupport.ContainsKey( ( int )baseline ); }
private static ListRequest m_packageListRequest = null;
private static UnityEditor.PackageManager.PackageInfo m_urpPackageInfo;
private static UnityEditor.PackageManager.PackageInfo m_hdrpPackageInfo;
private static bool m_lateImport = false;
private static string m_latePackageToImport;
private static bool m_requireUpdateList = false;
private static AIImportFlags m_importingPackage = AIImportFlags.None;
private static AISRPBaseline m_currentURPBaseline = AISRPBaseline.AI_SRP_INVALID;
private static AISRPBaseline m_currentHDRPBaseline = AISRPBaseline.AI_SRP_INVALID;
public static AISRPBaseline CurrentURPBaseline { get { return m_currentURPBaseline; } }
public static AISRPBaseline CurrentHDRPBaseline { get { return m_currentHDRPBaseline; } }
private static int m_packageURPVersion = 0; // @diogo: starts as missing
private static int m_packageHDRPVersion = 0;
public static int PackageURPBaseline { get { return m_packageURPVersion; } }
public static int PackageHDRPBaseline { get { return m_packageHDRPVersion; } }
private static string m_projectName = null;
private static string ProjectName
{
get
{
if ( string.IsNullOrEmpty( m_projectName ) )
{
string[] s = Application.dataPath.Split( '/' );
m_projectName = s[ s.Length - 2 ];
}
return m_projectName;
}
}
static AIPackageManagerHelper()
{
RequestInfo();
}
static void WaitForPackageListBeforeUpdating()
{
if ( m_packageListRequest.IsCompleted )
{
Update();
EditorApplication.update -= WaitForPackageListBeforeUpdating;
}
}
public static void RequestInfo()
{
if ( !m_requireUpdateList && m_importingPackage == AIImportFlags.None )
{
m_requireUpdateList = true;
m_packageListRequest = UnityEditor.PackageManager.Client.List( true );
EditorApplication.update += WaitForPackageListBeforeUpdating;
}
}
static void FailedPackageImport( string packageName, string errorMessage )
{
FinishImporter();
}
static void CancelledPackageImport( string packageName )
{
FinishImporter();
}
static void CompletedPackageImport( string packageName )
{
FinishImporter();
}
public static void CheckLatePackageImport()
{
if ( !Application.isPlaying && m_lateImport && !string.IsNullOrEmpty( m_latePackageToImport ) )
{
m_lateImport = false;
StartImporting( m_latePackageToImport );
m_latePackageToImport = string.Empty;
}
}
public static bool StartImporting( string packagePath )
{
if ( !Preferences.GlobalAutoSRP )
{
m_importingPackage = AIImportFlags.None;
return false;
}
if ( Application.isPlaying )
{
if ( !m_lateImport )
{
m_lateImport = true;
m_latePackageToImport = packagePath;
Debug.LogWarning( "Amplify Impostors requires the \"" + packagePath + "\" package to be installed in order to continue. Please exit Play mode to proceed." );
}
return false;
}
AssetDatabase.importPackageCancelled += CancelledPackageImport;
AssetDatabase.importPackageCompleted += CompletedPackageImport;
AssetDatabase.importPackageFailed += FailedPackageImport;
AssetDatabase.ImportPackage( packagePath, false );
return true;
}
public static void FinishImporter()
{
m_importingPackage = AIImportFlags.None;
AssetDatabase.importPackageCancelled -= CancelledPackageImport;
AssetDatabase.importPackageCompleted -= CompletedPackageImport;
AssetDatabase.importPackageFailed -= FailedPackageImport;
}
private static readonly string SemVerPattern = @"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$";
public static int PackageVersionStringToCode( string version, out int major, out int minor, out int patch )
{
MatchCollection matches = Regex.Matches( version, SemVerPattern, RegexOptions.Multiline );
bool validMatch = ( matches.Count > 0 && matches[ 0 ].Groups.Count >= 4 );
major = validMatch ? int.Parse( matches[ 0 ].Groups[ 1 ].Value ) : 99;
minor = validMatch ? int.Parse( matches[ 0 ].Groups[ 2 ].Value ) : 99;
patch = validMatch ? int.Parse( matches[ 0 ].Groups[ 3 ].Value ) : 99;
int versionCode;
versionCode = major * 10000;
versionCode += minor * 100;
versionCode += patch;
return versionCode;
}
private static int PackageVersionElementsToCode( int major, int minor, int patch )
{
return major * 10000 + minor * 100 + patch;
}
private static void CheckPackageImport( AIImportFlags flag, AISRPBaseline baseline, string guid, string version )
{
Debug.Assert( flag == AIImportFlags.HDRP || flag == AIImportFlags.URP );
string path = AssetDatabase.GUIDToAssetPath( guid );
if ( !string.IsNullOrEmpty( path ) && File.Exists( path ) )
{
uint currentCRC = CRC32( File.ReadAllBytes( path ) );
string srpName = flag.ToString();
string packageBaseKey = string.Format( PackageBaseFormat, srpName, ProjectName );
string packageCRCKey = string.Format( PackageCRCFormat, srpName, ProjectName );
AISRPBaseline savedBaseline = ( AISRPBaseline )EditorPrefs.GetInt( packageBaseKey );
uint savedCRC = ( uint )EditorPrefs.GetInt( packageCRCKey, 0 );
bool foundNewVersion = ( savedBaseline != baseline ) || ( savedCRC != currentCRC );
EditorPrefs.SetInt( packageBaseKey, ( int )baseline );
EditorPrefs.SetInt( packageCRCKey, ( int )currentCRC );
string testPath0 = string.Empty;
string testPath1 = string.Empty;
string testPath2 = string.Empty;
switch ( flag )
{
case AIImportFlags.URP:
{
testPath0 = AssetDatabase.GUIDToAssetPath( URPBakeTemplateGUID );
testPath1 = AssetDatabase.GUIDToAssetPath( URPOctahedronGUID );
testPath2 = AssetDatabase.GUIDToAssetPath( URPSphericalGUID );
break;
}
case AIImportFlags.HDRP:
{
testPath0 = AssetDatabase.GUIDToAssetPath( HDRPBakeTemplateGUID );
testPath1 = AssetDatabase.GUIDToAssetPath( HDRPOctahedronGUID );
testPath2 = AssetDatabase.GUIDToAssetPath( HDRPSphericalGUID );
break;
}
}
if ( foundNewVersion || !File.Exists( testPath0 ) || !File.Exists( testPath1 ) || !File.Exists( testPath2 ) )
{
m_importingPackage |= flag;
if ( StartImporting( path ) && foundNewVersion )
{
Debug.Log( "[AmplifyImpostors] " + string.Format( NewVersionDetectedFormat, srpName, version ) );
}
}
}
}
public static void Update()
{
CheckLatePackageImport();
if ( m_requireUpdateList && m_importingPackage == AIImportFlags.None )
{
if ( m_packageListRequest != null && m_packageListRequest.IsCompleted )
{
m_requireUpdateList = false;
foreach ( UnityEditor.PackageManager.PackageInfo pi in m_packageListRequest.Result )
{
int version = PackageVersionStringToCode( pi.version, out int major, out int minor, out int patch );
int baselineMajor = major;
int baselineMinor = ( major >= 17 ) ? minor: 0; // from 17+ baseline includes minor version
int baseline = PackageVersionElementsToCode( baselineMajor, baselineMinor, 0 );
AISRPPackageDesc match;
if ( pi.name.Equals( URPPackageId ) && m_srpPackageSupport.TryGetValue( baseline, out match ) )
{
// Universal Rendering Pipeline
m_currentURPBaseline = match.baseline;
m_packageURPVersion = version;
m_urpPackageInfo = pi;
CheckPackageImport( AIImportFlags.URP, match.baseline, match.guidURP, pi.version );
}
else if ( pi.name.Equals( HDRPPackageId ) && m_srpPackageSupport.TryGetValue( baseline, out match ) )
{
// High-Definition Rendering Pipeline
m_currentHDRPBaseline = match.baseline;
m_packageHDRPVersion = version;
m_hdrpPackageInfo = pi;
CheckPackageImport( AIImportFlags.HDRP, match.baseline, match.guidHDRP, pi.version );
}
}
// Make sure AmplifyImpostors.cginc is updated
ApplySRP();
}
}
}
private static void ApplySRP()
{
string impostorCGincPath = AssetDatabase.GUIDToAssetPath( ImpostorsGCincGUID );
if ( string.IsNullOrEmpty( impostorCGincPath ) )
return;
string cginc = string.Empty;
if ( !string.IsNullOrEmpty( impostorCGincPath ) && File.Exists( impostorCGincPath ) )
{
cginc = File.ReadAllText( impostorCGincPath );
}
bool saveAndRefresh = false;
Match cgincMatch = Regex.Match( cginc, @"#define AI_HDRP_VERSION (\d*)", RegexOptions.Multiline );
if ( cgincMatch.Success )
{
string cgincSRPversion = cgincMatch.Groups[ 1 ].Value;
if ( cgincSRPversion != ( ( int )m_packageHDRPVersion ).ToString() )
{
cginc = cginc.Replace( cgincMatch.Groups[ 0 ].Value, "#define AI_HDRP_VERSION " + ( ( int )m_packageHDRPVersion ).ToString() );
saveAndRefresh = true;
}
}
cgincMatch = Regex.Match( cginc, @"#define AI_URP_VERSION (\d*)", RegexOptions.Multiline );
if ( cgincMatch.Success )
{
string cgincSRPversion = cgincMatch.Groups[ 1 ].Value;
if ( cgincSRPversion != ( ( int )m_packageURPVersion ).ToString() )
{
cginc = cginc.Replace( cgincMatch.Groups[ 0 ].Value, "#define AI_URP_VERSION " + ( ( int )m_packageURPVersion ).ToString() );
saveAndRefresh = true;
}
}
if ( saveAndRefresh )
{
File.WriteAllText( impostorCGincPath, cginc );
}
}
// Polynomial: 0xedb88320
static readonly uint[] crc32_tab = {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
};
private static uint CRC32( byte[] buf, uint crc = 0 )
{
uint i = 0;
uint size = ( uint )buf.Length;
crc = crc ^ 0xFFFFFFFF;
while ( size-- > 0 )
{
crc = crc32_tab[ ( crc ^ buf[ i++ ] ) & 0xFF ] ^ ( crc >> 8 );
}
return crc ^ 0xFFFFFFFF;
}
}
public sealed class TemplatePostProcessor : AssetPostprocessor
{
static void OnPostprocessAllAssets( string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths )
{
AIPackageManagerHelper.RequestInfo();
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 58d52c2ec7a4198409aea2abf9311161
timeCreated: 1548881060
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,579 @@
// Amplify Impostors
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using UnityEditor;
using System;
using UnityEngine.Networking;
using System.Collections;
using System.Collections.Generic;
namespace AmplifyImpostors
{
public enum TemplateSRPType
{
BiRP,
HDRP,
URP
}
public class AIStartScreen : EditorWindow
{
[MenuItem( "Window/Amplify Impostors/Start Screen", false, 1999 )]
public static void Init()
{
AIStartScreen window = ( AIStartScreen )GetWindow( typeof( AIStartScreen ), true, "Amplify Impostors Start Screen" );
window.minSize = new Vector2( 650, 500 );
window.maxSize = new Vector2( 650, 500 );
window.Show();
}
private static readonly string ChangeLogGUID = "967f64c31d8dde244a5e92f47deea593";
private static readonly string ResourcesGUID = "ae29426773add424290db1134bffc616";
private static readonly string BuiltInGUID = "ec7e2bd19b32d4c42948cb7cce07b40c";
private static readonly string UniversalGUID = "157f886533623a54683ec845ecb4de98";
private static readonly string HighDefinitionGUID = "25818ccda53725a4086c9b356f2f6139";
private static readonly string IconGUID = "1070aab9cfe961c409d48e3bec7f7ab0";
public static readonly string ChangelogURL = "https://amplify.pt/Banner/AIchangelog.json";
private static readonly string ManualURL = "https://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Impostors/Manual";
private static readonly string DiscordURL = "https://discordapp.com/invite/EdrVAP5";
private static readonly string ForumURL = "https://forum.unity.com/threads/amplify-impostors-next-generation-billboards.539844/";
private static readonly string SiteURL = "http://amplify.pt/download/";
private static readonly string StoreURL = "https://assetstore.unity.com/packages/tools/utilities/amplify-impostors-119877";
private static readonly GUIContent SamplesTitle = new GUIContent( "Samples", "Import samples according to you project rendering pipeline" );
private static readonly GUIContent ResourcesTitle = new GUIContent( "Learning Resources", "Check the online wiki for various topics about how to use AI with node examples and explanations" );
private static readonly GUIContent CommunityTitle = new GUIContent( "Community", "Need help? Reach us through our discord server or the official support Unity forum" );
private static readonly GUIContent UpdateTitle = new GUIContent( "Latest Update", "Check the lastest additions, improvements and bug fixes done to AI" );
private static readonly GUIContent AITitle = new GUIContent( "Amplify Impostors", "Are you using the latest version? Now you know" );
private const string OnlineVersionWarning = "Please enable \"Allow downloads over HTTP*\" in Player Settings to access latest version information via Start Screen.";
Vector2 m_scrollPosition = Vector2.zero;
Preferences.ShowOption m_startup = Preferences.ShowOption.Never;
[NonSerialized]
Texture packageIcon = null;
[NonSerialized]
Texture textIcon = null;
[NonSerialized]
Texture webIcon = null;
GUIContent HDRPbutton = null;
GUIContent URPbutton = null;
GUIContent BuiltInbutton = null;
GUIContent Manualbutton = null;
GUIContent DiscordButton = null;
GUIContent ForumButton = null;
GUIContent AIIcon = null;
RenderTexture rt;
[NonSerialized]
GUIStyle m_buttonStyle = null;
[NonSerialized]
GUIStyle m_buttonLeftStyle = null;
[NonSerialized]
GUIStyle m_buttonRightStyle = null;
[NonSerialized]
GUIStyle m_minibuttonStyle = null;
[NonSerialized]
GUIStyle m_labelStyle = null;
[NonSerialized]
GUIStyle m_linkStyle = null;
private ChangeLogInfo m_changeLog;
private bool m_infoDownloaded = false;
private string m_newVersion = string.Empty;
private static Dictionary<int, AISRPPackageDesc> m_srpSamplePackages = new Dictionary<int, AISRPPackageDesc>()
{
{ ( int )AISRPBaseline.AI_SRP_12_X, new AISRPPackageDesc( AISRPBaseline.AI_SRP_12_X, "b96ac023f1ef6c144891ecea1fa57ae8", "9d8cb26fa0bbd5743910e10e476c1b34" ) },
{ ( int )AISRPBaseline.AI_SRP_13_X, new AISRPPackageDesc( AISRPBaseline.AI_SRP_13_X, "b96ac023f1ef6c144891ecea1fa57ae8", "9d8cb26fa0bbd5743910e10e476c1b34" ) },
{ ( int )AISRPBaseline.AI_SRP_14_X, new AISRPPackageDesc( AISRPBaseline.AI_SRP_14_X, "c297d913695beab48aafeed7e786c21e", "4592c91874062c644b0606bd98342356" ) },
{ ( int )AISRPBaseline.AI_SRP_15_X, new AISRPPackageDesc( AISRPBaseline.AI_SRP_15_X, "49ea3764a534e4347848722ad53b9bf1", "0fd95d7c6a1a1864eb85fef533f5e5df" ) },
{ ( int )AISRPBaseline.AI_SRP_16_X, new AISRPPackageDesc( AISRPBaseline.AI_SRP_16_X, "349761993cf8d6a41970c379725073d4", "f61a93a0b64d3dd499926d4ad5816cb1" ) },
{ ( int )AISRPBaseline.AI_SRP_17_0, new AISRPPackageDesc( AISRPBaseline.AI_SRP_17_0, "63629f491cb46bb4cbb75e8761fc34a4", "9fe9254fd01d40f41b61d641720448e9" ) },
{ ( int )AISRPBaseline.AI_SRP_17_1, new AISRPPackageDesc( AISRPBaseline.AI_SRP_17_1, "fd4d8f8d9ad14334587b00cb40e4b3e9", "8b71dc5534f40fa408a50c379920bf60" ) },
{ ( int )AISRPBaseline.AI_SRP_17_2, new AISRPPackageDesc( AISRPBaseline.AI_SRP_17_2, "3015af40fd0745b43a5a3d20ec4c24a6", "c8fb2aae1cd370242acd84a1977fd5dc" ) },
};
private void OnEnable()
{
rt = new RenderTexture( 16, 16, 0 );
rt.Create();
m_startup = ( Preferences.ShowOption )EditorPrefs.GetInt( Preferences.PrefGlobalStartUp, 0 );
if ( textIcon == null )
{
Texture icon = EditorGUIUtility.IconContent( "TextAsset Icon" ).image;
var cache = RenderTexture.active;
RenderTexture.active = rt;
Graphics.Blit( icon, rt );
RenderTexture.active = cache;
textIcon = rt;
Manualbutton = new GUIContent( " Manual", textIcon );
}
if ( packageIcon == null )
{
packageIcon = EditorGUIUtility.IconContent( "BuildSettings.Editor.Small" ).image;
HDRPbutton = new GUIContent( " HDRP Samples", packageIcon );
URPbutton = new GUIContent( " URP Samples", packageIcon );
BuiltInbutton = new GUIContent( " Built-In Samples", packageIcon );
}
if ( webIcon == null )
{
webIcon = EditorGUIUtility.IconContent( "BuildSettings.Web.Small" ).image;
DiscordButton = new GUIContent( " Discord", webIcon );
ForumButton = new GUIContent( " Unity Forum", webIcon );
}
if ( m_changeLog == null )
{
var changelog = AssetDatabase.LoadAssetAtPath<TextAsset>( AssetDatabase.GUIDToAssetPath( ChangeLogGUID ) );
string lastUpdate = string.Empty;
if ( changelog != null )
{
int oldestReleaseIndex = changelog.text.LastIndexOf( string.Format( "v{0}.{1}.{2}", VersionInfo.Major, VersionInfo.Minor, VersionInfo.Release ) );
lastUpdate = changelog.text.Substring( 0, changelog.text.IndexOf( "\nv", oldestReleaseIndex + 25 ) );// + "\n...";
lastUpdate = lastUpdate.Replace( "* ", "\u2022 " );
}
m_changeLog = new ChangeLogInfo( VersionInfo.FullNumber, lastUpdate );
}
if ( AIIcon == null )
{
AIIcon = new GUIContent( AssetDatabase.LoadAssetAtPath<Texture2D>( AssetDatabase.GUIDToAssetPath( IconGUID ) ) );
}
}
private void OnDisable()
{
if ( rt != null )
{
rt.Release();
DestroyImmediate( rt );
}
}
public void OnGUI()
{
if ( !m_infoDownloaded )
{
m_infoDownloaded = true;
StartBackgroundTask( StartRequest( ChangelogURL, () =>
{
if ( string.IsNullOrEmpty( www.error ) )
{
ChangeLogInfo temp;
try
{
temp = ChangeLogInfo.CreateFromJSON( www.downloadHandler.text );
}
catch ( Exception )
{
temp = null;
}
if ( temp != null && temp.Version >= m_changeLog.Version )
{
m_changeLog = temp;
}
int version = m_changeLog.Version;
int major = version / 10000;
int minor = version / 1000 - major * 10;
int release = version / 100 - ( version / 1000 ) * 10;
int revision = version - ( version / 100 ) * 100;
m_newVersion = major + "." + minor + "." + release + ( revision > 0 ? "." + revision : "" );
Repaint();
}
} ) );
}
if ( m_buttonStyle == null )
{
m_buttonStyle = new GUIStyle( GUI.skin.button );
m_buttonStyle.alignment = TextAnchor.MiddleLeft;
}
if ( m_buttonLeftStyle == null )
{
m_buttonLeftStyle = new GUIStyle( "ButtonLeft" );
m_buttonLeftStyle.alignment = TextAnchor.MiddleLeft;
m_buttonLeftStyle.margin = m_buttonStyle.margin;
m_buttonLeftStyle.margin.right = 0;
}
if ( m_buttonRightStyle == null )
{
m_buttonRightStyle = new GUIStyle( "ButtonRight" );
m_buttonRightStyle.alignment = TextAnchor.MiddleLeft;
m_buttonRightStyle.margin = m_buttonStyle.margin;
m_buttonRightStyle.margin.left = 0;
}
if ( m_minibuttonStyle == null )
{
m_minibuttonStyle = new GUIStyle( "MiniButton" );
m_minibuttonStyle.alignment = TextAnchor.MiddleLeft;
m_minibuttonStyle.margin = m_buttonStyle.margin;
m_minibuttonStyle.margin.left = 20;
m_minibuttonStyle.normal.textColor = m_buttonStyle.normal.textColor;
m_minibuttonStyle.hover.textColor = m_buttonStyle.hover.textColor;
}
if ( m_labelStyle == null )
{
m_labelStyle = new GUIStyle( "BoldLabel" );
m_labelStyle.margin = new RectOffset( 4, 4, 4, 4 );
m_labelStyle.padding = new RectOffset( 2, 2, 2, 2 );
m_labelStyle.fontSize = 13;
}
if ( m_linkStyle == null )
{
var inv = AssetDatabase.LoadAssetAtPath<Texture2D>( AssetDatabase.GUIDToAssetPath( "a91a70303ba684645a7a87a0ddec0eb7" ) ); // find a better solution for transparent buttons
m_linkStyle = new GUIStyle();
m_linkStyle.normal.textColor = new Color( 0.2980392f, 0.4901961f, 1f );
m_linkStyle.hover.textColor = Color.white;
m_linkStyle.active.textColor = Color.grey;
m_linkStyle.margin.top = 3;
m_linkStyle.margin.bottom = 2;
m_linkStyle.hover.background = inv;
m_linkStyle.active.background = inv;
}
EditorGUILayout.BeginHorizontal( GUIStyle.none, GUILayout.ExpandWidth( true ) );
{
// left column
EditorGUILayout.BeginVertical( GUILayout.Width( 175 ) );
{
GUILayout.Label( SamplesTitle, m_labelStyle );
EditorGUILayout.BeginHorizontal();
if ( GUILayout.Button( HDRPbutton, m_buttonLeftStyle ) )
{
if ( AIPackageManagerHelper.CurrentHDRPBaseline != AISRPBaseline.AI_SRP_INVALID )
{
ImportSample( HDRPbutton.text, TemplateSRPType.HDRP );
}
else
{
EditorUtility.DisplayDialog( "Import Sample", "Import failed because a valid HDRP package could not be found on this project.\n\nPlease install the \"High Definition RP\" package via \"Window/Package Manager\" before attempting to import HDRP samples again.", "OK" );
}
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
if ( GUILayout.Button( URPbutton, m_buttonLeftStyle ) )
{
if ( AIPackageManagerHelper.CurrentURPBaseline != AISRPBaseline.AI_SRP_INVALID )
{
ImportSample( URPbutton.text, TemplateSRPType.URP );
}
else
{
EditorUtility.DisplayDialog( "Import Sample", "Import failed because valid URP package could not be found on this project.\n\nPlease install the \"Universal RP\" package via \"Window/Package Manager\" before attempting to import URP samples again.", "OK" );
}
}
EditorGUILayout.EndHorizontal();
if ( GUILayout.Button( BuiltInbutton, m_buttonStyle ) )
ImportSample( BuiltInbutton.text, TemplateSRPType.BiRP );
GUILayout.Space( 10 );
GUILayout.Label( ResourcesTitle, m_labelStyle );
if ( GUILayout.Button( Manualbutton, m_buttonStyle ) )
Application.OpenURL( ManualURL );
}
EditorGUILayout.EndVertical();
// right column
EditorGUILayout.BeginVertical( GUILayout.Width( 650 - 175 - 9 ), GUILayout.ExpandHeight( true ) );
{
GUILayout.Label( CommunityTitle, m_labelStyle );
EditorGUILayout.BeginHorizontal( GUILayout.ExpandWidth( true ) );
{
if ( GUILayout.Button( DiscordButton, GUILayout.ExpandWidth( true ) ) )
{
Application.OpenURL( DiscordURL );
}
if ( GUILayout.Button( ForumButton, GUILayout.ExpandWidth( true ) ) )
{
Application.OpenURL( ForumURL );
}
}
EditorGUILayout.EndHorizontal();
GUILayout.Label( UpdateTitle, m_labelStyle );
m_scrollPosition = GUILayout.BeginScrollView( m_scrollPosition, "ProgressBarBack", GUILayout.ExpandHeight( true ), GUILayout.ExpandWidth( true ) );
GUILayout.Label( m_changeLog.LastUpdate, "WordWrappedMiniLabel", GUILayout.ExpandHeight( true ) );
GUILayout.EndScrollView();
EditorGUILayout.BeginHorizontal( GUILayout.ExpandWidth( true ) );
{
EditorGUILayout.BeginVertical();
GUILayout.Label( AITitle, m_labelStyle );
GUILayout.Label( "Installed Version: " + VersionInfo.StaticToString() );
if ( m_changeLog.Version > VersionInfo.FullNumber )
{
var cache = GUI.color;
GUI.color = Color.red;
GUILayout.Label( "New version available: " + m_newVersion, "BoldLabel" );
GUI.color = cache;
}
else
{
var cache = GUI.color;
GUI.color = Color.green;
GUILayout.Label( "You are using the latest version", "BoldLabel" );
GUI.color = cache;
}
EditorGUILayout.BeginHorizontal();
GUILayout.Label( "Download links:" );
if ( GUILayout.Button( "Amplify", m_linkStyle ) )
Application.OpenURL( SiteURL );
GUILayout.Label( "-" );
if ( GUILayout.Button( "Asset Store", m_linkStyle ) )
Application.OpenURL( StoreURL );
EditorGUILayout.EndHorizontal();
GUILayout.Space( 7 );
EditorGUILayout.EndVertical();
GUILayout.FlexibleSpace();
EditorGUILayout.BeginVertical();
GUILayout.Space( 7 );
GUILayout.Label( AIIcon );
EditorGUILayout.EndVertical();
}
EditorGUILayout.EndHorizontal();
}
EditorGUILayout.EndVertical();
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal( "ProjectBrowserBottomBarBg", GUILayout.ExpandWidth( true ), GUILayout.Height( 22 ) );
{
GUILayout.FlexibleSpace();
EditorGUI.BeginChangeCheck();
var cache = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = 100;
m_startup = ( Preferences.ShowOption )EditorGUILayout.EnumPopup( "Show At Startup", m_startup, GUILayout.Width( 220 ) );
EditorGUIUtility.labelWidth = cache;
if ( EditorGUI.EndChangeCheck() )
{
EditorPrefs.SetInt( Preferences.PrefGlobalStartUp, ( int )m_startup );
}
}
EditorGUILayout.EndHorizontal();
}
void ImportSample( string pipeline, TemplateSRPType srpType )
{
if ( EditorUtility.DisplayDialog( "Import Sample", "This will import the samples for" + pipeline.Replace( " Samples", "" ) + ", please make sure the pipeline is properly installed and/or selected before importing the samples.\n\nContinue?", "Yes", "No" ) )
{
AssetDatabase.ImportPackage( AssetDatabase.GUIDToAssetPath( ResourcesGUID ), false );
switch ( srpType )
{
case TemplateSRPType.BiRP:
{
AssetDatabase.ImportPackage( AssetDatabase.GUIDToAssetPath( BuiltInGUID ), false );
break;
}
case TemplateSRPType.URP:
{
if ( m_srpSamplePackages.TryGetValue( ( int )AIPackageManagerHelper.CurrentURPBaseline, out AISRPPackageDesc desc ) )
{
string path = AssetDatabase.GUIDToAssetPath( desc.guidURP );
if ( !string.IsNullOrEmpty( path ) )
{
AssetDatabase.ImportPackage( AssetDatabase.GUIDToAssetPath( UniversalGUID ), false );
AssetDatabase.ImportPackage( path, false );
}
}
break;
}
case TemplateSRPType.HDRP:
{
if ( m_srpSamplePackages.TryGetValue( ( int )AIPackageManagerHelper.CurrentHDRPBaseline, out AISRPPackageDesc desc ) )
{
string path = AssetDatabase.GUIDToAssetPath( desc.guidHDRP );
if ( !string.IsNullOrEmpty( path ) )
{
AssetDatabase.ImportPackage( AssetDatabase.GUIDToAssetPath( HighDefinitionGUID ), false );
AssetDatabase.ImportPackage( path, false );
}
}
break;
}
default:
{
// no action
break;
}
}
}
}
UnityWebRequest www;
IEnumerator StartRequest( string url, Action success = null )
{
using ( www = UnityWebRequest.Get( url ) )
{
yield return www.SendWebRequest();
while ( www.isDone == false )
yield return null;
if ( success != null )
success();
}
}
public static void StartBackgroundTask( IEnumerator update, Action end = null )
{
EditorApplication.CallbackFunction closureCallback = null;
closureCallback = () =>
{
try
{
if ( update.MoveNext() == false )
{
if ( end != null )
end();
EditorApplication.update -= closureCallback;
}
}
catch ( Exception ex )
{
if ( end != null )
end();
Debug.LogException( ex );
EditorApplication.update -= closureCallback;
}
};
EditorApplication.update += closureCallback;
}
}
[Serializable]
internal class ChangeLogInfo
{
public int Version;
public string LastUpdate;
public static ChangeLogInfo CreateFromJSON( string jsonString )
{
return JsonUtility.FromJson<ChangeLogInfo>( jsonString );
}
public ChangeLogInfo( int version, string lastUpdate )
{
Version = version;
LastUpdate = lastUpdate;
}
}
[InitializeOnLoad]
public static class ShowStartScreen
{
static ShowStartScreen()
{
EditorApplication.update += Update;
}
static UnityWebRequest www;
static IEnumerator StartRequest( string url, Action success = null )
{
using ( www = UnityWebRequest.Get( url ) )
{
yield return www.SendWebRequest();
while ( www.isDone == false )
yield return null;
if ( success != null )
success();
}
}
static void Update()
{
EditorApplication.update -= Update;
if ( !EditorApplication.isPlayingOrWillChangePlaymode && !Application.isBatchMode )
{
Preferences.ShowOption show = Preferences.ShowOption.Never;
if ( !EditorPrefs.HasKey( Preferences.PrefGlobalStartUp ) )
{
show = Preferences.ShowOption.Always;
EditorPrefs.SetInt( Preferences.PrefGlobalStartUp, 0 );
}
else
{
if ( Time.realtimeSinceStartup < 10 )
{
show = ( Preferences.ShowOption )EditorPrefs.GetInt( Preferences.PrefGlobalStartUp, 0 );
// check version here
if ( show == Preferences.ShowOption.OnNewVersion )
{
AIStartScreen.StartBackgroundTask( StartRequest( AIStartScreen.ChangelogURL, () =>
{
if ( string.IsNullOrEmpty( www.error ) )
{
ChangeLogInfo changeLog;
try
{
changeLog = ChangeLogInfo.CreateFromJSON( www.downloadHandler.text );
}
catch ( Exception )
{
changeLog = null;
}
if ( changeLog != null )
{
if ( changeLog.Version > VersionInfo.FullNumber )
{
AIStartScreen.Init();
}
}
}
} ) );
}
}
}
if ( show == Preferences.ShowOption.Always )
{
AIStartScreen.Init();
}
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: bb3b831ec4e30074cac85e49f922a6e4
timeCreated: 1585827066
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: ec28673eb846ce34fa7fa827aa5c2f8a
folderAsset: yes
timeCreated: 1527851330
licenseType: Store
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,67 @@
// Amplify Impostors
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
namespace AmplifyImpostors
{
public class About : EditorWindow
{
private const string AboutImageGUID = "f6d52893e066905409ec8ac1bde8d300";
private Vector2 m_scrollPosition = Vector2.zero;
private Texture2D m_aboutImage;
[MenuItem( "Window/Amplify Impostors/Manual", false, 2000 )]
static void OpenManual()
{
Application.OpenURL( "http://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Impostors/Manual" );
}
[MenuItem( "Window/Amplify Impostors/About...", false, 2001 )]
static void Init()
{
About window = (About)GetWindow( typeof( About ), true, "About Amplify Impostors" );
window.minSize = new Vector2( 502, 250 );
window.maxSize = new Vector2( 502, 250 );
window.Show();
}
private void OnEnable()
{
m_aboutImage = AssetDatabase.LoadAssetAtPath<Texture2D>( AssetDatabase.GUIDToAssetPath( AboutImageGUID ) );
}
public void OnGUI()
{
m_scrollPosition = GUILayout.BeginScrollView( m_scrollPosition );
GUILayout.BeginVertical();
GUILayout.Space( 10 );
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUILayout.Box( m_aboutImage, GUIStyle.none );
if( Event.current.type == EventType.MouseUp && GUILayoutUtility.GetLastRect().Contains( Event.current.mousePosition ) )
Application.OpenURL( "http://www.amplify.pt" );
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUIStyle labelStyle = new GUIStyle( EditorStyles.label );
labelStyle.alignment = TextAnchor.MiddleCenter;
labelStyle.wordWrap = true;
GUILayout.Label( "\nAmplify Impostors " + VersionInfo.StaticToString(), labelStyle, GUILayout.ExpandWidth( true ) );
GUILayout.Label( "\nCopyright (c) Amplify Creations, Lda. All rights reserved.\n", labelStyle, GUILayout.ExpandWidth( true ) );
GUILayout.EndVertical();
GUILayout.EndScrollView();
}
}
}
#endif

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2ef56149981af214daf70b2c156f9442
timeCreated: 1481126958
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
{
"name": "AmplifyImpostors.Editor",
"rootNamespace": "",
"references": [
"GUID:a1a7cacb6cec073439a2b2c1849d773b"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: beb7ced4cc341384592d9187e65da6b5
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 9472d3e5cffc4654a8179ab127664b8f
folderAsset: yes
timeCreated: 1526997181
licenseType: Store
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,226 @@
// Amplify Impostors
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
using UnityEditorInternal;
using System.Collections.Generic;
namespace AmplifyImpostors
{
[CustomEditor( typeof( AmplifyImpostorBakePreset ) )]
public class AmplifyImpostorBakePresetEditor : Editor
{
AmplifyImpostorBakePreset instance;
private ReorderableList m_reorderableOutput = null;
private bool m_usingStandard;
public static readonly GUIContent BakeShaderStr = new GUIContent( "Bake Shader", "Shader used to bake the different outputs" );
public static readonly GUIContent RuntimeShaderStr = new GUIContent( "Runtime Shader", "Custom impostor shader to assign the outputs to" );
public static readonly GUIContent PipelineStr = new GUIContent( "Pipeline", "Defines the default preset for the selected pipeline" );
public static readonly GUIContent TargetsStr = new GUIContent( "RT#", "Render Target number" );
public static readonly GUIContent SuffixStr = new GUIContent( "Suffix", "Name suffix for file saving and for material assignment" );
public static readonly int[] TexScaleOpt = { 1, 2, 4, 8 };
public static readonly GUIContent[] TexScaleListStr = { new GUIContent( "1" ), new GUIContent( "1\u20442" ), new GUIContent( "1\u20444" ), new GUIContent( "1\u20448" ) };
public static readonly GUIContent TexScaleStr = new GUIContent( "Scale", "Texture Scaling" );
public static readonly GUIContent ColorSpaceStr = new GUIContent( "sRGB", "Texture color space" );
public static readonly GUIContent[] ColorSpaceListStr = { new GUIContent( "| sRGB" ), new GUIContent( "Linear" ) };
public static readonly int[] CompressionOpt = { 0, 3, 1, 2 };
public static readonly GUIContent[] CompressionListStr = { new GUIContent( "None" ), new GUIContent( "Low" ), new GUIContent( "Normal" ), new GUIContent( "High" ) };
public static readonly GUIContent CompressionStr = new GUIContent( "Compression", "Compression quality" );
public static readonly GUIContent FormatStr = new GUIContent( "Format", "File save format" );
public static readonly GUIContent ChannelsStr = new GUIContent( "Channels", "Channels being used" );
public GUIContent AlphaIcon;
public static readonly GUIContent OverrideStr = new GUIContent( "Override", "Override" );
public void OnEnable()
{
instance = (AmplifyImpostorBakePreset)target;
Preferences.LoadDefaults();
AlphaIcon = EditorGUIUtility.IconContent( "PreTextureAlpha" );
AlphaIcon.tooltip = "Alpha output selection";
AddList();
}
private void OnDisable()
{
RemoveList();
}
void RemoveList()
{
m_reorderableOutput.drawHeaderCallback -= DrawHeader;
m_reorderableOutput.drawElementCallback -= DrawElement;
m_reorderableOutput.onAddCallback -= AddItem;
}
void AddList()
{
m_usingStandard = false;
if( instance.BakeShader == null )
m_usingStandard = true;
m_reorderableOutput = new ReorderableList( instance.Output, typeof( TextureOutput ), !m_usingStandard, true, !m_usingStandard, !m_usingStandard );
m_reorderableOutput.drawHeaderCallback += DrawHeader;
m_reorderableOutput.drawElementCallback += DrawElement;
m_reorderableOutput.onAddCallback += AddItem;
}
void RefreshList()
{
RemoveList();
AddList();
}
private void DrawHeader( Rect rect )
{
var style = new GUIStyle( GUI.skin.label ) { alignment = TextAnchor.MiddleCenter };
rect.xMax -= 20;
Rect alphaRect = rect;
alphaRect.width = 24;
alphaRect.x = rect.xMax;
alphaRect.height = 24;
rect.xMax -= 35;
Rect overrideRect = rect;
overrideRect.width = 32;
EditorGUI.LabelField( overrideRect, TargetsStr, style );
overrideRect = rect;
overrideRect.xMin += 32 + ( m_usingStandard ? 0 : 13 );
overrideRect.width = EditorGUIUtility.labelWidth - overrideRect.xMin + 13;
EditorGUI.LabelField( overrideRect, SuffixStr, style );
Rect optionRect = rect;
optionRect.xMin = EditorGUIUtility.labelWidth + 23;
float fullwidth = optionRect.width;
optionRect.width = fullwidth * 0.25f;
EditorGUI.LabelField( optionRect, TexScaleStr, style );
optionRect.x += optionRect.width;
EditorGUI.LabelField( optionRect, ( optionRect.width < 60 ) ? new GUIContent( "Chan" ) : ChannelsStr, style );
optionRect.x += optionRect.width;
optionRect.width = 35;
EditorGUI.LabelField( optionRect, ColorSpaceStr, style );
optionRect.x += optionRect.width;
optionRect.width = fullwidth * 0.25f;
EditorGUI.LabelField( optionRect, ( optionRect.width < 75 ) ? new GUIContent( "Comp" ) : CompressionStr, style );
optionRect.x += optionRect.width;
EditorGUI.LabelField( optionRect, ( optionRect.width < 40 ) ? new GUIContent( "Fmt" ) : FormatStr, style );
EditorGUI.LabelField( alphaRect, AlphaIcon, style );
}
private void DrawElement( Rect rect, int index, bool active, bool focused )
{
rect.y += 1;
Rect alphaRect = rect;
alphaRect.height = EditorGUIUtility.singleLineHeight;
alphaRect.width = 20;
alphaRect.x = rect.xMax - alphaRect.width;
rect.xMax -= alphaRect.width + 35;
Rect overrideRect = rect;
overrideRect.width = 16;
overrideRect.height = EditorGUIUtility.singleLineHeight;
EditorGUI.LabelField( overrideRect, new GUIContent( index.ToString() ) );
rect.height = EditorGUIUtility.singleLineHeight;
Rect toggleRect = rect;
toggleRect.x = overrideRect.xMax;
toggleRect.width = 16;
instance.Output[ index ].Active = EditorGUI.Toggle( toggleRect, instance.Output[ index ].Active );
rect.y += 1;
EditorGUI.BeginDisabledGroup( !instance.Output[ index ].Active );
Rect nameRect = rect;
nameRect.x = toggleRect.xMax;
nameRect.width = EditorGUIUtility.labelWidth - 32 - ( m_usingStandard ? 5 : 19 );
instance.Output[ index ].Name = EditorGUI.TextField( nameRect, instance.Output[ index ].Name );
Rect optionRect = rect;
optionRect.xMin = nameRect.xMax;
float fullwidth = optionRect.width;
optionRect.width = fullwidth * 0.25f;
instance.Output[ index ].Scale = (TextureScale)EditorGUI.IntPopup( optionRect, (int)instance.Output[ index ].Scale, TexScaleListStr, TexScaleOpt );
optionRect.x += optionRect.width;
instance.Output[ index ].Channels = (TextureChannels)EditorGUI.EnumPopup( optionRect, instance.Output[ index ].Channels );
optionRect.x += optionRect.width + 10;
optionRect.width = 35;
optionRect.y -= 1;
instance.Output[ index ].SRGB = EditorGUI.Toggle( optionRect, instance.Output[ index ].SRGB );
optionRect.y += 1;
optionRect.x += optionRect.width - 10;
optionRect.width = fullwidth * 0.25f;
instance.Output[ index ].Compression = (TextureCompression)EditorGUI.IntPopup( optionRect, (int)instance.Output[ index ].Compression, CompressionListStr, CompressionOpt );
optionRect.x += optionRect.width;
instance.Output[ index ].ImageFormat = (ImageFormat)EditorGUI.EnumPopup( optionRect, instance.Output[ index ].ImageFormat );
EditorGUI.EndDisabledGroup();
alphaRect.xMin += 4;
instance.AlphaIndex = EditorGUI.Toggle( alphaRect, instance.AlphaIndex == index, "radio" ) ? index : instance.AlphaIndex;
}
private void AddItem( ReorderableList reordableList )
{
reordableList.list.Add( new TextureOutput() );
EditorUtility.SetDirty( target );
}
public override void OnInspectorGUI()
{
//base.OnInspectorGUI();
EditorGUI.BeginChangeCheck();
instance.BakeShader = EditorGUILayout.ObjectField( BakeShaderStr, instance.BakeShader, typeof( Shader ), false ) as Shader;
instance.RuntimeShader = EditorGUILayout.ObjectField( RuntimeShaderStr, instance.RuntimeShader, typeof( Shader ), false ) as Shader;
//instance.Pipeline = (PresetPipeline)EditorGUILayout.EnumPopup( PipelineStr, instance.Pipeline );
m_usingStandard = instance.BakeShader == null;
bool check = false;
if( EditorGUI.EndChangeCheck() )
{
check = true;
}
if( check || ( m_usingStandard && ( instance.Output.Count == 0 || instance.Output.Count < 6 ) ) )
{
check = false;
if( m_usingStandard )
{
instance.Output.Clear();
instance.Output = new List<TextureOutput>()
{
new TextureOutput(true, Preferences.GlobalAlbedo, TextureScale.Full, true, TextureChannels.RGBA, TextureCompression.High, ImageFormat.TGA ),
new TextureOutput(true, Preferences.GlobalNormals, TextureScale.Full, false, TextureChannels.RGBA, TextureCompression.High, ImageFormat.TGA ),
new TextureOutput(true, Preferences.GlobalSpecular, TextureScale.Full, true, TextureChannels.RGBA, TextureCompression.High, ImageFormat.TGA ),
new TextureOutput(true, Preferences.GlobalOcclusion, TextureScale.Full, true, TextureChannels.RGB, TextureCompression.Normal, ImageFormat.TGA ),
new TextureOutput(true, Preferences.GlobalEmission, TextureScale.Full, false, TextureChannels.RGB, TextureCompression.High, ImageFormat.EXR ),
new TextureOutput(true, Preferences.GlobalPosition, TextureScale.Quarter, false, TextureChannels.RGB, TextureCompression.None, ImageFormat.TGA ),
};
}
RefreshList();
Repaint();
}
m_reorderableOutput.DoLayoutList();
if( GUI.changed )
EditorUtility.SetDirty( instance );
}
}
}
#endif

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d0c60e21ade34544d8b569cc5b4f9bcc
timeCreated: 1533227802
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 1e5cc34cc2f367241ac97a4989568b02
timeCreated: 1517223131
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: ce6be581eb19e354fa5ea32b84bc03d2
folderAsset: yes
timeCreated: 1531234144
licenseType: Store
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,22 @@
{
"name": "AIToASE",
"rootNamespace": "",
"references": [
"GUID:f540dafdfbc0586439d98823585550d4",
"GUID:a1a7cacb6cec073439a2b2c1849d773b",
"GUID:beb7ced4cc341384592d9187e65da6b5"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [
"AMPLIFY_SHADER_EDITOR"
],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c36a092b2f77a6146a1ab23843ac10cb
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: bd1302eae8cb12848b4b8f4f6d4efc58
timeCreated: 1531149136
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 332cc9d439efa534f91e7a5bccdae4e3
folderAsset: yes
timeCreated: 1526989506
licenseType: Store
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 8c05d9cf624ad484eb90e8a08cdaa971
folderAsset: yes
timeCreated: 1533124318
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,72 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 32f7caa019b8743459b7b0ab1fdc3bae, type: 3}
m_Name: BakePreset
m_EditorClassIdentifier:
BakeShader: {fileID: 0}
RuntimeShader: {fileID: 0}
AlphaIndex: 0
Output:
- Index: -1
OverrideMask: 0
Active: 1
Name: _Albedo
Scale: 1
SRGB: 1
Channels: 0
Compression: 2
ImageFormat: 1
- Index: -1
OverrideMask: 0
Active: 1
Name: _Normals
Scale: 1
SRGB: 0
Channels: 0
Compression: 2
ImageFormat: 1
- Index: -1
OverrideMask: 0
Active: 1
Name: _Specular
Scale: 1
SRGB: 1
Channels: 0
Compression: 2
ImageFormat: 1
- Index: -1
OverrideMask: 0
Active: 1
Name: _Occlusion
Scale: 1
SRGB: 1
Channels: 1
Compression: 1
ImageFormat: 1
- Index: -1
OverrideMask: 0
Active: 1
Name: _Emission
Scale: 1
SRGB: 0
Channels: 1
Compression: 2
ImageFormat: 2
- Index: -1
OverrideMask: 0
Active: 0
Name: _Position
Scale: 4
SRGB: 0
Channels: 1
Compression: 0
ImageFormat: 1

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 9025aeb3b5a73cf47ab124248896e91b
timeCreated: 1533124339
licenseType: Store
NativeFormatImporter:
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,53 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 32f7caa019b8743459b7b0ab1fdc3bae, type: 3}
m_Name: StandardDeferred
m_EditorClassIdentifier:
BakeShader: {fileID: 0}
RuntimeShader: {fileID: 0}
AlphaIndex: 0
Output:
- Index: -1
OverrideMask: 0
Active: 1
Name: _AlbedoAlpha
Scale: 1
SRGB: 1
Channels: 0
Compression: 1
ImageFormat: 1
- Index: -1
OverrideMask: 0
Active: 1
Name: _SpecularSmoothness
Scale: 1
SRGB: 1
Channels: 0
Compression: 1
ImageFormat: 1
- Index: -1
OverrideMask: 0
Active: 1
Name: _NormalDepth
Scale: 1
SRGB: 0
Channels: 0
Compression: 1
ImageFormat: 1
- Index: -1
OverrideMask: 0
Active: 1
Name: _EmissionOcclusion
Scale: 1
SRGB: 0
Channels: 0
Compression: 1
ImageFormat: 1

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: e4786beb7716da54dbb02a632681cc37
timeCreated: 1533124339
licenseType: Store
NativeFormatImporter:
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,54 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 32f7caa019b8743459b7b0ab1fdc3bae, type: 3}
m_Name: StandardURP
m_EditorClassIdentifier:
BakeShader: {fileID: 4800000, guid: 491949b665cd59d43bc93c611092dcae, type: 3}
RuntimeShader: {fileID: 0}
AlphaIndex: 0
Output:
- Index: -1
OverrideMask: 0
Active: 1
Name: _AlbedoAlpha
Scale: 1
SRGB: 1
Channels: 0
Compression: 1
ImageFormat: 1
- Index: -1
OverrideMask: 0
Active: 1
Name: _SpecularSmoothness
Scale: 1
SRGB: 1
Channels: 0
Compression: 1
ImageFormat: 1
- Index: -1
OverrideMask: 0
Active: 1
Name: _NormalDepth
Scale: 1
SRGB: 0
Channels: 0
Compression: 1
ImageFormat: 1
- Index: -1
OverrideMask: 0
Active: 1
Name: _EmissionOcclusion
Scale: 1
SRGB: 0
Channels: 0
Compression: 1
ImageFormat: 1

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 0403878495ffa3c4e9d4bcb3eac9b559
timeCreated: 1533124339
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: a584bb2074b0f964c85dbc76df763b95
folderAsset: yes
timeCreated: 1548431940
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 9e679b6707e1ca346a5605da9d86dedf
folderAsset: yes
timeCreated: 1610981190
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 4b4be1ceefb066d4ca4938a1554bca3b
folderAsset: yes
timeCreated: 1526989522
licenseType: Store
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: ac8314ac006c63e4ea98b73d3f187f27
folderAsset: yes
timeCreated: 1526998697
licenseType: Store
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,292 @@
// Made with Amplify Shader Editor
// Available at the Unity Asset Store - http://u3d.as/y3X
Shader "Hidden/Baking URP"
{
Properties
{
[HideInInspector] _WorkflowMode("WorkflowMode", Float) = 1.0
[MainColor] _BaseColor("Color", Color) = (1,1,1,1)
[MainTexture] _BaseMap("Albedo", 2D) = "white" {}
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
_Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5
_GlossMapScale("Smoothness Scale", Range(0.0, 1.0)) = 1.0
_SmoothnessTextureChannel("Smoothness texture channel", Float) = 0
_Metallic("Metallic", Range(0.0, 1.0)) = 0.0
_MetallicGlossMap("Metallic", 2D) = "white" {}
_SpecColor("Specular", Color) = (0.2, 0.2, 0.2)
_SpecGlossMap("Specular", 2D) = "white" {}
[ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0
[ToggleOff] _EnvironmentReflections("Environment Reflections", Float) = 1.0
_BumpScale("Scale", Float) = 1.0
_BumpMap("Normal Map", 2D) = "bump" {}
_OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0
_OcclusionMap("Occlusion", 2D) = "white" {}
_EmissionColor("Color", Color) = (0,0,0)
_EmissionMap("Emission", 2D) = "white" {}
[HideInInspector] _Surface("__surface", Float) = 0.0
[HideInInspector] _Blend("__blend", Float) = 0.0
[HideInInspector] _AlphaClip("__clip", Float) = 0.0
[HideInInspector] _SrcBlend("__src", Float) = 1.0
[HideInInspector] _DstBlend("__dst", Float) = 0.0
[HideInInspector] _ZWrite("__zw", Float) = 1.0
[HideInInspector] _Cull("__cull", Float) = 2.0
_ReceiveShadows("Receive Shadows", Float) = 1.0
[HideInInspector] _QueueOffset("Queue offset", Float) = 0.0
[HideInInspector] _MainTex("BaseMap", 2D) = "white" {}
[HideInInspector] _Color("Base Color", Color) = (1, 1, 1, 1)
[HideInInspector] _GlossMapScale("Smoothness", Float) = 0.0
[HideInInspector] _Glossiness("Smoothness", Float) = 0.0
[HideInInspector] _GlossyReflections("EnvironmentReflections", Float) = 0.0
}
SubShader
{
LOD 0
Tags { "RenderPipeline"="UniversalPipeline" "RenderType"="Opaque" "Queue"="Geometry" }
Cull Back
HLSLINCLUDE
#pragma target 3.0
ENDHLSL
Pass
{
Tags { "LightMode"="UniversalForward" }
Name "Base"
Blend One Zero
ZWrite On
ZTest LEqual
Offset 0 , 0
ColorMask RGBA
HLSLPROGRAM
#define ASE_SRP_VERSION 70105
// Required to compile gles 2.0 with standard srp library
#pragma prefer_hlslcc gles
#pragma exclude_renderers d3d11_9x
// -------------------------------------
// Lightweight Pipeline keywords
#pragma shader_feature _SAMPLE_GI
// -------------------------------------
// Unity defined keywords
#pragma multi_compile_fog
//--------------------------------------
// GPU Instancing
#pragma multi_compile_instancing
#pragma vertex vert
#pragma fragment frag
#pragma shader_feature _SPECULAR_SETUP
#pragma shader_feature _METALLICSPECGLOSSMAP
#pragma shader_feature _SPECGLOSSMAP
#pragma shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
#pragma shader_feature _NORMALMAP
#pragma shader_feature _OCCLUSIONMAP
#pragma shader_feature _EMISSION
#pragma shader_feature _ALPHATEST_ON
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
// Lighting include is needed because of GI
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
struct GraphVertexInput
{
float4 vertex : POSITION;
float4 ase_normal : NORMAL;
float4 ase_texcoord : TEXCOORD0;
float4 ase_tangent : TANGENT;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct GraphVertexOutput
{
float4 position : POSITION;
float4 ase_texcoord : TEXCOORD0;
float4 ase_texcoord1 : TEXCOORD1;
float4 ase_texcoord2 : TEXCOORD2;
float4 ase_texcoord3 : TEXCOORD3;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
float2 AIBaseMapST( out float2 Offset )
{
#if UNITY_VERSION >= 201910
Offset = _BaseMap_ST.zw;
return _BaseMap_ST.xy;
#else
Offset = _MainTex_ST.zw;
return _MainTex_ST.xy;
#endif
}
float3 AIUSurfaceOutput( float2 inputUv , out float3 albedo , out float3 normal , out float3 specular , out float smoothness , out float metallic , out float occlusion , out float3 emission , out float alpha )
{
SurfaceData surfaceData;
InitializeStandardLitSurfaceData(inputUv, surfaceData);
albedo = surfaceData.albedo;
normal = surfaceData.normalTS;
specular = surfaceData.specular;
smoothness = surfaceData.smoothness;
metallic = surfaceData.metallic;
occlusion = surfaceData.occlusion;
emission = surfaceData.emission;
alpha = surfaceData.alpha;
BRDFData brdfData;
InitializeBRDFData(surfaceData.albedo, surfaceData.metallic, surfaceData.specular, surfaceData.smoothness, surfaceData.alpha, brdfData);
albedo = brdfData.diffuse;
specular = brdfData.specular;
return surfaceData.albedo;
}
GraphVertexOutput vert (GraphVertexInput v)
{
GraphVertexOutput o = (GraphVertexOutput)0;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
float3 ase_worldTangent = TransformObjectToWorldDir(v.ase_tangent.xyz);
o.ase_texcoord1.xyz = ase_worldTangent;
float3 ase_worldNormal = TransformObjectToWorldNormal(v.ase_normal.xyz);
o.ase_texcoord2.xyz = ase_worldNormal;
float ase_vertexTangentSign = v.ase_tangent.w * unity_WorldTransformParams.w;
float3 ase_worldBitangent = cross( ase_worldNormal, ase_worldTangent ) * ase_vertexTangentSign;
o.ase_texcoord3.xyz = ase_worldBitangent;
float3 objectToViewPos = TransformWorldToView(TransformObjectToWorld(v.vertex.xyz));
float eyeDepth = -objectToViewPos.z;
o.ase_texcoord.z = eyeDepth;
o.ase_texcoord.xy = v.ase_texcoord.xy;
//setting value to unused interpolator channels and avoid initialization warnings
o.ase_texcoord.w = 0;
o.ase_texcoord1.w = 0;
o.ase_texcoord2.w = 0;
o.ase_texcoord3.w = 0;
v.vertex.xyz += float3( 0, 0, 0 ) ;
o.position = TransformObjectToHClip(v.vertex.xyz);
return o;
}
void frag( GraphVertexOutput IN ,
out half4 outGBuffer0 : SV_Target0,
out half4 outGBuffer1 : SV_Target1,
out half4 outGBuffer2 : SV_Target2,
out half4 outGBuffer3 : SV_Target3,
out half4 outGBuffer4 : SV_Target4,
out half4 outGBuffer5 : SV_Target5,
out half4 outGBuffer6 : SV_Target6,
out half4 outGBuffer7 : SV_Target7,
out float outDepth : SV_Depth
)
{
UNITY_SETUP_INSTANCE_ID( IN );
float2 Offset1_g8 = float2( 0,0 );
float2 localAIBaseMapST1_g8 = AIBaseMapST( Offset1_g8 );
float2 uv02_g8 = IN.ase_texcoord.xy * localAIBaseMapST1_g8 + Offset1_g8;
float2 inputUv3_g8 = uv02_g8;
float3 albedo3_g8 = float3( 0,0,0 );
float3 normal3_g8 = float3( 0,0,0 );
float3 specular3_g8 = float3( 0,0,0 );
float smoothness3_g8 = 0.0;
float metallic3_g8 = 0.0;
float occlusion3_g8 = 0.0;
float3 emission3_g8 = float3( 0,0,0 );
float alpha3_g8 = 0.0;
float3 localAIUSurfaceOutput3_g8 = AIUSurfaceOutput( inputUv3_g8 , albedo3_g8 , normal3_g8 , specular3_g8 , smoothness3_g8 , metallic3_g8 , occlusion3_g8 , emission3_g8 , alpha3_g8 );
float4 appendResult240 = (float4(albedo3_g8 , 1.0));
float4 appendResult256 = (float4(specular3_g8 , smoothness3_g8));
float3 ase_worldTangent = IN.ase_texcoord1.xyz;
float3 ase_worldNormal = IN.ase_texcoord2.xyz;
float3 ase_worldBitangent = IN.ase_texcoord3.xyz;
float3 tanToWorld0 = float3( ase_worldTangent.x, ase_worldBitangent.x, ase_worldNormal.x );
float3 tanToWorld1 = float3( ase_worldTangent.y, ase_worldBitangent.y, ase_worldNormal.y );
float3 tanToWorld2 = float3( ase_worldTangent.z, ase_worldBitangent.z, ase_worldNormal.z );
float3 tanNormal8_g7 = normal3_g8;
float3 worldNormal8_g7 = float3(dot(tanToWorld0,tanNormal8_g7), dot(tanToWorld1,tanNormal8_g7), dot(tanToWorld2,tanNormal8_g7));
float eyeDepth = IN.ase_texcoord.z;
float temp_output_4_0_g7 = ( -1.0 / UNITY_MATRIX_P[2].z );
float temp_output_7_0_g7 = ( ( eyeDepth + temp_output_4_0_g7 ) / temp_output_4_0_g7 );
float4 appendResult11_g7 = (float4((worldNormal8_g7*0.5 + 0.5) , temp_output_7_0_g7));
float4 appendResult257 = (float4(emission3_g8 , occlusion3_g8));
#ifdef _ALPHATEST_ON
float staticSwitch244 = ( alpha3_g8 - _Cutoff );
#else
float staticSwitch244 = 1.0;
#endif
outGBuffer0 = appendResult240;
outGBuffer1 = appendResult256;
outGBuffer2 = appendResult11_g7;
outGBuffer3 = appendResult257;
outGBuffer4 = 0;
outGBuffer5 = 0;
outGBuffer6 = 0;
outGBuffer7 = 0;
float alpha = staticSwitch244;
#if _AlphaClip
clip( alpha );
#endif
outDepth = IN.position.z;
}
ENDHLSL
}
}
CustomEditor "ASEMaterialInspector"
}
/*ASEBEGIN
Version=17501
-1543;-544;1159;937;-1495.402;817.9362;1.613313;True;False
Node;AmplifyShaderEditor.FunctionNode;272;2160,-192;Inherit;False;Universal Surface Output;-1;;8;4220f49336ae49347952a65dcdfa5710;0;0;8;FLOAT3;0;FLOAT3;4;FLOAT3;5;FLOAT;6;FLOAT;7;FLOAT;8;FLOAT3;9;FLOAT;10
Node;AmplifyShaderEditor.RangedFloatNode;241;2269.678,295.5062;Float;False;Global;_Cutoff;_Cutoff;0;0;Fetch;True;0;0;False;0;0.5;0;0;0;0;1;FLOAT;0
Node;AmplifyShaderEditor.RangedFloatNode;238;2274.845,138.1202;Float;False;Constant;_Alpha1;Alpha1;2;0;Create;True;0;0;False;0;1;0;0;0;0;1;FLOAT;0
Node;AmplifyShaderEditor.SimpleSubtractOpNode;243;2516.462,261.5877;Inherit;False;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.DynamicAppendNode;257;2622.835,21.34941;Inherit;False;FLOAT4;4;0;FLOAT3;0,0,0;False;1;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;0;False;1;FLOAT4;0
Node;AmplifyShaderEditor.FunctionNode;187;2599.477,-190.5401;Inherit;False;Pack Normal Depth;-1;;9;8e386dbec347c9f44befea8ff816d188;0;1;12;FLOAT3;0,0,0;False;3;FLOAT4;0;FLOAT3;14;FLOAT;15
Node;AmplifyShaderEditor.DynamicAppendNode;256;2618.15,-71.96327;Inherit;False;FLOAT4;4;0;FLOAT3;0,0,0;False;1;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;0;False;1;FLOAT4;0
Node;AmplifyShaderEditor.DynamicAppendNode;240;2629.412,-303.1327;Inherit;False;FLOAT4;4;0;FLOAT3;0,0,0;False;1;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;0;False;1;FLOAT4;0
Node;AmplifyShaderEditor.StaticSwitch;244;2724.947,165.0664;Float;False;Property;_Keyword4;Keyword 4;7;0;Fetch;False;0;0;False;0;0;0;0;False;_ALPHATEST_ON;Toggle;2;Key0;Key1;Fetch;False;9;1;FLOAT;0;False;0;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;0;False;4;FLOAT;0;False;5;FLOAT;0;False;6;FLOAT;0;False;7;FLOAT;0;False;8;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;271;3048.978,-256.7144;Float;False;True;-1;2;ASEMaterialInspector;0;16;Hidden/Baking URP;6ee191abcace33c46a5dd52068b074e0;True;Base;0;0;Base;10;False;False;False;True;0;False;-1;False;False;False;False;False;True;3;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;True;2;0;True;1;1;False;-1;0;False;-1;0;1;False;-1;0;False;-1;False;False;False;True;True;True;True;True;0;False;-1;True;False;255;False;-1;255;False;-1;255;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;7;False;-1;1;False;-1;1;False;-1;1;False;-1;True;1;False;-1;True;3;False;-1;True;True;0;False;-1;0;False;-1;True;1;LightMode=UniversalForward;False;0;;0;0;Standard;1;Receive Shadows;1;0;1;True;False;;0
WireConnection;243;0;272;10
WireConnection;243;1;241;0
WireConnection;257;0;272;9
WireConnection;257;3;272;8
WireConnection;187;12;272;4
WireConnection;256;0;272;5
WireConnection;256;3;272;6
WireConnection;240;0;272;0
WireConnection;240;3;238;0
WireConnection;244;1;238;0
WireConnection;244;0;243;0
WireConnection;271;0;240;0
WireConnection;271;1;256;0
WireConnection;271;2;187;0
WireConnection;271;3;257;0
WireConnection;271;8;244;0
ASEEND*/
//CHKSM=C78E9D5DCBD2FA1B8434E38B06EA3616FC75C7BA

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 491949b665cd59d43bc93c611092dcae
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,386 @@
// Amplify Impostors
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
Shader "Hidden/GBufferToOutput"
{
Properties
{
_GBuffer0( "GBuffer0", 2D ) = "white" {}
_GBuffer1( "GBuffer1", 2D ) = "white" {}
_GBuffer2( "GBuffer2", 2D ) = "white" {}
_GBuffer3( "GBuffer3", 2D ) = "white" {}
_Depth( "Depth", 2D ) = "white" {}
}
CGINCLUDE
#pragma target 4.5
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"
#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
#pragma multi_compile _ PROBE_VOLUMES_L1 PROBE_VOLUMES_L2
#define RENDER_PIPELINE_BiRP ( 0 )
#define RENDER_PIPELINE_HDRP ( 1 )
#define RENDER_PIPELINE_URP ( 2 )
uniform uint _RenderPipeline;
uniform sampler2D _GBuffer0;
uniform sampler2D _GBuffer1;
uniform sampler2D _GBuffer2;
uniform sampler2D _GBuffer3;
uniform sampler2D _Depth;
uniform StructuredBuffer<float4x4> _CameraInvViewProjPerFrame;
uniform float2 _FrameCount;
uniform float3 _BoundsMin;
uniform float3 _BoundsSize;
float2 Unpack888UIntToFloat2( uint3 x )
{
uint hi = x.z >> 4;
uint lo = x.z & 15;
uint2 cb = x.xy | uint2( lo << 8, hi << 8 );
return cb / 4095.0;
}
float2 Unpack888ToFloat2( float3 x )
{
uint3 i = ( uint3 )( x * 255.5 );
return Unpack888UIntToFloat2( i );
}
float3 UnpackNormalOctQuadEncode( float2 f )
{
float3 n = float3( f.x, f.y, 1.0 - ( f.x < 0 ? -f.x : f.x ) - ( f.y < 0 ? -f.y : f.y ) );
float t = max( -n.z, 0.0 );
n.xy += float2( n.x >= 0.0 ? -t : t, n.y >= 0.0 ? -t : t );
return normalize( n );
}
void UnpackFloatInt( float val, float maxi, float precision, out float f, out uint i )
{
float precisionMinusOne = precision - 1.0;
float t1 = ( ( precision / maxi ) - 1.0 ) / precisionMinusOne;
float t2 = ( precision / maxi ) / precisionMinusOne;
i = int( ( val / t2 ) + rcp( precisionMinusOne ) );
f = saturate( ( -t2 * float( i ) + val ) / t1 );
}
void UnpackFloatInt8bit( float val, float maxi, out float f, out uint i )
{
UnpackFloatInt( val, maxi, 256.0, f, i );
}
float3 GammaToLinearSpaceExact( float3 linRGB )
{
return float3( GammaToLinearSpaceExact( linRGB.r ), GammaToLinearSpaceExact( linRGB.g ), GammaToLinearSpaceExact( linRGB.b ) );
}
#define kDielectricSpec float4( 0.04, 0.04, 0.04, 1.0 - 0.04 ) // standard dielectric reflectivity coef at incident angle (= 4%)
uint UnpackMaterialFlags( float packedMaterialFlags )
{
return uint( ( packedMaterialFlags * 255.0 ) + 0.5 );
}
float MetallicFromReflectivity( float reflectivity )
{
float oneMinusDielectricSpec = kDielectricSpec.a;
return ( reflectivity - kDielectricSpec.r ) / oneMinusDielectricSpec;
}
inline float2 FrameCoordsFromUV( float2 uv )
{
return uv * _FrameCount.xy;
}
inline uint FrameIndexFromFrameCoords( float2 frameCoords )
{
uint2 frame = ( uint2 )floor( frameCoords );
return frame.y * _FrameCount.x + frame.x;
}
inline float3 ScreenToPosition( float2 uv, float deviceDepth )
{
float2 frameCoords = FrameCoordsFromUV( uv );
uint frameIndex = FrameIndexFromFrameCoords( frameCoords );
float4x4 invViewProjMatrix = _CameraInvViewProjPerFrame.Load( frameIndex );
float4 positionCS = float4( frac( frameCoords ) * 2.0 - 1.0, deviceDepth, 1.0 );
#if UNITY_UV_STARTS_AT_TOP
positionCS.y = -positionCS.y;
#endif
float4 hposition = mul( invViewProjMatrix, positionCS );
float3 position = hposition.xyz / hposition.w;
return position;
}
float4 GBufferToOutput_BiRP( const float2 uv, const float depth, const int outputIndex )
{
// GBuffer0: Albedo (RGB) Occlusion (A) {SRGB}
// GBuffer1: Specular (RGB) Smoothness (A) {SRGB}
// GBuffer2: Normals (RGB) {LINEAR}
// GBuffer3: Emission (RGB) {LINEAR}
float alpha = 1 - step( depth, 0 );
float4 result = 0;
if ( outputIndex == 0 )
{
// _Albedo(Alpha)
result.rgb = tex2D( _GBuffer0, uv ).rgb;
result.a = alpha;
}
else if ( outputIndex == 1 )
{
// _Normal(Depth)
result.rgb = tex2D( _GBuffer2, uv ).rgb;
result.a = depth;
}
else if ( outputIndex == 2 )
{
// _Specular(Smoothness)
result = tex2D( _GBuffer1, uv );
}
else if ( outputIndex == 3 )
{
// _Occlusion
result.rgb = tex2D( _GBuffer0, uv ).aaa;
result.a = 0;
}
else if ( outputIndex == 4 )
{
// _Emission
result.rgb = tex2D( _GBuffer3, uv ).rgb;
result.a = 0;
}
return result;
}
float4 GBufferToOutput_HDRP( const float2 uv, const float depth, const int outputIndex )
{
// GBuffer0: Albedo (RGB) Occlusion (A) [A => occlusion(7) / isLightmap(1)] {SRGB}
// GBuffer1: Normals (RGB) PerceptualRoughness (A) [RGB => X:Y / 12:12 / Octa] {LINEAR}
// GBuffer2: Specular (RGB) {LINEAR}
// GBuffer3: Emission (RGB) {LINEAR}
float alpha = 1 - step( depth, 0 );
float4 result = 0;
if ( outputIndex == 0 )
{
// _Albedo(Alpha)
result.rgb = tex2D( _GBuffer0, uv ).rgb;
result.a = alpha;
}
else if ( outputIndex == 1 )
{
// _Normal(Depth)
// TODO: unpack normals to world
result.rgb = UnpackNormalOctQuadEncode( Unpack888ToFloat2( tex2D( _GBuffer1, uv ).rgb ) * 2.0 - 1.0 ) * 0.5 + 0.5;
result.a = depth;
}
else if ( outputIndex == 2 )
{
// _Specular(Smoothness)
result.rgb = GammaToLinearSpaceExact( tex2D( _GBuffer2, uv ).rgb );
result.a = 1 - tex2D( _GBuffer1, uv ).a;
}
else if ( outputIndex == 3 )
{
// _Occlusion
float occlusion = tex2D( _GBuffer0, uv ).a;
#if defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2)
uint isLightmap;
UnpackFloatInt8bit( occlusion, 2, occlusion, isLightmap );
#endif
result.rgb = occlusion;
result.a = 0;
}
else if ( outputIndex == 4 )
{
// _Emission
float3 emission = tex2D( _GBuffer3, uv ).rgb;
#define AO_IN_GBUFFER3_TAG float3( 1 << 11, 1, 1 << 10 )
emission *= all( emission.xz == AO_IN_GBUFFER3_TAG.xz ) ? 0 : 1;
result.rgb = emission;
result.a = 0;
}
return result;
}
float4 GBufferToOutput_URP( const float2 uv, const float depth, const int outputIndex )
{
// GBuffer0: Albedo (RGB) MaterialFlags (A) [A => miscFlags(7) / specularSetup(1)] {SRGB}
// GBuffer1: Specular (RGB) Occlusion (A) [specularSetup ? R => Metallic : RGB => Specular ] {LINEAR}
// GBuffer2: Normals (RGB) Smoothness (A) {LINEAR}
// GBuffer3: Emission (RGB) {LINEAR}
float alpha = 1 - step( depth, 0 );
float4 gbuffer0 = tex2D( _GBuffer0, uv );
float4 gbuffer1 = tex2D( _GBuffer1, uv );
float4 gbuffer2 = tex2D( _GBuffer2, uv );
float4 gbuffer3 = tex2D( _GBuffer3, uv );
const int kMaterialFlagSpecularSetup = 8;
float3 albedo = gbuffer0.rgb;
uint materialFlags = UnpackMaterialFlags( gbuffer0.a );
float occlusion = gbuffer1.a;
float smoothness = gbuffer2.a;
float3 specular = gbuffer1.rgb;
float3 emission = gbuffer3.rgb;
if ( ( materialFlags & kMaterialFlagSpecularSetup ) == 0 ) // Metallic workflow?
{
float reflectivity = gbuffer1.r;
float oneMinusReflectivity = 1.0 - reflectivity;
float metallic = MetallicFromReflectivity( reflectivity );
specular = lerp( kDielectricSpec.rgb, albedo, metallic );
albedo *= oneMinusReflectivity;
}
float4 result = 0;
if ( outputIndex == 0 )
{
// _Albedo(Alpha)
result.rgb = albedo;
result.a = alpha;
}
else if ( outputIndex == 1 )
{
// _Normal(Depth)
#ifdef _GBUFFER_NORMALS_OCT
result.rgb = UnpackNormalOctQuadEncode( Unpack888ToFloat2( gbuffer2.rgb ) * 2.0 - 1.0 ) * 0.5 + 0.5;
#else
result.rgb = gbuffer2.rgb * 0.5 + 0.5;
#endif
result.a = depth;
}
else if ( outputIndex == 2 )
{
// _Specular(Smoothness)
result.rgb = specular;
result.a = smoothness;
}
else if ( outputIndex == 3 )
{
// _Occlusion
result.rgb = occlusion;
result.a = 0;
}
else if ( outputIndex == 4 )
{
// _Emission
result.rgb = emission;
result.a = 0;
}
return result;
}
float4 GBufferToOutput( const float2 uv, const int outputIndex )
{
float depth = SAMPLE_RAW_DEPTH_TEXTURE( _Depth, uv ).r;
#if !defined( UNITY_REVERSED_Z )
depth = 1 - depth;
#endif
float4 result = 0;
if ( outputIndex == 5 ) // Position: same for all render pipelines
{
result.rgb = ( ScreenToPosition( uv, depth ) - _BoundsMin ) / _BoundsSize;
result.a = 0;
}
else
{
if ( _RenderPipeline == RENDER_PIPELINE_BiRP )
{
result = GBufferToOutput_BiRP( uv, depth, outputIndex );
}
else if ( _RenderPipeline == RENDER_PIPELINE_HDRP )
{
result = GBufferToOutput_HDRP( uv, depth, outputIndex );
}
else if ( _RenderPipeline == RENDER_PIPELINE_URP )
{
result = GBufferToOutput_URP( uv, depth, outputIndex );
}
}
return result;
}
ENDCG
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
ZWrite On
ZTest LEqual
ColorMask RGBA
Blend Off
Cull Off
Offset 0,0
Pass // GBuffer to Output 0
{
CGPROGRAM
float4 frag( v2f_img i ) : SV_Target
{
return GBufferToOutput( i.uv, 0 );
}
ENDCG
}
Pass // GBuffer to Output 1
{
CGPROGRAM
float4 frag( v2f_img i ) : SV_Target
{
return GBufferToOutput( i.uv, 1 );
}
ENDCG
}
Pass // GBuffer to Output 2
{
CGPROGRAM
float4 frag( v2f_img i ) : SV_Target
{
return GBufferToOutput( i.uv, 2 );
}
ENDCG
}
Pass // GBuffer to Output 3
{
CGPROGRAM
float4 frag( v2f_img i ) : SV_Target
{
return GBufferToOutput( i.uv, 3 );
}
ENDCG
}
Pass // GBuffer to Output 4
{
CGPROGRAM
float4 frag( v2f_img i ) : SV_Target
{
return GBufferToOutput( i.uv, 4 );
}
ENDCG
}
Pass // GBuffer to Output 5
{
CGPROGRAM
float4 frag( v2f_img i ) : SV_Target
{
return GBufferToOutput( i.uv, 5 );
}
ENDCG
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 9587d58ea8f1dac478d1adbf2a63d31f
timeCreated: 1524073284
licenseType: Store
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,89 @@
Shader /*ase_name*/ "Hidden/Impostors/Baking/Bake"/*end*/
{
Properties
{
/*ase_props*/
}
SubShader
{
Tags{ "RenderType" = "Opaque" }
LOD 100
CGINCLUDE
#pragma target 4.0
ENDCG
Cull Back
/*ase_pass*/
Pass
{
Name "Unlit"
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#pragma multi_compile_fwdbase
/*ase_pragma*/
struct appdata
{
float4 vertex : POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
/*ase_vdata:p=p*/
};
struct v2f
{
UNITY_POSITION(pos);
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
/*ase_interp(0,):sp=sp.xyzw*/
};
/*ase_globals*/
v2f vert(appdata v /*ase_vert_input*/)
{
v2f o = (v2f)0;
UNITY_SETUP_INSTANCE_ID( v );
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( o );
UNITY_TRANSFER_INSTANCE_ID( v, o );
/*ase_vert_code:v=appdata;o=v2f*/
v.vertex.xyz += /*ase_vert_out:Local Vertex;Float3*/ float3(0,0,0) /*end*/;
o.pos = UnityObjectToClipPos(v.vertex);
return o;
}
void frag(v2f i /*ase_frag_input*/,
out half4 outGBuffer0 : SV_Target0,
out half4 outGBuffer1 : SV_Target1,
out half4 outGBuffer2 : SV_Target2,
out half4 outGBuffer3 : SV_Target3,
out half4 outGBuffer4 : SV_Target4,
out half4 outGBuffer5 : SV_Target5,
out half4 outGBuffer6 : SV_Target6,
out half4 outGBuffer7 : SV_Target7,
out float outDepth : SV_Depth
)
{
UNITY_SETUP_INSTANCE_ID( i );
/*ase_frag_code:i=v2f*/
outGBuffer0 = /*ase_frag_out:Output RT 0;Float4*/0/*end*/;
outGBuffer1 = /*ase_frag_out:Output RT 1;Float4*/0/*end*/;
outGBuffer2 = /*ase_frag_out:Output RT 2;Float4*/0/*end*/;
outGBuffer3 = /*ase_frag_out:Output RT 3;Float4*/0/*end*/;
outGBuffer4 = /*ase_frag_out:Output RT 4;Float4*/0/*end*/;
outGBuffer5 = /*ase_frag_out:Output RT 5;Float4*/0/*end*/;
outGBuffer6 = /*ase_frag_out:Output RT 6;Float4*/0/*end*/;
outGBuffer7 = /*ase_frag_out:Output RT 7;Float4*/0/*end*/;
float alpha = /*ase_frag_out:Clip;Float*/1/*end*/;
clip( alpha );
outDepth = i.pos.z;
}
ENDCG
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: f53051a8190f7044fa936bd7fbe116c1
timeCreated: 1525095235
licenseType: Store
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,128 @@
Shader /*ase_name*/ "Hidden/Impostors/Baking/Bake URP"/*end*/
{
Properties
{
/*ase_props*/
}
SubShader
{
/*ase_subshader_options:Name=Additional Options
Option:Receive Shadows:false,true:true
true:RemoveDefine:_RECEIVE_SHADOWS_OFF 1
false:SetDefine:_RECEIVE_SHADOWS_OFF 1
*/
Tags{ "RenderPipeline" = "UniversalPipeline" "RenderType"="Opaque" "Queue"="Geometry"}
Cull Back
HLSLINCLUDE
#pragma target 3.0
ENDHLSL
/*ase_pass*/
Pass
{
Tags{"LightMode" = "UniversalForward"}
Name "Base"
Blend One Zero
ZWrite On
ZTest LEqual
Offset 0,0
ColorMask RGBA
/*ase_stencil*/
HLSLPROGRAM
// Required to compile gles 2.0 with standard srp library
#pragma prefer_hlslcc gles
#pragma exclude_renderers d3d11_9x
// -------------------------------------
// Lightweight Pipeline keywords
#pragma shader_feature _SAMPLE_GI
// -------------------------------------
// Unity defined keywords
#pragma multi_compile_fog
//--------------------------------------
// GPU Instancing
#pragma multi_compile_instancing
#pragma vertex vert
#pragma fragment frag
/*ase_pragma*/
// Lighting include is needed because of GI
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
/*ase_globals*/
struct GraphVertexInput
{
float4 vertex : POSITION;
float4 ase_normal : NORMAL;
/*ase_vdata:p=p;n=n*/
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct GraphVertexOutput
{
float4 position : POSITION;
/*ase_interp(0,):sp=sp*/
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
/*ase_funcs*/
GraphVertexOutput vert (GraphVertexInput v/*ase_vert_input*/)
{
GraphVertexOutput o = (GraphVertexOutput)0;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
/*ase_vert_code:v=GraphVertexInput;o=GraphVertexOutput*/
v.vertex.xyz += /*ase_vert_out:Vertex Offset;Float3*/ float3( 0, 0, 0 ) /*end*/;
o.position = TransformObjectToHClip(v.vertex.xyz);
return o;
}
void frag( GraphVertexOutput IN /*ase_frag_input*/,
out half4 outGBuffer0 : SV_Target0,
out half4 outGBuffer1 : SV_Target1,
out half4 outGBuffer2 : SV_Target2,
out half4 outGBuffer3 : SV_Target3,
out half4 outGBuffer4 : SV_Target4,
out half4 outGBuffer5 : SV_Target5,
out half4 outGBuffer6 : SV_Target6,
out half4 outGBuffer7 : SV_Target7,
out float outDepth : SV_Depth
)
{
UNITY_SETUP_INSTANCE_ID( IN );
/*ase_frag_code:IN=GraphVertexOutput*/
outGBuffer0 = /*ase_frag_out:Output RT 0;Float4*/0/*end*/;
outGBuffer1 = /*ase_frag_out:Output RT 1;Float4*/0/*end*/;
outGBuffer2 = /*ase_frag_out:Output RT 2;Float4*/0/*end*/;
outGBuffer3 = /*ase_frag_out:Output RT 3;Float4*/0/*end*/;
outGBuffer4 = /*ase_frag_out:Output RT 4;Float4*/0/*end*/;
outGBuffer5 = /*ase_frag_out:Output RT 5;Float4*/0/*end*/;
outGBuffer6 = /*ase_frag_out:Output RT 6;Float4*/0/*end*/;
outGBuffer7 = /*ase_frag_out:Output RT 7;Float4*/0/*end*/;
float alpha = /*ase_frag_out:Clip;Float*/1/*end*/;
#if _AlphaClip
clip( alpha );
#endif
outDepth = IN.position.z;
}
ENDHLSL
}
/*ase_pass_end*/
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 6ee191abcace33c46a5dd52068b074e0
timeCreated: 1525095235
licenseType: Pro
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,113 @@
// Amplify Impostors
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
Shader "Hidden/ImpostorDilate"
{
Properties
{
_MainTex( "", 2D ) = "white" {}
_MaskTex( "", 2D ) = "black" {}
}
CGINCLUDE
#include "UnityCG.cginc"
sampler2D _MainTex;
sampler2D _MaskTex;
float4 _MainTex_TexelSize;
float4 frag_dilate( v2f_img i, bool alpha )
{
float2 offsets[ 8 ] =
{
float2( -1, -1 ),
float2( 0, -1 ),
float2( +1, -1 ),
float2( -1, 0 ),
float2( +1, 0 ),
float2( -1, +1 ),
float2( 0, +1 ),
float2( +1, +1 )
};
float4 ref_main = tex2D( _MainTex, i.uv.xy );
float ref_mask = tex2D( _MaskTex, i.uv.xy ).a;
float4 result = 0;
if ( ref_mask == 0 )
{
float hits = 0;
for ( int tap = 0; tap < 8; tap++ )
{
float2 uv = i.uv.xy + offsets[ tap ] * _MainTex_TexelSize.xy;
float4 main = tex2Dlod( _MainTex, float4( uv, 0, 0 ) );
float mask = tex2Dlod( _MaskTex, float4( uv, 0, 0 ) ).a;
if ( mask != ref_mask )
{
result += main;
hits++;
}
}
if ( hits > 0 )
{
if ( alpha )
{
result /= hits;
}
else
{
result = float4( result.rgb / hits, ref_main.a );
}
}
else
{
result = ref_main;
}
}
else
{
result = ref_main;
}
return result;
}
ENDCG
SubShader
{
ZTest Always Cull Off ZWrite Off Fog{ Mode off }
// Dilate RGB
Pass
{
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
float4 frag( v2f_img i ) : SV_target
{
return frag_dilate( i, false );
}
ENDCG
}
// Dilate RGBA
Pass
{
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
float4 frag( v2f_img i ) : SV_target
{
return frag_dilate( i, true );
}
ENDCG
}
}
FallBack Off
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 57c23892d43bc9f458360024c5985405
timeCreated: 1519122216
licenseType: Store
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,89 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 78b2425a2284af743826c689403a4924, type: 3}
m_Name: LW Surface Output
m_EditorClassIdentifier:
m_functionInfo: "// Made with Amplify Shader Editor\n// Available at the Unity Asset
Store - http://u3d.as/y3X \n/*ASEBEGIN\nVersion=16600\n1937;-168;1048;592;1293.491;134.017;1.40646;True;False\nNode;AmplifyShaderEditor.TextureCoordinatesNode;2;-736,192;Float;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4\nNode;AmplifyShaderEditor.CustomExpressionNode;3;-480,192;Float;False;SurfaceData
surfaceData@$InitializeStandardLitSurfaceData(inputUv, surfaceData)@$albedo =
surfaceData.albedo@$normal = surfaceData.normalTS@$specular = surfaceData.specular@$smoothness
= surfaceData.smoothness@$metallic = surfaceData.metallic@$occlusion = surfaceData.occlusion@$emission
= surfaceData.emission@$alpha = surfaceData.alpha@$return surfaceData.albedo@;3;False;9;True;inputUv;FLOAT2;0,0;In;;Float;True;albedo;FLOAT3;0,0,0;Out;;Float;True;normal;FLOAT3;0,0,0;Out;;Float;True;specular;FLOAT3;0,0,0;Out;;Float;True;smoothness;FLOAT;0;Out;;Float;True;metallic;FLOAT;0;Out;;Float;True;occlusion;FLOAT;0;Out;;Float;True;emission;FLOAT3;0,0,0;Out;;Float;True;alpha;FLOAT;0;Out;;Float;AILWSurfaceOutput;False;False;0;9;0;FLOAT2;0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;3;FLOAT3;0,0,0;False;4;FLOAT;0;False;5;FLOAT;0;False;6;FLOAT;0;False;7;FLOAT3;0,0,0;False;8;FLOAT;0;False;9;FLOAT3;0;FLOAT3;2;FLOAT3;3;FLOAT3;4;FLOAT;5;FLOAT;6;FLOAT;7;FLOAT3;8;FLOAT;9\nNode;AmplifyShaderEditor.CustomExpressionNode;1;-894,216;Float;False;#if
UNITY_VERSION >= 201910$\tOffset = _BaseMap_ST.zw@$\treturn _BaseMap_ST.xy@$#else$\tOffset
= _MainTex_ST.zw@$\treturn _MainTex_ST.xy@$#endif;2;False;1;True;Offset;FLOAT2;0,0;Out;;Float;AIBaseMapST;False;False;0;1;0;FLOAT2;0,0;False;2;FLOAT2;0;FLOAT2;1\nNode;AmplifyShaderEditor.FunctionOutput;0;0,0;Float;False;True;albedo;0;False;1;0;FLOAT3;0,0,0;False;1;FLOAT3;0\nNode;AmplifyShaderEditor.FunctionOutput;4;0,80;Float;False;False;normal;1;False;1;0;FLOAT3;0,0,0;False;1;FLOAT3;0\nNode;AmplifyShaderEditor.FunctionOutput;5;0,160;Float;False;False;specular;2;False;1;0;FLOAT3;0,0,0;False;1;FLOAT3;0\nNode;AmplifyShaderEditor.FunctionOutput;6;0,240;Float;False;False;smoothness;3;False;1;0;FLOAT;0;False;1;FLOAT;0\nNode;AmplifyShaderEditor.FunctionOutput;7;0,320;Float;False;False;metallic;4;False;1;0;FLOAT;0;False;1;FLOAT;0\nNode;AmplifyShaderEditor.FunctionOutput;8;0,400;Float;False;False;occlusion;5;False;1;0;FLOAT;0;False;1;FLOAT;0\nNode;AmplifyShaderEditor.FunctionOutput;9;0,480;Float;False;False;emission;6;False;1;0;FLOAT3;0,0,0;False;1;FLOAT3;0\nNode;AmplifyShaderEditor.FunctionOutput;10;0,560;Float;False;False;alpha;7;False;1;0;FLOAT;0;False;1;FLOAT;0\nWireConnection;2;0;1;0\nWireConnection;2;1;1;1\nWireConnection;3;0;2;0\nWireConnection;0;0;3;2\nWireConnection;4;0;3;3\nWireConnection;5;0;3;4\nWireConnection;6;0;3;5\nWireConnection;7;0;3;6\nWireConnection;8;0;3;7\nWireConnection;9;0;3;8\nWireConnection;10;0;3;9\nASEEND*/\n//CHKSM=DDFC76478753BE09B2F62873DF6B8937C1708562"
m_functionName:
m_description:
m_additionalIncludes:
m_additionalIncludes: []
m_outsideIncludes: []
m_additionalPragmas:
m_additionalPragmas: []
m_outsidePragmas: []
m_additionalDirectives:
m_validData: 0
m_isDirty: 1
m_moduleName: ' Additional Directives'
m_independentModule: 1
m_additionalDirectives:
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
m_shaderFunctionDirectives: []
m_nativeDirectives: []
m_nativeDirectivesFoldout: 0
m_directivesSaveItems:
- LineType: 2
LineValue: shader_feature _SPECULAR_SETUP
GUIDToggle: 0
GUIDValue:
- LineType: 2
LineValue: shader_feature _METALLICSPECGLOSSMAP
GUIDToggle: 0
GUIDValue:
- LineType: 2
LineValue: shader_feature _SPECGLOSSMAP
GUIDToggle: 0
GUIDValue:
- LineType: 2
LineValue: shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
GUIDToggle: 0
GUIDValue:
- LineType: 2
LineValue: shader_feature _NORMALMAP
GUIDToggle: 0
GUIDValue:
- LineType: 2
LineValue: shader_feature _OCCLUSIONMAP
GUIDToggle: 0
GUIDValue:
- LineType: 2
LineValue: shader_feature _EMISSION
GUIDToggle: 0
GUIDValue:
- LineType: 2
LineValue: shader_feature _ALPHATEST_ON
GUIDToggle: 0
GUIDValue:
- LineType: 0
LineValue: Packages/com.unity.render-pipelines.lightweight/Shaders/LitInput.hlsl
GUIDToggle: 0
GUIDValue:
m_nodeCategory: 3
m_customNodeCategory:
m_previewPosition: 0
m_hidden: 0

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e2be1502f7ed00d41bfee12016ebf14e
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,39 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 78b2425a2284af743826c689403a4924, type: 3}
m_Name: Pack Lightmap RGBM
m_EditorClassIdentifier:
m_functionInfo: "// Made with Amplify Shader Editor\n// Available at the Unity Asset
Store - http://u3d.as/y3X \n/*ASEBEGIN\nVersion=16307\n1927;-213;1066;963;822;473;1;True;False\nNode;AmplifyShaderEditor.CustomExpressionNode;1;-192,0;Float;False;#ifdef
UNITY_CG_INCLUDED$return UnityEncodeRGBM(RGB, EMISSIVE_RGBM_SCALE)@$#else$return
PackEmissiveRGBM(RGB)@$#endif;4;False;1;True;RGB;FLOAT3;0,0,0;In;;Float;ASEPackLightmap;False;False;0;1;0;FLOAT3;0,0,0;False;1;FLOAT4;0\nNode;AmplifyShaderEditor.FunctionInput;2;-384,0;Float;False;RGB;3;0;False;1;0;FLOAT3;0,0,0;False;1;FLOAT3;0\nNode;AmplifyShaderEditor.FunctionOutput;0;0,0;Float;False;True;Out;0;False;1;0;FLOAT4;0,0,0,0;False;1;FLOAT4;0\nWireConnection;1;0;2;0\nWireConnection;0;0;1;0\nASEEND*/\n//CHKSM=960FDC61487D8F7526E63C87C9F209A934FEDE00"
m_functionName:
m_description:
m_additionalIncludes:
m_additionalIncludes: []
m_outsideIncludes: []
m_additionalPragmas:
m_additionalPragmas: []
m_outsidePragmas: []
m_additionalDirectives:
m_validData: 0
m_isDirty: 0
m_moduleName: ' Additional Directives'
m_independentModule: 1
m_additionalDirectives: []
m_shaderFunctionDirectives: []
m_nativeDirectives: []
m_nativeDirectivesFoldout: 0
m_directivesSaveItems: []
m_nodeCategory: 3
m_customNodeCategory:
m_previewPosition: 0
m_hidden: 0

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d7520c37495f89245ab2431d8b82f8ce
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,46 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 78b2425a2284af743826c689403a4924, type: 3}
m_Name: Pack Normal Depth
m_EditorClassIdentifier:
m_functionInfo: "// Made with Amplify Shader Editor v1.9.8.1\n// Available at the
Unity Asset Store - http://u3d.as/y3X \n/*ASEBEGIN\nVersion=19801\nNode;AmplifyShaderEditor.DynamicAppendNode;11;-368,32;Inherit;False;FLOAT4;4;0;FLOAT3;0,0,0;False;1;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;0;False;1;FLOAT4;0\nNode;AmplifyShaderEditor.Vector3Node;13;-1280,32;Float;False;Constant;_Vector0;Vector
0;0;0;Create;True;0;0;0;False;0;False;0,0,1;0,0,0;0;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3\nNode;AmplifyShaderEditor.WorldNormalVector;8;-896,32;Inherit;False;False;1;0;FLOAT3;0,0,1;False;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3\nNode;AmplifyShaderEditor.ScaleAndOffsetNode;10;-640,32;Inherit;False;3;0;FLOAT3;0,0,0;False;1;FLOAT;0.5;False;2;FLOAT;0.5;False;1;FLOAT3;0\nNode;AmplifyShaderEditor.FunctionInput;12;-1072,32;Inherit;False;Normal;3;0;False;1;0;FLOAT3;0,0,0;False;1;FLOAT3;0\nNode;AmplifyShaderEditor.WireNode;17;-688,160;Inherit;False;1;0;FLOAT3;0,0,0;False;1;FLOAT3;0\nNode;AmplifyShaderEditor.WireNode;16;-704,144;Inherit;False;1;0;FLOAT3;0,0,0;False;1;FLOAT3;0\nNode;AmplifyShaderEditor.SurfaceDepthNode;5;-672,224;Inherit;False;3;1;0;FLOAT3;0,0,0;False;1;FLOAT;0\nNode;AmplifyShaderEditor.FunctionOutput;0;-128,32;Inherit;False;True;-1;Out;0;False;1;0;FLOAT4;0,0,0,0;False;1;FLOAT4;0\nNode;AmplifyShaderEditor.FunctionOutput;14;-128,128;Inherit;False;False;-1;World
Normal;1;False;1;0;FLOAT3;0,0,0;False;1;FLOAT3;0\nNode;AmplifyShaderEditor.FunctionOutput;15;-128,224;Inherit;False;False;-1;Depth;2;False;1;0;FLOAT;0;False;1;FLOAT;0\nWireConnection;11;0;10;0\nWireConnection;11;3;5;0\nWireConnection;8;0;12;0\nWireConnection;10;0;8;0\nWireConnection;12;0;13;0\nWireConnection;17;0;16;0\nWireConnection;16;0;8;0\nWireConnection;0;0;11;0\nWireConnection;14;0;17;0\nWireConnection;15;0;5;0\nASEEND*/\n//CHKSM=D5537877CD415BB76CEF4C7C461D1816113ECD94"
m_functionName:
m_description: Packs the appropriate values for Normal and Depth into a RGBA output,
for custom impostor baking shaders.
m_additionalIncludes:
m_additionalIncludes: []
m_outsideIncludes: []
m_additionalPragmas:
m_additionalPragmas: []
m_outsidePragmas: []
m_additionalDirectives:
m_validData: 0
m_isDirty: 0
m_moduleName: ' Additional Directives'
m_independentModule: 1
m_customEdited: 0
m_additionalDirectives: []
m_shaderFunctionDirectives: []
m_nativeDirectives: []
m_nativeDirectivesIndex: -1
m_nativeDirectivesFoldout: 0
m_directivesSaveItems: []
m_nodeCategory: 0
m_headerStyle: 0
m_headerColor: {r: 1, g: 0.4, b: 0, a: 1}
m_customNodeCategory: Amplify Impostor Baking
m_previewPosition: 0
m_hidden: 0
m_url:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 8e386dbec347c9f44befea8ff816d188
timeCreated: 1533740780
licenseType: Store
NativeFormatImporter:
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,44 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 78b2425a2284af743826c689403a4924, type: 3}
m_Name: Pack Position
m_EditorClassIdentifier:
m_functionInfo: "// Made with Amplify Shader Editor v1.9.8.1\n// Available at the
Unity Asset Store - http://u3d.as/y3X \n/*ASEBEGIN\nVersion=19801\nNode;AmplifyShaderEditor.Vector3Node;18;-944,192;Inherit;False;Global;_AI_BoundsMin;_AI_BoundsMin;68;0;Create;True;0;0;0;False;0;False;0,0,0;-5.651775,-2.861023E-06,-5.795368;0;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3\nNode;AmplifyShaderEditor.WorldPosInputsNode;19;-912,32;Inherit;False;0;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3\nNode;AmplifyShaderEditor.SimpleSubtractOpNode;20;-688,32;Inherit;False;2;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;1;FLOAT3;0\nNode;AmplifyShaderEditor.Vector3Node;21;-656,144;Inherit;False;Global;_AI_BoundsSize;_AI_BoundsSize;68;0;Create;True;0;0;0;False;0;False;0,0,0;11.74819,17.99618,11.29399;0;4;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3\nNode;AmplifyShaderEditor.SimpleDivideOpNode;22;-400,32;Inherit;False;2;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;1;FLOAT3;0\nNode;AmplifyShaderEditor.FunctionOutput;0;-128,32;Inherit;False;True;-1;Out;0;False;1;0;FLOAT3;0,0,0;False;1;FLOAT3;0\nWireConnection;20;0;19;0\nWireConnection;20;1;18;0\nWireConnection;22;0;20;0\nWireConnection;22;1;21;0\nWireConnection;0;0;22;0\nASEEND*/\n//CHKSM=A3C701025F011AC9D65E95BA33D722431FD4AC05"
m_functionName:
m_description: Packs the appropriate Position value into a RGB output, for custom
impostor baking shaders.
m_additionalIncludes:
m_additionalIncludes: []
m_outsideIncludes: []
m_additionalPragmas:
m_additionalPragmas: []
m_outsidePragmas: []
m_additionalDirectives:
m_validData: 0
m_isDirty: 0
m_moduleName: ' Additional Directives'
m_independentModule: 1
m_customEdited: 0
m_additionalDirectives: []
m_shaderFunctionDirectives: []
m_nativeDirectives: []
m_nativeDirectivesIndex: -1
m_nativeDirectivesFoldout: 0
m_directivesSaveItems: []
m_nodeCategory: 0
m_headerStyle: 0
m_headerColor: {r: 1, g: 0.4, b: 0, a: 1}
m_customNodeCategory: Amplify Impostor Baking
m_previewPosition: 0
m_hidden: 0
m_url:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f75fe2559c5388d42bf4914fdb8a9281
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,531 @@
// Amplify Impostors
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
Shader "Hidden/ShaderPacker"
{
Properties
{
_MainTex("_MainTex", 2D) = "white" {}
_A("A", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
ZWrite Off
ZTest Always
ColorMask RGBA
Blend Off
Cull Off
Offset 0,0
Pass // Pack Depth 0
{
CGPROGRAM
#pragma target 3.0
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
uniform sampler2D _A;
float4 frag( v2f_img i ) : SV_Target
{
float depth = tex2D( _A, i.uv ).r;
#if UNITY_REVERSED_Z != 1
depth = 1-depth;
#endif
float4 finalColor = (float4(tex2D( _MainTex, i.uv ).rgb , depth));
return finalColor;
}
ENDCG
}
Pass // Fix Emission 1
{
CGPROGRAM
#pragma target 3.0
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
float4 frag (v2f_img i ) : SV_Target
{
float4 finalColor = tex2D( _MainTex, i.uv );
//#if !defined(UNITY_HDR_ON)
finalColor.rgb = -log2(finalColor.rgb);
//#endif
return finalColor;
}
ENDCG
}
Pass // Render Only Alpha (for the inspector) 2
{
CGPROGRAM
#pragma target 3.0
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
float4 frag (v2f_img i ) : SV_Target
{
float4 finalColor = tex2D( _MainTex, i.uv );
return float4(0,0,0,finalColor.a);
}
ENDCG
}
Pass // 3
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
#include "UnityCG.cginc"
sampler2D _MainTex;
uniform float4 _MainTex_ST;
uniform float4x4 unity_GUIClipTextureMatrix;
sampler2D _GUIClipTexture;
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
float2 texcoord : TEXCOORD0;
float2 clipUV : TEXCOORD1;
};
v2f vert( appdata_t v )
{
v2f o;
o.vertex = UnityObjectToClipPos( v.vertex );
o.texcoord = TRANSFORM_TEX( v.texcoord.xy, _MainTex );
float3 eyePos = UnityObjectToViewPos( v.vertex );
o.clipUV = mul( unity_GUIClipTextureMatrix, float4( eyePos.xy, 0, 1.0 ) );
return o;
}
float4 frag( v2f i ) : SV_Target
{
float2 fraction = sign(frac(i.texcoord * 5) * 2 - 1);
float3 back = saturate(fraction.x*fraction.y) * 0.125 + 0.275 + 0.05;
float4 c = tex2D( _MainTex, i.texcoord );
c.rgb = lerp( back, c.rgb, c.a );
c.a = tex2D( _GUIClipTexture, i.clipUV ).a;
return c;
}
ENDCG
}
Pass // Copy Alpha 4
{
CGPROGRAM
#pragma target 3.0
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
uniform sampler2D _A;
fixed4 frag (v2f_img i ) : SV_Target
{
float alpha = tex2D( _A, i.uv ).a;
fixed4 finalColor = (float4(tex2D( _MainTex, i.uv ).rgb , alpha));
return finalColor;
}
ENDCG
}
Pass // Fix albedo 5
{
CGPROGRAM
#pragma target 3.0
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
uniform sampler2D _A; //specular
fixed4 frag (v2f_img i ) : SV_Target
{
float3 spec = tex2D( _A, i.uv ).rgb;
float4 alb = tex2D( _MainTex, i.uv );
alb.rgb = alb.rgb / (1-spec);
return alb;
}
ENDCG
}
Pass // TGA BGR format 6
{
CGPROGRAM
#pragma target 3.0
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
fixed4 frag(v2f_img i) : SV_Target
{
return tex2D(_MainTex, i.uv).bgra;
}
ENDCG
}
Pass // point sampling 7
{
CGPROGRAM
#pragma target 3.0
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
fixed4 frag(v2f_img i) : SV_Target
{
return tex2Dlod(_MainTex, float4(i.uv, 0, 0));
}
ENDCG
}
Pass // point sampling alpha 8
{
CGPROGRAM
#pragma target 3.0
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
fixed4 frag(v2f_img i) : SV_Target
{
fixed4 finalColor = tex2Dlod(_MainTex, float4(i.uv, 0, 0));
return float4(0, 0, 0, finalColor.a);
}
ENDCG
}
Pass // transform normal 9
{
CGPROGRAM
#pragma target 3.0
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
uniform float4x4 _Matrix;
fixed4 frag(v2f_img i) : SV_Target
{
fixed4 finalColor = tex2Dlod(_MainTex, float4(i.uv, 0, 0));
finalColor.xyz = mul(_Matrix, float4(finalColor.xyz * 2 - 1,1)).xyz * 0.5 + 0.5;
return finalColor;
}
ENDCG
}
Pass // deffered normal HD 10
{
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
float2 texcoord : TEXCOORD0;
};
float2 Unpack888ToFloat2( float3 x )
{
uint3 i = ( uint3 )( x * 255.0 );
uint hi = i.z >> 4;
uint lo = i.z & 15;
uint2 cb = i.xy | uint2( lo << 8, hi << 8 );
return cb / 4095.0;
}
float3 UnpackNormalOctQuadEncode( float2 f )
{
float3 n = float3( f.x, f.y, 1.0 - abs( f.x ) - abs( f.y ) );
float t = max( -n.z, 0.0 );
n.xy += n.xy >= 0.0 ? -t.xx : t.xx;
return normalize( n );
}
v2f vert (appdata_t v)
{
v2f o;
UNITY_INITIALIZE_OUTPUT(v2f, o);
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = v.texcoord.xy;
return o;
}
float4 frag( v2f i ) : SV_Target
{
float4 normalBuffer = tex2D( _MainTex, i.texcoord );
float alpha = 0;
if( normalBuffer.a != 0 )
alpha = 1;
float2 octNormalWS = Unpack888ToFloat2( normalBuffer.xyz );
float3 normalWS = UnpackNormalOctQuadEncode( octNormalWS * 2.0 - 1.0 );
float perceptualRoughness = normalBuffer.a;
return float4( ( normalWS * 0.5 + 0.5 ) * alpha, ( 1 - perceptualRoughness ) * alpha );
}
ENDCG
}
Pass // copy depth 11
{
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma target 3.0
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
uniform sampler2D _A;
float4 frag( v2f_img i ) : SV_Target
{
float depth = SAMPLE_RAW_DEPTH_TEXTURE( _MainTex, i.uv ).r;
#if !defined( UNITY_REVERSED_Z )
depth = 1 - depth;
#endif
float3 color = tex2D( _A, i.uv ).rgb;
float alpha = 1 - step( depth, 0 );
return float4( color, alpha );
}
ENDCG
}
Pass // copy 12
{
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma target 3.0
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
uint UnpackInt( float f, uint numBits )
{
uint maxInt = ( 1u << numBits ) - 1u;
return ( uint )( f * maxInt + 0.5 ); // Round instead of truncating
}
uint PackFloatToUInt( float src, uint offset, uint numBits )
{
return UnpackInt( src, numBits ) << offset;
}
float3 UnpackFromR11G11B10f( uint rgb )
{
float r = f16tof32( ( rgb >> 17 ) & 0x7FF0 );
float g = f16tof32( ( rgb >> 6 ) & 0x7FF0 );
float b = f16tof32( ( rgb << 5 ) & 0x7FE0 );
return float3( r, g, b );
}
float4 frag( v2f_img i ) : SV_Target
{
float4 col = tex2D( _MainTex, i.uv );
uint3 s = 0;
s.r = PackFloatToUInt( col.r, 0, 11 );
s.g = PackFloatToUInt( col.r, 11, 11 );
s.b = PackFloatToUInt( col.r, 22, 10 );
float3 t = UnpackFromR11G11B10f( s );
//col.rgb = UnpackFromR11G11B10f( col.rgb );
return col;
//return float4( t.x,0,0, 1 );
}
ENDCG
}
Pass // copy and decode features and diffusion 13
{
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma target 3.0
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
float PackInt(uint i, uint numBits)
{
uint maxInt = (1u << numBits) - 1u;
return saturate(i * rcp(maxInt));
}
uint UnpackInt(float f, uint numBits)
{
uint maxInt = (1u << numBits) - 1u;
return (uint)(f * maxInt + 0.5);
}
void UnpackFloatInt(float val, float maxi, float precision, out float f, out uint i)
{
float precisionMinusOne = precision - 1.0;
float t1 = ((precision / maxi) - 1.0) / precisionMinusOne;
float t2 = (precision / maxi) / precisionMinusOne;
i = int((val / t2) + rcp(precisionMinusOne));
f = saturate((-t2 * float(i) + val) / t1);
}
void UnpackFloatInt8bit(float val, float maxi, out float f, out uint i)
{
UnpackFloatInt(val, maxi, 256.0, f, i);
}
#define MATERIALFEATUREFLAGS_LIT_STANDARD (1)
#define MATERIALFEATUREFLAGS_LIT_SPECULAR_COLOR (2)
#define MATERIALFEATUREFLAGS_LIT_SUBSURFACE_SCATTERING (4)
#define MATERIALFEATUREFLAGS_LIT_TRANSMISSION (8)
#define MATERIALFEATUREFLAGS_LIT_ANISOTROPY (16)
#define MATERIALFEATUREFLAGS_LIT_IRIDESCENCE (32)
#define MATERIALFEATUREFLAGS_LIT_CLEAR_COAT (64)
#define GBUFFER_LIT_STANDARD 0
#define GBUFFER_LIT_SSS 1
#define GBUFFER_LIT_TRANSMISSION 2
#define GBUFFER_LIT_TRANSMISSION_SSS 3
#define GBUFFER_LIT_ANISOTROPIC 4
#define GBUFFER_LIT_IRIDESCENCE 5
#define UINT_MAX 0xFFFFFFFFu
#define MATERIAL_FEATURE_MASK_FLAGS (4095)
float _DiffusionProfileHashTable[16];
uint FindDiffusionProfileHash(uint diffusionProfileIndex)
{
if (diffusionProfileIndex == 0)
return 0;
uint diffusionProfileHash = 0;
uint i = 0;
diffusionProfileHash = asuint(_DiffusionProfileHashTable[diffusionProfileIndex]);
return diffusionProfileHash;
}
float4 frag( v2f_img i ) : SV_Target
{
float4 src = tex2D( _MainTex, i.uv );
float coatMask;
uint materialFeatureId;
uint tileFeatureFlags = UINT_MAX;
tileFeatureFlags &= MATERIAL_FEATURE_MASK_FLAGS;
UnpackFloatInt8bit( src.a, 8, coatMask, materialFeatureId );
uint pixelFeatureFlags = MATERIALFEATUREFLAGS_LIT_STANDARD;
bool pixelHasSubsurface = materialFeatureId == GBUFFER_LIT_TRANSMISSION_SSS || materialFeatureId == GBUFFER_LIT_SSS;
bool pixelHasTransmission = materialFeatureId == GBUFFER_LIT_TRANSMISSION_SSS || materialFeatureId == GBUFFER_LIT_TRANSMISSION;
bool pixelHasAnisotropy = materialFeatureId == GBUFFER_LIT_ANISOTROPIC;
bool pixelHasIridescence = materialFeatureId == GBUFFER_LIT_IRIDESCENCE;
bool pixelHasClearCoat = coatMask > 0.0;
pixelFeatureFlags |= tileFeatureFlags & (pixelHasSubsurface ? MATERIALFEATUREFLAGS_LIT_SUBSURFACE_SCATTERING : 0);
pixelFeatureFlags |= tileFeatureFlags & (pixelHasTransmission ? MATERIALFEATUREFLAGS_LIT_TRANSMISSION : 0);
pixelFeatureFlags |= tileFeatureFlags & (pixelHasAnisotropy ? MATERIALFEATUREFLAGS_LIT_ANISOTROPY : 0);
pixelFeatureFlags |= tileFeatureFlags & (pixelHasIridescence ? MATERIALFEATUREFLAGS_LIT_IRIDESCENCE : 0);
pixelFeatureFlags |= tileFeatureFlags & (pixelHasClearCoat ? MATERIALFEATUREFLAGS_LIT_CLEAR_COAT : 0);
float3 hash = 0;
if( pixelHasSubsurface || pixelHasTransmission )
{
float subsurfaceMask;
uint diffusionProfileIndex;
UnpackFloatInt8bit( src.b, 16, subsurfaceMask, diffusionProfileIndex );
uint diffusionProfileHash = FindDiffusionProfileHash( diffusionProfileIndex );
hash.r = PackInt( ( diffusionProfileHash >> 16 ) & 0x000000FF, 8 );
hash.g = PackInt( ( diffusionProfileHash >> 8 ) & 0x000000FF, 8 );
hash.b = PackInt( ( diffusionProfileHash >> 0 ) & 0x000000FF, 8 );
//uint r = UnpackInt(hash.r, 8) << 16;
//uint g = UnpackInt(hash.g, 8) << 8;
//uint b = UnpackInt(hash.b, 8);
//uint Test = ( 0x40 << 24) | r | g | b;
//if( Test == diffusionProfileHash )
// hash = 1;
//else
// hash = 0;
//hash = asfloat(diffusionProfileHash);
}
return float4( hash, src.a );
//return float4( 0,src.g ,src.b, src.a );
}
ENDCG
}
Pass // 14 point resize
{
CGPROGRAM
#pragma target 3.0
#pragma vertex vert_img
#pragma fragment frag
#include "UnityCG.cginc"
Texture2D _MainTex;
SamplerState sampler_MainTex_Point_Repeat;
//uniform sampler2D _MainTex;
fixed4 frag(v2f_img i) : SV_Target
{
return UNITY_SAMPLE_TEX2D_SAMPLER(_MainTex,_MainTex_Point_Repeat,i.uv);
//return tex2D(_MainTex, i.uv);
}
ENDCG
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 31bd3cd74692f384a916d9d7ea87710d
timeCreated: 1524073284
licenseType: Store
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,100 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 78b2425a2284af743826c689403a4924, type: 3}
m_Name: Universal Surface Output
m_EditorClassIdentifier:
m_functionInfo: "// Made with Amplify Shader Editor\n// Available at the Unity Asset
Store - http://u3d.as/y3X \n/*ASEBEGIN\nVersion=17501\n-1543;-544;1159;937;1371.55;376.6313;1.40646;True;False\nNode;AmplifyShaderEditor.CustomExpressionNode;3;-480,192;Float;False;SurfaceData
surfaceData@$InitializeStandardLitSurfaceData(inputUv, surfaceData)@$albedo =
surfaceData.albedo@$normal = surfaceData.normalTS@$specular = surfaceData.specular@$smoothness
= surfaceData.smoothness@$metallic = surfaceData.metallic@$occlusion = surfaceData.occlusion@$emission
= surfaceData.emission@$alpha = surfaceData.alpha@$BRDFData brdfData@$InitializeBRDFData(surfaceData.albedo,
surfaceData.metallic, surfaceData.specular, surfaceData.smoothness, surfaceData.alpha,
brdfData)@$albedo = brdfData.diffuse@$specular = brdfData.specular@$return surfaceData.albedo@;3;False;9;True;inputUv;FLOAT2;0,0;In;;Float;False;True;albedo;FLOAT3;0,0,0;Out;;Float;False;True;normal;FLOAT3;0,0,0;Out;;Float;False;True;specular;FLOAT3;0,0,0;Out;;Float;False;True;smoothness;FLOAT;0;Out;;Float;False;True;metallic;FLOAT;0;Out;;Float;False;True;occlusion;FLOAT;0;Out;;Float;False;True;emission;FLOAT3;0,0,0;Out;;Float;False;True;alpha;FLOAT;0;Out;;Float;False;AIUSurfaceOutput;False;False;0;9;0;FLOAT2;0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;3;FLOAT3;0,0,0;False;4;FLOAT;0;False;5;FLOAT;0;False;6;FLOAT;0;False;7;FLOAT3;0,0,0;False;8;FLOAT;0;False;9;FLOAT3;0;FLOAT3;2;FLOAT3;3;FLOAT3;4;FLOAT;5;FLOAT;6;FLOAT;7;FLOAT3;8;FLOAT;9\nNode;AmplifyShaderEditor.CustomExpressionNode;1;-894,216;Float;False;#if
UNITY_VERSION >= 201910$\tOffset = _BaseMap_ST.zw@$\treturn _BaseMap_ST.xy@$#else$\tOffset
= _MainTex_ST.zw@$\treturn _MainTex_ST.xy@$#endif;2;False;1;True;Offset;FLOAT2;0,0;Out;;Float;False;AIBaseMapST;False;False;0;1;0;FLOAT2;0,0;False;2;FLOAT2;0;FLOAT2;1\nNode;AmplifyShaderEditor.TextureCoordinatesNode;2;-736,192;Inherit;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4\nNode;AmplifyShaderEditor.FunctionOutput;8;0,400;Inherit;False;False;-1;occlusion;5;False;1;0;FLOAT;0;False;1;FLOAT;0\nNode;AmplifyShaderEditor.FunctionOutput;9;0,480;Inherit;False;False;-1;emission;6;False;1;0;FLOAT3;0,0,0;False;1;FLOAT3;0\nNode;AmplifyShaderEditor.FunctionOutput;10;0,560;Inherit;False;False;-1;alpha;7;False;1;0;FLOAT;0;False;1;FLOAT;0\nNode;AmplifyShaderEditor.FunctionOutput;7;0,320;Inherit;False;False;-1;metallic;4;False;1;0;FLOAT;0;False;1;FLOAT;0\nNode;AmplifyShaderEditor.FunctionOutput;4;0,80;Inherit;False;False;-1;normal;1;False;1;0;FLOAT3;0,0,0;False;1;FLOAT3;0\nNode;AmplifyShaderEditor.FunctionOutput;0;0,0;Inherit;False;True;-1;albedo;0;False;1;0;FLOAT3;0,0,0;False;1;FLOAT3;0\nNode;AmplifyShaderEditor.FunctionOutput;6;0,240;Inherit;False;False;-1;smoothness;3;False;1;0;FLOAT;0;False;1;FLOAT;0\nNode;AmplifyShaderEditor.FunctionOutput;5;0,160;Inherit;False;False;-1;specular;2;False;1;0;FLOAT3;0,0,0;False;1;FLOAT3;0\nWireConnection;3;0;2;0\nWireConnection;2;0;1;0\nWireConnection;2;1;1;1\nWireConnection;8;0;3;7\nWireConnection;9;0;3;8\nWireConnection;10;0;3;9\nWireConnection;7;0;3;6\nWireConnection;4;0;3;3\nWireConnection;0;0;3;2\nWireConnection;6;0;3;5\nWireConnection;5;0;3;4\nASEEND*/\n//CHKSM=C53F96DA3A853E395D1322ED18E582058108A328"
m_functionName:
m_description:
m_additionalIncludes:
m_additionalIncludes: []
m_outsideIncludes: []
m_additionalPragmas:
m_additionalPragmas: []
m_outsidePragmas: []
m_additionalDirectives:
m_validData: 0
m_isDirty: 1
m_moduleName: ' Additional Directives'
m_independentModule: 1
m_additionalDirectives:
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
m_shaderFunctionDirectives: []
m_nativeDirectives: []
m_nativeDirectivesIndex: -1
m_nativeDirectivesFoldout: 0
m_directivesSaveItems:
- LineType: 2
LineValue: shader_feature _SPECULAR_SETUP
GUIDToggle: 0
GUIDValue:
Origin: 2
- LineType: 2
LineValue: shader_feature _METALLICSPECGLOSSMAP
GUIDToggle: 0
GUIDValue:
Origin: 2
- LineType: 2
LineValue: shader_feature _SPECGLOSSMAP
GUIDToggle: 0
GUIDValue:
Origin: 2
- LineType: 2
LineValue: shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
GUIDToggle: 0
GUIDValue:
Origin: 2
- LineType: 2
LineValue: shader_feature _NORMALMAP
GUIDToggle: 0
GUIDValue:
Origin: 2
- LineType: 2
LineValue: shader_feature _OCCLUSIONMAP
GUIDToggle: 0
GUIDValue:
Origin: 2
- LineType: 2
LineValue: shader_feature _EMISSION
GUIDToggle: 0
GUIDValue:
Origin: 2
- LineType: 2
LineValue: shader_feature _ALPHATEST_ON
GUIDToggle: 0
GUIDValue:
Origin: 2
- LineType: 0
LineValue: Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl
GUIDToggle: 0
GUIDValue:
Origin: 2
m_nodeCategory: 3
m_customNodeCategory:
m_previewPosition: 0
m_hidden: 0

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4220f49336ae49347952a65dcdfa5710
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,14 @@
Before installing HDRP or URP support packages:
Install HDRP (com.unity.render-pipelines.high-definition) or URP (com.unity.render-pipelines.universal)
via Package Manager
Unity SRP support packages are provided as follows:
* URP Shaders 10x.unitypackage => for URP 10.x and 11.x
* HDRP Shaders 10x.unitypackage => for HDRP 10.x and 11.x
* URP Shaders 12x.unitypackage => for URP 12.x and 13.x
* HDRP Shaders 12x.unitypackage => for HDRP 12.x and 13.x
* URP Shaders 14x.unitypackage => for URP 14.x and 15.x
* HDRP Shaders 14x.unitypackage => for HDRP 14.x and 15.x

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: abfe587e51b78c748adca176f5176a07
timeCreated: 1481127071
licenseType: Store
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 52e87e2b501b12844ab12184f0a45989
folderAsset: yes
timeCreated: 1526998688
licenseType: Store
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,721 @@
// Amplify Impostors
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
#ifndef AMPLIFYIMPOSTORS_INCLUDED
#define AMPLIFYIMPOSTORS_INCLUDED
#include "AmplifyImpostorsConfig.cginc"
//#define AI_DEPTH_OPTIMIZATION
#if defined( SHADER_API_D3D11 ) && defined( AI_DEPTH_OPTIMIZATION )
#define AI_POSITION_QUALIFIERS linear noperspective centroid
#define AI_DEPTH_SEMANTIC SV_DepthLessEqual
// NOTE: not fully implemented yet
// vertex stage => positionCS += DepthOptimization_ClipPositionOffset();
#else
#undef AI_DEPTH_OPTIMIZATION
#define AI_POSITION_QUALIFIERS
#define AI_DEPTH_SEMANTIC SV_Depth
#endif
#if ( defined( AI_HD_RENDERPIPELINE ) || defined( AI_LW_RENDERPIPELINE ) ) && !defined( AI_RENDERPIPELINE )
#define AI_RENDERPIPELINE
#endif
float2 VectorToOctahedron( float3 N )
{
N /= dot( 1.0, abs( N ) );
if ( N.z <= 0 )
{
N.xy = ( 1 - abs( N.yx ) ) * ( N.xy >= 0 ? 1.0 : -1.0 );
}
return N.xy;
}
float2 VectorToHemiOctahedron( float3 N )
{
N.xy /= dot( 1.0, abs( N ) );
return float2( N.x + N.y, N.x - N.y );
}
float3 OctahedronToVector( float2 Oct )
{
float3 N = float3( Oct, 1.0 - dot( 1.0, abs( Oct ) ) );
if ( N.z < 0 )
{
N.xy = ( 1 - abs( N.yx ) ) * ( N.xy >= 0 ? 1.0 : -1.0 );
}
return normalize( N );
}
float3 HemiOctahedronToVector( float2 Oct )
{
Oct = float2( Oct.x + Oct.y, Oct.x - Oct.y ) *0.5;
float3 N = float3( Oct, 1 - dot( 1.0, abs( Oct ) ) );
return normalize( N );
}
sampler2D _Albedo;
sampler2D _Normals;
#if defined( AI_RENDERPIPELINE )
TEXTURE2D( _Specular );
SAMPLER( sampler_Specular );
#else
sampler2D _Specular;
#endif
sampler2D _Occlusion;
sampler2D _Emission;
sampler2D _Position;
CBUFFER_START( UnityPerMaterial )
float _FramesX;
float _FramesY;
float _Frames;
float _ImpostorSize;
float _Parallax;
float _TextureBias;
float _ClipMask;
float _DepthSize;
float _AI_ShadowBias;
float _AI_ShadowView;
float _AI_ForwardBias;
float4 _Offset;
float4 _AI_SizeOffset;
float4 _AI_BoundsMin;
float4 _AI_BoundsSize;
#if defined( EFFECT_HUE_VARIATION )
half4 _HueVariation;
#endif
CBUFFER_END
#ifdef AI_RENDERPIPELINE
#define AI_SAMPLEBIAS( textureName, samplerName, coord2, bias ) SAMPLE_TEXTURE2D_BIAS( textureName, samplerName, coord2, bias )
#define AI_ObjectToWorld GetObjectToWorldMatrix()
#define AI_WorldToObject GetWorldToObjectMatrix()
#define AI_INV_TWO_PI INV_TWO_PI
#define AI_PI PI
#define AI_INV_PI INV_PI
#else
#define AI_SAMPLEBIAS( textureName, samplerName, coord2, bias ) tex2Dbias( textureName, float4( coord2, 0, bias ) )
#define AI_ObjectToWorld unity_ObjectToWorld
#define AI_WorldToObject unity_WorldToObject
#define AI_INV_TWO_PI UNITY_INV_TWO_PI
#define AI_PI UNITY_PI
#define AI_INV_PI UNITY_INV_PI
#endif
float4 DepthOptimization_ClipPositionOffset()
{
#if defined( AI_DEPTH_OPTIMIZATION )
return float4( 0, 0, _DepthSize * 0.5, 0 );
#else
return 0;
#endif
}
inline void RayPlaneIntersectionUV( float3 normal, float3 rayPosition, float3 rayDirection, out float2 uvs, out float3 localNormal )
{
// n = normal
// p0 = ( 0, 0, 0 ) assuming center as zero
// l0 = ray position
// l = ray direction
// solving to:
// t = distance along ray that intersects the plane = ( ( p0 - l0 ) . n ) / ( l . n )
// p = intersection point
float lDotN = dot( rayDirection, normal ); // l . n
float p0l0DotN = dot( -rayPosition, normal ); // ( p0 - l0 ) . n
float t = p0l0DotN / lDotN; // if > 0 then it's intersecting
float3 p = rayDirection * t + rayPosition;
// create frame UVs
float3 upVector = float3( 0, 1, 0 );
float3 tangent = normalize( cross( upVector, normal ) + float3( -0.001, 0, 0 ) );
float3 bitangent = cross( tangent, normal );
float frameX = dot( p, tangent );
float frameZ = dot( p, bitangent );
uvs = -float2( frameX, frameZ ); // why negative???
if ( t <= 0.0 ) // not intersecting
{
uvs = 0;
}
float3x3 worldToLocal = float3x3( tangent, bitangent, normal ); // TBN (same as doing separate dots?, assembly looks the same)
localNormal = normalize( mul( worldToLocal, rayDirection ) );
}
inline void OctaImpostorVertex( inout float3 vertex, out float3 normal, out float4 tangent, out float4 uvsFrame1, out float4 uvsFrame2, out float4 uvsFrame3, out float4 octaFrame, out float4 viewPos )
{
// Inputs
float2 uvOffset = _AI_SizeOffset.zw;
float parallax = -_Parallax; // check sign later
float UVscale = _ImpostorSize;
float framesXY = _Frames;
float prevFrame = framesXY - 1;
float3 fractions = 1.0 / float3( framesXY, prevFrame, UVscale );
float fractionsFrame = fractions.x;
float fractionsPrevFrame = fractions.y;
float fractionsUVscale = fractions.z;
float3 worldCameraPos;
#if ( defined( SHADERPASS ) && ( defined( SHADERPASS_DEPTHNORMALSONLY ) && SHADERPASS == SHADERPASS_DEPTHNORMALSONLY ) ) || defined( UNITY_PASS_SHADOWCASTER )
float3 worldOrigin = 0;
float4 perspective = float4( 0, 0, 0, 1 );
if ( UNITY_MATRIX_P[ 3 ][ 3 ] == 1 )
{
perspective = float4( 0, 0, 5000, 0 );
worldOrigin = AI_ObjectToWorld._m03_m13_m23;
}
worldCameraPos = worldOrigin + mul( UNITY_MATRIX_I_V, perspective ).xyz;
#else
// @diogo: not using UNITY_MATRIX_I_V here due to a unity bug sending slightly different matrices between depth-only and forward passes.
if ( UNITY_MATRIX_P[ 3 ][ 3 ] == 1 )
{
worldCameraPos = AI_ObjectToWorld._m03_m13_m23 + UNITY_MATRIX_I_V._m02_m12_m22 * 5000;
}
else
{
#if defined( AI_RENDERPIPELINE )
worldCameraPos = GetCameraRelativePositionWS( _WorldSpaceCameraPos );
#else
worldCameraPos = _WorldSpaceCameraPos;
#endif
}
#endif
float3 objectCameraPosition = mul( AI_WorldToObject, float4( worldCameraPos, 1 ) ).xyz - _Offset.xyz; //ray origin
float3 objectCameraDirection = normalize( objectCameraPosition );
// @diogo: quantize to avoid a compiler bug causing mismatching values between passes
objectCameraDirection = trunc( objectCameraDirection * 65536.0 ) / 65536.0;
// Create orthogonal vectors to define the billboard
float3 upVector = float3( 0, 1, 0 );
float3 objectHorizontalVector = normalize( cross( objectCameraDirection, upVector ) );
float3 objectVerticalVector = cross( objectHorizontalVector, objectCameraDirection );
// Billboard
float2 uvExpansion = vertex.xy;
float3 billboard = objectHorizontalVector * uvExpansion.x + objectVerticalVector * uvExpansion.y;
float3 localDir = billboard - objectCameraPosition; // ray direction
// Octahedron Frame
#if defined( _HEMI_ON )
objectCameraDirection.y = max( 0.001, objectCameraDirection.y );
float2 frameOcta = VectorToHemiOctahedron( objectCameraDirection.xzy ) * 0.5 + 0.5;
#else
float2 frameOcta = VectorToOctahedron( objectCameraDirection.xzy ) * 0.5 + 0.5;
#endif
// Setup for octahedron
float2 prevOctaFrame = frameOcta * prevFrame;
float2 baseOctaFrame = floor( prevOctaFrame );
float2 fractionOctaFrame = ( baseOctaFrame * fractionsFrame );
// Octa 1
float2 octaFrame1 = ( baseOctaFrame * fractionsPrevFrame ) * 2.0 - 1.0;
#if defined( _HEMI_ON )
float3 octa1WorldY = HemiOctahedronToVector( octaFrame1 ).xzy;
#else
float3 octa1WorldY = OctahedronToVector( octaFrame1 ).xzy;
#endif
float3 octa1LocalY;
float2 uvFrame1;
RayPlaneIntersectionUV( octa1WorldY, objectCameraPosition, localDir, /*out*/ uvFrame1, /*out*/ octa1LocalY );
float2 uvParallax1 = octa1LocalY.xy * fractionsFrame * parallax;
uvFrame1 = ( uvFrame1 * fractionsUVscale + 0.5 ) * fractionsFrame + fractionOctaFrame;
uvsFrame1 = float4( uvParallax1, uvFrame1 ) - float4( 0, 0, uvOffset );
// Octa 2
float2 fractPrevOctaFrame = frac( prevOctaFrame );
float2 cornerDifference = lerp( float2( 0, 1 ) , float2( 1,0 ) , saturate( ceil( ( fractPrevOctaFrame.x - fractPrevOctaFrame.y ) ) ) );
float2 octaFrame2 = ( ( baseOctaFrame + cornerDifference ) * fractionsPrevFrame ) * 2.0 - 1.0;
#if defined( _HEMI_ON )
float3 octa2WorldY = HemiOctahedronToVector( octaFrame2 ).xzy;
#else
float3 octa2WorldY = OctahedronToVector( octaFrame2 ).xzy;
#endif
float3 octa2LocalY;
float2 uvFrame2;
RayPlaneIntersectionUV( octa2WorldY, objectCameraPosition, localDir, /*out*/ uvFrame2, /*out*/ octa2LocalY );
float2 uvParallax2 = octa2LocalY.xy * fractionsFrame * parallax;
uvFrame2 = ( uvFrame2 * fractionsUVscale + 0.5 ) * fractionsFrame + ( ( cornerDifference * fractionsFrame ) + fractionOctaFrame );
uvsFrame2 = float4( uvParallax2, uvFrame2 ) - float4( 0, 0, uvOffset );
// Octa 3
float2 octaFrame3 = ( ( baseOctaFrame + 1 ) * fractionsPrevFrame ) * 2.0 - 1.0;
#ifdef _HEMI_ON
float3 octa3WorldY = HemiOctahedronToVector( octaFrame3 ).xzy;
#else
float3 octa3WorldY = OctahedronToVector( octaFrame3 ).xzy;
#endif
float3 octa3LocalY;
float2 uvFrame3;
RayPlaneIntersectionUV( octa3WorldY, objectCameraPosition, localDir, /*out*/ uvFrame3, /*out*/ octa3LocalY );
float2 uvParallax3 = octa3LocalY.xy * fractionsFrame * parallax;
uvFrame3 = ( uvFrame3 * fractionsUVscale + 0.5 ) * fractionsFrame + ( fractionOctaFrame + fractionsFrame );
uvsFrame3 = float4( uvParallax3, uvFrame3 ) - float4( 0, 0, uvOffset );
// maybe remove this?
octaFrame = 0;
octaFrame.xy = prevOctaFrame;
#if defined( AI_CLIP_NEIGHBOURS_FRAMES )
octaFrame.zw = fractionOctaFrame;
#endif
vertex = billboard + _Offset.xyz;
normal = objectCameraDirection;
tangent = float4( objectHorizontalVector, 1 );
// view pos
viewPos = 0;
#if defined( AI_RENDERPIPELINE )
viewPos.xyz = TransformWorldToView( TransformObjectToWorld( vertex.xyz ) );
#else
viewPos.xyz = UnityObjectToViewPos( vertex.xyz );
#endif
#if defined( EFFECT_HUE_VARIATION )
float hueVariationAmount = frac( AI_ObjectToWorld[ 0 ].w + AI_ObjectToWorld[ 1 ].w + AI_ObjectToWorld[ 2 ].w );
viewPos.w = saturate( hueVariationAmount * _HueVariation.a );
#endif
}
inline void OctaImpostorVertex( inout float4 vertex, out float3 normal, out float4 tangent, out float4 uvsFrame1, out float4 uvsFrame2, out float4 uvsFrame3, out float4 octaFrame, out float4 viewPos )
{
OctaImpostorVertex( vertex.xyz, normal, tangent, uvsFrame1, uvsFrame2, uvsFrame3, octaFrame, viewPos );
}
inline void OctaImpostorVertex( inout float4 vertex, out float3 normal, out float4 uvsFrame1, out float4 uvsFrame2, out float4 uvsFrame3, out float4 octaFrame, out float4 viewPos )
{
float4 tangent;
OctaImpostorVertex( vertex.xyz, normal, tangent, uvsFrame1, uvsFrame2, uvsFrame3, octaFrame, viewPos );
}
inline void OctaImpostorFragment( inout SurfaceOutputStandardSpecular o, out float4 clipPos, out float3 worldPos, float4 uvsFrame1, float4 uvsFrame2, float4 uvsFrame3, float4 octaFrame, float4 viewPos )
{
// Weights
float2 fraction = frac( octaFrame.xy );
float2 invFraction = 1 - fraction;
float3 weights;
weights.x = min( invFraction.x, invFraction.y );
weights.y = abs( fraction.x - fraction.y );
weights.z = min( fraction.x, fraction.y );
float parallax1 = tex2Dbias( _Normals, float4( uvsFrame1.zw, 0, -1 ) ).a;
float parallax2 = tex2Dbias( _Normals, float4( uvsFrame2.zw, 0, -1 ) ).a;
float parallax3 = tex2Dbias( _Normals, float4( uvsFrame3.zw, 0, -1 ) ).a;
float2 parallax1_uv = ( ( 0.5 - parallax1 ) * uvsFrame1.xy ) + uvsFrame1.zw;
float2 parallax2_uv = ( ( 0.5 - parallax2 ) * uvsFrame2.xy ) + uvsFrame2.zw;
float2 parallax3_uv = ( ( 0.5 - parallax3 ) * uvsFrame3.xy ) + uvsFrame3.zw;
// albedo alpha
float4 albedo1 = tex2Dbias( _Albedo, float4( parallax1_uv, 0, _TextureBias ) );
float4 albedo2 = tex2Dbias( _Albedo, float4( parallax2_uv, 0, _TextureBias ) );
float4 albedo3 = tex2Dbias( _Albedo, float4( parallax3_uv, 0, _TextureBias ) );
float4 blendedAlbedo = albedo1 * weights.x + albedo2 * weights.y + albedo3 * weights.z;
// Early clip
o.Alpha = blendedAlbedo.a;
#if !defined( AI_SKIP_ALPHA_CLIP )
clip( o.Alpha - _ClipMask );
#endif
#if defined( AI_CLIP_NEIGHBOURS_FRAMES )
float t = ceil( fraction.x - fraction.y );
float4 cornerDifference = float4( t, 1 - t, 1, 1 );
float2 step_1 = ( parallax1_uv - octaFrame.zw ) * _Frames;
float4 step23 = ( float4( parallax2_uv, parallax3_uv ) - octaFrame.zwzw ) * _Frames - cornerDifference;
step_1 = step_1 * ( 1 - step_1 );
step23 = step23 * ( 1 - step23 );
float3 steps;
steps.x = step_1.x * step_1.y;
steps.y = step23.x * step23.y;
steps.z = step23.z * step23.w;
steps = step( -steps, 0 );
float final = dot( steps, weights );
clip( final - 0.5 );
#endif
#if defined( EFFECT_HUE_VARIATION )
half3 shiftedColor = lerp( blendedAlbedo.rgb, _HueVariation.rgb, viewPos.w );
half maxBase = max( blendedAlbedo.r, max( blendedAlbedo.g, blendedAlbedo.b ) );
half newMaxBase = max( shiftedColor.r, max( shiftedColor.g, shiftedColor.b ) );
maxBase /= newMaxBase;
maxBase = maxBase * 0.5f + 0.5f;
shiftedColor.rgb *= maxBase;
blendedAlbedo.rgb = saturate( shiftedColor );
#endif
o.Albedo = blendedAlbedo.rgb;
// Normal
float3 normal1 = tex2Dbias( _Normals, float4( parallax1_uv, 0, _TextureBias ) ).rgb;
float3 normal2 = tex2Dbias( _Normals, float4( parallax2_uv, 0, _TextureBias ) ).rgb;
float3 normal3 = tex2Dbias( _Normals, float4( parallax3_uv, 0, _TextureBias ) ).rgb;
float3 blendedNormal = normal1 * weights.x + normal2 * weights.y + normal3 * weights.z;
float3 objectNormal = blendedNormal * 2.0 - 1.0;
float3 worldNormal = normalize( mul( (float3x3)AI_ObjectToWorld, objectNormal ) );
o.Normal = worldNormal;
// Depth
float depth = parallax1 * weights.x + parallax2 * weights.y + parallax3 * weights.z;
#if defined( AI_DEPTH_OPTIMIZATION )
depth = -( 1 - depth ) * _DepthSize * length( AI_ObjectToWorld[ 2 ].xyz );
#else
depth = ( depth - 0.5 ) * _DepthSize * length( AI_ObjectToWorld[ 2 ].xyz );
#endif
// Specular Smoothness
#if defined( _SPECULARMAP )
float4 specular1 = AI_SAMPLEBIAS( _Specular, sampler_Specular, parallax1_uv, _TextureBias );
float4 specular2 = AI_SAMPLEBIAS( _Specular, sampler_Specular, parallax2_uv, _TextureBias );
float4 specular3 = AI_SAMPLEBIAS( _Specular, sampler_Specular, parallax3_uv, _TextureBias );
float4 blendedSpecular = specular1 * weights.x + specular2 * weights.y + specular3 * weights.z;
o.Specular = blendedSpecular.rgb;
o.Smoothness = blendedSpecular.a;
#else
o.Specular = 0;
o.Smoothness = 0;
#endif
#if defined( _OCCLUSIONMAP )
float occlusion1 = tex2Dbias( _Occlusion, float4( parallax1_uv, 0, _TextureBias ) ).g;
float occlusion2 = tex2Dbias( _Occlusion, float4( parallax2_uv, 0, _TextureBias ) ).g;
float occlusion3 = tex2Dbias( _Occlusion, float4( parallax3_uv, 0, _TextureBias ) ).g;
o.Occlusion = occlusion1 * weights.x + occlusion2 * weights.y + occlusion3 * weights.z;
#else
o.Occlusion = 1;
#endif
#if defined( _EMISSIONMAP )
// Emission Occlusion
float3 emission1 = tex2Dbias( _Emission, float4( parallax1_uv, 0, _TextureBias ) ).rgb;
float3 emission2 = tex2Dbias( _Emission, float4( parallax2_uv, 0, _TextureBias ) ).rgb;
float3 emission3 = tex2Dbias( _Emission, float4( parallax3_uv, 0, _TextureBias ) ).rgb;
o.Emission = emission1 * weights.x + emission2 * weights.y + emission3 * weights.z;
#else
o.Emission = 0;
#endif
#if defined( _POSITIONMAP )
// Position
float4 position1 = tex2Dbias( _Position, float4( parallax1_uv, 0, _TextureBias ) );
float4 position2 = tex2Dbias( _Position, float4( parallax2_uv, 0, _TextureBias ) );
float4 position3 = tex2Dbias( _Position, float4( parallax3_uv, 0, _TextureBias ) );
float4 blendedPosition = position1 * weights.x + position2 * weights.y + position3 * weights.z;
float3 objectPosition = blendedPosition.xyz * _AI_BoundsSize + _AI_BoundsMin;
float3 worldPosition = mul( AI_ObjectToWorld, float4( objectPosition, 1 ) ).xyz;
if ( blendedPosition.a > 0 )
{
viewPos.xyz = mul( UNITY_MATRIX_V, float4( worldPosition.xyz, 1 ) ).xyz;
depth = 0;
}
#endif
#if !defined( AI_RENDERPIPELINE ) // no SRP
#if defined( SHADOWS_DEPTH )
if ( unity_LightShadowBias.y == 1.0 ) // get only the shadowcaster, this is a hack
{
viewPos.z += depth * _AI_ShadowView - _AI_ShadowBias;
}
else
{
viewPos.z += depth + _AI_ForwardBias;
}
#elif defined( UNITY_PASS_SHADOWCASTER )
viewPos.z += depth * _AI_ShadowView - _AI_ShadowBias;
#else
viewPos.z += depth + _AI_ForwardBias;
#endif
#else // SRP
#if ( defined( SHADERPASS ) && ( ( defined( SHADERPASS_SHADOWS ) && SHADERPASS == SHADERPASS_SHADOWS ) || ( defined( SHADERPASS_SHADOWCASTER ) && SHADERPASS == SHADERPASS_SHADOWCASTER ) ) ) || defined( UNITY_PASS_SHADOWCASTER )
viewPos.z += depth * _AI_ShadowView - _AI_ShadowBias;
#else
viewPos.z += depth + _AI_ForwardBias;
#endif
#endif
worldPos = mul( UNITY_MATRIX_I_V, float4( viewPos.xyz, 1 ) ).xyz;
clipPos = mul( UNITY_MATRIX_P, float4( viewPos.xyz, 1 ) );
#if !defined( AI_RENDERPIPELINE ) // no SRP
#if defined( SHADOWS_DEPTH )
clipPos = UnityApplyLinearShadowBias( clipPos );
#endif
#else // SRP
#if defined( UNITY_PASS_SHADOWCASTER ) && !defined( SHADERPASS )
#if defined( UNITY_REVERSED_Z )
clipPos.z = min( clipPos.z, clipPos.w * UNITY_NEAR_CLIP_VALUE );
#else
clipPos.z = max( clipPos.z, clipPos.w * UNITY_NEAR_CLIP_VALUE );
#endif
#endif
#endif
clipPos.xyz /= clipPos.w;
if ( UNITY_NEAR_CLIP_VALUE < 0 )
{
clipPos = clipPos * 0.5 + 0.5;
}
}
inline void SphereImpostorVertex( inout float3 vertex, out float3 normal, out float4 tangent, out float4 frameUVs, out float4 viewPos )
{
// INPUTS
float2 uvOffset = _AI_SizeOffset.zw;
float sizeX = _FramesX;
float sizeY = _FramesY - 1; // adjusted
float UVscale = _ImpostorSize;
float4 fractions = 1 / float4( sizeX, _FramesY, sizeY, UVscale );
float2 sizeFraction = fractions.xy;
float axisSizeFraction = fractions.z;
float fractionsUVscale = fractions.w;
float3 worldCameraPos;
#if ( defined(SHADERPASS) && (defined(SHADERPASS_DEPTHNORMALSONLY) && SHADERPASS == SHADERPASS_DEPTHNORMALSONLY) ) || defined(UNITY_PASS_SHADOWCASTER)
float3 worldOrigin = 0;
float4 perspective = float4( 0, 0, 0, 1 );
if ( UNITY_MATRIX_P[ 3 ][ 3 ] == 1 )
{
perspective = float4( 0, 0, 5000, 0 );
worldOrigin = AI_ObjectToWorld._m03_m13_m23;
}
worldCameraPos = worldOrigin + mul( UNITY_MATRIX_I_V, perspective ).xyz;
#else
// @diogo: not using UNITY_MATRIX_I_V here due to a unity bug sending slightly different matrices between depth-only and forward passes.
if ( UNITY_MATRIX_P[ 3 ][ 3 ] == 1 )
{
worldCameraPos = AI_ObjectToWorld._m03_m13_m23 + UNITY_MATRIX_I_V._m02_m12_m22 * 5000;
}
else
{
#if defined( AI_RENDERPIPELINE )
worldCameraPos = GetCameraRelativePositionWS( _WorldSpaceCameraPos );
#else
worldCameraPos = _WorldSpaceCameraPos;
#endif
}
#endif
float3 objectCameraPosition = mul( AI_WorldToObject, float4( worldCameraPos, 1 ) ).xyz - _Offset.xyz; //ray origin
float3 objectCameraDirection = normalize( objectCameraPosition );
// Create orthogonal vectors to define the billboard
float3 upVector = float3( 0,1,0 );
float3 objectHorizontalVector = normalize( cross( objectCameraDirection, upVector ) );
float3 objectVerticalVector = cross( objectHorizontalVector, objectCameraDirection );
// Create vertical radial angle
float verticalAngle = frac( atan2( -objectCameraDirection.z, -objectCameraDirection.x ) * AI_INV_TWO_PI ) * sizeX + 0.5;
// Create horizontal radial angle
float verticalDot = dot( objectCameraDirection, upVector );
float upAngle = ( acos( -verticalDot ) * AI_INV_PI ) + axisSizeFraction * 0.5f;
float yRot = sizeFraction.x * AI_PI * verticalDot * ( 2 * frac( verticalAngle ) - 1 );
// Billboard rotation
float2 uvExpansion = vertex.xy;
float cosY = cos( yRot );
float sinY = sin( yRot );
float2 uvRotator = mul( uvExpansion, float2x2( cosY, -sinY, sinY, cosY ) );
// Billboard
float3 billboard = objectHorizontalVector * uvRotator.x + objectVerticalVector * uvRotator.y + _Offset.xyz;
// Frame coords
float2 relativeCoords = float2( floor( verticalAngle ), min( floor( upAngle * sizeY ), sizeY ) );
float2 frameUV = ( ( uvExpansion * fractionsUVscale + 0.5 ) + relativeCoords ) * sizeFraction;
frameUVs.xy = frameUV - uvOffset;
// Parallax
#if defined( _USE_PARALLAX_ON )
float3 objectNormalVector = cross( objectHorizontalVector, -objectVerticalVector );
float3x3 worldToLocal = float3x3( objectHorizontalVector, objectVerticalVector, objectNormalVector );
float3 sphereLocal = normalize( mul( worldToLocal, billboard - objectCameraPosition ) );
frameUVs.zw = sphereLocal.xy * sizeFraction * _Parallax;
#else
frameUVs.zw = 0;
#endif
viewPos.w = 0;
#if defined( AI_RENDERPIPELINE )
viewPos.xyz = TransformWorldToView( TransformObjectToWorld( billboard ) );
#else
viewPos.xyz = UnityObjectToViewPos( billboard );
#endif
#if defined( AI_DEPTH_OPTIMIZATION )
viewPos.z += _DepthSize * 0.5;
#endif
#if defined( EFFECT_HUE_VARIATION )
float hueVariationAmount = frac( AI_ObjectToWorld[ 0 ].w + AI_ObjectToWorld[ 1 ].w + AI_ObjectToWorld[ 2 ].w );
viewPos.w = saturate( hueVariationAmount * _HueVariation.a );
#endif
vertex = billboard;
normal = objectCameraDirection;
tangent = float4( objectHorizontalVector, 1 );
}
inline void SphereImpostorVertex( inout float4 vertex, out float3 normal, out float4 tangent, out float4 frameUVs, out float4 viewPos )
{
SphereImpostorVertex( vertex.xyz, normal, tangent, frameUVs, viewPos );
}
inline void SphereImpostorVertex( inout float4 vertex, out float3 normal, out float4 frameUVs, out float4 viewPos )
{
float4 tangent;
SphereImpostorVertex( vertex.xyz, normal, tangent, frameUVs, viewPos );
}
inline void SphereImpostorFragment( inout SurfaceOutputStandardSpecular o, out float4 clipPos, out float3 worldPos, float4 frameUV, float4 viewPos )
{
#if defined( _USE_PARALLAX_ON )
float parallax = tex2Dbias( _Normals, float4( frameUV.xy, 0, -1 ) ).a;
frameUV.xy = ( ( 0.5 - parallax ) * frameUV.zw ) + frameUV.xy;
#endif
// Albedo + Alpha
float4 albedo = tex2Dbias( _Albedo, float4( frameUV.xy, 0, _TextureBias ) );
// Early clip
o.Alpha = albedo.a;
#if !defined( AI_SKIP_ALPHA_CLIP )
clip( o.Alpha - _ClipMask );
#endif
#if defined( EFFECT_HUE_VARIATION )
half3 shiftedColor = lerp( albedo.rgb, _HueVariation.rgb, viewPos.w );
half maxBase = max( albedo.r, max( albedo.g, albedo.b ) );
half newMaxBase = max( shiftedColor.r, max( shiftedColor.g, shiftedColor.b ) );
maxBase /= newMaxBase;
maxBase = maxBase * 0.5f + 0.5f;
shiftedColor.rgb *= maxBase;
albedo.rgb = saturate( shiftedColor );
#endif
o.Albedo = albedo.rgb;
// Normal
float4 normalSample = tex2Dbias( _Normals, float4( frameUV.xy, 0, _TextureBias ) );
float4 objectNormal = normalSample * 2 - 1;
float3 worldNormal = normalize( mul( ( float3x3 )AI_ObjectToWorld, objectNormal.xyz ) );
o.Normal = worldNormal;
// Depth
#if defined( AI_DEPTH_OPTIMIZATION )
float depth = -( 1 - normalSample.a ) * _DepthSize * length( AI_ObjectToWorld[ 2 ].xyz );
#else
float depth = objectNormal.w * 0.5 * _DepthSize * length( AI_ObjectToWorld[ 2 ].xyz );
#endif
// Specular Smoothness
#if defined( _SPECULARMAP )
float4 specular = AI_SAMPLEBIAS( _Specular, sampler_Specular, frameUV.xy, _TextureBias );
o.Specular = specular.rgb;
o.Smoothness = specular.a;
#else
o.Specular = 0;
o.Smoothness = 0;
#endif
// Occlusion
#if defined( _OCCLUSIONMAP )
o.Occlusion = tex2Dbias( _Occlusion, float4( frameUV.xy, 0, _TextureBias ) ).g;
#else
o.Occlusion = 1;
#endif
// Emission
#if defined( _EMISSIONMAP )
o.Emission = tex2Dbias( _Emission, float4( frameUV.xy, 0, _TextureBias ) ).rgb;
#else
o.Emission = 0;
#endif
#if defined( _POSITIONMAP )
// Position
float4 position = tex2Dbias( _Position, float4( frameUV.xy, 0, _TextureBias ) );
float3 objectPosition = position.xyz * _AI_BoundsSize + _AI_BoundsMin;
float3 worldPosition = mul( AI_ObjectToWorld, float4( objectPosition, 1 ) ).xyz;
if ( position.a > 0 )
{
viewPos.xyz = mul( UNITY_MATRIX_V, float4( worldPosition.xyz, 1 ) ).xyz;
depth = 0;
}
#endif
#if !defined( AI_RENDERPIPELINE ) // no SRP
#if defined( SHADOWS_DEPTH )
if ( unity_LightShadowBias.y == 1.0 ) // get only the shadowcaster, this is a hack
{
viewPos.z += depth * _AI_ShadowView - _AI_ShadowBias;
}
else
{
viewPos.z += depth + _AI_ForwardBias;
}
#elif defined( UNITY_PASS_SHADOWCASTER )
viewPos.z += depth * _AI_ShadowView - _AI_ShadowBias;
#else
viewPos.z += depth + _AI_ForwardBias;
#endif
#else // SRP
#if ( defined( SHADERPASS ) && ( ( defined( SHADERPASS_SHADOWS ) && SHADERPASS == SHADERPASS_SHADOWS ) || ( defined( SHADERPASS_SHADOWCASTER ) && SHADERPASS == SHADERPASS_SHADOWCASTER ) ) ) || defined( UNITY_PASS_SHADOWCASTER )
viewPos.z += depth * _AI_ShadowView - _AI_ShadowBias;
#else
viewPos.z += depth + _AI_ForwardBias;
#endif
#endif
worldPos = mul( UNITY_MATRIX_I_V, float4( viewPos.xyz, 1 ) ).xyz;
clipPos = mul( UNITY_MATRIX_P, float4( viewPos.xyz, 1 ) );
#if !defined( AI_RENDERPIPELINE ) // no SRP
#if defined( SHADOWS_DEPTH )
clipPos = UnityApplyLinearShadowBias( clipPos );
#endif
#else // SRP
#if defined( UNITY_PASS_SHADOWCASTER ) && !defined( SHADERPASS )
#if defined( UNITY_REVERSED_Z )
clipPos.z = min( clipPos.z, clipPos.w * UNITY_NEAR_CLIP_VALUE );
#else
clipPos.z = max( clipPos.z, clipPos.w * UNITY_NEAR_CLIP_VALUE );
#endif
#endif
#endif
clipPos.xyz /= clipPos.w;
if ( UNITY_NEAR_CLIP_VALUE < 0 )
{
clipPos = clipPos * 0.5 + 0.5;
}
}
#endif //AMPLIFYIMPOSTORS_INCLUDED

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: b88b76e7061d41545aaf145c34304b89
timeCreated: 1532429889
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,15 @@
// Amplify Impostors
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
#ifndef AMPLIFYIMPOSTORSCONFIG_INCLUDED
#define AMPLIFYIMPOSTORSCONFIG_INCLUDED
// uncomment the next define to activate neighbour frame clipping globally
// use it only if your impostors show small artifacts at edges at some rotations
//#define AI_CLIP_NEIGHBOURS_FRAMES
// don't touch the next define, it's automatically set by script
#define AI_HDRP_VERSION 0
#define AI_URP_VERSION 170004
#endif //AMPLIFYIMPOSTORSCONFIG_INCLUDED

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 806d6cc0f22ee994f8cd901b6718f08d
timeCreated: 1532429889
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 30a8e337ed84177439ca24b6a5c97cd1
timeCreated: 1525095235
licenseType: Store
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: ad3e6cbf440fc8843823405e7e862e1a
timeCreated: 1520620337
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 7a405f58bac896e46ad633cb1274d4ba
timeCreated: 1525095235
licenseType: Store
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,659 @@
// Amplify Impostors
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
Shader "Hidden/Amplify Impostors/Octahedron Impostor"
{
Properties
{
[NoScaleOffset] _Albedo( "Albedo (RGB) Alpha (A)", 2D ) = "white" {}
[NoScaleOffset] _Normals( "Normals (RGB) Depth (A)", 2D ) = "white" {}
[NoScaleOffset] _Specular( "Specular (RGB) Smoothness (A)", 2D ) = "black" {}
[NoScaleOffset] _Occlusion( "Occlusion (RGB)", 2D ) = "white" {}
[NoScaleOffset] _Emission( "Emission (RGB)", 2D ) = "black" {}
[NoScaleOffset] _Position( "Position (RGB)", 2D ) = "black" {}
_ClipMask( "Clip", Range( 0, 1 ) ) = 0.5
_TextureBias( "Texture Bias", Float ) = -1
_Parallax( "Parallax", Range( -1, 1 ) ) = 1
_AI_ShadowBias( "Shadow Bias", Range( 0, 2 ) ) = 0.333
_AI_ShadowView( "Shadow View", Range( 0, 1 ) ) = 1
_AI_ForwardBias( "Forward Bias", Range( 0, 2 ) ) = 0.0
[Toggle( _HEMI_ON )] _Hemi( "Hemi", Float ) = 0
[Toggle( EFFECT_HUE_VARIATION )] _Hue( "Use SpeedTree Hue", Float ) = 0
_HueVariation( "Hue Variation", Color ) = ( 0, 0, 0, 0 )
[Toggle( AI_CLIP_NEIGHBOURS_FRAMES )] AI_CLIP_NEIGHBOURS_FRAMES( "Clip Neighbours Frames", Float ) = 0
[Toggle] _AI_AlphaToCoverage( "Alpha To Coverage", Float ) = 0
[HideInInspector] _Frames( "Frames", Float ) = 16
[HideInInspector] _DepthSize( "DepthSize", Float ) = 1
[HideInInspector] _ImpostorSize( "Impostor Size", Float ) = 1
[HideInInspector] _Offset( "Offset", Vector ) = ( 0, 0, 0, 0 )
[HideInInspector] _AI_SizeOffset( "Size & Offset", Vector ) = ( 0, 0, 0, 0 )
[HideInInspector] _AI_BoundsMin( "Bounds Min", Vector ) = ( 0, 0, 0, 0 )
[HideInInspector] _AI_BoundsSize( "Bounds Size", Vector ) = ( 0, 0, 0, 0 )
}
SubShader
{
Tags { "RenderType"="Opaque" "Queue"="Geometry" "DisableBatching"="True" }
Cull Back
AlphaToMask [_AI_AlphaToCoverage]
CGINCLUDE
#pragma target 3.5
#define UNITY_SAMPLE_FULL_SH_PER_PIXEL 1
#pragma shader_feature_local _HEMI_ON
#pragma shader_feature_local EFFECT_HUE_VARIATION
#pragma shader_feature_local AI_CLIP_NEIGHBOURS_FRAMES
#pragma shader_feature_local_fragment _SPECULARMAP
#pragma shader_feature_local_fragment _OCCLUSIONMAP
#pragma shader_feature_local_fragment _EMISSIONMAP
#pragma shader_feature_local_fragment _POSITIONMAP
ENDCG
Pass
{
Name "ForwardBase"
Tags { "LightMode"="ForwardBase" }
ZWrite On
CGPROGRAM
// compile directives
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#pragma multi_compile_fwdbase
#pragma multi_compile_instancing
#pragma multi_compile __ LOD_FADE_CROSSFADE
#include "HLSLSupport.cginc"
#if !defined( UNITY_INSTANCED_LOD_FADE )
#define UNITY_INSTANCED_LOD_FADE
#endif
#if !defined( UNITY_INSTANCED_SH )
#define UNITY_INSTANCED_SH
#endif
#if !defined( UNITY_INSTANCED_LIGHTMAPSTS )
#define UNITY_INSTANCED_LIGHTMAPSTS
#endif
#include "UnityShaderVariables.cginc"
#include "UnityShaderUtilities.cginc"
#ifndef UNITY_PASS_FORWARDBASE
#define UNITY_PASS_FORWARDBASE
#endif
#include "UnityCG.cginc"
#include "Lighting.cginc"
#include "UnityPBSLighting.cginc"
#include "AutoLight.cginc"
#include "UnityStandardUtils.cginc"
#include "AmplifyImpostors.cginc"
struct v2f
{
UNITY_POSITION(pos);
float4 uvsFrame1 : TEXCOORD0;
float4 uvsFrame2 : TEXCOORD1;
float4 uvsFrame3 : TEXCOORD2;
float4 octaFrame : TEXCOORD3;
float4 viewPos : TEXCOORD4;
UNITY_LIGHTING_COORDS(5,6)
UNITY_FOG_COORDS(7)
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert( appdata_full v )
{
UNITY_SETUP_INSTANCE_ID(v);
v2f o;
UNITY_INITIALIZE_OUTPUT(v2f,o);
UNITY_TRANSFER_INSTANCE_ID(v,o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
OctaImpostorVertex( v.vertex, v.normal, o.uvsFrame1, o.uvsFrame2, o.uvsFrame3, o.octaFrame, o.viewPos );
o.pos = UnityObjectToClipPos(v.vertex);
float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
half3 worldNormal = UnityObjectToWorldNormal(v.normal);
UNITY_TRANSFER_LIGHTING(o, v.texcoord1.xy);
UNITY_TRANSFER_FOG(o,o.pos);
return o;
}
half4 frag( v2f IN, out float outDepth : SV_Depth ) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(IN);
SurfaceOutputStandardSpecular o;
UNITY_INITIALIZE_OUTPUT( SurfaceOutputStandardSpecular, o );
float4 clipPos;
float3 worldPos;
OctaImpostorFragment( o, clipPos, worldPos, IN.uvsFrame1, IN.uvsFrame2, IN.uvsFrame3, IN.octaFrame, IN.viewPos );
IN.pos.zw = clipPos.zw;
outDepth = IN.pos.z;
#ifndef USING_DIRECTIONAL_LIGHT
half3 lightDir = normalize(UnityWorldSpaceLightDir(worldPos));
#else
half3 lightDir = _WorldSpaceLightPos0.xyz;
#endif
half3 worldViewDir = normalize(UnityWorldSpaceViewDir(worldPos));
UNITY_APPLY_DITHER_CROSSFADE(IN.pos.xy);
UNITY_LIGHT_ATTENUATION(atten, IN, worldPos)
half4 c = 0;
UnityGI gi;
UNITY_INITIALIZE_OUTPUT(UnityGI, gi);
gi.indirect.diffuse = 0;
gi.indirect.specular = 0;
gi.light.color = _LightColor0.rgb;
gi.light.dir = lightDir;
UnityGIInput giInput;
UNITY_INITIALIZE_OUTPUT(UnityGIInput, giInput);
giInput.light = gi.light;
giInput.worldPos = worldPos;
giInput.worldViewDir = worldViewDir;
giInput.atten = atten;
giInput.probeHDR[0] = unity_SpecCube0_HDR;
giInput.probeHDR[1] = unity_SpecCube1_HDR;
#if UNITY_SPECCUBE_BLENDING || UNITY_SPECCUBE_BOX_PROJECTION
giInput.boxMin[0] = unity_SpecCube0_BoxMin;
#endif
#if UNITY_SPECCUBE_BOX_PROJECTION
giInput.boxMax[0] = unity_SpecCube0_BoxMax;
giInput.probePosition[0] = unity_SpecCube0_ProbePosition;
giInput.boxMax[1] = unity_SpecCube1_BoxMax;
giInput.boxMin[1] = unity_SpecCube1_BoxMin;
giInput.probePosition[1] = unity_SpecCube1_ProbePosition;
#endif
LightingStandardSpecular_GI(o, giInput, gi);
c += LightingStandardSpecular (o, worldViewDir, gi);
c.rgb += o.Emission;
UNITY_APPLY_FOG(IN.fogCoord, c);
return c;
}
ENDCG
}
Pass
{
Name "ForwardAdd"
Tags { "LightMode"="ForwardAdd" }
ZWrite Off
Blend One One
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#pragma multi_compile_instancing
#pragma multi_compile_fwdadd_fullshadows
#pragma multi_compile __ LOD_FADE_CROSSFADE
#pragma skip_variants INSTANCING_ON
#include "HLSLSupport.cginc"
#if !defined( UNITY_INSTANCED_LOD_FADE )
#define UNITY_INSTANCED_LOD_FADE
#endif
#if !defined( UNITY_INSTANCED_SH )
#define UNITY_INSTANCED_SH
#endif
#if !defined( UNITY_INSTANCED_LIGHTMAPSTS )
#define UNITY_INSTANCED_LIGHTMAPSTS
#endif
#include "UnityShaderVariables.cginc"
#include "UnityShaderUtilities.cginc"
#ifndef UNITY_PASS_FORWARDADD
#define UNITY_PASS_FORWARDADD
#endif
#include "UnityCG.cginc"
#include "Lighting.cginc"
#include "UnityPBSLighting.cginc"
#include "AutoLight.cginc"
#include "UnityStandardUtils.cginc"
#include "AmplifyImpostors.cginc"
struct v2f
{
UNITY_POSITION( pos );
float4 uvsFrame1 : TEXCOORD0;
float4 uvsFrame2 : TEXCOORD1;
float4 uvsFrame3 : TEXCOORD2;
float4 octaFrame : TEXCOORD3;
float4 viewPos : TEXCOORD4;
UNITY_LIGHTING_COORDS(5,6)
UNITY_FOG_COORDS(7)
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert( appdata_full v )
{
UNITY_SETUP_INSTANCE_ID(v);
v2f o;
UNITY_INITIALIZE_OUTPUT(v2f,o);
UNITY_TRANSFER_INSTANCE_ID(v,o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
OctaImpostorVertex( v.vertex, v.normal, o.uvsFrame1, o.uvsFrame2, o.uvsFrame3, o.octaFrame, o.viewPos );
o.pos = UnityObjectToClipPos(v.vertex);
UNITY_TRANSFER_LIGHTING(o, v.texcoord1.xy);
UNITY_TRANSFER_FOG(o,o.pos);
return o;
}
half4 frag( v2f IN, out float outDepth : SV_Depth ) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(IN);
SurfaceOutputStandardSpecular o;
UNITY_INITIALIZE_OUTPUT( SurfaceOutputStandardSpecular, o );
float4 clipPos;
float3 worldPos;
OctaImpostorFragment( o, clipPos, worldPos, IN.uvsFrame1, IN.uvsFrame2, IN.uvsFrame3, IN.octaFrame, IN.viewPos );
IN.pos.zw = clipPos.zw;
outDepth = IN.pos.z;
#ifndef USING_DIRECTIONAL_LIGHT
half3 lightDir = normalize(UnityWorldSpaceLightDir(worldPos));
#else
half3 lightDir = _WorldSpaceLightPos0.xyz;
#endif
half3 worldViewDir = normalize(UnityWorldSpaceViewDir(worldPos));
UNITY_APPLY_DITHER_CROSSFADE(IN.pos.xy);
UNITY_LIGHT_ATTENUATION(atten, IN, worldPos)
half4 c = 0;
UnityGI gi;
UNITY_INITIALIZE_OUTPUT(UnityGI, gi);
gi.indirect.diffuse = 0;
gi.indirect.specular = 0;
gi.light.color = _LightColor0.rgb;
gi.light.dir = lightDir;
gi.light.color *= atten;
c += LightingStandardSpecular (o, worldViewDir, gi);
UNITY_APPLY_FOG(IN.fogCoord, c);
return c;
}
ENDCG
}
Pass
{
Name "Deferred"
Tags { "LightMode"="Deferred" }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_instancing
#pragma multi_compile __ LOD_FADE_CROSSFADE
#pragma exclude_renderers nomrt
#pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
#pragma multi_compile_prepassfinal
#include "HLSLSupport.cginc"
#if !defined( UNITY_INSTANCED_LOD_FADE )
#define UNITY_INSTANCED_LOD_FADE
#endif
#if !defined( UNITY_INSTANCED_SH )
#define UNITY_INSTANCED_SH
#endif
#if !defined( UNITY_INSTANCED_LIGHTMAPSTS )
#define UNITY_INSTANCED_LIGHTMAPSTS
#endif
#include "UnityShaderVariables.cginc"
#include "UnityShaderUtilities.cginc"
#ifndef UNITY_PASS_DEFERRED
#define UNITY_PASS_DEFERRED
#endif
#include "UnityCG.cginc"
#include "Lighting.cginc"
#include "UnityPBSLighting.cginc"
#include "UnityStandardUtils.cginc"
#include "AmplifyImpostors.cginc"
half4 unity_Ambient;
struct v2f
{
UNITY_POSITION(pos);
float4 uvsFrame1 : TEXCOORD0;
float4 uvsFrame2 : TEXCOORD1;
float4 uvsFrame3 : TEXCOORD2;
float4 octaFrame : TEXCOORD3;
float4 viewPos : TEXCOORD4;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert( appdata_full v )
{
UNITY_SETUP_INSTANCE_ID(v);
v2f o;
UNITY_INITIALIZE_OUTPUT(v2f,o);
UNITY_TRANSFER_INSTANCE_ID(v,o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
OctaImpostorVertex( v.vertex, v.normal, o.uvsFrame1, o.uvsFrame2, o.uvsFrame3, o.octaFrame, o.viewPos );
o.pos = UnityObjectToClipPos(v.vertex);
float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
half3 worldNormal = UnityObjectToWorldNormal(v.normal);
float3 viewDirForLight = UnityWorldSpaceViewDir(worldPos);
return o;
}
void frag( v2f IN,
out half4 outGBuffer0 : SV_Target0,
out half4 outGBuffer1 : SV_Target1,
out half4 outGBuffer2 : SV_Target2,
out half4 outEmission : SV_Target3,
out float outDepth : SV_Depth )
{
UNITY_SETUP_INSTANCE_ID(IN);
SurfaceOutputStandardSpecular o;
UNITY_INITIALIZE_OUTPUT( SurfaceOutputStandardSpecular, o );
float4 clipPos;
float3 worldPos;
OctaImpostorFragment( o, clipPos, worldPos, IN.uvsFrame1, IN.uvsFrame2, IN.uvsFrame3, IN.octaFrame, IN.viewPos );
IN.pos.zw = clipPos.zw;
outDepth = IN.pos.z;
#ifndef USING_DIRECTIONAL_LIGHT
half3 lightDir = normalize(UnityWorldSpaceLightDir(worldPos));
#else
half3 lightDir = _WorldSpaceLightPos0.xyz;
#endif
half3 worldViewDir = normalize(UnityWorldSpaceViewDir(worldPos));
UNITY_APPLY_DITHER_CROSSFADE(IN.pos.xy);
half atten = 1;
UnityGI gi;
UNITY_INITIALIZE_OUTPUT(UnityGI, gi);
gi.indirect.diffuse = 0;
gi.indirect.specular = 0;
gi.light.color = 0;
gi.light.dir = half3(0,1,0);
UnityGIInput giInput;
UNITY_INITIALIZE_OUTPUT(UnityGIInput, giInput);
giInput.light = gi.light;
giInput.worldPos = worldPos;
giInput.worldViewDir = worldViewDir;
giInput.atten = atten;
giInput.probeHDR[0] = unity_SpecCube0_HDR;
giInput.probeHDR[1] = unity_SpecCube1_HDR;
#if defined(UNITY_SPECCUBE_BLENDING) || defined(UNITY_SPECCUBE_BOX_PROJECTION)
giInput.boxMin[0] = unity_SpecCube0_BoxMin;
#endif
#ifdef UNITY_SPECCUBE_BOX_PROJECTION
giInput.boxMax[0] = unity_SpecCube0_BoxMax;
giInput.probePosition[0] = unity_SpecCube0_ProbePosition;
giInput.boxMax[1] = unity_SpecCube1_BoxMax;
giInput.boxMin[1] = unity_SpecCube1_BoxMin;
giInput.probePosition[1] = unity_SpecCube1_ProbePosition;
#endif
LightingStandardSpecular_GI(o, giInput, gi);
outEmission = LightingStandardSpecular_Deferred (o, worldViewDir, gi, outGBuffer0, outGBuffer1, outGBuffer2);
#ifndef UNITY_HDR_ON
outEmission.rgb = exp2(-outEmission.rgb);
#endif
}
ENDCG
}
Pass
{
Name "ShadowCaster"
Tags { "LightMode"="ShadowCaster" }
ZWrite On
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_shadowcaster
#pragma multi_compile __ LOD_FADE_CROSSFADE
#ifndef UNITY_PASS_SHADOWCASTER
#define UNITY_PASS_SHADOWCASTER
#endif
#pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
#pragma multi_compile_instancing
#include "HLSLSupport.cginc"
#if !defined( UNITY_INSTANCED_LOD_FADE )
#define UNITY_INSTANCED_LOD_FADE
#endif
#include "UnityShaderVariables.cginc"
#include "UnityShaderUtilities.cginc"
#include "UnityCG.cginc"
#include "Lighting.cginc"
#include "UnityPBSLighting.cginc"
#include "UnityStandardUtils.cginc"
#include "AmplifyImpostors.cginc"
struct v2f
{
V2F_SHADOW_CASTER;
float4 uvsFrame1 : TEXCOORD0;
float4 uvsFrame2 : TEXCOORD1;
float4 uvsFrame3 : TEXCOORD2;
float4 octaFrame : TEXCOORD3;
float4 viewPos : TEXCOORD4;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert( appdata_full v )
{
UNITY_SETUP_INSTANCE_ID(v);
v2f o;
UNITY_INITIALIZE_OUTPUT(v2f,o);
UNITY_TRANSFER_INSTANCE_ID(v,o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
OctaImpostorVertex( v.vertex, v.normal, o.uvsFrame1, o.uvsFrame2, o.uvsFrame3, o.octaFrame, o.viewPos );
TRANSFER_SHADOW_CASTER(o)
return o;
}
half4 frag( v2f IN, out float outDepth : SV_Depth ) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(IN);
SurfaceOutputStandardSpecular o;
UNITY_INITIALIZE_OUTPUT( SurfaceOutputStandardSpecular, o );
float4 clipPos;
float3 worldPos;
OctaImpostorFragment( o, clipPos, worldPos, IN.uvsFrame1, IN.uvsFrame2, IN.uvsFrame3, IN.octaFrame, IN.viewPos );
IN.pos.zw = clipPos.zw;
outDepth = IN.pos.z;
UNITY_APPLY_DITHER_CROSSFADE(IN.pos.xy);
SHADOW_CASTER_FRAGMENT(IN)
}
ENDCG
}
Pass
{
Name "SceneSelectionPass"
Tags{ "LightMode" = "SceneSelectionPass" }
ZWrite On
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile __ LOD_FADE_CROSSFADE
#pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
#pragma multi_compile_instancing
#include "HLSLSupport.cginc"
#if !defined( UNITY_INSTANCED_LOD_FADE )
#define UNITY_INSTANCED_LOD_FADE
#endif
#include "UnityShaderVariables.cginc"
#include "UnityShaderUtilities.cginc"
#include "UnityCG.cginc"
#include "Lighting.cginc"
#include "UnityPBSLighting.cginc"
#include "UnityStandardUtils.cginc"
#include "AmplifyImpostors.cginc"
int _ObjectId;
int _PassValue;
struct v2f
{
UNITY_POSITION( pos );
float4 uvsFrame1 : TEXCOORD0;
float4 uvsFrame2 : TEXCOORD1;
float4 uvsFrame3 : TEXCOORD2;
float4 octaFrame : TEXCOORD3;
float4 viewPos : TEXCOORD4;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert( appdata_full v )
{
UNITY_SETUP_INSTANCE_ID(v);
v2f o;
UNITY_INITIALIZE_OUTPUT(v2f,o);
UNITY_TRANSFER_INSTANCE_ID(v,o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
OctaImpostorVertex( v.vertex, v.normal, o.uvsFrame1, o.uvsFrame2, o.uvsFrame3, o.octaFrame, o.viewPos );
o.pos = UnityObjectToClipPos( v.vertex );
return o;
}
half4 frag( v2f IN, out float outDepth : SV_Depth ) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(IN);
SurfaceOutputStandardSpecular o;
UNITY_INITIALIZE_OUTPUT( SurfaceOutputStandardSpecular, o );
float4 clipPos;
float3 worldPos;
OctaImpostorFragment( o, clipPos, worldPos, IN.uvsFrame1, IN.uvsFrame2, IN.uvsFrame3, IN.octaFrame, IN.viewPos );
IN.pos.zw = clipPos.zw;
outDepth = IN.pos.z;
UNITY_APPLY_DITHER_CROSSFADE(IN.pos.xy);
return float4( _ObjectId, _PassValue, 1.0, 1.0 );
}
ENDCG
}
Pass
{
Name "ScenePickingPass"
Tags { "LightMode" = "Picking" }
ZWrite On
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile __ LOD_FADE_CROSSFADE
#pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
#pragma multi_compile_instancing
#include "HLSLSupport.cginc"
#if !defined( UNITY_INSTANCED_LOD_FADE )
#define UNITY_INSTANCED_LOD_FADE
#endif
#include "UnityShaderVariables.cginc"
#include "UnityShaderUtilities.cginc"
#include "UnityCG.cginc"
#include "Lighting.cginc"
#include "UnityPBSLighting.cginc"
#include "UnityStandardUtils.cginc"
#include "AmplifyImpostors.cginc"
float4 _SelectionID;
struct v2f
{
UNITY_POSITION( pos );
float4 uvsFrame1 : TEXCOORD0;
float4 uvsFrame2 : TEXCOORD1;
float4 uvsFrame3 : TEXCOORD2;
float4 octaFrame : TEXCOORD3;
float4 viewPos : TEXCOORD4;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert( appdata_full v )
{
UNITY_SETUP_INSTANCE_ID(v);
v2f o;
UNITY_INITIALIZE_OUTPUT(v2f,o);
UNITY_TRANSFER_INSTANCE_ID(v,o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
OctaImpostorVertex( v.vertex, v.normal, o.uvsFrame1, o.uvsFrame2, o.uvsFrame3, o.octaFrame, o.viewPos );
o.pos = UnityObjectToClipPos( v.vertex );
return o;
}
half4 frag( v2f IN, out float outDepth : SV_Depth ) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(IN);
SurfaceOutputStandardSpecular o;
UNITY_INITIALIZE_OUTPUT( SurfaceOutputStandardSpecular, o );
float4 clipPos;
float3 worldPos;
OctaImpostorFragment( o, clipPos, worldPos, IN.uvsFrame1, IN.uvsFrame2, IN.uvsFrame3, IN.octaFrame, IN.viewPos );
IN.pos.zw = clipPos.zw;
outDepth = IN.pos.z;
UNITY_APPLY_DITHER_CROSSFADE(IN.pos.xy);
return _SelectionID;
}
ENDCG
}
}
Fallback Off
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 572f9be5706148142b8da6e9de53acdb
timeCreated: 1521828552
licenseType: Store
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 83dd8de9a5c14874884f9012def4fdcc
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,639 @@
// Amplify Impostors
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
Shader "Hidden/Amplify Impostors/Spherical Impostor"
{
Properties
{
[NoScaleOffset] _Albedo( "Albedo (RGB) Alpha (A)", 2D ) = "white" {}
[NoScaleOffset] _Normals( "Normals (RGB) Depth (A)", 2D ) = "white" {}
[NoScaleOffset] _Specular( "Specular (RGB) Smoothness (A)", 2D ) = "black" {}
[NoScaleOffset] _Occlusion( "Occlusion (RGB)", 2D ) = "white" {}
[NoScaleOffset] _Emission( "Emission (RGB)", 2D ) = "black" {}
[NoScaleOffset] _Position( "Position (RGB)", 2D ) = "black" {}
_ClipMask( "Clip", Range( 0, 1 ) ) = 0.5
_TextureBias( "Texture Bias", Float ) = -1
[Toggle( _USE_PARALLAX_ON )] _Use_Parallax( "Use Parallax", Float ) = 0
_Parallax( "Parallax", Range( -1, 1 ) ) = 1
_AI_ShadowBias( "Shadow Bias", Range( 0, 2 ) ) = 0.333
_AI_ShadowView( "Shadow View", Range( 0, 1 ) ) = 1
_AI_ForwardBias( "Forward Bias", Range( 0, 2 ) ) = 0.0
[Toggle( EFFECT_HUE_VARIATION )] _Hue( "Use SpeedTree Hue", Float ) = 0
_HueVariation( "Hue Variation", Color ) = ( 0, 0, 0, 0 )
[Toggle] _AI_AlphaToCoverage( "Alpha To Coverage", Float ) = 0
[HideInInspector] _FramesX( "Frames X", Float ) = 16
[HideInInspector] _FramesY( "Frames Y", Float ) = 16
[HideInInspector] _DepthSize( "DepthSize", Float ) = 1
[HideInInspector] _ImpostorSize( "Impostor Size", Float ) = 1
[HideInInspector] _Offset( "Offset", Vector ) = ( 0, 0, 0, 0 )
[HideInInspector] _AI_SizeOffset( "Size & Offset", Vector ) = ( 0, 0, 0, 0 )
[HideInInspector] _AI_BoundsMin( "Bounds Min", Vector ) = ( 0, 0, 0, 0 )
[HideInInspector] _AI_BoundsSize( "Bounds Size", Vector ) = ( 0, 0, 0, 0 )
}
SubShader
{
Tags { "RenderType"="Opaque" "Queue"="Geometry" "DisableBatching"="True" }
Cull Back
AlphaToMask [_AI_AlphaToCoverage]
CGINCLUDE
#pragma target 3.5
#define UNITY_SAMPLE_FULL_SH_PER_PIXEL 1
#pragma shader_feature_local _USE_PARALLAX_ON
#pragma shader_feature_local EFFECT_HUE_VARIATION
#pragma shader_feature_local_fragment _SPECULARMAP
#pragma shader_feature_local_fragment _OCCLUSIONMAP
#pragma shader_feature_local_fragment _EMISSIONMAP
#pragma shader_feature_local_fragment _POSITIONMAP
ENDCG
Pass
{
Name "ForwardBase"
Tags { "LightMode"="ForwardBase" }
ZWrite On
CGPROGRAM
// compile directives
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#pragma multi_compile_fwdbase
#pragma multi_compile_instancing
#pragma multi_compile __ LOD_FADE_CROSSFADE
#include "HLSLSupport.cginc"
#if !defined( UNITY_INSTANCED_LOD_FADE )
#define UNITY_INSTANCED_LOD_FADE
#endif
#if !defined( UNITY_INSTANCED_SH )
#define UNITY_INSTANCED_SH
#endif
#if !defined( UNITY_INSTANCED_LIGHTMAPSTS )
#define UNITY_INSTANCED_LIGHTMAPSTS
#endif
#include "UnityShaderVariables.cginc"
#include "UnityShaderUtilities.cginc"
#ifndef UNITY_PASS_FORWARDBASE
#define UNITY_PASS_FORWARDBASE
#endif
#include "UnityCG.cginc"
#include "Lighting.cginc"
#include "UnityPBSLighting.cginc"
#include "AutoLight.cginc"
#include "UnityStandardUtils.cginc"
#include "AmplifyImpostors.cginc"
struct v2f
{
UNITY_POSITION(pos);
float4 frameUVs : TEXCOORD0;
float4 viewPos : TEXCOORD1;
UNITY_LIGHTING_COORDS(2,3)
UNITY_FOG_COORDS(4)
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert( appdata_full v )
{
UNITY_SETUP_INSTANCE_ID(v);
v2f o;
UNITY_INITIALIZE_OUTPUT(v2f,o);
UNITY_TRANSFER_INSTANCE_ID(v,o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
SphereImpostorVertex( v.vertex, v.normal, o.frameUVs, o.viewPos );
o.pos = UnityObjectToClipPos(v.vertex);
float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
half3 worldNormal = UnityObjectToWorldNormal(v.normal);
UNITY_TRANSFER_LIGHTING(o, v.texcoord1.xy);
UNITY_TRANSFER_FOG(o,o.pos);
return o;
}
half4 frag( v2f IN, out float outDepth : SV_Depth ) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(IN);
SurfaceOutputStandardSpecular o;
UNITY_INITIALIZE_OUTPUT( SurfaceOutputStandardSpecular, o );
float4 clipPos;
float3 worldPos;
SphereImpostorFragment( o, clipPos, worldPos, IN.frameUVs, IN.viewPos );
IN.pos.zw = clipPos.zw;
outDepth = IN.pos.z;
#ifndef USING_DIRECTIONAL_LIGHT
half3 lightDir = normalize(UnityWorldSpaceLightDir(worldPos));
#else
half3 lightDir = _WorldSpaceLightPos0.xyz;
#endif
half3 worldViewDir = normalize(UnityWorldSpaceViewDir(worldPos));
UNITY_APPLY_DITHER_CROSSFADE(IN.pos.xy);
UNITY_LIGHT_ATTENUATION(atten, IN, worldPos)
half4 c = 0;
UnityGI gi;
UNITY_INITIALIZE_OUTPUT(UnityGI, gi);
gi.indirect.diffuse = 0;
gi.indirect.specular = 0;
gi.light.color = _LightColor0.rgb;
gi.light.dir = lightDir;
UnityGIInput giInput;
UNITY_INITIALIZE_OUTPUT(UnityGIInput, giInput);
giInput.light = gi.light;
giInput.worldPos = worldPos;
giInput.worldViewDir = worldViewDir;
giInput.atten = atten;
giInput.probeHDR[0] = unity_SpecCube0_HDR;
giInput.probeHDR[1] = unity_SpecCube1_HDR;
#if UNITY_SPECCUBE_BLENDING || UNITY_SPECCUBE_BOX_PROJECTION
giInput.boxMin[0] = unity_SpecCube0_BoxMin;
#endif
#if UNITY_SPECCUBE_BOX_PROJECTION
giInput.boxMax[0] = unity_SpecCube0_BoxMax;
giInput.probePosition[0] = unity_SpecCube0_ProbePosition;
giInput.boxMax[1] = unity_SpecCube1_BoxMax;
giInput.boxMin[1] = unity_SpecCube1_BoxMin;
giInput.probePosition[1] = unity_SpecCube1_ProbePosition;
#endif
LightingStandardSpecular_GI(o, giInput, gi);
c += LightingStandardSpecular (o, worldViewDir, gi);
c.rgb += o.Emission;
UNITY_APPLY_FOG(IN.fogCoord, c);
return c;
}
ENDCG
}
Pass
{
Name "ForwardAdd"
Tags { "LightMode"="ForwardAdd" }
ZWrite Off
Blend One One
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#pragma multi_compile_instancing
#pragma multi_compile_fwdadd_fullshadows
#pragma multi_compile __ LOD_FADE_CROSSFADE
#pragma skip_variants INSTANCING_ON
#include "HLSLSupport.cginc"
#if !defined( UNITY_INSTANCED_LOD_FADE )
#define UNITY_INSTANCED_LOD_FADE
#endif
#if !defined( UNITY_INSTANCED_SH )
#define UNITY_INSTANCED_SH
#endif
#if !defined( UNITY_INSTANCED_LIGHTMAPSTS )
#define UNITY_INSTANCED_LIGHTMAPSTS
#endif
#include "UnityShaderVariables.cginc"
#include "UnityShaderUtilities.cginc"
#ifndef UNITY_PASS_FORWARDADD
#define UNITY_PASS_FORWARDADD
#endif
#include "UnityCG.cginc"
#include "Lighting.cginc"
#include "UnityPBSLighting.cginc"
#include "AutoLight.cginc"
#include "UnityStandardUtils.cginc"
#include "AmplifyImpostors.cginc"
struct v2f
{
UNITY_POSITION(pos);
float4 frameUVs : TEXCOORD0;
float4 viewPos : TEXCOORD1;
UNITY_LIGHTING_COORDS(2,3)
UNITY_FOG_COORDS(4)
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert( appdata_full v )
{
UNITY_SETUP_INSTANCE_ID(v);
v2f o;
UNITY_INITIALIZE_OUTPUT(v2f,o);
UNITY_TRANSFER_INSTANCE_ID(v,o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
SphereImpostorVertex( v.vertex, v.normal, o.frameUVs, o.viewPos );
o.pos = UnityObjectToClipPos(v.vertex);
UNITY_TRANSFER_LIGHTING(o, v.texcoord1.xy);
UNITY_TRANSFER_FOG(o,o.pos);
return o;
}
half4 frag( v2f IN, out float outDepth : SV_Depth ) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(IN);
SurfaceOutputStandardSpecular o;
UNITY_INITIALIZE_OUTPUT( SurfaceOutputStandardSpecular, o );
float4 clipPos;
float3 worldPos;
SphereImpostorFragment( o, clipPos, worldPos, IN.frameUVs, IN.viewPos );
IN.pos.zw = clipPos.zw;
outDepth = IN.pos.z;
#ifndef USING_DIRECTIONAL_LIGHT
half3 lightDir = normalize(UnityWorldSpaceLightDir(worldPos));
#else
half3 lightDir = _WorldSpaceLightPos0.xyz;
#endif
half3 worldViewDir = normalize(UnityWorldSpaceViewDir(worldPos));
UNITY_APPLY_DITHER_CROSSFADE(IN.pos.xy);
UNITY_LIGHT_ATTENUATION(atten, IN, worldPos)
half4 c = 0;
UnityGI gi;
UNITY_INITIALIZE_OUTPUT(UnityGI, gi);
gi.indirect.diffuse = 0;
gi.indirect.specular = 0;
gi.light.color = _LightColor0.rgb;
gi.light.dir = lightDir;
gi.light.color *= atten;
c += LightingStandardSpecular (o, worldViewDir, gi);
UNITY_APPLY_FOG(IN.fogCoord, c);
return c;
}
ENDCG
}
Pass
{
Name "Deferred"
Tags { "LightMode"="Deferred" }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_instancing
#pragma multi_compile __ LOD_FADE_CROSSFADE
#pragma exclude_renderers nomrt
#pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
#pragma multi_compile_prepassfinal
#include "HLSLSupport.cginc"
#if !defined( UNITY_INSTANCED_LOD_FADE )
#define UNITY_INSTANCED_LOD_FADE
#endif
#if !defined( UNITY_INSTANCED_SH )
#define UNITY_INSTANCED_SH
#endif
#if !defined( UNITY_INSTANCED_LIGHTMAPSTS )
#define UNITY_INSTANCED_LIGHTMAPSTS
#endif
#include "UnityShaderVariables.cginc"
#include "UnityShaderUtilities.cginc"
#ifndef UNITY_PASS_DEFERRED
#define UNITY_PASS_DEFERRED
#endif
#include "UnityCG.cginc"
#include "Lighting.cginc"
#include "UnityPBSLighting.cginc"
#include "UnityStandardUtils.cginc"
#include "AmplifyImpostors.cginc"
half4 unity_Ambient;
struct v2f
{
UNITY_POSITION(pos);
float4 frameUVs : TEXCOORD0;
float4 viewPos : TEXCOORD1;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert( appdata_full v )
{
UNITY_SETUP_INSTANCE_ID(v);
v2f o;
UNITY_INITIALIZE_OUTPUT(v2f,o);
UNITY_TRANSFER_INSTANCE_ID(v,o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
SphereImpostorVertex( v.vertex, v.normal, o.frameUVs, o.viewPos );
o.pos = UnityObjectToClipPos(v.vertex);
float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
half3 worldNormal = UnityObjectToWorldNormal(v.normal);
float3 viewDirForLight = UnityWorldSpaceViewDir(worldPos);
return o;
}
void frag( v2f IN,
out half4 outGBuffer0 : SV_Target0,
out half4 outGBuffer1 : SV_Target1,
out half4 outGBuffer2 : SV_Target2,
out half4 outEmission : SV_Target3,
out float outDepth : SV_Depth )
{
UNITY_SETUP_INSTANCE_ID(IN);
SurfaceOutputStandardSpecular o;
UNITY_INITIALIZE_OUTPUT( SurfaceOutputStandardSpecular, o );
float4 clipPos;
float3 worldPos;
SphereImpostorFragment( o, clipPos, worldPos, IN.frameUVs, IN.viewPos );
IN.pos.zw = clipPos.zw;
outDepth = IN.pos.z;
#ifndef USING_DIRECTIONAL_LIGHT
half3 lightDir = normalize(UnityWorldSpaceLightDir(worldPos));
#else
half3 lightDir = _WorldSpaceLightPos0.xyz;
#endif
half3 worldViewDir = normalize(UnityWorldSpaceViewDir(worldPos));
UNITY_APPLY_DITHER_CROSSFADE(IN.pos.xy);
half atten = 1;
UnityGI gi;
UNITY_INITIALIZE_OUTPUT(UnityGI, gi);
gi.indirect.diffuse = 0;
gi.indirect.specular = 0;
gi.light.color = 0;
gi.light.dir = half3(0,1,0);
UnityGIInput giInput;
UNITY_INITIALIZE_OUTPUT(UnityGIInput, giInput);
giInput.light = gi.light;
giInput.worldPos = worldPos;
giInput.worldViewDir = worldViewDir;
giInput.atten = atten;
giInput.probeHDR[0] = unity_SpecCube0_HDR;
giInput.probeHDR[1] = unity_SpecCube1_HDR;
#if defined(UNITY_SPECCUBE_BLENDING) || defined(UNITY_SPECCUBE_BOX_PROJECTION)
giInput.boxMin[0] = unity_SpecCube0_BoxMin;
#endif
#ifdef UNITY_SPECCUBE_BOX_PROJECTION
giInput.boxMax[0] = unity_SpecCube0_BoxMax;
giInput.probePosition[0] = unity_SpecCube0_ProbePosition;
giInput.boxMax[1] = unity_SpecCube1_BoxMax;
giInput.boxMin[1] = unity_SpecCube1_BoxMin;
giInput.probePosition[1] = unity_SpecCube1_ProbePosition;
#endif
LightingStandardSpecular_GI(o, giInput, gi);
outEmission = LightingStandardSpecular_Deferred (o, worldViewDir, gi, outGBuffer0, outGBuffer1, outGBuffer2);
#ifndef UNITY_HDR_ON
outEmission.rgb = exp2(-outEmission.rgb);
#endif
}
ENDCG
}
Pass
{
Name "ShadowCaster"
Tags { "LightMode"="ShadowCaster" }
ZWrite On
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_shadowcaster
#pragma multi_compile __ LOD_FADE_CROSSFADE
#ifndef UNITY_PASS_SHADOWCASTER
#define UNITY_PASS_SHADOWCASTER
#endif
#pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
#pragma multi_compile_instancing
#include "HLSLSupport.cginc"
#if !defined( UNITY_INSTANCED_LOD_FADE )
#define UNITY_INSTANCED_LOD_FADE
#endif
#include "UnityShaderVariables.cginc"
#include "UnityShaderUtilities.cginc"
#include "UnityCG.cginc"
#include "Lighting.cginc"
#include "UnityPBSLighting.cginc"
#include "UnityStandardUtils.cginc"
#include "AmplifyImpostors.cginc"
struct v2f
{
V2F_SHADOW_CASTER;
float4 frameUVs : TEXCOORD0;
float4 viewPos : TEXCOORD1;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert( appdata_full v )
{
UNITY_SETUP_INSTANCE_ID(v);
v2f o;
UNITY_INITIALIZE_OUTPUT(v2f,o);
UNITY_TRANSFER_INSTANCE_ID(v,o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
SphereImpostorVertex( v.vertex, v.normal, o.frameUVs, o.viewPos );
TRANSFER_SHADOW_CASTER(o)
return o;
}
half4 frag( v2f IN, out float outDepth : SV_Depth ) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(IN);
SurfaceOutputStandardSpecular o;
UNITY_INITIALIZE_OUTPUT( SurfaceOutputStandardSpecular, o );
float4 clipPos;
float3 worldPos;
SphereImpostorFragment( o, clipPos, worldPos, IN.frameUVs, IN.viewPos );
IN.pos.zw = clipPos.zw;
outDepth = IN.pos.z;
UNITY_APPLY_DITHER_CROSSFADE(IN.pos.xy);
SHADOW_CASTER_FRAGMENT(IN)
}
ENDCG
}
Pass
{
Name "SceneSelectionPass"
Tags{ "LightMode" = "SceneSelectionPass" }
ZWrite On
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile __ LOD_FADE_CROSSFADE
#pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
#pragma multi_compile_instancing
#include "HLSLSupport.cginc"
#if !defined( UNITY_INSTANCED_LOD_FADE )
#define UNITY_INSTANCED_LOD_FADE
#endif
#include "UnityShaderVariables.cginc"
#include "UnityShaderUtilities.cginc"
#include "UnityCG.cginc"
#include "Lighting.cginc"
#include "UnityPBSLighting.cginc"
#include "UnityStandardUtils.cginc"
#include "AmplifyImpostors.cginc"
int _ObjectId;
int _PassValue;
struct v2f
{
UNITY_POSITION( pos );
float4 frameUVs : TEXCOORD0;
float4 viewPos : TEXCOORD1;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert( appdata_full v )
{
UNITY_SETUP_INSTANCE_ID(v);
v2f o;
UNITY_INITIALIZE_OUTPUT(v2f,o);
UNITY_TRANSFER_INSTANCE_ID(v,o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
SphereImpostorVertex( v.vertex, v.normal, o.frameUVs, o.viewPos );
o.pos = UnityObjectToClipPos( v.vertex );
return o;
}
half4 frag( v2f IN, out float outDepth : SV_Depth ) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(IN);
SurfaceOutputStandardSpecular o;
UNITY_INITIALIZE_OUTPUT( SurfaceOutputStandardSpecular, o );
float4 clipPos;
float3 worldPos;
SphereImpostorFragment( o, clipPos, worldPos, IN.frameUVs, IN.viewPos );
IN.pos.zw = clipPos.zw;
outDepth = IN.pos.z;
UNITY_APPLY_DITHER_CROSSFADE(IN.pos.xy);
return float4( _ObjectId, _PassValue, 1.0, 1.0 );
}
ENDCG
}
Pass
{
Name "ScenePickingPass"
Tags{ "LightMode" = "Picking" }
ZWrite On
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile __ LOD_FADE_CROSSFADE
#pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
#pragma multi_compile_instancing
#include "HLSLSupport.cginc"
#if !defined( UNITY_INSTANCED_LOD_FADE )
#define UNITY_INSTANCED_LOD_FADE
#endif
#include "UnityShaderVariables.cginc"
#include "UnityShaderUtilities.cginc"
#include "UnityCG.cginc"
#include "Lighting.cginc"
#include "UnityPBSLighting.cginc"
#include "UnityStandardUtils.cginc"
#include "AmplifyImpostors.cginc"
float4 _SelectionID;
struct v2f
{
UNITY_POSITION( pos );
float4 frameUVs : TEXCOORD0;
float4 viewPos : TEXCOORD1;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert( appdata_full v )
{
UNITY_SETUP_INSTANCE_ID(v);
v2f o;
UNITY_INITIALIZE_OUTPUT(v2f,o);
UNITY_TRANSFER_INSTANCE_ID(v,o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
SphereImpostorVertex( v.vertex, v.normal, o.frameUVs, o.viewPos );
o.pos = UnityObjectToClipPos( v.vertex );
return o;
}
half4 frag( v2f IN, out float outDepth : SV_Depth ) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(IN);
SurfaceOutputStandardSpecular o;
UNITY_INITIALIZE_OUTPUT( SurfaceOutputStandardSpecular, o );
float4 clipPos;
float3 worldPos;
SphereImpostorFragment( o, clipPos, worldPos, IN.frameUVs, IN.viewPos );
IN.pos.zw = clipPos.zw;
outDepth = IN.pos.z;
UNITY_APPLY_DITHER_CROSSFADE(IN.pos.xy);
return _SelectionID;
}
ENDCG
}
}
Fallback Off
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: e82933f4c0eb9ba42aab0739f48efe21
timeCreated: 1519841093
licenseType: Store
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: da79d698f4bf0164e910ad798d07efdf
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 2562e63c61d9c63438d6c3eaa14a1eef
folderAsset: yes
timeCreated: 1527851493
licenseType: Store
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

View File

@@ -0,0 +1,98 @@
fileFormatVersion: 2
guid: f6d52893e066905409ec8ac1bde8d300
timeCreated: 1481127003
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 0
linearTexture: 1
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: 1
mipBias: -1
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View File

@@ -0,0 +1,136 @@
fileFormatVersion: 2
guid: 1070aab9cfe961c409d48e3bec7f7ab0
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 1
swizzle: 50462976
cookieLightType: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 64
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 64
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: WebGL
maxTextureSize: 64
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 64
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 B

View File

@@ -0,0 +1,58 @@
fileFormatVersion: 2
guid: a91a70303ba684645a7a87a0ddec0eb7
timeCreated: 1496682298
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
buildTargetSettings: []
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 56b0cc7421d6a36449f3aebd19b3ae02
folderAsset: yes
timeCreated: 1526989445
licenseType: Store
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: fadcc2d9a34a1a34f93d4962ec37e6e7
timeCreated: 1517223090
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,105 @@
// Amplify Impostors
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System.Collections.Generic;
using UnityEngine;
namespace AmplifyImpostors
{
public enum ImpostorType
{
Spherical = 0,
Octahedron = 1,
HemiOctahedron = 2
}
[System.Flags]
public enum DeferredBuffers
{
AlbedoAlpha = 0x1,
SpecularSmoothness = 0x2,
NormalDepth = 0x4,
EmissionOcclusion = 0x8,
}
public enum RenderingMaps
{
Standard = 0,
Custom = 1,
}
[CreateAssetMenu( fileName = "New Impostor", order = 85 )]
[HelpURL( "https://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Impostors/Manual" )]
public class AmplifyImpostorAsset : ScriptableObject
{
[SerializeField]
public Material Material;
[SerializeField]
public Mesh Mesh;
[HideInInspector]
[SerializeField]
public int Version = 0;
[SerializeField]
public ImpostorType ImpostorType = ImpostorType.Octahedron;
[HideInInspector]
[SerializeField]
public bool LockedSizes = true;
[HideInInspector]
[SerializeField]
public int SelectedSize = 2048;
[SerializeField]
public Vector2 TexSize = new Vector2( 2048, 2048 );
[HideInInspector]
[SerializeField]
public bool DecoupleAxisFrames = false;
[SerializeField]
[Range( 1, 32 )]
public int HorizontalFrames = 16;
[SerializeField]
[Range( 1, 33 )] //check if 33 is needed later
public int VerticalFrames = 16;
[SerializeField]
[Range( 0, 64 )]
public int PixelPadding = 32;
[SerializeField]
[Range( 4, 16 )]
public int MaxVertices = 8;
[SerializeField]
[Range( 0f, 0.2f )]
public float Tolerance = 0.15f;
[SerializeField]
[Range( 0f, 1f )]
public float NormalScale = 0.01f;
[SerializeField]
public Vector2[] ShapePoints = new Vector2[] {
new Vector2(0.15f, 0f),
new Vector2(0.85f, 0f),
new Vector2(1f, 0.15f),
new Vector2(1f, 0.85f),
new Vector2(0.85f, 1f),
new Vector2(0.15f, 1f),
new Vector2(0f, 0.85f),
new Vector2(0f, 0.15f),
};
[SerializeField]
public AmplifyImpostorBakePreset Preset;
[SerializeField]
public List<TextureOutput> OverrideOutput = new List<TextureOutput>();
}
}

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: e7ba7a43222473d4292f91ae936fe2cc
timeCreated: 1530191356
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,115 @@
// Amplify Impostors
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System.Collections.Generic;
using UnityEngine;
namespace AmplifyImpostors
{
public enum ImageFormat
{
PNG = 0,
TGA = 1,
EXR = 2
}
public enum TextureChannels
{
RGBA = 0,
RGB = 1
}
public enum TextureCompression
{
None = 0,
Normal = 1,
High = 2,
Low = 3,
}
public enum TextureScale
{
Full = 1,
Half = 2,
Quarter = 4,
Eighth = 8,
}
[System.Flags]
public enum OverrideMask
{
OutputToggle = 1 << 0,
NameSuffix = 1 << 1,
RelativeScale = 1 << 2,
ColorSpace = 1 << 3,
QualityCompression = 1 << 4,
FileFormat = 1 << 5,
}
public enum PresetPipeline
{
Legacy = 0,
Lightweight = 1,
HighDefinition = 2
}
[System.Serializable]
public class TextureOutput
{
[SerializeField]
public int Index = -1;
[SerializeField]
public OverrideMask OverrideMask = 0;
public bool Active = true;
public string Name = string.Empty;
public TextureScale Scale = TextureScale.Full;
public bool SRGB = false;
public TextureChannels Channels = TextureChannels.RGBA;
public TextureCompression Compression = TextureCompression.Normal;
public ImageFormat ImageFormat = ImageFormat.TGA;
public TextureOutput() { }
public TextureOutput( bool a, string n, TextureScale s, bool sr, TextureChannels c, TextureCompression nc, ImageFormat i )
{
Active = a;
Name = n;
Scale = s;
SRGB = sr;
Channels = c;
Compression = nc;
ImageFormat = i;
}
public TextureOutput Clone()
{
return (TextureOutput)this.MemberwiseClone();
}
}
[CreateAssetMenu( fileName = "New Bake Preset", order = 86 )]
public class AmplifyImpostorBakePreset : ScriptableObject
{
// 0 => _Albedo(Alpha)
// 1 => _Normals(Depth)
// 2 => _Specular(Smoothness)
// 3 => _Occlusion
// 4 => _Emission
// 5 => _Position
public const int DefaultOutputCount = 6;
[SerializeField]
public Shader BakeShader = null;
[SerializeField]
public Shader RuntimeShader = null;
[SerializeField]
public int AlphaIndex = 0;
[SerializeField]
public List<TextureOutput> Output = new List<TextureOutput>();
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 32f7caa019b8743459b7b0ab1fdc3bae
timeCreated: 1533123553
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,4 @@
{
"name": "AmplifyImpostors.Runtime",
"allowUnsafeCode": true
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a1a7cacb6cec073439a2b2c1849d773b
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 77734ff038237eb409985a81c51661db
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,27 @@
// Amplify Impostors
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
//#define HDRP10
using UnityEngine;
using UnityEngine.Rendering;
namespace AmplifyImpostors
{
public class BakeHDRPTool
{
#if HDRP10
static UnityEngine.Rendering.HighDefinition.ShaderVariablesGlobal g_globalShaderVariables = new UnityEngine.Rendering.HighDefinition.ShaderVariablesGlobal();
public static void SetupShaderVariableGlobals( Matrix4x4 viewMat, Matrix4x4 projMatrix , CommandBuffer commandBuffer )
{
g_globalShaderVariables._ViewMatrix = viewMat;
g_globalShaderVariables._InvViewMatrix = viewMat.inverse;
g_globalShaderVariables._ProjMatrix = projMatrix;
g_globalShaderVariables._ViewProjMatrix = projMatrix * viewMat;
g_globalShaderVariables._WorldSpaceCameraPos_Internal = Vector4.zero;
ConstantBuffer.PushGlobal( commandBuffer, g_globalShaderVariables, UnityEngine.Rendering.HighDefinition.HDShaderIDs._ShaderVariablesGlobal );
}
#else
public static void SetupShaderVariableGlobals( Matrix4x4 viewMat, Matrix4x4 projMatrix , CommandBuffer commandBuffer ){/*This does nothing on HDRP lower that 10*/}
#endif
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e367a26cc52b15240b9dfc03c3537c16
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,462 @@
// Amplify Impostors
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using UnityEngine.Rendering;
#if UNITY_EDITOR
using UnityEditor;
#endif
using System.Reflection;
using System;
using System.IO;
namespace AmplifyImpostors
{
public static class BoundsEx
{
public static Bounds Transform( this Bounds bounds, Matrix4x4 matrix )
{
var center = matrix.MultiplyPoint3x4( bounds.center );
var extents = bounds.extents;
var axisX = matrix.MultiplyVector( new Vector3( extents.x, 0, 0 ) );
var axisY = matrix.MultiplyVector( new Vector3( 0, extents.y, 0 ) );
var axisZ = matrix.MultiplyVector( new Vector3( 0, 0, extents.z ) );
extents.x = Mathf.Abs( axisX.x ) + Mathf.Abs( axisY.x ) + Mathf.Abs( axisZ.x );
extents.y = Mathf.Abs( axisX.y ) + Mathf.Abs( axisY.y ) + Mathf.Abs( axisZ.y );
extents.z = Mathf.Abs( axisX.z ) + Mathf.Abs( axisY.z ) + Mathf.Abs( axisZ.z );
return new Bounds { center = center, extents = extents };
}
}
public static class MaterialEx
{
#if UNITY_EDITOR
public static void CopyPropertiesFrom( this Material to, Material from )
{
int count = from.shader.GetPropertyCount();
for( int i = 0; i < count; i++ )
{
var ty = from.shader.GetPropertyType( i );
var name = from.shader.GetPropertyName( i );
switch( ty )
{
case ShaderPropertyType.Color:
to.SetColor( name, from.GetColor( name ) );
break;
case ShaderPropertyType.Vector:
to.SetVector( name, from.GetVector( name ) );
break;
case ShaderPropertyType.Float:
to.SetFloat( name, from.GetFloat( name ) );
break;
case ShaderPropertyType.Range:
to.SetFloat( name, from.GetFloat( name ) );
break;
case ShaderPropertyType.Texture:
to.SetTexture( name, from.GetTexture( name ) );
to.SetTextureOffset( name, from.GetTextureOffset( name ) );
to.SetTextureScale( name, from.GetTextureScale( name ) );
break;
default:
break;
}
}
to.renderQueue = from.renderQueue;
to.globalIlluminationFlags = from.globalIlluminationFlags;
to.shaderKeywords = from.shaderKeywords;
foreach( var keyword in to.shaderKeywords )
{
to.EnableKeyword( keyword );
}
to.enableInstancing = from.enableInstancing;
EditorUtility.SetDirty( to );
}
#endif
public static void EnsureTextureKeywordState( this Material material, string property, string keyword )
{
var tex = material.HasProperty( property ) ? material.GetTexture( property ) : null;
EnsureKeywordState( material, keyword, tex != null );
}
public static void EnsureKeywordState( this Material material, string keyword, bool state )
{
if ( state && !material.IsKeywordEnabled( keyword ) )
{
material.EnableKeyword( keyword );
}
else if ( !state && material.IsKeywordEnabled( keyword ) )
{
material.DisableKeyword( keyword );
}
}
}
public static class Texture2DEx
{
static readonly byte[] Footer = { 0x54, 0x52, 0x55, 0x45, 0x56, 0x49, 0x53, 0x49, 0x4F, 0x4E, 0x2D, 0x58, 0x46, 0x49, 0x4C, 0x45, 0x2E, 0x00 }; // TRUEVISION-XFILE.\0 signature (new TGA format)
public enum Compression
{
None,
RLE
}
public static byte[] EncodeToTGA( this Texture2D tex, Compression compression = Compression.RLE )
{
const int headerSize = 18;
const int bytesRGB24 = 3;
const int bytesRGBA32 = 4;
int bytesPerPixel = tex.format == TextureFormat.ARGB32 || tex.format == TextureFormat.RGBA32 ? bytesRGBA32 : bytesRGB24;
using( MemoryStream stream = new MemoryStream( headerSize + tex.width * tex.height * bytesPerPixel ) )
{
using( BinaryWriter writer = new BinaryWriter( stream ) )
{
writer.Write( (byte)0 ); // IDLength (not in use)
writer.Write( (byte)0 ); // ColorMapType (not in use)
writer.Write( (byte)( compression == Compression.None ? 2 : 10 ) ); // DataTypeCode (10 == Runlength encoded RGB images)
writer.Write( (short)0 ); // ColorMapOrigin (not in use)
writer.Write( (short)0 ); // ColorMapLength (not in use)
writer.Write( (byte)0 ); // ColorMapDepth (not in use)
writer.Write( (short)0 ); // Origin X
writer.Write( (short)0 ); // Origin Y
writer.Write( (short)tex.width ); // Width
writer.Write( (short)tex.height ); // Height
writer.Write( (byte)( bytesPerPixel * 8 ) ); // Bits Per Pixel
writer.Write( (byte)8 ); // ImageDescriptor (photoshop uses 8?)
Color32[] pixels = tex.GetPixels32();
if( compression == Compression.None )
{
for( int i = 0; i < pixels.Length; i++ )
{
Color32 pixel = pixels[ i ];
writer.Write( pixel.r );
writer.Write( pixel.g );
writer.Write( pixel.b );
if( bytesPerPixel == bytesRGBA32 )
writer.Write( pixel.a );
}
}
else
{
const int maxPacket = 128;
int packetStart = 0;
int packetEnd = 0;
while( packetStart < pixels.Length )
{
Color32 currentPixel = pixels[ packetStart ];
bool isRLE = ( packetStart != pixels.Length - 1 ) && Equals( pixels[ packetStart ], pixels[ packetStart + 1 ] );
int endOfWidth = ( ( packetStart / tex.width ) + 1 ) * tex.width;
int readEnd = Mathf.Min( packetStart + maxPacket, pixels.Length, endOfWidth );
for( packetEnd = packetStart + 1; packetEnd < readEnd; ++packetEnd )
{
bool bPreviousEqualsCurrent = Equals( pixels[ packetEnd - 1 ], pixels[ packetEnd ] );
if( !isRLE && bPreviousEqualsCurrent || isRLE && !bPreviousEqualsCurrent )
break;
}
int packetLength = packetEnd - packetStart;
if( isRLE )
{
writer.Write( (byte)( ( packetLength - 1 ) | ( 1 << 7 ) ) );
writer.Write( currentPixel.r );
writer.Write( currentPixel.g );
writer.Write( currentPixel.b );
if( bytesPerPixel == bytesRGBA32 )
writer.Write( currentPixel.a );
}
else
{
writer.Write( (byte)( packetLength - 1 ) );
for( int i = packetStart; i < packetEnd; ++i )
{
Color32 pixel = pixels[ i ];
writer.Write( pixel.r );
writer.Write( pixel.g );
writer.Write( pixel.b );
if( bytesPerPixel == bytesRGBA32 )
writer.Write( pixel.a );
}
}
packetStart = packetEnd;
}
}
writer.Write( 0 ); // Offset of meta-information (not in use)
writer.Write( 0 ); // Offset of Developer-Area (not in use)
writer.Write( Footer ); // Signature
}
return stream.ToArray();
}
}
private static bool Equals( Color32 first, Color32 second )
{
return first.r == second.r && first.g == second.g && first.b == second.b && first.a == second.a;
}
}
public static class SpriteUtilityEx
{
private static System.Type type = null;
public static System.Type Type { get { return ( type == null ) ? type = System.Type.GetType( "UnityEditor.Sprites.SpriteUtility, UnityEditor" ) : type; } }
public static void GenerateOutline( Texture2D texture, Rect rect, float detail, byte alphaTolerance, bool holeDetection, out Vector2[][] paths )
{
Vector2[][] opaths = new Vector2[ 0 ][];
object[] parameters = new object[] { texture, rect, detail, alphaTolerance, holeDetection, opaths };
MethodInfo method = Type.GetMethod( "GenerateOutline", BindingFlags.Static | BindingFlags.NonPublic );
method.Invoke( null, parameters );
paths = (Vector2[][])parameters[ 5 ];
}
}
public static class RenderTextureEx
{
public static RenderTexture GetTemporary( RenderTexture renderTexture )
{
return RenderTexture.GetTemporary( renderTexture.width, renderTexture.height, renderTexture.depth, renderTexture.format );
}
}
public static class Vector2Ex
{
public static float Cross( this Vector2 O, Vector2 A, Vector2 B )
{
return ( A.x - O.x ) * ( B.y - O.y ) - ( A.y - O.y ) * ( B.x - O.x );
}
public static float TriangleArea( this Vector2 O, Vector2 A, Vector2 B )
{
return Mathf.Abs( ( A.x - B.x ) * ( O.y - A.y ) - ( A.x - O.x ) * ( B.y - A.y ) ) * 0.5f;
}
public static float TriangleArea( this Vector3 O, Vector3 A, Vector3 B )
{
return Mathf.Abs( ( A.x - B.x ) * ( O.y - A.y ) - ( A.x - O.x ) * ( B.y - A.y ) ) * 0.5f;
}
public static Vector2[] ConvexHull( Vector2[] P )
{
if( P.Length > 1 )
{
int n = P.Length, k = 0;
Vector2[] H = new Vector2[ 2 * n ];
Comparison<Vector2> comparison = new Comparison<Vector2>( ( a, b ) =>
{
if( a.x == b.x )
return a.y.CompareTo( b.y );
else
return a.x.CompareTo( b.x );
} );
Array.Sort<Vector2>( P, comparison );
// Build lower hull
for( int i = 0; i < n; ++i )
{
while( k >= 2 && P[ i ].Cross( H[ k - 2 ], H[ k - 1 ] ) <= 0 )
k--;
H[ k++ ] = P[ i ];
}
// Build upper hull
for( int i = n - 2, t = k + 1; i >= 0; i-- )
{
while( k >= t && P[ i ].Cross( H[ k - 2 ], H[ k - 1 ] ) <= 0 )
k--;
H[ k++ ] = P[ i ];
}
if( k > 1 )
Array.Resize<Vector2>( ref H, k - 1 );
return H;
}
else if( P.Length <= 1 )
{
return P;
}
else
{
return null;
}
}
public static Vector2[] ScaleAlongNormals( Vector2[] P, float scaleAmount )
{
Vector2[] normals = new Vector2[ P.Length ];
for( int i = 0; i < normals.Length; i++ )
{
int prev = i - 1;
int next = i + 1;
if( i == 0 )
prev = P.Length - 1;
if( i == P.Length - 1 )
next = 0;
Vector2 ba = P[ i ] - P[ prev ];
Vector2 bc = P[ i ] - P[ next ];
Vector2 normal = ( ba.normalized + bc.normalized ).normalized;
normals[ i ] = normal;
}
for( int i = 0; i < normals.Length; i++ )
{
P[ i ] = P[ i ] + normals[ i ] * scaleAmount;
}
return P;
}
static Vector2[] ReduceLeastSignificantVertice( Vector2[] P )
{
float currentArea = 0;
int smallestIndex = 0;
int replacementIndex = 0;
Vector2 newPos = Vector2.zero;
for( int i = 0; i < P.Length; i++ )
{
int next = i + 1;
int upNext = i + 2;
int finalNext = i + 3;
if( next >= P.Length )
next -= P.Length;
if( upNext >= P.Length )
upNext -= P.Length;
if( finalNext >= P.Length )
finalNext -= P.Length;
Vector2 intersect = GetIntersectionPointCoordinates( P[ i ], P[ next ], P[ upNext ], P[ finalNext ] );
if( i == 0 )
{
currentArea = intersect.TriangleArea( P[ next ], P[ upNext ] );
if( OutsideBounds( intersect ) > 0 )
currentArea = currentArea + OutsideBounds( intersect ) * 1;
smallestIndex = next;
replacementIndex = upNext;
newPos = intersect;
}
else
{
float newArea = intersect.TriangleArea( P[ next ], P[ upNext ] );
if( OutsideBounds( intersect ) > 0 )
newArea = newArea + OutsideBounds( intersect ) * 1;
if( newArea < currentArea && OutsideBounds( intersect ) <= 0 )
{
currentArea = newArea;
smallestIndex = next;
replacementIndex = upNext;
newPos = intersect;
}
}
}
P[ replacementIndex ] = newPos;
return Array.FindAll<Vector2>( P, x => Array.IndexOf( P, x ) != smallestIndex );
}
public static Vector2[] ReduceVertices( Vector2[] P, int maxVertices )
{
if( maxVertices == 4 )
{
// turn into a box
Rect newBox = new Rect( P[ 0 ].x, P[ 0 ].y, 0f, 0f );
for( int i = 0; i < P.Length; i++ )
{
newBox.xMin = Mathf.Min( newBox.xMin, P[ i ].x );
newBox.xMax = Mathf.Max( newBox.xMax, P[ i ].x );
newBox.yMin = Mathf.Min( newBox.yMin, P[ i ].y );
newBox.yMax = Mathf.Max( newBox.yMax, P[ i ].y );
}
P = new Vector2[]
{
new Vector2(newBox.xMin, newBox.yMin),
new Vector2(newBox.xMax, newBox.yMin),
new Vector2(newBox.xMax, newBox.yMax),
new Vector2(newBox.xMin, newBox.yMax),
};
}
else
{
// remove vertices to target count (naive implementation)
int reduction = Math.Max( 0, P.Length - maxVertices );
for( int k = 0; k < reduction; k++ )
{
P = ReduceLeastSignificantVertice( P );
// OLD METHOD
//float prevArea = 0;
//int indexForRemoval = 0;
//for( int i = 0; i < P.Length; i++ )
//{
// int prev = i - 1;
// int next = i + 1;
// if( i == 0 )
// prev = P.Length - 1;
// if( i == P.Length - 1 )
// next = 0;
// float area = P[ i ].TriangleArea( P[ prev ], P[ next ] );
// if( i == 0 )
// prevArea = area;
// if( area < prevArea )
// {
// indexForRemoval = i;
// prevArea = area;
// }
//}
//ArrayUtility.RemoveAt<Vector2>( ref P, indexForRemoval );
}
}
return P;
}
static Vector2 GetIntersectionPointCoordinates( Vector2 A1, Vector2 A2, Vector2 B1, Vector2 B2 )
{
float tmp = ( B2.x - B1.x ) * ( A2.y - A1.y ) - ( B2.y - B1.y ) * ( A2.x - A1.x );
if( tmp == 0 )
{
return ( ( Vector2.Lerp( A2, B1, 0.5f ) - ( Vector2.one * 0.5f ) ) * 1000 ) + ( Vector2.one * 500f );//Vector2.positiveInfinity;// Vector2.zero;
}
float mu = ( ( A1.x - B1.x ) * ( A2.y - A1.y ) - ( A1.y - B1.y ) * ( A2.x - A1.x ) ) / tmp;
return new Vector2(
B1.x + ( B2.x - B1.x ) * mu,
B1.y + ( B2.y - B1.y ) * mu
);
}
static float OutsideBounds( Vector2 P )
{
P = P - ( Vector2.one * 0.5f );
float vert = Mathf.Clamp01( Mathf.Abs( P.y ) - 0.5f );
float hori = Mathf.Clamp01( Mathf.Abs( P.x ) - 0.5f );
return hori + vert;
}
}
}

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 821be38acbe37c847922cabdcd593fe5
timeCreated: 1517333254
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,80 @@
// Amplify Impostors
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace AmplifyImpostors
{
public static class ImpostorBakingTools
{
#if UNITY_EDITOR
public static string OpenFolderForImpostor( this AmplifyImpostor instance )
{
string oneLevelUp = Application.dataPath + "/../";
string directory = Path.GetFullPath( oneLevelUp ).Replace( "\\", "/" );
string objectPath = AssetDatabase.GetAssetPath( instance.RootTransform );
// Find Path next to prefab
if( string.IsNullOrEmpty( objectPath ) )
{
objectPath = AssetDatabase.GetAssetPath( PrefabUtility.GetCorrespondingObjectFromSource( instance.RootTransform ) );
}
Preferences.GlobalRelativeFolder = EditorPrefs.GetString( Preferences.PrefGlobalRelativeFolder, "" );
string fullpath = string.Empty;
string suggestedRelativePath = directory + objectPath;
if( string.IsNullOrEmpty( objectPath ) )
suggestedRelativePath = Application.dataPath;
else
suggestedRelativePath = Path.GetDirectoryName( suggestedRelativePath ).Replace( "\\", "/" );
Preferences.GlobalFolder = EditorPrefs.GetString( Preferences.PrefGlobalFolder, "" );
// Find best match
if( Preferences.GlobalDefaultMode && AssetDatabase.IsValidFolder( Preferences.GlobalFolder.TrimStart( '/' ) ) )
fullpath = directory + Preferences.GlobalFolder;
else if( AssetDatabase.IsValidFolder( FileUtil.GetProjectRelativePath( suggestedRelativePath + Preferences.GlobalRelativeFolder ).TrimEnd( '/' ) ) )
fullpath = suggestedRelativePath + Preferences.GlobalRelativeFolder;
else if( AssetDatabase.IsValidFolder( FileUtil.GetProjectRelativePath( suggestedRelativePath ).TrimEnd( '/' ) ) )
fullpath = suggestedRelativePath;
else
fullpath = Application.dataPath;
string fileName = instance.name + "_Impostor";
if( !string.IsNullOrEmpty( instance.m_impostorName ) )
fileName = instance.m_impostorName;
//Debug.Log( fullpath );
//Debug.Log( fileName );
string folderpath = EditorUtility.SaveFilePanelInProject( "Save Impostor to folder", fileName, "asset", "", FileUtil.GetProjectRelativePath( fullpath ) );
fileName = Path.GetFileNameWithoutExtension( folderpath );
if( !string.IsNullOrEmpty( fileName ) )
{
folderpath = Path.GetDirectoryName( folderpath ).Replace( "\\", "/" );
if( !string.IsNullOrEmpty( folderpath ) )
{
folderpath += "/";
if( !Preferences.GlobalDefaultMode )
{
instance.m_folderPath = folderpath;
}
else
{
Preferences.GlobalFolder = folderpath;
EditorPrefs.SetString( Preferences.PrefGlobalFolder, Preferences.GlobalFolder );
}
instance.m_impostorName = fileName;
}
}
return folderpath;
}
#endif
}
}

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 8f54ccaf72377ff41a49e3882c8b6e7f
timeCreated: 1527167385
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,203 @@
// Amplify Impostors
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using System.IO;
using UnityEditor;
using UnityEngine;
namespace AmplifyImpostors
{
public class Preferences
{
#if UNITY_EDITOR
public enum ShowOption
{
Always = 0,
OnNewVersion = 1,
Never = 2
}
private static readonly GUIContent StartUp = new GUIContent( "Show start screen on Unity launch", "You can set if you want to see the start screen everytime Unity launches, only just when there's a new version available or never." );
private static readonly GUIContent AutoSRP = new GUIContent( "Auto import SRP shaders", "By default Amplify Impostors checks for your SRP version and automatically imports compatible shaders.\nTurn this OFF if you prefer to import them manually." );
public static readonly string PrefGlobalFolder = "IMPOSTORS_GLOBALFOLDER";
public static readonly string PrefGlobalRelativeFolder = "IMPOSTORS_GLOBALRELATIVEFOLDER";
public static readonly string PrefGlobalDefault = "IMPOSTORS_GLOBALDEFAULT";
public static readonly string PrefGlobalTexImport = "IMPOSTORS_GLOBALTEXIMPORT";
public static readonly string PrefGlobalCreateLodGroup = "IMPOSTORS_GLOBALCREATELODGROUP ";
public static readonly string PrefGlobalGBuffer0Name = "IMPOSTORS_GLOBALGBUFFER0SUFFIX";
public static readonly string PrefGlobalGBuffer1Name = "IMPOSTORS_GLOBALGBUFFER1SUFFIX";
public static readonly string PrefGlobalGBuffer2Name = "IMPOSTORS_GLOBALGBUFFER2SUFFIX";
public static readonly string PrefGlobalGBuffer3Name = "IMPOSTORS_GLOBALGBUFFER3SUFFIX";
public static readonly string PrefGlobalGBuffer4Name = "IMPOSTORS_GLOBALGBUFFER4SUFFIX";
public static readonly string PrefGlobalGBuffer5Name = "IMPOSTORS_GLOBALGBUFFER5SUFFIX";
public static readonly string PrefGlobalBakingOptions = "IMPOSTORS_GLOBALBakingOptions";
public static readonly string PrefGlobalStartUp = "IMPOSTORS_GLOBALSTARTUP";
public static readonly string PrefGlobalAutoSRP = "IMPOSTORS_GLOBALAUTOSRP";
public static readonly string PrefDataImpType = "IMPOSTORS_DATAIMPTYPE";
public static readonly string PrefDataTexSizeLocked = "IMPOSTORS_DATATEXSIZEXLOCKED";
public static readonly string PrefDataTexSizeSelected = "IMPOSTORS_DATATEXSIZEXSELECTED";
public static readonly string PrefDataTexSizeX = "IMPOSTORS_DATATEXSIZEX";
public static readonly string PrefDataTexSizeY = "IMPOSTORS_DATATEXSIZEY";
public static readonly string PrefDataDecoupledFrames = "IMPOSTORS_DATADECOUPLEDFRAMES";
public static readonly string PrefDataXFrames = "IMPOSTORS_DATAXFRAMES";
public static readonly string PrefDataYFrames = "IMPOSTORS_DATAYFRAMES";
public static readonly string PrefDataPixelBleeding = "IMPOSTORS_DATAPIXELBLEEDING";
public static readonly string PrefDataTolerance = "IMPOSTORS_DATATOLERANCE ";
public static readonly string PrefDataNormalScale = "IMPOSTORS_DATANORMALSCALE";
public static readonly string PrefDataMaxVertices = "IMPOSTORS_DATAMAXVERTICES";
public static readonly string DefaultAlbedoName = "_AlbedoAlpha";
public static readonly string DefaultSpecularName = "_SpecularSmoothness";
public static readonly string DefaultNormalName = "_NormalDepth";
public static readonly string DefaultEmissionName = "_EmissionOcclusion";
public static readonly string DefaultOcclusionName = "_Occlusion";
public static readonly string DefaultPositionName = "_Position";
public static bool GlobalDefaultMode = EditorPrefs.GetBool( PrefGlobalDefault, false );
public static string GlobalFolder = EditorPrefs.GetString( PrefGlobalFolder, "" );
public static string GlobalRelativeFolder = EditorPrefs.GetString( PrefGlobalRelativeFolder, "" );
public static int GlobalTexImport = EditorPrefs.GetInt( PrefGlobalTexImport, 0 );
public static bool GlobalCreateLodGroup = EditorPrefs.GetBool( PrefGlobalCreateLodGroup, false );
public static string GlobalAlbedo = EditorPrefs.GetString( PrefGlobalGBuffer0Name, DefaultAlbedoName );
public static string GlobalNormals = EditorPrefs.GetString( PrefGlobalGBuffer1Name, DefaultNormalName );
public static string GlobalSpecular = EditorPrefs.GetString( PrefGlobalGBuffer2Name, DefaultSpecularName );
public static string GlobalOcclusion = EditorPrefs.GetString( PrefGlobalGBuffer3Name, DefaultOcclusionName );
public static string GlobalEmission = EditorPrefs.GetString( PrefGlobalGBuffer4Name, DefaultEmissionName );
public static string GlobalPosition = EditorPrefs.GetString( PrefGlobalGBuffer5Name, DefaultPositionName );
public static bool GlobalBakingOptions = EditorPrefs.GetBool( PrefGlobalBakingOptions, true );
public static ShowOption GlobalStartUp = ( ShowOption )EditorPrefs.GetInt( PrefGlobalStartUp, 0 );
public static bool GlobalAutoSRP = EditorPrefs.GetBool( PrefGlobalAutoSRP, true );
private static readonly GUIContent DefaultSuffixesLabel = new GUIContent( "Default Suffixes", "Default Suffixes for new Bake Presets" );
private static bool PrefsLoaded = false;
private static GUIContent PathButtonContent = new GUIContent();
[SettingsProvider]
public static SettingsProvider ImpostorsSettings()
{
var provider = new SettingsProvider( "Preferences/Amplify Impostors", SettingsScope.User )
{
guiHandler = ( string searchContext ) => {
PreferencesGUI();
}
};
return provider;
}
public static void PreferencesGUI()
{
if ( !PrefsLoaded )
{
LoadDefaults();
PrefsLoaded = true;
}
PathButtonContent.text = string.IsNullOrEmpty( GlobalFolder ) ? "Click to select folder" : GlobalFolder;
EditorGUIUtility.labelWidth = 250;
GlobalStartUp = ( ShowOption )EditorGUILayout.EnumPopup( StartUp, GlobalStartUp );
GlobalAutoSRP = EditorGUILayout.Toggle( AutoSRP, GlobalAutoSRP );
GlobalDefaultMode = ( FolderMode )EditorGUILayout.EnumPopup( "New Impostor Default Path", GlobalDefaultMode ? FolderMode.Global : FolderMode.RelativeToPrefab ) == FolderMode.Global;
EditorGUILayout.BeginHorizontal();
if ( GlobalDefaultMode )
{
EditorGUI.BeginChangeCheck();
GlobalFolder = EditorGUILayout.TextField( "Global Folder", GlobalFolder );
if ( EditorGUI.EndChangeCheck() )
{
GlobalFolder = GlobalFolder.TrimStart( new char[] { '/', '*', '.', ' ' } );
GlobalFolder = "/" + GlobalFolder;
GlobalFolder = GlobalFolder.TrimEnd( new char[] { '/', '*', '.', ' ' } );
EditorPrefs.SetString( PrefGlobalFolder, GlobalFolder );
}
if ( GUILayout.Button( "...", "minibutton", GUILayout.Width( 20 )/*GUILayout.MaxWidth( Screen.width * 0.5f )*/ ) )
{
string oneLevelUp = Application.dataPath + "/../";
string directory = Path.GetFullPath( oneLevelUp ).Replace( "\\", "/" );
string fullpath = directory + GlobalFolder;
string folderpath = EditorUtility.SaveFolderPanel( "Save Impostor to folder", FileUtil.GetProjectRelativePath( fullpath ), null );
folderpath = FileUtil.GetProjectRelativePath( folderpath );
if ( !string.IsNullOrEmpty( folderpath ) )
{
GlobalFolder = folderpath;
GlobalFolder = GlobalFolder.TrimStart( new char[] { '/', '*', '.', ' ' } );
GlobalFolder = "/" + GlobalFolder;
GlobalFolder = GlobalFolder.TrimEnd( new char[] { '/', '*', '.', ' ' } );
EditorPrefs.SetString( PrefGlobalFolder, GlobalFolder );
}
}
}
else
{
EditorGUI.BeginChangeCheck();
GlobalRelativeFolder = EditorGUILayout.TextField( "Relative to Prefab Folder", GlobalRelativeFolder );
if ( EditorGUI.EndChangeCheck() )
{
GlobalRelativeFolder = GlobalRelativeFolder.TrimStart( new char[] { '/', '*', '.', ' ' } );
GlobalRelativeFolder = "/" + GlobalRelativeFolder;
GlobalRelativeFolder = GlobalRelativeFolder.TrimEnd( new char[] { '/', '*', '.', ' ' } );
EditorPrefs.SetString( PrefGlobalRelativeFolder, GlobalRelativeFolder );
}
EditorGUI.BeginDisabledGroup( true );
GUILayout.Button( "...", "minibutton", GUILayout.Width( 20 ) );
EditorGUI.EndDisabledGroup();
}
EditorGUILayout.EndHorizontal();
GlobalTexImport = EditorGUILayout.Popup( "Texture Importer Settings", GlobalTexImport, new string[] { "Ask if resolution is different", "Don't ask, always change", "Don't ask, never change" } );
GlobalCreateLodGroup = EditorGUILayout.Toggle( "Create LODGroup if not present", GlobalCreateLodGroup );
GUILayout.Space( 5 );
GUILayout.Label( DefaultSuffixesLabel, "boldlabel" );
GlobalAlbedo = EditorGUILayout.TextField( "Albedo (RGB) Alpha (A)", GlobalAlbedo );
GlobalNormals = EditorGUILayout.TextField( "Normal (RGB) Depth (A)", GlobalNormals );
GlobalSpecular = EditorGUILayout.TextField( "Specular (RGB) Smoothness (A)", GlobalSpecular );
GlobalOcclusion = EditorGUILayout.TextField( "Occlusion (RGB)", GlobalOcclusion );
GlobalEmission = EditorGUILayout.TextField( "Emission (RGB)", GlobalEmission );
GlobalPosition = EditorGUILayout.TextField( "Position (RGB)", GlobalPosition );
if ( GUI.changed )
{
EditorPrefs.SetInt( PrefGlobalStartUp, ( int )GlobalStartUp );
EditorPrefs.SetBool( PrefGlobalAutoSRP, GlobalAutoSRP );
EditorPrefs.SetBool( PrefGlobalDefault, GlobalDefaultMode );
EditorPrefs.SetInt( PrefGlobalTexImport, GlobalTexImport );
EditorPrefs.SetBool( PrefGlobalCreateLodGroup, GlobalCreateLodGroup );
EditorPrefs.SetString( PrefGlobalGBuffer0Name, GlobalAlbedo );
EditorPrefs.SetString( PrefGlobalGBuffer1Name, GlobalSpecular );
EditorPrefs.SetString( PrefGlobalGBuffer2Name, GlobalNormals );
EditorPrefs.SetString( PrefGlobalGBuffer3Name, GlobalEmission );
EditorPrefs.SetString( PrefGlobalGBuffer4Name, GlobalOcclusion );
EditorPrefs.SetString( PrefGlobalGBuffer5Name, GlobalPosition );
}
}
public static void LoadDefaults()
{
GlobalStartUp = ( ShowOption )EditorPrefs.GetInt( PrefGlobalStartUp, 0 );
GlobalAutoSRP = EditorPrefs.GetBool( PrefGlobalAutoSRP, true );
GlobalFolder = EditorPrefs.GetString( PrefGlobalFolder, "" );
GlobalRelativeFolder = EditorPrefs.GetString( PrefGlobalRelativeFolder, "" );
GlobalDefaultMode = EditorPrefs.GetBool( PrefGlobalDefault, false );
GlobalTexImport = EditorPrefs.GetInt( PrefGlobalTexImport, 0 );
GlobalCreateLodGroup = EditorPrefs.GetBool( PrefGlobalCreateLodGroup, false );
GlobalBakingOptions = EditorPrefs.GetBool( PrefGlobalBakingOptions, true );
GlobalAlbedo = EditorPrefs.GetString( PrefGlobalGBuffer0Name, DefaultAlbedoName );
GlobalSpecular = EditorPrefs.GetString( PrefGlobalGBuffer1Name, DefaultSpecularName );
GlobalNormals = EditorPrefs.GetString( PrefGlobalGBuffer2Name, DefaultNormalName );
GlobalEmission = EditorPrefs.GetString( PrefGlobalGBuffer3Name, DefaultEmissionName );
GlobalOcclusion = EditorPrefs.GetString( PrefGlobalGBuffer4Name, DefaultOcclusionName );
GlobalPosition = EditorPrefs.GetString( PrefGlobalGBuffer5Name, DefaultPositionName );
}
#endif
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a5333d9fdffa80b4f82078d0b3a3670f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Some files were not shown because too many files have changed in this diff Show More