Initial commit
This commit is contained in:
Коммит
81ce021e98
|
@ -0,0 +1,46 @@
|
|||
# see http://editorconfig.org/ for docs on this file
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
end_of_line = lf ; help with sharing files across os's (i.e. network share or through local vm)
|
||||
#charset temporarily disabled due to bug in VS2017 changing to UTF-8 with BOM (https://favro.com/card/c564ede4ed3337f7b17986b6/Uni-17877)
|
||||
#charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
# trailing whitespace is significant in markdown (bad choice, bad!)
|
||||
[*.{md,markdown}]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
# keep these and the VS stuff below in sync with .hgeol's CRLF extensions
|
||||
[*.{vcproj,bat,cmd,xaml,tt,t4,ttinclude}]
|
||||
end_of_line = crlf
|
||||
|
||||
# this VS-specific stuff is based on experiments to see how VS will modify a file after it has been manually edited.
|
||||
# the settings are meant to closely match what VS does to minimize unnecessary diffs. this duplicates some settings in *
|
||||
# but let's be explicit here to be safe (in case someone wants to copy-paste this out to another .editorconfig).
|
||||
[*.{vcxproj,vcxproj.filters}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = crlf
|
||||
charset = utf-8-bom
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = false
|
||||
# must be broken out because of 51-char bug (https://github.com/editorconfig/editorconfig-visualstudio/issues/21)
|
||||
[*.{csproj,pyproj,props,targets}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = crlf
|
||||
charset = utf-8-bom
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = false
|
||||
[*.{sln,sln.template}]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
end_of_line = crlf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = false
|
|
@ -0,0 +1,37 @@
|
|||
## git-lfs ##
|
||||
#Image
|
||||
*.jpg filter=lfs diff=lfs merge=lfs -text
|
||||
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
||||
*.png filter=lfs diff=lfs merge=lfs -text
|
||||
*.gif filter=lfs diff=lfs merge=lfs -text
|
||||
*.psd filter=lfs diff=lfs merge=lfs -text
|
||||
*.ai filter=lfs diff=lfs merge=lfs -text
|
||||
*.tif filter=lfs diff=lfs merge=lfs -text
|
||||
#Audio
|
||||
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
||||
*.wav filter=lfs diff=lfs merge=lfs -text
|
||||
*.ogg filter=lfs diff=lfs merge=lfs -text
|
||||
#Video
|
||||
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
||||
*.mov filter=lfs diff=lfs merge=lfs -text
|
||||
#3D Object
|
||||
*.FBX filter=lfs diff=lfs merge=lfs -text
|
||||
*.fbx filter=lfs diff=lfs merge=lfs -text
|
||||
*.blend filter=lfs diff=lfs merge=lfs -text
|
||||
*.obj filter=lfs diff=lfs merge=lfs -text
|
||||
#ETC
|
||||
*.a filter=lfs diff=lfs merge=lfs -text
|
||||
*.exr filter=lfs diff=lfs merge=lfs -text
|
||||
*.tga filter=lfs diff=lfs merge=lfs -text
|
||||
*.pdf filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.dll filter=lfs diff=lfs merge=lfs -text
|
||||
*.unitypackage filter=lfs diff=lfs merge=lfs -text
|
||||
*.aif filter=lfs diff=lfs merge=lfs -text
|
||||
*.ttf filter=lfs diff=lfs merge=lfs -text
|
||||
*.rns filter=lfs diff=lfs merge=lfs -text
|
||||
*.reason filter=lfs diff=lfs merge=lfs -text
|
||||
*.lxo filter=lfs diff=lfs merge=lfs -text
|
||||
SAI filter=lfs diff=lfs merge=lfs -text
|
||||
*.anim filter=lfs diff=lfs merge=lfs -text
|
||||
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
|
@ -0,0 +1,52 @@
|
|||
/[Ll]ibrary/
|
||||
/[Tt]emp/
|
||||
/[Oo]bj/
|
||||
/[Bb]uild/
|
||||
/[Bb]uilds/
|
||||
/Assets/AssetStoreTools*
|
||||
|
||||
# Visual Studio 2015 cache directory
|
||||
/.vs/
|
||||
|
||||
# Autogenerated VS/MD/Consulo solution and project files
|
||||
ExportedObj/
|
||||
.consulo/
|
||||
*.csproj
|
||||
*.unityproj
|
||||
*.sln
|
||||
*.suo
|
||||
*.tmp
|
||||
*.user
|
||||
*.userprefs
|
||||
*.pidb
|
||||
*.booproj
|
||||
*.svd
|
||||
*.pdb
|
||||
|
||||
# Autogenerated by JetBrains Rider
|
||||
/.idea/
|
||||
/Assets/Plugins/Editor/JetBrains*
|
||||
|
||||
# Because Rider installs Unity plugin auto-magically it's necessary to ignore these
|
||||
Assets/Plugins.meta
|
||||
Assets/Plugins/Editor.meta
|
||||
|
||||
# Unity3D generated meta files
|
||||
*.pidb.meta
|
||||
|
||||
# Unity3D Generated File On Crash Reports
|
||||
sysinfo.txt
|
||||
|
||||
# Builds
|
||||
*.apk
|
||||
*.unitypackage
|
||||
|
||||
# Unity Scenes from Asset Packs
|
||||
/Assets/Troll Bridge Studios/**/*.unity
|
||||
/Assets/ParadoxNotion/**/*.unity
|
||||
/Assets/_UI/Materials/*Bar.mat
|
||||
#/ProjectSettings/ProjectVersion.txt
|
||||
.leu
|
||||
*.DotSettings
|
||||
ValidationSuiteResults/
|
||||
*.DS_Store
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 17bd9306175a7c94694e32403c9337eb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "AI.Planner.Domains",
|
||||
"references": [
|
||||
"Unity.AI.Planner",
|
||||
"Unity.Properties",
|
||||
"Unity.Entities"
|
||||
],
|
||||
"optionalUnityReferences": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": []
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2ca47f5dc919b7b4fa284617b7a49ae1
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7f7822917855cec42b0f5c2184669863
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a86edce2e7cb7d94fa0f19279d8d8ca7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,36 @@
|
|||
using System;
|
||||
using Unity.AI.Planner;
|
||||
using Unity.AI.Planner.DomainLanguage.TraitBased;
|
||||
using Unity.Entities;
|
||||
|
||||
namespace WorkaholicDomain
|
||||
{
|
||||
[Serializable]
|
||||
public partial struct Agent : ITrait<Agent>, IEquatable<Agent>
|
||||
{
|
||||
|
||||
public bool Equals(Agent other)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return GetType().GetHashCode();
|
||||
}
|
||||
|
||||
public object Clone() { return MemberwiseClone(); }
|
||||
public void SetComponentData(EntityManager entityManager, Entity domainObjectEntity)
|
||||
{
|
||||
SetTraitMask(entityManager, domainObjectEntity);
|
||||
entityManager.SetComponentData(domainObjectEntity, this);
|
||||
}
|
||||
|
||||
public void SetTraitMask(EntityManager entityManager, Entity domainObjectEntity)
|
||||
{
|
||||
var objectHash = entityManager.GetComponentData<HashCode>(domainObjectEntity);
|
||||
objectHash.TraitMask = objectHash.TraitMask | (uint)TraitMask.Agent;
|
||||
entityManager.SetComponentData(domainObjectEntity, objectHash);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fb442c3ae018027428eb1e64e6b651a0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,59 @@
|
|||
#if (NET_4_6 || NET_STANDARD_2_0)
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Unity.AI.Planner;
|
||||
using Unity.Properties;
|
||||
|
||||
namespace WorkaholicDomain
|
||||
{
|
||||
public partial struct Agent : IStructPropertyContainer<Agent>
|
||||
{
|
||||
private static StructPropertyBag<Agent> s_PropertyBag { get; set; }
|
||||
|
||||
/// <inheritdoc cref="Unity.Properties.IPropertyContainer.PropertyBag" />
|
||||
public IPropertyBag PropertyBag => s_PropertyBag;
|
||||
/// <inheritdoc cref="Unity.Properties.IPropertyContainer.VersionStorage" />
|
||||
public IVersionStorage VersionStorage => null;
|
||||
|
||||
private static void InitializeProperties()
|
||||
{
|
||||
}
|
||||
|
||||
static partial void InitializeCustomProperties();
|
||||
|
||||
private static void InitializePropertyBag()
|
||||
{
|
||||
s_PropertyBag = new StructPropertyBag<Agent>();
|
||||
}
|
||||
|
||||
static Agent()
|
||||
{
|
||||
InitializeProperties();
|
||||
InitializeCustomProperties();
|
||||
InitializePropertyBag();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Pass this object as a reference to the given handler.
|
||||
/// </summary>
|
||||
/// <param name="byRef">Handler to invoke.</param>
|
||||
/// <param name="context">Context argument passed to the handler.</param>
|
||||
public void MakeRef<TContext>(ByRef<Agent, TContext> byRef, TContext context)
|
||||
{
|
||||
byRef(ref this, context);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pass this object as a reference to the given handler, and return the result.
|
||||
/// </summary>
|
||||
/// <param name="byRef">Handler to invoke.</param>
|
||||
/// <param name="context">Context argument passed to the handler.</param>
|
||||
/// <returns>The handler's return value.</returns>
|
||||
public TReturn MakeRef<TContext, TReturn>(ByRef<Agent, TContext, TReturn> byRef, TContext context)
|
||||
{
|
||||
return byRef(ref this, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // (NET_4_6 || NET_STANDARD_2_0)
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 03b145e607e8d784b9868bc9f507afb3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,36 @@
|
|||
using System;
|
||||
using Unity.AI.Planner;
|
||||
using Unity.AI.Planner.DomainLanguage.TraitBased;
|
||||
using Unity.Entities;
|
||||
|
||||
namespace WorkaholicDomain
|
||||
{
|
||||
[Serializable]
|
||||
public partial struct Bed : ITrait<Bed>, IEquatable<Bed>
|
||||
{
|
||||
|
||||
public bool Equals(Bed other)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return GetType().GetHashCode();
|
||||
}
|
||||
|
||||
public object Clone() { return MemberwiseClone(); }
|
||||
public void SetComponentData(EntityManager entityManager, Entity domainObjectEntity)
|
||||
{
|
||||
SetTraitMask(entityManager, domainObjectEntity);
|
||||
entityManager.SetComponentData(domainObjectEntity, this);
|
||||
}
|
||||
|
||||
public void SetTraitMask(EntityManager entityManager, Entity domainObjectEntity)
|
||||
{
|
||||
var objectHash = entityManager.GetComponentData<HashCode>(domainObjectEntity);
|
||||
objectHash.TraitMask = objectHash.TraitMask | (uint)TraitMask.Bed;
|
||||
entityManager.SetComponentData(domainObjectEntity, objectHash);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fee822db6af04a246bdcc927febfe376
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,59 @@
|
|||
#if (NET_4_6 || NET_STANDARD_2_0)
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Unity.AI.Planner;
|
||||
using Unity.Properties;
|
||||
|
||||
namespace WorkaholicDomain
|
||||
{
|
||||
public partial struct Bed : IStructPropertyContainer<Bed>
|
||||
{
|
||||
private static StructPropertyBag<Bed> s_PropertyBag { get; set; }
|
||||
|
||||
/// <inheritdoc cref="Unity.Properties.IPropertyContainer.PropertyBag" />
|
||||
public IPropertyBag PropertyBag => s_PropertyBag;
|
||||
/// <inheritdoc cref="Unity.Properties.IPropertyContainer.VersionStorage" />
|
||||
public IVersionStorage VersionStorage => null;
|
||||
|
||||
private static void InitializeProperties()
|
||||
{
|
||||
}
|
||||
|
||||
static partial void InitializeCustomProperties();
|
||||
|
||||
private static void InitializePropertyBag()
|
||||
{
|
||||
s_PropertyBag = new StructPropertyBag<Bed>();
|
||||
}
|
||||
|
||||
static Bed()
|
||||
{
|
||||
InitializeProperties();
|
||||
InitializeCustomProperties();
|
||||
InitializePropertyBag();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Pass this object as a reference to the given handler.
|
||||
/// </summary>
|
||||
/// <param name="byRef">Handler to invoke.</param>
|
||||
/// <param name="context">Context argument passed to the handler.</param>
|
||||
public void MakeRef<TContext>(ByRef<Bed, TContext> byRef, TContext context)
|
||||
{
|
||||
byRef(ref this, context);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pass this object as a reference to the given handler, and return the result.
|
||||
/// </summary>
|
||||
/// <param name="byRef">Handler to invoke.</param>
|
||||
/// <param name="context">Context argument passed to the handler.</param>
|
||||
/// <returns>The handler's return value.</returns>
|
||||
public TReturn MakeRef<TContext, TReturn>(ByRef<Bed, TContext, TReturn> byRef, TContext context)
|
||||
{
|
||||
return byRef(ref this, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // (NET_4_6 || NET_STANDARD_2_0)
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a50d15c69db96e9459e0f44e5c57c0fe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
namespace WorkaholicDomain
|
||||
{
|
||||
public enum ConsumableType
|
||||
{
|
||||
Apple,
|
||||
Bottle,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: aeb47631969e63646a99bfe4c425e2ad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using Unity.AI.Planner;
|
||||
using Unity.AI.Planner.DomainLanguage.TraitBased;
|
||||
using Unity.Entities;
|
||||
|
||||
namespace WorkaholicDomain
|
||||
{
|
||||
[Serializable]
|
||||
public partial struct Dispenser : ITrait<Dispenser>, IEquatable<Dispenser>
|
||||
{
|
||||
public ConsumableType m_ConsumableType;
|
||||
|
||||
public bool Equals(Dispenser other)
|
||||
{
|
||||
return m_ConsumableType == other.m_ConsumableType;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return 397
|
||||
^ m_ConsumableType.GetHashCode();
|
||||
}
|
||||
|
||||
public object Clone() { return MemberwiseClone(); }
|
||||
public void SetComponentData(EntityManager entityManager, Entity domainObjectEntity)
|
||||
{
|
||||
SetTraitMask(entityManager, domainObjectEntity);
|
||||
entityManager.SetComponentData(domainObjectEntity, this);
|
||||
}
|
||||
|
||||
public void SetTraitMask(EntityManager entityManager, Entity domainObjectEntity)
|
||||
{
|
||||
var objectHash = entityManager.GetComponentData<HashCode>(domainObjectEntity);
|
||||
objectHash.TraitMask = objectHash.TraitMask | (uint)TraitMask.Dispenser;
|
||||
entityManager.SetComponentData(domainObjectEntity, objectHash);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0faa1d4622ad62b4c870c0624c92a458
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,74 @@
|
|||
#if (NET_4_6 || NET_STANDARD_2_0)
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Unity.AI.Planner;
|
||||
using Unity.Properties;
|
||||
|
||||
namespace WorkaholicDomain
|
||||
{
|
||||
public partial struct Dispenser : IStructPropertyContainer<Dispenser>
|
||||
{
|
||||
public static ValueStructProperty<Dispenser, ConsumableType> ConsumableTypeProperty { get; private set; }
|
||||
|
||||
private static StructPropertyBag<Dispenser> s_PropertyBag { get; set; }
|
||||
|
||||
/// <inheritdoc cref="Unity.Properties.IPropertyContainer.PropertyBag" />
|
||||
public IPropertyBag PropertyBag => s_PropertyBag;
|
||||
/// <inheritdoc cref="Unity.Properties.IPropertyContainer.VersionStorage" />
|
||||
public IVersionStorage VersionStorage => null;
|
||||
|
||||
private static void InitializeProperties()
|
||||
{
|
||||
ConsumableTypeProperty = new ValueStructProperty<Dispenser, ConsumableType>(
|
||||
"ConsumableType"
|
||||
,(ref Dispenser c) => c.m_ConsumableType
|
||||
,(ref Dispenser c, ConsumableType v) => c.m_ConsumableType = v
|
||||
);
|
||||
}
|
||||
|
||||
static partial void InitializeCustomProperties();
|
||||
|
||||
private static void InitializePropertyBag()
|
||||
{
|
||||
s_PropertyBag = new StructPropertyBag<Dispenser>(
|
||||
ConsumableTypeProperty
|
||||
);
|
||||
}
|
||||
|
||||
static Dispenser()
|
||||
{
|
||||
InitializeProperties();
|
||||
InitializeCustomProperties();
|
||||
InitializePropertyBag();
|
||||
}
|
||||
|
||||
public ConsumableType ConsumableType
|
||||
{
|
||||
get { return ConsumableTypeProperty.GetValue(ref this); }
|
||||
set { ConsumableTypeProperty.SetValue(ref this, value); }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Pass this object as a reference to the given handler.
|
||||
/// </summary>
|
||||
/// <param name="byRef">Handler to invoke.</param>
|
||||
/// <param name="context">Context argument passed to the handler.</param>
|
||||
public void MakeRef<TContext>(ByRef<Dispenser, TContext> byRef, TContext context)
|
||||
{
|
||||
byRef(ref this, context);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pass this object as a reference to the given handler, and return the result.
|
||||
/// </summary>
|
||||
/// <param name="byRef">Handler to invoke.</param>
|
||||
/// <param name="context">Context argument passed to the handler.</param>
|
||||
/// <returns>The handler's return value.</returns>
|
||||
public TReturn MakeRef<TContext, TReturn>(ByRef<Dispenser, TContext, TReturn> byRef, TContext context)
|
||||
{
|
||||
return byRef(ref this, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // (NET_4_6 || NET_STANDARD_2_0)
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 16a5f4363aad16447be5207fef0dd6d1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using Unity.AI.Planner;
|
||||
using Unity.AI.Planner.DomainLanguage.TraitBased;
|
||||
using Unity.Entities;
|
||||
|
||||
namespace WorkaholicDomain
|
||||
{
|
||||
[Serializable]
|
||||
public partial struct Duration : ITrait<Duration>, IEquatable<Duration>
|
||||
{
|
||||
public System.Int64 m_Time;
|
||||
|
||||
public bool Equals(Duration other)
|
||||
{
|
||||
return m_Time == other.m_Time;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return 397
|
||||
^ m_Time.GetHashCode();
|
||||
}
|
||||
|
||||
public object Clone() { return MemberwiseClone(); }
|
||||
public void SetComponentData(EntityManager entityManager, Entity domainObjectEntity)
|
||||
{
|
||||
SetTraitMask(entityManager, domainObjectEntity);
|
||||
entityManager.SetComponentData(domainObjectEntity, this);
|
||||
}
|
||||
|
||||
public void SetTraitMask(EntityManager entityManager, Entity domainObjectEntity)
|
||||
{
|
||||
var objectHash = entityManager.GetComponentData<HashCode>(domainObjectEntity);
|
||||
objectHash.TraitMask = objectHash.TraitMask | (uint)TraitMask.Duration;
|
||||
entityManager.SetComponentData(domainObjectEntity, objectHash);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3965c7165ecd5a8428595c51e24d504b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,74 @@
|
|||
#if (NET_4_6 || NET_STANDARD_2_0)
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Unity.AI.Planner;
|
||||
using Unity.Properties;
|
||||
|
||||
namespace WorkaholicDomain
|
||||
{
|
||||
public partial struct Duration : IStructPropertyContainer<Duration>
|
||||
{
|
||||
public static ValueStructProperty<Duration, System.Int64> TimeProperty { get; private set; }
|
||||
|
||||
private static StructPropertyBag<Duration> s_PropertyBag { get; set; }
|
||||
|
||||
/// <inheritdoc cref="Unity.Properties.IPropertyContainer.PropertyBag" />
|
||||
public IPropertyBag PropertyBag => s_PropertyBag;
|
||||
/// <inheritdoc cref="Unity.Properties.IPropertyContainer.VersionStorage" />
|
||||
public IVersionStorage VersionStorage => null;
|
||||
|
||||
private static void InitializeProperties()
|
||||
{
|
||||
TimeProperty = new ValueStructProperty<Duration, System.Int64>(
|
||||
"Time"
|
||||
,(ref Duration c) => c.m_Time
|
||||
,(ref Duration c, System.Int64 v) => c.m_Time = v
|
||||
);
|
||||
}
|
||||
|
||||
static partial void InitializeCustomProperties();
|
||||
|
||||
private static void InitializePropertyBag()
|
||||
{
|
||||
s_PropertyBag = new StructPropertyBag<Duration>(
|
||||
TimeProperty
|
||||
);
|
||||
}
|
||||
|
||||
static Duration()
|
||||
{
|
||||
InitializeProperties();
|
||||
InitializeCustomProperties();
|
||||
InitializePropertyBag();
|
||||
}
|
||||
|
||||
public System.Int64 Time
|
||||
{
|
||||
get { return TimeProperty.GetValue(ref this); }
|
||||
set { TimeProperty.SetValue(ref this, value); }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Pass this object as a reference to the given handler.
|
||||
/// </summary>
|
||||
/// <param name="byRef">Handler to invoke.</param>
|
||||
/// <param name="context">Context argument passed to the handler.</param>
|
||||
public void MakeRef<TContext>(ByRef<Duration, TContext> byRef, TContext context)
|
||||
{
|
||||
byRef(ref this, context);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pass this object as a reference to the given handler, and return the result.
|
||||
/// </summary>
|
||||
/// <param name="byRef">Handler to invoke.</param>
|
||||
/// <param name="context">Context argument passed to the handler.</param>
|
||||
/// <returns>The handler's return value.</returns>
|
||||
public TReturn MakeRef<TContext, TReturn>(ByRef<Duration, TContext, TReturn> byRef, TContext context)
|
||||
{
|
||||
return byRef(ref this, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // (NET_4_6 || NET_STANDARD_2_0)
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a9ba15b00e546f649b642232b51c21f4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,47 @@
|
|||
using System;
|
||||
using Unity.AI.Planner;
|
||||
using Unity.AI.Planner.DomainLanguage.TraitBased;
|
||||
using Unity.Entities;
|
||||
|
||||
namespace WorkaholicDomain
|
||||
{
|
||||
[Serializable]
|
||||
public partial struct Inventory : ITrait<Inventory>, IEquatable<Inventory>
|
||||
{
|
||||
public ConsumableType m_ConsumableType;
|
||||
public System.Int64 m_Amount;
|
||||
public NeedType m_SatisfiesNeed;
|
||||
public System.Int64 m_NeedReduction;
|
||||
|
||||
public bool Equals(Inventory other)
|
||||
{
|
||||
return m_ConsumableType == other.m_ConsumableType
|
||||
&& m_Amount == other.m_Amount
|
||||
&& m_SatisfiesNeed == other.m_SatisfiesNeed
|
||||
&& m_NeedReduction == other.m_NeedReduction;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return 397
|
||||
^ m_ConsumableType.GetHashCode()
|
||||
^ m_Amount.GetHashCode()
|
||||
^ m_SatisfiesNeed.GetHashCode()
|
||||
^ m_NeedReduction.GetHashCode();
|
||||
}
|
||||
|
||||
public object Clone() { return MemberwiseClone(); }
|
||||
public void SetComponentData(EntityManager entityManager, Entity domainObjectEntity)
|
||||
{
|
||||
SetTraitMask(entityManager, domainObjectEntity);
|
||||
entityManager.SetComponentData(domainObjectEntity, this);
|
||||
}
|
||||
|
||||
public void SetTraitMask(EntityManager entityManager, Entity domainObjectEntity)
|
||||
{
|
||||
var objectHash = entityManager.GetComponentData<HashCode>(domainObjectEntity);
|
||||
objectHash.TraitMask = objectHash.TraitMask | (uint)TraitMask.Inventory;
|
||||
entityManager.SetComponentData(domainObjectEntity, objectHash);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 868962aeb9c1b334c9fa2efccae22596
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,116 @@
|
|||
#if (NET_4_6 || NET_STANDARD_2_0)
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Unity.AI.Planner;
|
||||
using Unity.Properties;
|
||||
|
||||
namespace WorkaholicDomain
|
||||
{
|
||||
public partial struct Inventory : IStructPropertyContainer<Inventory>
|
||||
{
|
||||
public static ValueStructProperty<Inventory, ConsumableType> ConsumableTypeProperty { get; private set; }
|
||||
public static ValueStructProperty<Inventory, System.Int64> AmountProperty { get; private set; }
|
||||
public static ValueStructProperty<Inventory, NeedType> SatisfiesNeedProperty { get; private set; }
|
||||
public static ValueStructProperty<Inventory, System.Int64> NeedReductionProperty { get; private set; }
|
||||
|
||||
private static StructPropertyBag<Inventory> s_PropertyBag { get; set; }
|
||||
|
||||
/// <inheritdoc cref="Unity.Properties.IPropertyContainer.PropertyBag" />
|
||||
public IPropertyBag PropertyBag => s_PropertyBag;
|
||||
/// <inheritdoc cref="Unity.Properties.IPropertyContainer.VersionStorage" />
|
||||
public IVersionStorage VersionStorage => null;
|
||||
|
||||
private static void InitializeProperties()
|
||||
{
|
||||
ConsumableTypeProperty = new ValueStructProperty<Inventory, ConsumableType>(
|
||||
"ConsumableType"
|
||||
,(ref Inventory c) => c.m_ConsumableType
|
||||
,(ref Inventory c, ConsumableType v) => c.m_ConsumableType = v
|
||||
);
|
||||
|
||||
AmountProperty = new ValueStructProperty<Inventory, System.Int64>(
|
||||
"Amount"
|
||||
,(ref Inventory c) => c.m_Amount
|
||||
,(ref Inventory c, System.Int64 v) => c.m_Amount = v
|
||||
);
|
||||
|
||||
SatisfiesNeedProperty = new ValueStructProperty<Inventory, NeedType>(
|
||||
"SatisfiesNeed"
|
||||
,(ref Inventory c) => c.m_SatisfiesNeed
|
||||
,(ref Inventory c, NeedType v) => c.m_SatisfiesNeed = v
|
||||
);
|
||||
|
||||
NeedReductionProperty = new ValueStructProperty<Inventory, System.Int64>(
|
||||
"NeedReduction"
|
||||
,(ref Inventory c) => c.m_NeedReduction
|
||||
,(ref Inventory c, System.Int64 v) => c.m_NeedReduction = v
|
||||
);
|
||||
}
|
||||
|
||||
static partial void InitializeCustomProperties();
|
||||
|
||||
private static void InitializePropertyBag()
|
||||
{
|
||||
s_PropertyBag = new StructPropertyBag<Inventory>(
|
||||
ConsumableTypeProperty,
|
||||
AmountProperty,
|
||||
SatisfiesNeedProperty,
|
||||
NeedReductionProperty
|
||||
);
|
||||
}
|
||||
|
||||
static Inventory()
|
||||
{
|
||||
InitializeProperties();
|
||||
InitializeCustomProperties();
|
||||
InitializePropertyBag();
|
||||
}
|
||||
|
||||
public ConsumableType ConsumableType
|
||||
{
|
||||
get { return ConsumableTypeProperty.GetValue(ref this); }
|
||||
set { ConsumableTypeProperty.SetValue(ref this, value); }
|
||||
}
|
||||
|
||||
public System.Int64 Amount
|
||||
{
|
||||
get { return AmountProperty.GetValue(ref this); }
|
||||
set { AmountProperty.SetValue(ref this, value); }
|
||||
}
|
||||
|
||||
public NeedType SatisfiesNeed
|
||||
{
|
||||
get { return SatisfiesNeedProperty.GetValue(ref this); }
|
||||
set { SatisfiesNeedProperty.SetValue(ref this, value); }
|
||||
}
|
||||
|
||||
public System.Int64 NeedReduction
|
||||
{
|
||||
get { return NeedReductionProperty.GetValue(ref this); }
|
||||
set { NeedReductionProperty.SetValue(ref this, value); }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Pass this object as a reference to the given handler.
|
||||
/// </summary>
|
||||
/// <param name="byRef">Handler to invoke.</param>
|
||||
/// <param name="context">Context argument passed to the handler.</param>
|
||||
public void MakeRef<TContext>(ByRef<Inventory, TContext> byRef, TContext context)
|
||||
{
|
||||
byRef(ref this, context);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pass this object as a reference to the given handler, and return the result.
|
||||
/// </summary>
|
||||
/// <param name="byRef">Handler to invoke.</param>
|
||||
/// <param name="context">Context argument passed to the handler.</param>
|
||||
/// <returns>The handler's return value.</returns>
|
||||
public TReturn MakeRef<TContext, TReturn>(ByRef<Inventory, TContext, TReturn> byRef, TContext context)
|
||||
{
|
||||
return byRef(ref this, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // (NET_4_6 || NET_STANDARD_2_0)
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 999a83fa8d155ec45a090e4ec4d81a9a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,44 @@
|
|||
using System;
|
||||
using Unity.AI.Planner;
|
||||
using Unity.AI.Planner.DomainLanguage.TraitBased;
|
||||
using Unity.Entities;
|
||||
|
||||
namespace WorkaholicDomain
|
||||
{
|
||||
[Serializable]
|
||||
public partial struct Need : ITrait<Need>, IEquatable<Need>
|
||||
{
|
||||
public NeedType m_NeedType;
|
||||
public System.Int64 m_Urgency;
|
||||
public System.Int64 m_ChangePerSecond;
|
||||
|
||||
public bool Equals(Need other)
|
||||
{
|
||||
return m_NeedType == other.m_NeedType
|
||||
&& m_Urgency == other.m_Urgency
|
||||
&& m_ChangePerSecond == other.m_ChangePerSecond;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return 397
|
||||
^ m_NeedType.GetHashCode()
|
||||
^ m_Urgency.GetHashCode()
|
||||
^ m_ChangePerSecond.GetHashCode();
|
||||
}
|
||||
|
||||
public object Clone() { return MemberwiseClone(); }
|
||||
public void SetComponentData(EntityManager entityManager, Entity domainObjectEntity)
|
||||
{
|
||||
SetTraitMask(entityManager, domainObjectEntity);
|
||||
entityManager.SetComponentData(domainObjectEntity, this);
|
||||
}
|
||||
|
||||
public void SetTraitMask(EntityManager entityManager, Entity domainObjectEntity)
|
||||
{
|
||||
var objectHash = entityManager.GetComponentData<HashCode>(domainObjectEntity);
|
||||
objectHash.TraitMask = objectHash.TraitMask | (uint)TraitMask.Need;
|
||||
entityManager.SetComponentData(domainObjectEntity, objectHash);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 75c14d242b693b34480e55482d74670c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,102 @@
|
|||
#if (NET_4_6 || NET_STANDARD_2_0)
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Unity.AI.Planner;
|
||||
using Unity.Properties;
|
||||
|
||||
namespace WorkaholicDomain
|
||||
{
|
||||
public partial struct Need : IStructPropertyContainer<Need>
|
||||
{
|
||||
public static ValueStructProperty<Need, NeedType> NeedTypeProperty { get; private set; }
|
||||
public static ValueStructProperty<Need, System.Int64> UrgencyProperty { get; private set; }
|
||||
public static ValueStructProperty<Need, System.Int64> ChangePerSecondProperty { get; private set; }
|
||||
|
||||
private static StructPropertyBag<Need> s_PropertyBag { get; set; }
|
||||
|
||||
/// <inheritdoc cref="Unity.Properties.IPropertyContainer.PropertyBag" />
|
||||
public IPropertyBag PropertyBag => s_PropertyBag;
|
||||
/// <inheritdoc cref="Unity.Properties.IPropertyContainer.VersionStorage" />
|
||||
public IVersionStorage VersionStorage => null;
|
||||
|
||||
private static void InitializeProperties()
|
||||
{
|
||||
NeedTypeProperty = new ValueStructProperty<Need, NeedType>(
|
||||
"NeedType"
|
||||
,(ref Need c) => c.m_NeedType
|
||||
,(ref Need c, NeedType v) => c.m_NeedType = v
|
||||
);
|
||||
|
||||
UrgencyProperty = new ValueStructProperty<Need, System.Int64>(
|
||||
"Urgency"
|
||||
,(ref Need c) => c.m_Urgency
|
||||
,(ref Need c, System.Int64 v) => c.m_Urgency = v
|
||||
);
|
||||
|
||||
ChangePerSecondProperty = new ValueStructProperty<Need, System.Int64>(
|
||||
"ChangePerSecond"
|
||||
,(ref Need c) => c.m_ChangePerSecond
|
||||
,(ref Need c, System.Int64 v) => c.m_ChangePerSecond = v
|
||||
);
|
||||
}
|
||||
|
||||
static partial void InitializeCustomProperties();
|
||||
|
||||
private static void InitializePropertyBag()
|
||||
{
|
||||
s_PropertyBag = new StructPropertyBag<Need>(
|
||||
NeedTypeProperty,
|
||||
UrgencyProperty,
|
||||
ChangePerSecondProperty
|
||||
);
|
||||
}
|
||||
|
||||
static Need()
|
||||
{
|
||||
InitializeProperties();
|
||||
InitializeCustomProperties();
|
||||
InitializePropertyBag();
|
||||
}
|
||||
|
||||
public NeedType NeedType
|
||||
{
|
||||
get { return NeedTypeProperty.GetValue(ref this); }
|
||||
set { NeedTypeProperty.SetValue(ref this, value); }
|
||||
}
|
||||
|
||||
public System.Int64 Urgency
|
||||
{
|
||||
get { return UrgencyProperty.GetValue(ref this); }
|
||||
set { UrgencyProperty.SetValue(ref this, value); }
|
||||
}
|
||||
|
||||
public System.Int64 ChangePerSecond
|
||||
{
|
||||
get { return ChangePerSecondProperty.GetValue(ref this); }
|
||||
set { ChangePerSecondProperty.SetValue(ref this, value); }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Pass this object as a reference to the given handler.
|
||||
/// </summary>
|
||||
/// <param name="byRef">Handler to invoke.</param>
|
||||
/// <param name="context">Context argument passed to the handler.</param>
|
||||
public void MakeRef<TContext>(ByRef<Need, TContext> byRef, TContext context)
|
||||
{
|
||||
byRef(ref this, context);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pass this object as a reference to the given handler, and return the result.
|
||||
/// </summary>
|
||||
/// <param name="byRef">Handler to invoke.</param>
|
||||
/// <param name="context">Context argument passed to the handler.</param>
|
||||
/// <returns>The handler's return value.</returns>
|
||||
public TReturn MakeRef<TContext, TReturn>(ByRef<Need, TContext, TReturn> byRef, TContext context)
|
||||
{
|
||||
return byRef(ref this, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // (NET_4_6 || NET_STANDARD_2_0)
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fef7e0d99e9b0a44a8972a090b7e72a8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
namespace WorkaholicDomain
|
||||
{
|
||||
public enum NeedType
|
||||
{
|
||||
Hunger,
|
||||
Thirst,
|
||||
Fatigue,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a9422e30ee7ddc841af1ac41bc1af0f6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using Unity.AI.Planner;
|
||||
using Unity.AI.Planner.DomainLanguage.TraitBased;
|
||||
using Unity.Entities;
|
||||
|
||||
namespace WorkaholicDomain
|
||||
{
|
||||
[Serializable]
|
||||
public partial struct Time : ITrait<Time>, IEquatable<Time>
|
||||
{
|
||||
public System.Int64 m_Value;
|
||||
|
||||
public bool Equals(Time other)
|
||||
{
|
||||
return m_Value == other.m_Value;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return 397
|
||||
^ m_Value.GetHashCode();
|
||||
}
|
||||
|
||||
public object Clone() { return MemberwiseClone(); }
|
||||
public void SetComponentData(EntityManager entityManager, Entity domainObjectEntity)
|
||||
{
|
||||
SetTraitMask(entityManager, domainObjectEntity);
|
||||
entityManager.SetComponentData(domainObjectEntity, this);
|
||||
}
|
||||
|
||||
public void SetTraitMask(EntityManager entityManager, Entity domainObjectEntity)
|
||||
{
|
||||
var objectHash = entityManager.GetComponentData<HashCode>(domainObjectEntity);
|
||||
objectHash.TraitMask = objectHash.TraitMask | (uint)TraitMask.Time;
|
||||
entityManager.SetComponentData(domainObjectEntity, objectHash);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 24ef4b6ccf2f7f44e881bbd3ef309810
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,74 @@
|
|||
#if (NET_4_6 || NET_STANDARD_2_0)
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Unity.AI.Planner;
|
||||
using Unity.Properties;
|
||||
|
||||
namespace WorkaholicDomain
|
||||
{
|
||||
public partial struct Time : IStructPropertyContainer<Time>
|
||||
{
|
||||
public static ValueStructProperty<Time, System.Int64> ValueProperty { get; private set; }
|
||||
|
||||
private static StructPropertyBag<Time> s_PropertyBag { get; set; }
|
||||
|
||||
/// <inheritdoc cref="Unity.Properties.IPropertyContainer.PropertyBag" />
|
||||
public IPropertyBag PropertyBag => s_PropertyBag;
|
||||
/// <inheritdoc cref="Unity.Properties.IPropertyContainer.VersionStorage" />
|
||||
public IVersionStorage VersionStorage => null;
|
||||
|
||||
private static void InitializeProperties()
|
||||
{
|
||||
ValueProperty = new ValueStructProperty<Time, System.Int64>(
|
||||
"Value"
|
||||
,(ref Time c) => c.m_Value
|
||||
,(ref Time c, System.Int64 v) => c.m_Value = v
|
||||
);
|
||||
}
|
||||
|
||||
static partial void InitializeCustomProperties();
|
||||
|
||||
private static void InitializePropertyBag()
|
||||
{
|
||||
s_PropertyBag = new StructPropertyBag<Time>(
|
||||
ValueProperty
|
||||
);
|
||||
}
|
||||
|
||||
static Time()
|
||||
{
|
||||
InitializeProperties();
|
||||
InitializeCustomProperties();
|
||||
InitializePropertyBag();
|
||||
}
|
||||
|
||||
public System.Int64 Value
|
||||
{
|
||||
get { return ValueProperty.GetValue(ref this); }
|
||||
set { ValueProperty.SetValue(ref this, value); }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Pass this object as a reference to the given handler.
|
||||
/// </summary>
|
||||
/// <param name="byRef">Handler to invoke.</param>
|
||||
/// <param name="context">Context argument passed to the handler.</param>
|
||||
public void MakeRef<TContext>(ByRef<Time, TContext> byRef, TContext context)
|
||||
{
|
||||
byRef(ref this, context);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pass this object as a reference to the given handler, and return the result.
|
||||
/// </summary>
|
||||
/// <param name="byRef">Handler to invoke.</param>
|
||||
/// <param name="context">Context argument passed to the handler.</param>
|
||||
/// <returns>The handler's return value.</returns>
|
||||
public TReturn MakeRef<TContext, TReturn>(ByRef<Time, TContext, TReturn> byRef, TContext context)
|
||||
{
|
||||
return byRef(ref this, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // (NET_4_6 || NET_STANDARD_2_0)
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 99aa7f5436968bf4cb79dcbed68a4140
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 63f7d2f27358caf47943ce7f652187a0
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,229 @@
|
|||
using System.Collections.Generic;
|
||||
using Unity.AI.Planner;
|
||||
using Unity.AI.Planner.DomainLanguage.TraitBased;
|
||||
using Unity.Collections;
|
||||
using Unity.Entities;
|
||||
|
||||
namespace WorkaholicDomain.WorkaholicActions
|
||||
{
|
||||
public partial class Consume : BaseAction<Consume.Permutation>
|
||||
{
|
||||
public NativeArray<ComponentType> agentTypes { get; private set; }
|
||||
public NativeArray<ComponentType> inventoryTypes { get; private set; }
|
||||
public NativeArray<ComponentType> needTypes { get; private set; }
|
||||
public NativeArray<ComponentType> timeTypes { get; private set; }
|
||||
|
||||
List<(Entity, int)> m_agentEntities = new List<(Entity, int)>();
|
||||
List<(Entity, int)> m_inventoryEntities = new List<(Entity, int)>();
|
||||
List<(Entity, int)> m_needEntities = new List<(Entity, int)>();
|
||||
List<(Entity, int)> m_timeEntities = new List<(Entity, int)>();
|
||||
|
||||
public struct Permutation
|
||||
{
|
||||
public int agentIndex;
|
||||
public int inventoryIndex;
|
||||
public int needIndex;
|
||||
public int timeIndex;
|
||||
public int Length => 4;
|
||||
|
||||
public int this[int i]
|
||||
{
|
||||
get
|
||||
{
|
||||
switch(i)
|
||||
{
|
||||
case 0:
|
||||
return agentIndex;
|
||||
|
||||
case 1:
|
||||
return inventoryIndex;
|
||||
|
||||
case 2:
|
||||
return needIndex;
|
||||
|
||||
case 3:
|
||||
return timeIndex;
|
||||
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnCreateManager()
|
||||
{
|
||||
base.OnCreateManager();
|
||||
|
||||
agentTypes = new NativeArray<ComponentType>(new []
|
||||
{
|
||||
ComponentType.ReadOnly<Agent>(),
|
||||
ComponentType.ReadOnly<Location>(),
|
||||
}, Allocator.Persistent);
|
||||
|
||||
inventoryTypes = new NativeArray<ComponentType>(new []
|
||||
{
|
||||
ComponentType.ReadOnly<Inventory>(),
|
||||
}, Allocator.Persistent);
|
||||
|
||||
needTypes = new NativeArray<ComponentType>(new []
|
||||
{
|
||||
ComponentType.ReadOnly<Need>(),
|
||||
}, Allocator.Persistent);
|
||||
|
||||
timeTypes = new NativeArray<ComponentType>(new []
|
||||
{
|
||||
ComponentType.ReadOnly<Time>(),
|
||||
}, Allocator.Persistent);
|
||||
|
||||
|
||||
m_FilterTuples = new[]
|
||||
{
|
||||
(agentTypes, m_agentEntities),
|
||||
(inventoryTypes, m_inventoryEntities),
|
||||
(needTypes, m_needEntities),
|
||||
(timeTypes, m_timeEntities),
|
||||
};
|
||||
}
|
||||
|
||||
protected override void OnDestroyManager()
|
||||
{
|
||||
base.OnDestroyManager();
|
||||
|
||||
if (agentTypes.IsCreated)
|
||||
{
|
||||
agentTypes.Dispose();
|
||||
agentTypes = default;
|
||||
}
|
||||
if (inventoryTypes.IsCreated)
|
||||
{
|
||||
inventoryTypes.Dispose();
|
||||
inventoryTypes = default;
|
||||
}
|
||||
if (needTypes.IsCreated)
|
||||
{
|
||||
needTypes.Dispose();
|
||||
needTypes = default;
|
||||
}
|
||||
if (timeTypes.IsCreated)
|
||||
{
|
||||
timeTypes.Dispose();
|
||||
timeTypes = default;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void GenerateArgumentPermutations(Entity stateEntity)
|
||||
{
|
||||
var DomainObjects = GetComponentDataFromEntity<DomainObjectTrait>(true);
|
||||
var Locations = GetComponentDataFromEntity<Location>(true);
|
||||
var Inventorys = GetComponentDataFromEntity<Inventory>(true);
|
||||
var Needs = GetComponentDataFromEntity<Need>(true);
|
||||
var Times = GetComponentDataFromEntity<Time>(true);
|
||||
|
||||
FilterObjects(stateEntity);
|
||||
foreach (var (agentEntity, agentIndex) in m_agentEntities)
|
||||
{
|
||||
foreach (var (inventoryEntity, inventoryIndex) in m_inventoryEntities)
|
||||
{
|
||||
foreach (var (needEntity, needIndex) in m_needEntities)
|
||||
{
|
||||
foreach (var (timeEntity, timeIndex) in m_timeEntities)
|
||||
{
|
||||
if (!(Inventorys[inventoryEntity].SatisfiesNeed == Needs[needEntity].NeedType))
|
||||
continue;
|
||||
if (!(Inventorys[inventoryEntity].Amount > 0))
|
||||
continue;
|
||||
if (!(Needs[needEntity].Urgency >= Inventorys[inventoryEntity].NeedReduction))
|
||||
continue;
|
||||
m_ArgumentPermutations.Add(new Permutation()
|
||||
{
|
||||
agentIndex = agentIndex,
|
||||
inventoryIndex = inventoryIndex,
|
||||
needIndex = needIndex,
|
||||
timeIndex = timeIndex,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ApplyEffects(Permutation permutation, Entity parentPolicyGraphNodeEntity, Entity originalStateEntity, int horizon)
|
||||
{
|
||||
var actionNodeEntity = CreateActionNode(parentPolicyGraphNodeEntity);
|
||||
var stateCopyEntity = CopyState(originalStateEntity);
|
||||
|
||||
var domainObjectBuffer = EntityManager.GetBuffer<DomainObjectReference>(stateCopyEntity);
|
||||
var DomainObjects = GetComponentDataFromEntity<DomainObjectTrait>();
|
||||
var Locations = GetComponentDataFromEntity<Location>();
|
||||
var Inventorys = GetComponentDataFromEntity<Inventory>();
|
||||
var Needs = GetComponentDataFromEntity<Need>();
|
||||
var Times = GetComponentDataFromEntity<Time>();
|
||||
var objectHashes = GetComponentDataFromEntity<HashCode>();
|
||||
|
||||
var agentEntity = GetEntity(domainObjectBuffer, permutation.agentIndex, stateCopyEntity);
|
||||
var inventoryEntity = GetEntity(domainObjectBuffer, permutation.inventoryIndex, stateCopyEntity);
|
||||
var needEntity = GetEntity(domainObjectBuffer, permutation.needIndex, stateCopyEntity);
|
||||
var timeEntity = GetEntity(domainObjectBuffer, permutation.timeIndex, stateCopyEntity);
|
||||
|
||||
{
|
||||
var @inventory = Inventorys[inventoryEntity];
|
||||
var hash = objectHashes[inventoryEntity];
|
||||
hash.Value -= @inventory.GetHashCode();
|
||||
@inventory.Amount -= 1;
|
||||
Inventorys[inventoryEntity] = @inventory;
|
||||
hash.Value += @inventory.GetHashCode();
|
||||
objectHashes[inventoryEntity] = hash;
|
||||
}
|
||||
|
||||
{
|
||||
var @need = Needs[needEntity];
|
||||
var hash = objectHashes[needEntity];
|
||||
hash.Value -= @need.GetHashCode();
|
||||
@need.Urgency -= Inventorys[inventoryEntity].NeedReduction;
|
||||
Needs[needEntity] = @need;
|
||||
hash.Value += @need.GetHashCode();
|
||||
objectHashes[needEntity] = hash;
|
||||
}
|
||||
|
||||
{
|
||||
var @time = Times[timeEntity];
|
||||
var hash = objectHashes[timeEntity];
|
||||
hash.Value -= @time.GetHashCode();
|
||||
@time.Value += 1;
|
||||
Times[timeEntity] = @time;
|
||||
hash.Value += @time.GetHashCode();
|
||||
objectHashes[timeEntity] = hash;
|
||||
}
|
||||
|
||||
var argumentLength = permutation.Length;
|
||||
var argumentBuffer = EntityManager.GetBuffer<ActionNodeArgument>(actionNodeEntity);
|
||||
var arguments = new NativeArray<int>(argumentLength, Allocator.Temp);
|
||||
for (var i = 0; i < argumentLength; i++)
|
||||
{
|
||||
var argumentIndex = permutation[i];
|
||||
argumentBuffer.Add(new ActionNodeArgument() { DomainObjectReferenceIndex = argumentIndex });
|
||||
arguments[i] = argumentIndex;
|
||||
}
|
||||
|
||||
ApplyCustomActionEffectsToState(stateCopyEntity, originalStateEntity, arguments);
|
||||
|
||||
SetActionData(stateCopyEntity, originalStateEntity, parentPolicyGraphNodeEntity, horizon + 1, actionNodeEntity,
|
||||
Reward(originalStateEntity, stateCopyEntity, arguments));
|
||||
|
||||
arguments.Dispose();
|
||||
}
|
||||
|
||||
partial void ApplyCustomActionEffectsToState(Entity stateEntity, Entity originalStateEntity, NativeArray<int> arguments); // Implement this method in another file to extend the action's effects
|
||||
|
||||
float Reward(Entity startStateEntity, Entity endStateEntity, NativeArray<int> arguments)
|
||||
{
|
||||
var reward = -1f;
|
||||
SetCustomReward(ref reward, startStateEntity, endStateEntity, arguments);
|
||||
|
||||
return reward;
|
||||
}
|
||||
|
||||
partial void SetCustomReward(ref float reward, Entity startStateEntity, Entity endStateEntity, NativeArray<int> arguments); // Implement this method in another file to modify the reward
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f5efbf88542df5e498ed082a1309fe51
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
using Unity.AI.Planner.DomainLanguage.TraitBased;
|
||||
using Unity.Collections;
|
||||
using Unity.Entities;
|
||||
|
||||
namespace WorkaholicDomain.WorkaholicActions
|
||||
{
|
||||
public class Die : IStateTermination
|
||||
{
|
||||
public string Name
|
||||
{
|
||||
get => s_Name;
|
||||
set => s_Name = value;
|
||||
}
|
||||
|
||||
public NativeArray<ComponentType> ComponentTypes => m_ComponentTypes;
|
||||
|
||||
protected static string s_Name = "Die";
|
||||
NativeArray<ComponentType> m_ComponentTypes;
|
||||
|
||||
public Die()
|
||||
{
|
||||
m_ComponentTypes = new NativeArray<ComponentType>(new []
|
||||
{
|
||||
ComponentType.ReadOnly<Need>(),
|
||||
}, Allocator.Persistent);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (m_ComponentTypes.IsCreated)
|
||||
{
|
||||
m_ComponentTypes.Dispose();
|
||||
m_ComponentTypes = default;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShouldTerminate(EntityManager entityManager, Entity domainObjectEntity)
|
||||
{
|
||||
return entityManager.GetComponentData<Need>(domainObjectEntity).Urgency >= 100;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e29f775f699c8ff4f908dd8f05ac07cd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,179 @@
|
|||
using System.Collections.Generic;
|
||||
using Unity.AI.Planner;
|
||||
using Unity.AI.Planner.DomainLanguage.TraitBased;
|
||||
using Unity.Collections;
|
||||
using Unity.Entities;
|
||||
|
||||
namespace WorkaholicDomain.WorkaholicActions
|
||||
{
|
||||
public partial class Navigate : BaseAction<Navigate.Permutation>
|
||||
{
|
||||
public NativeArray<ComponentType> agentTypes { get; private set; }
|
||||
public NativeArray<ComponentType> toTypes { get; private set; }
|
||||
public NativeArray<ComponentType> timeTypes { get; private set; }
|
||||
|
||||
List<(Entity, int)> m_agentEntities = new List<(Entity, int)>();
|
||||
List<(Entity, int)> m_toEntities = new List<(Entity, int)>();
|
||||
List<(Entity, int)> m_timeEntities = new List<(Entity, int)>();
|
||||
|
||||
public struct Permutation
|
||||
{
|
||||
public int agentIndex;
|
||||
public int toIndex;
|
||||
public int timeIndex;
|
||||
public int Length => 3;
|
||||
|
||||
public int this[int i]
|
||||
{
|
||||
get
|
||||
{
|
||||
switch(i)
|
||||
{
|
||||
case 0:
|
||||
return agentIndex;
|
||||
|
||||
case 1:
|
||||
return toIndex;
|
||||
|
||||
case 2:
|
||||
return timeIndex;
|
||||
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnCreateManager()
|
||||
{
|
||||
base.OnCreateManager();
|
||||
|
||||
agentTypes = new NativeArray<ComponentType>(new []
|
||||
{
|
||||
ComponentType.ReadOnly<Agent>(),
|
||||
ComponentType.ReadOnly<Location>(),
|
||||
}, Allocator.Persistent);
|
||||
|
||||
toTypes = new NativeArray<ComponentType>(new []
|
||||
{
|
||||
ComponentType.ReadOnly<Location>(),
|
||||
}, Allocator.Persistent);
|
||||
|
||||
timeTypes = new NativeArray<ComponentType>(new []
|
||||
{
|
||||
ComponentType.ReadOnly<Time>(),
|
||||
}, Allocator.Persistent);
|
||||
|
||||
|
||||
m_FilterTuples = new[]
|
||||
{
|
||||
(agentTypes, m_agentEntities),
|
||||
(toTypes, m_toEntities),
|
||||
(timeTypes, m_timeEntities),
|
||||
};
|
||||
}
|
||||
|
||||
protected override void OnDestroyManager()
|
||||
{
|
||||
base.OnDestroyManager();
|
||||
|
||||
if (agentTypes.IsCreated)
|
||||
{
|
||||
agentTypes.Dispose();
|
||||
agentTypes = default;
|
||||
}
|
||||
if (toTypes.IsCreated)
|
||||
{
|
||||
toTypes.Dispose();
|
||||
toTypes = default;
|
||||
}
|
||||
if (timeTypes.IsCreated)
|
||||
{
|
||||
timeTypes.Dispose();
|
||||
timeTypes = default;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void GenerateArgumentPermutations(Entity stateEntity)
|
||||
{
|
||||
var DomainObjects = GetComponentDataFromEntity<DomainObjectTrait>(true);
|
||||
var Locations = GetComponentDataFromEntity<Location>(true);
|
||||
var Times = GetComponentDataFromEntity<Time>(true);
|
||||
|
||||
FilterObjects(stateEntity);
|
||||
foreach (var (agentEntity, agentIndex) in m_agentEntities)
|
||||
{
|
||||
foreach (var (toEntity, toIndex) in m_toEntities)
|
||||
{
|
||||
foreach (var (timeEntity, timeIndex) in m_timeEntities)
|
||||
{
|
||||
if (!(Locations[agentEntity].Position != Locations[toEntity].Position))
|
||||
continue;
|
||||
m_ArgumentPermutations.Add(new Permutation()
|
||||
{
|
||||
agentIndex = agentIndex,
|
||||
toIndex = toIndex,
|
||||
timeIndex = timeIndex,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ApplyEffects(Permutation permutation, Entity parentPolicyGraphNodeEntity, Entity originalStateEntity, int horizon)
|
||||
{
|
||||
var actionNodeEntity = CreateActionNode(parentPolicyGraphNodeEntity);
|
||||
var stateCopyEntity = CopyState(originalStateEntity);
|
||||
|
||||
var domainObjectBuffer = EntityManager.GetBuffer<DomainObjectReference>(stateCopyEntity);
|
||||
var DomainObjects = GetComponentDataFromEntity<DomainObjectTrait>();
|
||||
var Locations = GetComponentDataFromEntity<Location>();
|
||||
var Times = GetComponentDataFromEntity<Time>();
|
||||
var objectHashes = GetComponentDataFromEntity<HashCode>();
|
||||
|
||||
var agentEntity = GetEntity(domainObjectBuffer, permutation.agentIndex, stateCopyEntity);
|
||||
var toEntity = GetEntity(domainObjectBuffer, permutation.toIndex, stateCopyEntity);
|
||||
var timeEntity = GetEntity(domainObjectBuffer, permutation.timeIndex, stateCopyEntity);
|
||||
|
||||
{
|
||||
var @agent = Locations[agentEntity];
|
||||
var hash = objectHashes[agentEntity];
|
||||
hash.Value -= @agent.GetHashCode();
|
||||
@agent.Position = Locations[toEntity].Position;
|
||||
Locations[agentEntity] = @agent;
|
||||
hash.Value += @agent.GetHashCode();
|
||||
objectHashes[agentEntity] = hash;
|
||||
}
|
||||
|
||||
var argumentLength = permutation.Length;
|
||||
var argumentBuffer = EntityManager.GetBuffer<ActionNodeArgument>(actionNodeEntity);
|
||||
var arguments = new NativeArray<int>(argumentLength, Allocator.Temp);
|
||||
for (var i = 0; i < argumentLength; i++)
|
||||
{
|
||||
var argumentIndex = permutation[i];
|
||||
argumentBuffer.Add(new ActionNodeArgument() { DomainObjectReferenceIndex = argumentIndex });
|
||||
arguments[i] = argumentIndex;
|
||||
}
|
||||
|
||||
ApplyCustomActionEffectsToState(stateCopyEntity, originalStateEntity, arguments);
|
||||
|
||||
SetActionData(stateCopyEntity, originalStateEntity, parentPolicyGraphNodeEntity, horizon + 1, actionNodeEntity,
|
||||
Reward(originalStateEntity, stateCopyEntity, arguments));
|
||||
|
||||
arguments.Dispose();
|
||||
}
|
||||
|
||||
partial void ApplyCustomActionEffectsToState(Entity stateEntity, Entity originalStateEntity, NativeArray<int> arguments); // Implement this method in another file to extend the action's effects
|
||||
|
||||
float Reward(Entity startStateEntity, Entity endStateEntity, NativeArray<int> arguments)
|
||||
{
|
||||
var reward = -2f;
|
||||
SetCustomReward(ref reward, startStateEntity, endStateEntity, arguments);
|
||||
|
||||
return reward;
|
||||
}
|
||||
|
||||
partial void SetCustomReward(ref float reward, Entity startStateEntity, Entity endStateEntity, NativeArray<int> arguments); // Implement this method in another file to modify the reward
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e4d009fdab017d14faf36a7ec82ad5ae
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,220 @@
|
|||
using System.Collections.Generic;
|
||||
using Unity.AI.Planner;
|
||||
using Unity.AI.Planner.DomainLanguage.TraitBased;
|
||||
using Unity.Collections;
|
||||
using Unity.Entities;
|
||||
|
||||
namespace WorkaholicDomain.WorkaholicActions
|
||||
{
|
||||
public partial class Pickup : BaseAction<Pickup.Permutation>
|
||||
{
|
||||
public NativeArray<ComponentType> agentTypes { get; private set; }
|
||||
public NativeArray<ComponentType> dispenserTypes { get; private set; }
|
||||
public NativeArray<ComponentType> inventoryTypes { get; private set; }
|
||||
public NativeArray<ComponentType> timeTypes { get; private set; }
|
||||
|
||||
List<(Entity, int)> m_agentEntities = new List<(Entity, int)>();
|
||||
List<(Entity, int)> m_dispenserEntities = new List<(Entity, int)>();
|
||||
List<(Entity, int)> m_inventoryEntities = new List<(Entity, int)>();
|
||||
List<(Entity, int)> m_timeEntities = new List<(Entity, int)>();
|
||||
|
||||
public struct Permutation
|
||||
{
|
||||
public int agentIndex;
|
||||
public int dispenserIndex;
|
||||
public int inventoryIndex;
|
||||
public int timeIndex;
|
||||
public int Length => 4;
|
||||
|
||||
public int this[int i]
|
||||
{
|
||||
get
|
||||
{
|
||||
switch(i)
|
||||
{
|
||||
case 0:
|
||||
return agentIndex;
|
||||
|
||||
case 1:
|
||||
return dispenserIndex;
|
||||
|
||||
case 2:
|
||||
return inventoryIndex;
|
||||
|
||||
case 3:
|
||||
return timeIndex;
|
||||
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnCreateManager()
|
||||
{
|
||||
base.OnCreateManager();
|
||||
|
||||
agentTypes = new NativeArray<ComponentType>(new []
|
||||
{
|
||||
ComponentType.ReadOnly<Agent>(),
|
||||
ComponentType.ReadOnly<Location>(),
|
||||
}, Allocator.Persistent);
|
||||
|
||||
dispenserTypes = new NativeArray<ComponentType>(new []
|
||||
{
|
||||
ComponentType.ReadOnly<Location>(),
|
||||
ComponentType.ReadOnly<Dispenser>(),
|
||||
}, Allocator.Persistent);
|
||||
|
||||
inventoryTypes = new NativeArray<ComponentType>(new []
|
||||
{
|
||||
ComponentType.ReadOnly<Inventory>(),
|
||||
}, Allocator.Persistent);
|
||||
|
||||
timeTypes = new NativeArray<ComponentType>(new []
|
||||
{
|
||||
ComponentType.ReadOnly<Time>(),
|
||||
}, Allocator.Persistent);
|
||||
|
||||
|
||||
m_FilterTuples = new[]
|
||||
{
|
||||
(agentTypes, m_agentEntities),
|
||||
(dispenserTypes, m_dispenserEntities),
|
||||
(inventoryTypes, m_inventoryEntities),
|
||||
(timeTypes, m_timeEntities),
|
||||
};
|
||||
}
|
||||
|
||||
protected override void OnDestroyManager()
|
||||
{
|
||||
base.OnDestroyManager();
|
||||
|
||||
if (agentTypes.IsCreated)
|
||||
{
|
||||
agentTypes.Dispose();
|
||||
agentTypes = default;
|
||||
}
|
||||
if (dispenserTypes.IsCreated)
|
||||
{
|
||||
dispenserTypes.Dispose();
|
||||
dispenserTypes = default;
|
||||
}
|
||||
if (inventoryTypes.IsCreated)
|
||||
{
|
||||
inventoryTypes.Dispose();
|
||||
inventoryTypes = default;
|
||||
}
|
||||
if (timeTypes.IsCreated)
|
||||
{
|
||||
timeTypes.Dispose();
|
||||
timeTypes = default;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void GenerateArgumentPermutations(Entity stateEntity)
|
||||
{
|
||||
var DomainObjects = GetComponentDataFromEntity<DomainObjectTrait>(true);
|
||||
var Locations = GetComponentDataFromEntity<Location>(true);
|
||||
var Dispensers = GetComponentDataFromEntity<Dispenser>(true);
|
||||
var Inventorys = GetComponentDataFromEntity<Inventory>(true);
|
||||
var Times = GetComponentDataFromEntity<Time>(true);
|
||||
|
||||
FilterObjects(stateEntity);
|
||||
foreach (var (agentEntity, agentIndex) in m_agentEntities)
|
||||
{
|
||||
foreach (var (dispenserEntity, dispenserIndex) in m_dispenserEntities)
|
||||
{
|
||||
foreach (var (inventoryEntity, inventoryIndex) in m_inventoryEntities)
|
||||
{
|
||||
foreach (var (timeEntity, timeIndex) in m_timeEntities)
|
||||
{
|
||||
if (!(Locations[agentEntity].Position == Locations[dispenserEntity].Position))
|
||||
continue;
|
||||
if (!(Dispensers[dispenserEntity].ConsumableType == Inventorys[inventoryEntity].ConsumableType))
|
||||
continue;
|
||||
if (!(Inventorys[inventoryEntity].Amount < 3))
|
||||
continue;
|
||||
m_ArgumentPermutations.Add(new Permutation()
|
||||
{
|
||||
agentIndex = agentIndex,
|
||||
dispenserIndex = dispenserIndex,
|
||||
inventoryIndex = inventoryIndex,
|
||||
timeIndex = timeIndex,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ApplyEffects(Permutation permutation, Entity parentPolicyGraphNodeEntity, Entity originalStateEntity, int horizon)
|
||||
{
|
||||
var actionNodeEntity = CreateActionNode(parentPolicyGraphNodeEntity);
|
||||
var stateCopyEntity = CopyState(originalStateEntity);
|
||||
|
||||
var domainObjectBuffer = EntityManager.GetBuffer<DomainObjectReference>(stateCopyEntity);
|
||||
var DomainObjects = GetComponentDataFromEntity<DomainObjectTrait>();
|
||||
var Locations = GetComponentDataFromEntity<Location>();
|
||||
var Dispensers = GetComponentDataFromEntity<Dispenser>();
|
||||
var Inventorys = GetComponentDataFromEntity<Inventory>();
|
||||
var Times = GetComponentDataFromEntity<Time>();
|
||||
var objectHashes = GetComponentDataFromEntity<HashCode>();
|
||||
|
||||
var agentEntity = GetEntity(domainObjectBuffer, permutation.agentIndex, stateCopyEntity);
|
||||
var dispenserEntity = GetEntity(domainObjectBuffer, permutation.dispenserIndex, stateCopyEntity);
|
||||
var inventoryEntity = GetEntity(domainObjectBuffer, permutation.inventoryIndex, stateCopyEntity);
|
||||
var timeEntity = GetEntity(domainObjectBuffer, permutation.timeIndex, stateCopyEntity);
|
||||
|
||||
{
|
||||
var @inventory = Inventorys[inventoryEntity];
|
||||
var hash = objectHashes[inventoryEntity];
|
||||
hash.Value -= @inventory.GetHashCode();
|
||||
@inventory.Amount += 1;
|
||||
Inventorys[inventoryEntity] = @inventory;
|
||||
hash.Value += @inventory.GetHashCode();
|
||||
objectHashes[inventoryEntity] = hash;
|
||||
}
|
||||
|
||||
{
|
||||
var @time = Times[timeEntity];
|
||||
var hash = objectHashes[timeEntity];
|
||||
hash.Value -= @time.GetHashCode();
|
||||
@time.Value += 1;
|
||||
Times[timeEntity] = @time;
|
||||
hash.Value += @time.GetHashCode();
|
||||
objectHashes[timeEntity] = hash;
|
||||
}
|
||||
|
||||
var argumentLength = permutation.Length;
|
||||
var argumentBuffer = EntityManager.GetBuffer<ActionNodeArgument>(actionNodeEntity);
|
||||
var arguments = new NativeArray<int>(argumentLength, Allocator.Temp);
|
||||
for (var i = 0; i < argumentLength; i++)
|
||||
{
|
||||
var argumentIndex = permutation[i];
|
||||
argumentBuffer.Add(new ActionNodeArgument() { DomainObjectReferenceIndex = argumentIndex });
|
||||
arguments[i] = argumentIndex;
|
||||
}
|
||||
|
||||
ApplyCustomActionEffectsToState(stateCopyEntity, originalStateEntity, arguments);
|
||||
|
||||
SetActionData(stateCopyEntity, originalStateEntity, parentPolicyGraphNodeEntity, horizon + 1, actionNodeEntity,
|
||||
Reward(originalStateEntity, stateCopyEntity, arguments));
|
||||
|
||||
arguments.Dispose();
|
||||
}
|
||||
|
||||
partial void ApplyCustomActionEffectsToState(Entity stateEntity, Entity originalStateEntity, NativeArray<int> arguments); // Implement this method in another file to extend the action's effects
|
||||
|
||||
float Reward(Entity startStateEntity, Entity endStateEntity, NativeArray<int> arguments)
|
||||
{
|
||||
var reward = -1f;
|
||||
SetCustomReward(ref reward, startStateEntity, endStateEntity, arguments);
|
||||
|
||||
return reward;
|
||||
}
|
||||
|
||||
partial void SetCustomReward(ref float reward, Entity startStateEntity, Entity endStateEntity, NativeArray<int> arguments); // Implement this method in another file to modify the reward
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0fd31d8623d8f4046a55ca1910a8c0ee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,216 @@
|
|||
using System.Collections.Generic;
|
||||
using Unity.AI.Planner;
|
||||
using Unity.AI.Planner.DomainLanguage.TraitBased;
|
||||
using Unity.Collections;
|
||||
using Unity.Entities;
|
||||
|
||||
namespace WorkaholicDomain.WorkaholicActions
|
||||
{
|
||||
public partial class Sleep : BaseAction<Sleep.Permutation>
|
||||
{
|
||||
public NativeArray<ComponentType> agentTypes { get; private set; }
|
||||
public NativeArray<ComponentType> bedTypes { get; private set; }
|
||||
public NativeArray<ComponentType> timeTypes { get; private set; }
|
||||
public NativeArray<ComponentType> fatigueTypes { get; private set; }
|
||||
|
||||
List<(Entity, int)> m_agentEntities = new List<(Entity, int)>();
|
||||
List<(Entity, int)> m_bedEntities = new List<(Entity, int)>();
|
||||
List<(Entity, int)> m_timeEntities = new List<(Entity, int)>();
|
||||
List<(Entity, int)> m_fatigueEntities = new List<(Entity, int)>();
|
||||
|
||||
public struct Permutation
|
||||
{
|
||||
public int agentIndex;
|
||||
public int bedIndex;
|
||||
public int timeIndex;
|
||||
public int fatigueIndex;
|
||||
public int Length => 4;
|
||||
|
||||
public int this[int i]
|
||||
{
|
||||
get
|
||||
{
|
||||
switch(i)
|
||||
{
|
||||
case 0:
|
||||
return agentIndex;
|
||||
|
||||
case 1:
|
||||
return bedIndex;
|
||||
|
||||
case 2:
|
||||
return timeIndex;
|
||||
|
||||
case 3:
|
||||
return fatigueIndex;
|
||||
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnCreateManager()
|
||||
{
|
||||
base.OnCreateManager();
|
||||
|
||||
agentTypes = new NativeArray<ComponentType>(new []
|
||||
{
|
||||
ComponentType.ReadOnly<Agent>(),
|
||||
ComponentType.ReadOnly<Location>(),
|
||||
}, Allocator.Persistent);
|
||||
|
||||
bedTypes = new NativeArray<ComponentType>(new []
|
||||
{
|
||||
ComponentType.ReadOnly<Location>(),
|
||||
ComponentType.ReadOnly<Bed>(),
|
||||
}, Allocator.Persistent);
|
||||
|
||||
timeTypes = new NativeArray<ComponentType>(new []
|
||||
{
|
||||
ComponentType.ReadOnly<Time>(),
|
||||
}, Allocator.Persistent);
|
||||
|
||||
fatigueTypes = new NativeArray<ComponentType>(new []
|
||||
{
|
||||
ComponentType.ReadOnly<Need>(),
|
||||
}, Allocator.Persistent);
|
||||
|
||||
|
||||
m_FilterTuples = new[]
|
||||
{
|
||||
(agentTypes, m_agentEntities),
|
||||
(bedTypes, m_bedEntities),
|
||||
(timeTypes, m_timeEntities),
|
||||
(fatigueTypes, m_fatigueEntities),
|
||||
};
|
||||
}
|
||||
|
||||
protected override void OnDestroyManager()
|
||||
{
|
||||
base.OnDestroyManager();
|
||||
|
||||
if (agentTypes.IsCreated)
|
||||
{
|
||||
agentTypes.Dispose();
|
||||
agentTypes = default;
|
||||
}
|
||||
if (bedTypes.IsCreated)
|
||||
{
|
||||
bedTypes.Dispose();
|
||||
bedTypes = default;
|
||||
}
|
||||
if (timeTypes.IsCreated)
|
||||
{
|
||||
timeTypes.Dispose();
|
||||
timeTypes = default;
|
||||
}
|
||||
if (fatigueTypes.IsCreated)
|
||||
{
|
||||
fatigueTypes.Dispose();
|
||||
fatigueTypes = default;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void GenerateArgumentPermutations(Entity stateEntity)
|
||||
{
|
||||
var DomainObjects = GetComponentDataFromEntity<DomainObjectTrait>(true);
|
||||
var Locations = GetComponentDataFromEntity<Location>(true);
|
||||
var Times = GetComponentDataFromEntity<Time>(true);
|
||||
var Needs = GetComponentDataFromEntity<Need>(true);
|
||||
|
||||
FilterObjects(stateEntity);
|
||||
foreach (var (agentEntity, agentIndex) in m_agentEntities)
|
||||
{
|
||||
foreach (var (bedEntity, bedIndex) in m_bedEntities)
|
||||
{
|
||||
foreach (var (timeEntity, timeIndex) in m_timeEntities)
|
||||
{
|
||||
foreach (var (fatigueEntity, fatigueIndex) in m_fatigueEntities)
|
||||
{
|
||||
if (!(Locations[agentEntity].Position == Locations[bedEntity].Position))
|
||||
continue;
|
||||
if (!(Needs[fatigueEntity].NeedType == NeedType.Fatigue))
|
||||
continue;
|
||||
m_ArgumentPermutations.Add(new Permutation()
|
||||
{
|
||||
agentIndex = agentIndex,
|
||||
bedIndex = bedIndex,
|
||||
timeIndex = timeIndex,
|
||||
fatigueIndex = fatigueIndex,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ApplyEffects(Permutation permutation, Entity parentPolicyGraphNodeEntity, Entity originalStateEntity, int horizon)
|
||||
{
|
||||
var actionNodeEntity = CreateActionNode(parentPolicyGraphNodeEntity);
|
||||
var stateCopyEntity = CopyState(originalStateEntity);
|
||||
|
||||
var domainObjectBuffer = EntityManager.GetBuffer<DomainObjectReference>(stateCopyEntity);
|
||||
var DomainObjects = GetComponentDataFromEntity<DomainObjectTrait>();
|
||||
var Locations = GetComponentDataFromEntity<Location>();
|
||||
var Times = GetComponentDataFromEntity<Time>();
|
||||
var Needs = GetComponentDataFromEntity<Need>();
|
||||
var objectHashes = GetComponentDataFromEntity<HashCode>();
|
||||
|
||||
var agentEntity = GetEntity(domainObjectBuffer, permutation.agentIndex, stateCopyEntity);
|
||||
var bedEntity = GetEntity(domainObjectBuffer, permutation.bedIndex, stateCopyEntity);
|
||||
var timeEntity = GetEntity(domainObjectBuffer, permutation.timeIndex, stateCopyEntity);
|
||||
var fatigueEntity = GetEntity(domainObjectBuffer, permutation.fatigueIndex, stateCopyEntity);
|
||||
|
||||
{
|
||||
var @fatigue = Needs[fatigueEntity];
|
||||
var hash = objectHashes[fatigueEntity];
|
||||
hash.Value -= @fatigue.GetHashCode();
|
||||
@fatigue.Urgency = 0;
|
||||
Needs[fatigueEntity] = @fatigue;
|
||||
hash.Value += @fatigue.GetHashCode();
|
||||
objectHashes[fatigueEntity] = hash;
|
||||
}
|
||||
|
||||
{
|
||||
var @time = Times[timeEntity];
|
||||
var hash = objectHashes[timeEntity];
|
||||
hash.Value -= @time.GetHashCode();
|
||||
@time.Value += 7;
|
||||
Times[timeEntity] = @time;
|
||||
hash.Value += @time.GetHashCode();
|
||||
objectHashes[timeEntity] = hash;
|
||||
}
|
||||
|
||||
var argumentLength = permutation.Length;
|
||||
var argumentBuffer = EntityManager.GetBuffer<ActionNodeArgument>(actionNodeEntity);
|
||||
var arguments = new NativeArray<int>(argumentLength, Allocator.Temp);
|
||||
for (var i = 0; i < argumentLength; i++)
|
||||
{
|
||||
var argumentIndex = permutation[i];
|
||||
argumentBuffer.Add(new ActionNodeArgument() { DomainObjectReferenceIndex = argumentIndex });
|
||||
arguments[i] = argumentIndex;
|
||||
}
|
||||
|
||||
ApplyCustomActionEffectsToState(stateCopyEntity, originalStateEntity, arguments);
|
||||
|
||||
SetActionData(stateCopyEntity, originalStateEntity, parentPolicyGraphNodeEntity, horizon + 1, actionNodeEntity,
|
||||
Reward(originalStateEntity, stateCopyEntity, arguments));
|
||||
|
||||
arguments.Dispose();
|
||||
}
|
||||
|
||||
partial void ApplyCustomActionEffectsToState(Entity stateEntity, Entity originalStateEntity, NativeArray<int> arguments); // Implement this method in another file to extend the action's effects
|
||||
|
||||
float Reward(Entity startStateEntity, Entity endStateEntity, NativeArray<int> arguments)
|
||||
{
|
||||
var reward = -3f;
|
||||
SetCustomReward(ref reward, startStateEntity, endStateEntity, arguments);
|
||||
|
||||
return reward;
|
||||
}
|
||||
|
||||
partial void SetCustomReward(ref float reward, Entity startStateEntity, Entity endStateEntity, NativeArray<int> arguments); // Implement this method in another file to modify the reward
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e790cc10d9144cb408d8a0564c3873b1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,204 @@
|
|||
using System.Collections.Generic;
|
||||
using Unity.AI.Planner;
|
||||
using Unity.AI.Planner.DomainLanguage.TraitBased;
|
||||
using Unity.Collections;
|
||||
using Unity.Entities;
|
||||
|
||||
namespace WorkaholicDomain.WorkaholicActions
|
||||
{
|
||||
public partial class Work : BaseAction<Work.Permutation>
|
||||
{
|
||||
public NativeArray<ComponentType> agentTypes { get; private set; }
|
||||
public NativeArray<ComponentType> workstationTypes { get; private set; }
|
||||
public NativeArray<ComponentType> durationTypes { get; private set; }
|
||||
public NativeArray<ComponentType> timeTypes { get; private set; }
|
||||
|
||||
List<(Entity, int)> m_agentEntities = new List<(Entity, int)>();
|
||||
List<(Entity, int)> m_workstationEntities = new List<(Entity, int)>();
|
||||
List<(Entity, int)> m_durationEntities = new List<(Entity, int)>();
|
||||
List<(Entity, int)> m_timeEntities = new List<(Entity, int)>();
|
||||
|
||||
public struct Permutation
|
||||
{
|
||||
public int agentIndex;
|
||||
public int workstationIndex;
|
||||
public int durationIndex;
|
||||
public int timeIndex;
|
||||
public int Length => 4;
|
||||
|
||||
public int this[int i]
|
||||
{
|
||||
get
|
||||
{
|
||||
switch(i)
|
||||
{
|
||||
case 0:
|
||||
return agentIndex;
|
||||
|
||||
case 1:
|
||||
return workstationIndex;
|
||||
|
||||
case 2:
|
||||
return durationIndex;
|
||||
|
||||
case 3:
|
||||
return timeIndex;
|
||||
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnCreateManager()
|
||||
{
|
||||
base.OnCreateManager();
|
||||
|
||||
agentTypes = new NativeArray<ComponentType>(new []
|
||||
{
|
||||
ComponentType.ReadOnly<Agent>(),
|
||||
ComponentType.ReadOnly<Location>(),
|
||||
}, Allocator.Persistent);
|
||||
|
||||
workstationTypes = new NativeArray<ComponentType>(new []
|
||||
{
|
||||
ComponentType.ReadOnly<Workstation>(),
|
||||
ComponentType.ReadOnly<Location>(),
|
||||
}, Allocator.Persistent);
|
||||
|
||||
durationTypes = new NativeArray<ComponentType>(new []
|
||||
{
|
||||
ComponentType.ReadOnly<Duration>(),
|
||||
}, Allocator.Persistent);
|
||||
|
||||
timeTypes = new NativeArray<ComponentType>(new []
|
||||
{
|
||||
ComponentType.ReadOnly<Time>(),
|
||||
}, Allocator.Persistent);
|
||||
|
||||
|
||||
m_FilterTuples = new[]
|
||||
{
|
||||
(agentTypes, m_agentEntities),
|
||||
(workstationTypes, m_workstationEntities),
|
||||
(durationTypes, m_durationEntities),
|
||||
(timeTypes, m_timeEntities),
|
||||
};
|
||||
}
|
||||
|
||||
protected override void OnDestroyManager()
|
||||
{
|
||||
base.OnDestroyManager();
|
||||
|
||||
if (agentTypes.IsCreated)
|
||||
{
|
||||
agentTypes.Dispose();
|
||||
agentTypes = default;
|
||||
}
|
||||
if (workstationTypes.IsCreated)
|
||||
{
|
||||
workstationTypes.Dispose();
|
||||
workstationTypes = default;
|
||||
}
|
||||
if (durationTypes.IsCreated)
|
||||
{
|
||||
durationTypes.Dispose();
|
||||
durationTypes = default;
|
||||
}
|
||||
if (timeTypes.IsCreated)
|
||||
{
|
||||
timeTypes.Dispose();
|
||||
timeTypes = default;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void GenerateArgumentPermutations(Entity stateEntity)
|
||||
{
|
||||
var DomainObjects = GetComponentDataFromEntity<DomainObjectTrait>(true);
|
||||
var Locations = GetComponentDataFromEntity<Location>(true);
|
||||
var Durations = GetComponentDataFromEntity<Duration>(true);
|
||||
var Times = GetComponentDataFromEntity<Time>(true);
|
||||
|
||||
FilterObjects(stateEntity);
|
||||
foreach (var (agentEntity, agentIndex) in m_agentEntities)
|
||||
{
|
||||
foreach (var (workstationEntity, workstationIndex) in m_workstationEntities)
|
||||
{
|
||||
foreach (var (durationEntity, durationIndex) in m_durationEntities)
|
||||
{
|
||||
foreach (var (timeEntity, timeIndex) in m_timeEntities)
|
||||
{
|
||||
if (!(Locations[agentEntity].Position == Locations[workstationEntity].Position))
|
||||
continue;
|
||||
m_ArgumentPermutations.Add(new Permutation()
|
||||
{
|
||||
agentIndex = agentIndex,
|
||||
workstationIndex = workstationIndex,
|
||||
durationIndex = durationIndex,
|
||||
timeIndex = timeIndex,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ApplyEffects(Permutation permutation, Entity parentPolicyGraphNodeEntity, Entity originalStateEntity, int horizon)
|
||||
{
|
||||
var actionNodeEntity = CreateActionNode(parentPolicyGraphNodeEntity);
|
||||
var stateCopyEntity = CopyState(originalStateEntity);
|
||||
|
||||
var domainObjectBuffer = EntityManager.GetBuffer<DomainObjectReference>(stateCopyEntity);
|
||||
var DomainObjects = GetComponentDataFromEntity<DomainObjectTrait>();
|
||||
var Locations = GetComponentDataFromEntity<Location>();
|
||||
var Durations = GetComponentDataFromEntity<Duration>();
|
||||
var Times = GetComponentDataFromEntity<Time>();
|
||||
var objectHashes = GetComponentDataFromEntity<HashCode>();
|
||||
|
||||
var agentEntity = GetEntity(domainObjectBuffer, permutation.agentIndex, stateCopyEntity);
|
||||
var workstationEntity = GetEntity(domainObjectBuffer, permutation.workstationIndex, stateCopyEntity);
|
||||
var durationEntity = GetEntity(domainObjectBuffer, permutation.durationIndex, stateCopyEntity);
|
||||
var timeEntity = GetEntity(domainObjectBuffer, permutation.timeIndex, stateCopyEntity);
|
||||
|
||||
{
|
||||
var @time = Times[timeEntity];
|
||||
var hash = objectHashes[timeEntity];
|
||||
hash.Value -= @time.GetHashCode();
|
||||
@time.Value += Durations[durationEntity].Time;
|
||||
Times[timeEntity] = @time;
|
||||
hash.Value += @time.GetHashCode();
|
||||
objectHashes[timeEntity] = hash;
|
||||
}
|
||||
|
||||
var argumentLength = permutation.Length;
|
||||
var argumentBuffer = EntityManager.GetBuffer<ActionNodeArgument>(actionNodeEntity);
|
||||
var arguments = new NativeArray<int>(argumentLength, Allocator.Temp);
|
||||
for (var i = 0; i < argumentLength; i++)
|
||||
{
|
||||
var argumentIndex = permutation[i];
|
||||
argumentBuffer.Add(new ActionNodeArgument() { DomainObjectReferenceIndex = argumentIndex });
|
||||
arguments[i] = argumentIndex;
|
||||
}
|
||||
|
||||
ApplyCustomActionEffectsToState(stateCopyEntity, originalStateEntity, arguments);
|
||||
|
||||
SetActionData(stateCopyEntity, originalStateEntity, parentPolicyGraphNodeEntity, horizon + 1, actionNodeEntity,
|
||||
Reward(originalStateEntity, stateCopyEntity, arguments));
|
||||
|
||||
arguments.Dispose();
|
||||
}
|
||||
|
||||
partial void ApplyCustomActionEffectsToState(Entity stateEntity, Entity originalStateEntity, NativeArray<int> arguments); // Implement this method in another file to extend the action's effects
|
||||
|
||||
float Reward(Entity startStateEntity, Entity endStateEntity, NativeArray<int> arguments)
|
||||
{
|
||||
var reward = 1f;
|
||||
SetCustomReward(ref reward, startStateEntity, endStateEntity, arguments);
|
||||
|
||||
return reward;
|
||||
}
|
||||
|
||||
partial void SetCustomReward(ref float reward, Entity startStateEntity, Entity endStateEntity, NativeArray<int> arguments); // Implement this method in another file to modify the reward
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 43dc81c71ad5c5244bfc91d73f28a0e2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,320 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Unity.AI.Planner;
|
||||
using Unity.AI.Planner.DomainLanguage.TraitBased;
|
||||
using Unity.Entities;
|
||||
|
||||
namespace WorkaholicDomain
|
||||
{
|
||||
[Flags]
|
||||
public enum TraitMask : uint // Can change enum backing depending on number of traits.
|
||||
{
|
||||
None = 0,
|
||||
Workstation = 1,
|
||||
Bed = 2,
|
||||
Dispenser = 4,
|
||||
Inventory = 8,
|
||||
Need = 16,
|
||||
Time = 32,
|
||||
Agent = 64,
|
||||
Duration = 128,
|
||||
Location = 2147483648,
|
||||
}
|
||||
|
||||
public static class TraitMaskUtility
|
||||
{
|
||||
public static uint GetTraitMask(params Type[] traitFilter)
|
||||
{
|
||||
var traitMask = TraitMask.None;
|
||||
foreach (var trait in traitFilter)
|
||||
{
|
||||
switch (trait.Name)
|
||||
{
|
||||
case nameof(Workstation):
|
||||
traitMask |= TraitMask.Workstation;
|
||||
break;
|
||||
|
||||
case nameof(Bed):
|
||||
traitMask |= TraitMask.Bed;
|
||||
break;
|
||||
|
||||
case nameof(Dispenser):
|
||||
traitMask |= TraitMask.Dispenser;
|
||||
break;
|
||||
|
||||
case nameof(Inventory):
|
||||
traitMask |= TraitMask.Inventory;
|
||||
break;
|
||||
|
||||
case nameof(Need):
|
||||
traitMask |= TraitMask.Need;
|
||||
break;
|
||||
|
||||
case nameof(Time):
|
||||
traitMask |= TraitMask.Time;
|
||||
break;
|
||||
|
||||
case nameof(Agent):
|
||||
traitMask |= TraitMask.Agent;
|
||||
break;
|
||||
|
||||
case nameof(Duration):
|
||||
traitMask |= TraitMask.Duration;
|
||||
break;
|
||||
|
||||
case nameof(Location):
|
||||
traitMask |= TraitMask.Location;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return (uint)traitMask;
|
||||
}
|
||||
}
|
||||
|
||||
public class WorkaholicDomainUpdateSystem : PolicyGraphUpdateSystem
|
||||
{
|
||||
List<Entity> m_EntityListLHS = new List<Entity>();
|
||||
List<Entity> m_EntityListRHS = new List<Entity>();
|
||||
|
||||
ComponentType WorkstationTrait;
|
||||
ComponentType BedTrait;
|
||||
ComponentType DispenserTrait;
|
||||
ComponentType InventoryTrait;
|
||||
ComponentType NeedTrait;
|
||||
ComponentType TimeTrait;
|
||||
ComponentType AgentTrait;
|
||||
ComponentType DurationTrait;
|
||||
ComponentType LocationTrait;
|
||||
|
||||
bool zeroSizedWorkstation;
|
||||
bool zeroSizedBed;
|
||||
bool zeroSizedDispenser;
|
||||
bool zeroSizedInventory;
|
||||
bool zeroSizedNeed;
|
||||
bool zeroSizedTime;
|
||||
bool zeroSizedAgent;
|
||||
bool zeroSizedDuration;
|
||||
bool zeroSizedLocation;
|
||||
|
||||
protected override void OnCreateManager()
|
||||
{
|
||||
base.OnCreateManager();
|
||||
|
||||
WorkstationTrait = ComponentType.Create<Workstation>();
|
||||
BedTrait = ComponentType.Create<Bed>();
|
||||
DispenserTrait = ComponentType.Create<Dispenser>();
|
||||
InventoryTrait = ComponentType.Create<Inventory>();
|
||||
NeedTrait = ComponentType.Create<Need>();
|
||||
TimeTrait = ComponentType.Create<Time>();
|
||||
AgentTrait = ComponentType.Create<Agent>();
|
||||
DurationTrait = ComponentType.Create<Duration>();
|
||||
LocationTrait = ComponentType.Create<Location>();
|
||||
|
||||
zeroSizedWorkstation = WorkstationTrait.IsZeroSized;
|
||||
zeroSizedBed = BedTrait.IsZeroSized;
|
||||
zeroSizedDispenser = DispenserTrait.IsZeroSized;
|
||||
zeroSizedInventory = InventoryTrait.IsZeroSized;
|
||||
zeroSizedNeed = NeedTrait.IsZeroSized;
|
||||
zeroSizedTime = TimeTrait.IsZeroSized;
|
||||
zeroSizedAgent = AgentTrait.IsZeroSized;
|
||||
zeroSizedDuration = DurationTrait.IsZeroSized;
|
||||
zeroSizedLocation = LocationTrait.IsZeroSized;
|
||||
}
|
||||
|
||||
internal override HashCode HashState(Entity stateEntity)
|
||||
{
|
||||
var domainObjectBuffer = EntityManager.GetBuffer<DomainObjectReference>(stateEntity);
|
||||
var domainObjectHashCodes = GetComponentDataFromEntity<HashCode>();
|
||||
|
||||
// h = 3860031 + (h+y)*2779 + (h*y*2) // from How to Hash a Set by Richard O’Keefe
|
||||
var stateHashValue = 0;
|
||||
|
||||
for (var i = 0; i < domainObjectBuffer.Length; i++)
|
||||
{
|
||||
var objHash = domainObjectHashCodes[domainObjectBuffer[i].DomainObjectEntity].Value;
|
||||
stateHashValue = 3860031 + (stateHashValue + objHash) * 2779 + (stateHashValue * objHash * 2);
|
||||
}
|
||||
|
||||
var stateHashCode = domainObjectHashCodes[stateEntity];
|
||||
var traitMask = (TraitMask) stateHashCode.TraitMask;
|
||||
|
||||
if ((traitMask & TraitMask.Workstation) != 0)
|
||||
{
|
||||
var traitHash = EntityManager.GetComponentData<Workstation>(stateEntity).GetHashCode();
|
||||
stateHashValue = 3860031 + (stateHashValue + traitHash) * 2779 + (stateHashValue * traitHash * 2);
|
||||
}
|
||||
if ((traitMask & TraitMask.Bed) != 0)
|
||||
{
|
||||
var traitHash = EntityManager.GetComponentData<Bed>(stateEntity).GetHashCode();
|
||||
stateHashValue = 3860031 + (stateHashValue + traitHash) * 2779 + (stateHashValue * traitHash * 2);
|
||||
}
|
||||
if ((traitMask & TraitMask.Dispenser) != 0)
|
||||
{
|
||||
var traitHash = EntityManager.GetComponentData<Dispenser>(stateEntity).GetHashCode();
|
||||
stateHashValue = 3860031 + (stateHashValue + traitHash) * 2779 + (stateHashValue * traitHash * 2);
|
||||
}
|
||||
if ((traitMask & TraitMask.Inventory) != 0)
|
||||
{
|
||||
var traitHash = EntityManager.GetComponentData<Inventory>(stateEntity).GetHashCode();
|
||||
stateHashValue = 3860031 + (stateHashValue + traitHash) * 2779 + (stateHashValue * traitHash * 2);
|
||||
}
|
||||
if ((traitMask & TraitMask.Need) != 0)
|
||||
{
|
||||
var traitHash = EntityManager.GetComponentData<Need>(stateEntity).GetHashCode();
|
||||
stateHashValue = 3860031 + (stateHashValue + traitHash) * 2779 + (stateHashValue * traitHash * 2);
|
||||
}
|
||||
if ((traitMask & TraitMask.Time) != 0)
|
||||
{
|
||||
var traitHash = EntityManager.GetComponentData<Time>(stateEntity).GetHashCode();
|
||||
stateHashValue = 3860031 + (stateHashValue + traitHash) * 2779 + (stateHashValue * traitHash * 2);
|
||||
}
|
||||
if ((traitMask & TraitMask.Agent) != 0)
|
||||
{
|
||||
var traitHash = EntityManager.GetComponentData<Agent>(stateEntity).GetHashCode();
|
||||
stateHashValue = 3860031 + (stateHashValue + traitHash) * 2779 + (stateHashValue * traitHash * 2);
|
||||
}
|
||||
if ((traitMask & TraitMask.Duration) != 0)
|
||||
{
|
||||
var traitHash = EntityManager.GetComponentData<Duration>(stateEntity).GetHashCode();
|
||||
stateHashValue = 3860031 + (stateHashValue + traitHash) * 2779 + (stateHashValue * traitHash * 2);
|
||||
}
|
||||
if ((traitMask & TraitMask.Location) != 0)
|
||||
{
|
||||
var traitHash = EntityManager.GetComponentData<Location>(stateEntity).GetHashCode();
|
||||
stateHashValue = 3860031 + (stateHashValue + traitHash) * 2779 + (stateHashValue * traitHash * 2);
|
||||
}
|
||||
|
||||
stateHashCode.Value = stateHashValue;
|
||||
return stateHashCode;
|
||||
}
|
||||
|
||||
protected override bool StateEquals(Entity lhsStateEntity, Entity rhsStateEntity)
|
||||
{
|
||||
m_EntityListLHS.Clear();
|
||||
m_EntityListRHS.Clear();
|
||||
|
||||
// Easy check is to make sure each state has the same number of domain objects
|
||||
var lhsObjectBuffer = EntityManager.GetBuffer<DomainObjectReference>(lhsStateEntity);
|
||||
var rhsObjectBuffer = EntityManager.GetBuffer<DomainObjectReference>(rhsStateEntity);
|
||||
if (lhsObjectBuffer.Length != rhsObjectBuffer.Length)
|
||||
return false;
|
||||
|
||||
for (var i = 0; i < lhsObjectBuffer.Length; i++)
|
||||
{
|
||||
m_EntityListLHS.Add(lhsObjectBuffer[i].DomainObjectEntity);
|
||||
m_EntityListRHS.Add(rhsObjectBuffer[i].DomainObjectEntity);
|
||||
}
|
||||
|
||||
// Next, check that each object has at least one match (by hash/checksum/trait mask)
|
||||
var entityHashCodes = GetComponentDataFromEntity<HashCode>();
|
||||
var lhsHashCode = entityHashCodes[lhsStateEntity];
|
||||
var rhsHashCode = entityHashCodes[rhsStateEntity];
|
||||
if (lhsHashCode != rhsHashCode)
|
||||
return false;
|
||||
|
||||
for (var index = 0; index < m_EntityListLHS.Count; index++)
|
||||
{
|
||||
var entityLHS = m_EntityListLHS[index];
|
||||
|
||||
// Check for any objects with matching hash code.
|
||||
var hashLHS = entityHashCodes[entityLHS];
|
||||
var foundMatch = false;
|
||||
for (var rhsIndex = 0; rhsIndex < m_EntityListRHS.Count; rhsIndex++)
|
||||
{
|
||||
var entityRHS = m_EntityListRHS[rhsIndex];
|
||||
if (hashLHS == entityHashCodes[entityRHS])
|
||||
{
|
||||
foundMatch = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// No matching object found.
|
||||
if (!foundMatch)
|
||||
return false;
|
||||
}
|
||||
|
||||
// todo do not need to grab zero-sized components
|
||||
var Workstations = GetComponentDataFromEntity<Workstation>(true);
|
||||
var Beds = GetComponentDataFromEntity<Bed>(true);
|
||||
var Dispensers = GetComponentDataFromEntity<Dispenser>(true);
|
||||
var Inventorys = GetComponentDataFromEntity<Inventory>(true);
|
||||
var Needs = GetComponentDataFromEntity<Need>(true);
|
||||
var Times = GetComponentDataFromEntity<Time>(true);
|
||||
var Agents = GetComponentDataFromEntity<Agent>(true);
|
||||
var Durations = GetComponentDataFromEntity<Duration>(true);
|
||||
var Locations = GetComponentDataFromEntity<Location>(true);
|
||||
|
||||
|
||||
while (m_EntityListLHS.Count > 0)
|
||||
{
|
||||
var entityLHS = m_EntityListLHS[0];
|
||||
|
||||
// Check for any objects with matching hash code.
|
||||
var hashLHS = entityHashCodes[entityLHS];
|
||||
var firstMatchIndex = -1;
|
||||
for (var rhsIndex = 0; rhsIndex < m_EntityListRHS.Count; rhsIndex++)
|
||||
{
|
||||
var entityRHS = m_EntityListRHS[rhsIndex];
|
||||
if (hashLHS == entityHashCodes[entityRHS])
|
||||
{
|
||||
firstMatchIndex = rhsIndex;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var traitMask = (TraitMask)hashLHS.TraitMask;
|
||||
|
||||
var hasWorkstation = (traitMask & TraitMask.Workstation) != 0;
|
||||
var hasBed = (traitMask & TraitMask.Bed) != 0;
|
||||
var hasDispenser = (traitMask & TraitMask.Dispenser) != 0;
|
||||
var hasInventory = (traitMask & TraitMask.Inventory) != 0;
|
||||
var hasNeed = (traitMask & TraitMask.Need) != 0;
|
||||
var hasTime = (traitMask & TraitMask.Time) != 0;
|
||||
var hasAgent = (traitMask & TraitMask.Agent) != 0;
|
||||
var hasDuration = (traitMask & TraitMask.Duration) != 0;
|
||||
var hasLocation = (traitMask & TraitMask.Location) != 0;
|
||||
|
||||
|
||||
var foundMatch = false;
|
||||
for (var rhsIndex = firstMatchIndex; rhsIndex < m_EntityListRHS.Count; rhsIndex++)
|
||||
{
|
||||
var entityRHS = m_EntityListRHS[rhsIndex];
|
||||
if (hashLHS != entityHashCodes[entityRHS])
|
||||
continue;
|
||||
|
||||
if (hasWorkstation && !zeroSizedWorkstation && !Workstations[entityLHS].Equals(Workstations[entityRHS]))
|
||||
continue;
|
||||
if (hasBed && !zeroSizedBed && !Beds[entityLHS].Equals(Beds[entityRHS]))
|
||||
continue;
|
||||
if (hasDispenser && !zeroSizedDispenser && !Dispensers[entityLHS].Equals(Dispensers[entityRHS]))
|
||||
continue;
|
||||
if (hasInventory && !zeroSizedInventory && !Inventorys[entityLHS].Equals(Inventorys[entityRHS]))
|
||||
continue;
|
||||
if (hasNeed && !zeroSizedNeed && !Needs[entityLHS].Equals(Needs[entityRHS]))
|
||||
continue;
|
||||
if (hasTime && !zeroSizedTime && !Times[entityLHS].Equals(Times[entityRHS]))
|
||||
continue;
|
||||
if (hasAgent && !zeroSizedAgent && !Agents[entityLHS].Equals(Agents[entityRHS]))
|
||||
continue;
|
||||
if (hasDuration && !zeroSizedDuration && !Durations[entityLHS].Equals(Durations[entityRHS]))
|
||||
continue;
|
||||
if (hasLocation && !zeroSizedLocation && !Locations[entityLHS].Equals(Locations[entityRHS]))
|
||||
continue;
|
||||
|
||||
|
||||
m_EntityListLHS.RemoveAt(0);
|
||||
m_EntityListRHS.RemoveAt(rhsIndex);
|
||||
foundMatch = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!foundMatch)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 41a375a22fbca4d4eba5831c850d8713
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,36 @@
|
|||
using System;
|
||||
using Unity.AI.Planner;
|
||||
using Unity.AI.Planner.DomainLanguage.TraitBased;
|
||||
using Unity.Entities;
|
||||
|
||||
namespace WorkaholicDomain
|
||||
{
|
||||
[Serializable]
|
||||
public partial struct Workstation : ITrait<Workstation>, IEquatable<Workstation>
|
||||
{
|
||||
|
||||
public bool Equals(Workstation other)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return GetType().GetHashCode();
|
||||
}
|
||||
|
||||
public object Clone() { return MemberwiseClone(); }
|
||||
public void SetComponentData(EntityManager entityManager, Entity domainObjectEntity)
|
||||
{
|
||||
SetTraitMask(entityManager, domainObjectEntity);
|
||||
entityManager.SetComponentData(domainObjectEntity, this);
|
||||
}
|
||||
|
||||
public void SetTraitMask(EntityManager entityManager, Entity domainObjectEntity)
|
||||
{
|
||||
var objectHash = entityManager.GetComponentData<HashCode>(domainObjectEntity);
|
||||
objectHash.TraitMask = objectHash.TraitMask | (uint)TraitMask.Workstation;
|
||||
entityManager.SetComponentData(domainObjectEntity, objectHash);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 11e82ec0753a03843a7b2def8b1b2bcc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,59 @@
|
|||
#if (NET_4_6 || NET_STANDARD_2_0)
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Unity.AI.Planner;
|
||||
using Unity.Properties;
|
||||
|
||||
namespace WorkaholicDomain
|
||||
{
|
||||
public partial struct Workstation : IStructPropertyContainer<Workstation>
|
||||
{
|
||||
private static StructPropertyBag<Workstation> s_PropertyBag { get; set; }
|
||||
|
||||
/// <inheritdoc cref="Unity.Properties.IPropertyContainer.PropertyBag" />
|
||||
public IPropertyBag PropertyBag => s_PropertyBag;
|
||||
/// <inheritdoc cref="Unity.Properties.IPropertyContainer.VersionStorage" />
|
||||
public IVersionStorage VersionStorage => null;
|
||||
|
||||
private static void InitializeProperties()
|
||||
{
|
||||
}
|
||||
|
||||
static partial void InitializeCustomProperties();
|
||||
|
||||
private static void InitializePropertyBag()
|
||||
{
|
||||
s_PropertyBag = new StructPropertyBag<Workstation>();
|
||||
}
|
||||
|
||||
static Workstation()
|
||||
{
|
||||
InitializeProperties();
|
||||
InitializeCustomProperties();
|
||||
InitializePropertyBag();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Pass this object as a reference to the given handler.
|
||||
/// </summary>
|
||||
/// <param name="byRef">Handler to invoke.</param>
|
||||
/// <param name="context">Context argument passed to the handler.</param>
|
||||
public void MakeRef<TContext>(ByRef<Workstation, TContext> byRef, TContext context)
|
||||
{
|
||||
byRef(ref this, context);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pass this object as a reference to the given handler, and return the result.
|
||||
/// </summary>
|
||||
/// <param name="byRef">Handler to invoke.</param>
|
||||
/// <param name="context">Context argument passed to the handler.</param>
|
||||
/// <returns>The handler's return value.</returns>
|
||||
public TReturn MakeRef<TContext, TReturn>(ByRef<Workstation, TContext, TReturn> byRef, TContext context)
|
||||
{
|
||||
return byRef(ref this, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // (NET_4_6 || NET_STANDARD_2_0)
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a3ddb28eeef6bee459e781e5aed7e7db
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3d9d6ecb5838995438ce747b0a062444
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,49 @@
|
|||
#if WORKAHOLICACTIONS_GENERATED
|
||||
using System;
|
||||
using Unity.AI.Planner;
|
||||
using Unity.AI.Planner.DomainLanguage.TraitBased;
|
||||
using Unity.Collections;
|
||||
using Unity.Entities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace WorkaholicDomain.WorkaholicActions
|
||||
{
|
||||
public partial class Navigate
|
||||
{
|
||||
const float kWalkingSpeed = 0.47f; // m/s
|
||||
|
||||
partial void ApplyCustomActionEffectsToState(Entity stateEntity, Entity originalStateEntity, NativeArray<int> arguments)
|
||||
{
|
||||
// Agent location has already been updated, so use the original state for getting location data
|
||||
var domainObjectBuffer = EntityManager.GetBuffer<DomainObjectReference>(originalStateEntity);
|
||||
|
||||
var agentEntity = domainObjectBuffer[arguments[0]].DomainObjectEntity;
|
||||
var destinationEntity = domainObjectBuffer[arguments[1]].DomainObjectEntity;
|
||||
|
||||
var agentLocation = EntityManager.GetComponentData<Location>(agentEntity);
|
||||
var destinationLocation = EntityManager.GetComponentData<Location>(destinationEntity);
|
||||
|
||||
// Now update the new state's time
|
||||
var distance = Vector3.Distance(agentLocation.Position, destinationLocation.Position);
|
||||
var deltaTime = Mathf.FloorToInt(distance / kWalkingSpeed + 1f);
|
||||
|
||||
SetTrait((ref Time time) => time.Value += deltaTime, stateEntity);
|
||||
}
|
||||
|
||||
partial void SetCustomReward(ref float reward, Entity startStateEntity, Entity endStateEntity, NativeArray<int> arguments)
|
||||
{
|
||||
// Agent location has already been updated, so use the original state for getting location data
|
||||
var domainObjectBuffer = EntityManager.GetBuffer<DomainObjectReference>(startStateEntity);
|
||||
|
||||
var agentEntity = domainObjectBuffer[arguments[0]].DomainObjectEntity;
|
||||
var destinationEntity = domainObjectBuffer[arguments[1]].DomainObjectEntity;
|
||||
|
||||
var agentLocation = EntityManager.GetComponentData<Location>(agentEntity);
|
||||
var destinationLocation = EntityManager.GetComponentData<Location>(destinationEntity);
|
||||
|
||||
var distance = Vector3.Distance(agentLocation.Position, destinationLocation.Position);
|
||||
reward *= distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bd4b560357063754eb48cc521168c1d8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,23 @@
|
|||
#if WORKAHOLICACTIONS_GENERATED
|
||||
using System;
|
||||
using Unity.AI.Planner.DomainLanguage.TraitBased;
|
||||
using Unity.Collections;
|
||||
using Unity.Entities;
|
||||
|
||||
namespace WorkaholicDomain.WorkaholicActions
|
||||
{
|
||||
public partial class Work
|
||||
{
|
||||
partial void SetCustomReward(ref float reward, Entity startStateEntity, Entity endStateEntity, NativeArray<int> arguments)
|
||||
{
|
||||
// Agent location has already been updated, so use the original state for getting location data
|
||||
var domainObjectBuffer = EntityManager.GetBuffer<DomainObjectReference>(startStateEntity);
|
||||
|
||||
var durationEntity = domainObjectBuffer[arguments[2]].DomainObjectEntity;
|
||||
var duration = EntityManager.GetComponentData<Duration>(durationEntity).Time;
|
||||
|
||||
reward *= duration;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: be38e115b285c2041a9130847c6774c5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,2 @@
|
|||
-define:WORKAHOLICACTIONS_GENERATED
|
||||
-define:WORKAHOLICDOMAIN_GENERATED
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a679f53017fe3834ab16306423946873
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2b4056dcbe099d54684a1d3ad0d58634
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ea89ccac0c8997a4ab694f53da471bc1
|
||||
folderAsset: yes
|
||||
timeCreated: 1502818365
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 16d2385cf15ccbe439034ca2d0671b31
|
||||
folderAsset: yes
|
||||
timeCreated: 1502983602
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:253da4512416504ab2334f46c7260e17a8fd5ff9b2458b7e9a2cc61c0ae7f585
|
||||
size 8297663
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 65f9bc8cfa385254d9be7163192fa651
|
||||
timeCreated: 1505148674
|
||||
licenseType: Pro
|
||||
NativeFormatImporter:
|
||||
mainObjectFileID: 7400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:28ea73baf0857db38e3efe33f9274887c3506b7764e17dd5bd876a7a904cf4e2
|
||||
size 8235089
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e49d3210da6b29c438156058f7472ee1
|
||||
timeCreated: 1505146012
|
||||
licenseType: Pro
|
||||
NativeFormatImporter:
|
||||
mainObjectFileID: 7400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:b62f2b67730a38311d0154756683c29eb59d91d5b79418e5fdd72f2bd666acd9
|
||||
size 6664602
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 167b10338d52d6c4986beec93d3b35c8
|
||||
timeCreated: 1506451404
|
||||
licenseType: Pro
|
||||
NativeFormatImporter:
|
||||
mainObjectFileID: 7400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:78d57fb364df111078616d0e447cea8ed0c608a6422743c5e8c3fc6b31b92564
|
||||
size 6664598
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 67fe33d53ad317f4eb01bcaf9aa98801
|
||||
timeCreated: 1506451396
|
||||
licenseType: Pro
|
||||
NativeFormatImporter:
|
||||
mainObjectFileID: 7400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:7ec605fa82bc3e231cda1a56ef8d79871c7d187f0d6152582915844b50e46e64
|
||||
size 8283667
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8d8620b04c0cd7540b5ed63020dab0f5
|
||||
timeCreated: 1505173781
|
||||
licenseType: Pro
|
||||
NativeFormatImporter:
|
||||
mainObjectFileID: 7400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:5e4c1135f631ecf9d9cf77ea2f129c68d770c5d8869e717187e5807e9fb63d7d
|
||||
size 5773452
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 607ff55671af1474284fc71b508744a6
|
||||
timeCreated: 1505173779
|
||||
licenseType: Pro
|
||||
NativeFormatImporter:
|
||||
mainObjectFileID: 7400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bff40dc4f8ca49c4f863dee8bfb7608d
|
||||
timeCreated: 1502983617
|
||||
licenseType: Pro
|
||||
NativeFormatImporter:
|
||||
mainObjectFileID: 9100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4c720a80891b30a47b30616374fb004e
|
||||
folderAsset: yes
|
||||
timeCreated: 1502818489
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,292 @@
|
|||
// Shader created with Shader Forge v1.38
|
||||
// Shader Forge (c) Neat Corporation / Joachim Holmer - http://www.acegikmo.com/shaderforge/
|
||||
// Note: Manually altering this data may prevent you from opening it in Shader Forge
|
||||
/*SF_DATA;ver:1.38;sub:START;pass:START;ps:flbk:,iptp:0,cusa:False,bamd:0,cgin:,lico:1,lgpr:1,limd:3,spmd:1,trmd:0,grmd:1,uamb:True,mssp:True,bkdf:False,hqlp:False,rprd:False,enco:False,rmgx:True,imps:True,rpth:0,vtps:0,hqsc:True,nrmq:1,nrsp:0,vomd:0,spxs:False,tesm:0,olmd:1,culm:0,bsrc:0,bdst:1,dpts:2,wrdp:True,dith:0,atcv:False,rfrpo:True,rfrpn:Refraction,coma:15,ufog:True,aust:True,igpj:False,qofs:0,qpre:1,rntp:1,fgom:False,fgoc:False,fgod:False,fgor:False,fgmd:0,fgcr:0.5,fgcg:0.5,fgcb:0.5,fgca:1,fgde:0.01,fgrn:0,fgrf:300,stcl:False,atwp:False,stva:128,stmr:255,stmw:255,stcp:6,stps:0,stfa:0,stfz:0,ofsf:0,ofsu:0,f2p0:False,fnsp:False,fnfb:False,fsmp:False;n:type:ShaderForge.SFN_Final,id:2865,x:32719,y:32712,varname:node_2865,prsc:2|diff-8683-OUT,spec-2860-OUT,gloss-7455-OUT,normal-5964-RGB,transm-2094-R,lwrap-6076-OUT,difocc-2846-R,spcocc-2846-R;n:type:ShaderForge.SFN_Tex2d,id:5964,x:31352,y:32646,ptovrint:True,ptlb:Normal Map,ptin:_BumpMap,varname:_BumpMap,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,ntxv:3,isnm:True;n:type:ShaderForge.SFN_Tex2d,id:2846,x:31214,y:32974,ptovrint:False,ptlb:node_2846,ptin:_node_2846,varname:node_2846,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:81ae15997cb9d9e429a8bedf6099d2a4,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Tex2d,id:2094,x:31892,y:32809,ptovrint:False,ptlb:node_2094,ptin:_node_2094,varname:node_2094,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:78358780d5b46ff4d822cc40aec67e32,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Tex2d,id:7300,x:31220,y:33152,ptovrint:False,ptlb:node_7300,ptin:_node_7300,varname:node_7300,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:ad34d2bca67b615439f6608dd7a30498,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Multiply,id:4044,x:31566,y:33152,varname:node_4044,prsc:2|A-4502-OUT,B-3742-OUT;n:type:ShaderForge.SFN_Vector1,id:3742,x:31400,y:33317,varname:node_3742,prsc:2,v1:-1;n:type:ShaderForge.SFN_Add,id:7455,x:31746,y:33152,varname:node_7455,prsc:2|A-4044-OUT,B-8690-OUT;n:type:ShaderForge.SFN_Vector1,id:8690,x:31566,y:33317,varname:node_8690,prsc:2,v1:1;n:type:ShaderForge.SFN_Tex2d,id:2077,x:31710,y:32352,ptovrint:False,ptlb:node_2077,ptin:_node_2077,varname:node_2077,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:54bbca7ae723ac04f9e947001e70bd57,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Power,id:8683,x:32263,y:32228,varname:node_8683,prsc:2|VAL-2077-RGB,EXP-5705-OUT;n:type:ShaderForge.SFN_Subtract,id:5705,x:32276,y:32383,varname:node_5705,prsc:2|A-126-OUT,B-2456-OUT;n:type:ShaderForge.SFN_Vector1,id:126,x:32036,y:32383,varname:node_126,prsc:2,v1:3;n:type:ShaderForge.SFN_Fresnel,id:2456,x:31892,y:32658,varname:node_2456,prsc:2|NRM-5964-RGB,EXP-7337-OUT;n:type:ShaderForge.SFN_Vector1,id:7337,x:31701,y:32692,varname:node_7337,prsc:2,v1:2;n:type:ShaderForge.SFN_Multiply,id:6076,x:32049,y:32738,varname:node_6076,prsc:2|A-2456-OUT,B-2094-R;n:type:ShaderForge.SFN_Multiply,id:8414,x:31380,y:32806,varname:node_8414,prsc:2|A-4582-RGB,B-2846-R;n:type:ShaderForge.SFN_LightColor,id:4582,x:31214,y:32806,varname:node_4582,prsc:2;n:type:ShaderForge.SFN_Vector1,id:2860,x:32417,y:32707,varname:node_2860,prsc:2,v1:0;n:type:ShaderForge.SFN_Power,id:4502,x:31400,y:33152,varname:node_4502,prsc:2|VAL-7300-R,EXP-4341-OUT;n:type:ShaderForge.SFN_Dot,id:654,x:30997,y:34792,varname:node_654,prsc:2,dt:0;n:type:ShaderForge.SFN_Vector1,id:4341,x:31220,y:33317,varname:node_4341,prsc:2,v1:1.5;proporder:5964-2846-2094-7300-2077;pass:END;sub:END;*/
|
||||
|
||||
Shader "Shader Forge/Otto" {
|
||||
Properties {
|
||||
_BumpMap ("Normal Map", 2D) = "bump" {}
|
||||
_node_2846 ("node_2846", 2D) = "white" {}
|
||||
_node_2094 ("node_2094", 2D) = "white" {}
|
||||
_node_7300 ("node_7300", 2D) = "white" {}
|
||||
_node_2077 ("node_2077", 2D) = "white" {}
|
||||
}
|
||||
SubShader {
|
||||
Tags {
|
||||
"RenderType"="Opaque"
|
||||
}
|
||||
Pass {
|
||||
Name "FORWARD"
|
||||
Tags {
|
||||
"LightMode"="ForwardBase"
|
||||
}
|
||||
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#define UNITY_PASS_FORWARDBASE
|
||||
#include "UnityCG.cginc"
|
||||
#include "AutoLight.cginc"
|
||||
#include "UnityPBSLighting.cginc"
|
||||
#include "UnityStandardBRDF.cginc"
|
||||
#pragma multi_compile_fwdbase_fullshadows
|
||||
#pragma multi_compile_fog
|
||||
#pragma only_renderers d3d9 d3d11 glcore gles
|
||||
#pragma target 3.0
|
||||
uniform sampler2D _BumpMap; uniform float4 _BumpMap_ST;
|
||||
uniform sampler2D _node_2846; uniform float4 _node_2846_ST;
|
||||
uniform sampler2D _node_2094; uniform float4 _node_2094_ST;
|
||||
uniform sampler2D _node_7300; uniform float4 _node_7300_ST;
|
||||
uniform sampler2D _node_2077; uniform float4 _node_2077_ST;
|
||||
struct VertexInput {
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float4 tangent : TANGENT;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
};
|
||||
struct VertexOutput {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv0 : TEXCOORD0;
|
||||
float4 posWorld : TEXCOORD1;
|
||||
float3 normalDir : TEXCOORD2;
|
||||
float3 tangentDir : TEXCOORD3;
|
||||
float3 bitangentDir : TEXCOORD4;
|
||||
LIGHTING_COORDS(5,6)
|
||||
UNITY_FOG_COORDS(7)
|
||||
};
|
||||
VertexOutput vert (VertexInput v) {
|
||||
VertexOutput o = (VertexOutput)0;
|
||||
o.uv0 = v.texcoord0;
|
||||
o.normalDir = UnityObjectToWorldNormal(v.normal);
|
||||
o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz );
|
||||
o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
|
||||
o.posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||
float3 lightColor = _LightColor0.rgb;
|
||||
o.pos = UnityObjectToClipPos( v.vertex );
|
||||
UNITY_TRANSFER_FOG(o,o.pos);
|
||||
TRANSFER_VERTEX_TO_FRAGMENT(o)
|
||||
return o;
|
||||
}
|
||||
float4 frag(VertexOutput i) : COLOR {
|
||||
i.normalDir = normalize(i.normalDir);
|
||||
float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);
|
||||
float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
|
||||
float3 _BumpMap_var = UnpackNormal(tex2D(_BumpMap,TRANSFORM_TEX(i.uv0, _BumpMap)));
|
||||
float3 normalLocal = _BumpMap_var.rgb;
|
||||
float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals
|
||||
float3 viewReflectDirection = reflect( -viewDirection, normalDirection );
|
||||
float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);
|
||||
float3 lightColor = _LightColor0.rgb;
|
||||
float3 halfDirection = normalize(viewDirection+lightDirection);
|
||||
////// Lighting:
|
||||
float attenuation = LIGHT_ATTENUATION(i);
|
||||
float3 attenColor = attenuation * _LightColor0.xyz;
|
||||
float Pi = 3.141592654;
|
||||
float InvPi = 0.31830988618;
|
||||
///////// Gloss:
|
||||
float4 _node_7300_var = tex2D(_node_7300,TRANSFORM_TEX(i.uv0, _node_7300));
|
||||
float gloss = 1.0 - ((pow(_node_7300_var.r,1.5)*(-1.0))+1.0); // Convert roughness to gloss
|
||||
float perceptualRoughness = ((pow(_node_7300_var.r,1.5)*(-1.0))+1.0);
|
||||
float roughness = perceptualRoughness * perceptualRoughness;
|
||||
float specPow = exp2( gloss * 10.0 + 1.0 );
|
||||
/////// GI Data:
|
||||
UnityLight light;
|
||||
#ifdef LIGHTMAP_OFF
|
||||
light.color = lightColor;
|
||||
light.dir = lightDirection;
|
||||
light.ndotl = LambertTerm (normalDirection, light.dir);
|
||||
#else
|
||||
light.color = half3(0.f, 0.f, 0.f);
|
||||
light.ndotl = 0.0f;
|
||||
light.dir = half3(0.f, 0.f, 0.f);
|
||||
#endif
|
||||
UnityGIInput d;
|
||||
d.light = light;
|
||||
d.worldPos = i.posWorld.xyz;
|
||||
d.worldViewDir = viewDirection;
|
||||
d.atten = attenuation;
|
||||
Unity_GlossyEnvironmentData ugls_en_data;
|
||||
ugls_en_data.roughness = 1.0 - gloss;
|
||||
ugls_en_data.reflUVW = viewReflectDirection;
|
||||
UnityGI gi = UnityGlobalIllumination(d, 1, normalDirection, ugls_en_data );
|
||||
lightDirection = gi.light.dir;
|
||||
lightColor = gi.light.color;
|
||||
////// Specular:
|
||||
float NdotL = saturate(dot( normalDirection, lightDirection ));
|
||||
float LdotH = saturate(dot(lightDirection, halfDirection));
|
||||
float3 specularColor = 0.0;
|
||||
float specularMonochrome;
|
||||
float4 _node_2077_var = tex2D(_node_2077,TRANSFORM_TEX(i.uv0, _node_2077));
|
||||
float node_2456 = pow(1.0-max(0,dot(_BumpMap_var.rgb, viewDirection)),2.0);
|
||||
float3 diffuseColor = pow(_node_2077_var.rgb,(3.0-node_2456)); // Need this for specular when using metallic
|
||||
diffuseColor = DiffuseAndSpecularFromMetallic( diffuseColor, specularColor, specularColor, specularMonochrome );
|
||||
specularMonochrome = 1.0-specularMonochrome;
|
||||
float NdotV = abs(dot( normalDirection, viewDirection ));
|
||||
float NdotH = saturate(dot( normalDirection, halfDirection ));
|
||||
float VdotH = saturate(dot( viewDirection, halfDirection ));
|
||||
float visTerm = SmithJointGGXVisibilityTerm( NdotL, NdotV, roughness );
|
||||
float normTerm = GGXTerm(NdotH, roughness);
|
||||
float specularPBL = (visTerm*normTerm) * UNITY_PI;
|
||||
#ifdef UNITY_COLORSPACE_GAMMA
|
||||
specularPBL = sqrt(max(1e-4h, specularPBL));
|
||||
#endif
|
||||
specularPBL = max(0, specularPBL * NdotL);
|
||||
#if defined(_SPECULARHIGHLIGHTS_OFF)
|
||||
specularPBL = 0.0;
|
||||
#endif
|
||||
specularPBL *= any(specularColor) ? 1.0 : 0.0;
|
||||
float3 directSpecular = attenColor*specularPBL*FresnelTerm(specularColor, LdotH);
|
||||
float3 specular = directSpecular;
|
||||
/////// Diffuse:
|
||||
NdotL = dot( normalDirection, lightDirection );
|
||||
float4 _node_2094_var = tex2D(_node_2094,TRANSFORM_TEX(i.uv0, _node_2094));
|
||||
float node_6076 = (node_2456*_node_2094_var.r);
|
||||
float3 w = float3(node_6076,node_6076,node_6076)*0.5; // Light wrapping
|
||||
float3 NdotLWrap = NdotL * ( 1.0 - w );
|
||||
float3 forwardLight = max(float3(0.0,0.0,0.0), NdotLWrap + w );
|
||||
float3 backLight = max(float3(0.0,0.0,0.0), -NdotLWrap + w ) * float3(_node_2094_var.r,_node_2094_var.r,_node_2094_var.r);
|
||||
NdotL = max(0.0,dot( normalDirection, lightDirection ));
|
||||
half fd90 = 0.5 + 2 * LdotH * LdotH * (1-gloss);
|
||||
float nlPow5 = Pow5(1-NdotLWrap);
|
||||
float nvPow5 = Pow5(1-NdotV);
|
||||
float3 directDiffuse = ((forwardLight+backLight) + ((1 +(fd90 - 1)*nlPow5) * (1 + (fd90 - 1)*nvPow5) * NdotL)) * attenColor;
|
||||
float3 indirectDiffuse = float3(0,0,0);
|
||||
indirectDiffuse += UNITY_LIGHTMODEL_AMBIENT.rgb; // Ambient Light
|
||||
float4 _node_2846_var = tex2D(_node_2846,TRANSFORM_TEX(i.uv0, _node_2846));
|
||||
indirectDiffuse *= _node_2846_var.r; // Diffuse AO
|
||||
float3 diffuse = (directDiffuse + indirectDiffuse) * diffuseColor;
|
||||
/// Final Color:
|
||||
float3 finalColor = diffuse + specular;
|
||||
fixed4 finalRGBA = fixed4(finalColor,1);
|
||||
UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
|
||||
return finalRGBA;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
Pass {
|
||||
Name "FORWARD_DELTA"
|
||||
Tags {
|
||||
"LightMode"="ForwardAdd"
|
||||
}
|
||||
Blend One One
|
||||
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#define UNITY_PASS_FORWARDADD
|
||||
#include "UnityCG.cginc"
|
||||
#include "AutoLight.cginc"
|
||||
#include "UnityPBSLighting.cginc"
|
||||
#include "UnityStandardBRDF.cginc"
|
||||
#pragma multi_compile_fwdadd_fullshadows
|
||||
#pragma multi_compile_fog
|
||||
#pragma only_renderers d3d9 d3d11 glcore gles
|
||||
#pragma target 3.0
|
||||
uniform sampler2D _BumpMap; uniform float4 _BumpMap_ST;
|
||||
uniform sampler2D _node_2094; uniform float4 _node_2094_ST;
|
||||
uniform sampler2D _node_7300; uniform float4 _node_7300_ST;
|
||||
uniform sampler2D _node_2077; uniform float4 _node_2077_ST;
|
||||
struct VertexInput {
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float4 tangent : TANGENT;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
};
|
||||
struct VertexOutput {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv0 : TEXCOORD0;
|
||||
float4 posWorld : TEXCOORD1;
|
||||
float3 normalDir : TEXCOORD2;
|
||||
float3 tangentDir : TEXCOORD3;
|
||||
float3 bitangentDir : TEXCOORD4;
|
||||
LIGHTING_COORDS(5,6)
|
||||
UNITY_FOG_COORDS(7)
|
||||
};
|
||||
VertexOutput vert (VertexInput v) {
|
||||
VertexOutput o = (VertexOutput)0;
|
||||
o.uv0 = v.texcoord0;
|
||||
o.normalDir = UnityObjectToWorldNormal(v.normal);
|
||||
o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz );
|
||||
o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
|
||||
o.posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||
float3 lightColor = _LightColor0.rgb;
|
||||
o.pos = UnityObjectToClipPos( v.vertex );
|
||||
UNITY_TRANSFER_FOG(o,o.pos);
|
||||
TRANSFER_VERTEX_TO_FRAGMENT(o)
|
||||
return o;
|
||||
}
|
||||
float4 frag(VertexOutput i) : COLOR {
|
||||
i.normalDir = normalize(i.normalDir);
|
||||
float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);
|
||||
float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
|
||||
float3 _BumpMap_var = UnpackNormal(tex2D(_BumpMap,TRANSFORM_TEX(i.uv0, _BumpMap)));
|
||||
float3 normalLocal = _BumpMap_var.rgb;
|
||||
float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals
|
||||
float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - i.posWorld.xyz,_WorldSpaceLightPos0.w));
|
||||
float3 lightColor = _LightColor0.rgb;
|
||||
float3 halfDirection = normalize(viewDirection+lightDirection);
|
||||
////// Lighting:
|
||||
float attenuation = LIGHT_ATTENUATION(i);
|
||||
float3 attenColor = attenuation * _LightColor0.xyz;
|
||||
float Pi = 3.141592654;
|
||||
float InvPi = 0.31830988618;
|
||||
///////// Gloss:
|
||||
float4 _node_7300_var = tex2D(_node_7300,TRANSFORM_TEX(i.uv0, _node_7300));
|
||||
float gloss = 1.0 - ((pow(_node_7300_var.r,1.5)*(-1.0))+1.0); // Convert roughness to gloss
|
||||
float perceptualRoughness = ((pow(_node_7300_var.r,1.5)*(-1.0))+1.0);
|
||||
float roughness = perceptualRoughness * perceptualRoughness;
|
||||
float specPow = exp2( gloss * 10.0 + 1.0 );
|
||||
////// Specular:
|
||||
float NdotL = saturate(dot( normalDirection, lightDirection ));
|
||||
float LdotH = saturate(dot(lightDirection, halfDirection));
|
||||
float3 specularColor = 0.0;
|
||||
float specularMonochrome;
|
||||
float4 _node_2077_var = tex2D(_node_2077,TRANSFORM_TEX(i.uv0, _node_2077));
|
||||
float node_2456 = pow(1.0-max(0,dot(_BumpMap_var.rgb, viewDirection)),2.0);
|
||||
float3 diffuseColor = pow(_node_2077_var.rgb,(3.0-node_2456)); // Need this for specular when using metallic
|
||||
diffuseColor = DiffuseAndSpecularFromMetallic( diffuseColor, specularColor, specularColor, specularMonochrome );
|
||||
specularMonochrome = 1.0-specularMonochrome;
|
||||
float NdotV = abs(dot( normalDirection, viewDirection ));
|
||||
float NdotH = saturate(dot( normalDirection, halfDirection ));
|
||||
float VdotH = saturate(dot( viewDirection, halfDirection ));
|
||||
float visTerm = SmithJointGGXVisibilityTerm( NdotL, NdotV, roughness );
|
||||
float normTerm = GGXTerm(NdotH, roughness);
|
||||
float specularPBL = (visTerm*normTerm) * UNITY_PI;
|
||||
#ifdef UNITY_COLORSPACE_GAMMA
|
||||
specularPBL = sqrt(max(1e-4h, specularPBL));
|
||||
#endif
|
||||
specularPBL = max(0, specularPBL * NdotL);
|
||||
#if defined(_SPECULARHIGHLIGHTS_OFF)
|
||||
specularPBL = 0.0;
|
||||
#endif
|
||||
specularPBL *= any(specularColor) ? 1.0 : 0.0;
|
||||
float3 directSpecular = attenColor*specularPBL*FresnelTerm(specularColor, LdotH);
|
||||
float3 specular = directSpecular;
|
||||
/////// Diffuse:
|
||||
NdotL = dot( normalDirection, lightDirection );
|
||||
float4 _node_2094_var = tex2D(_node_2094,TRANSFORM_TEX(i.uv0, _node_2094));
|
||||
float node_6076 = (node_2456*_node_2094_var.r);
|
||||
float3 w = float3(node_6076,node_6076,node_6076)*0.5; // Light wrapping
|
||||
float3 NdotLWrap = NdotL * ( 1.0 - w );
|
||||
float3 forwardLight = max(float3(0.0,0.0,0.0), NdotLWrap + w );
|
||||
float3 backLight = max(float3(0.0,0.0,0.0), -NdotLWrap + w ) * float3(_node_2094_var.r,_node_2094_var.r,_node_2094_var.r);
|
||||
NdotL = max(0.0,dot( normalDirection, lightDirection ));
|
||||
half fd90 = 0.5 + 2 * LdotH * LdotH * (1-gloss);
|
||||
float nlPow5 = Pow5(1-NdotLWrap);
|
||||
float nvPow5 = Pow5(1-NdotV);
|
||||
float3 directDiffuse = ((forwardLight+backLight) + ((1 +(fd90 - 1)*nlPow5) * (1 + (fd90 - 1)*nvPow5) * NdotL)) * attenColor;
|
||||
float3 diffuse = directDiffuse * diffuseColor;
|
||||
/// Final Color:
|
||||
float3 finalColor = diffuse + specular;
|
||||
fixed4 finalRGBA = fixed4(finalColor * 1,0);
|
||||
UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
|
||||
return finalRGBA;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
CustomEditor "ShaderForgeMaterialInspector"
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7a3407103bb9e314485a1918c1afb6e1
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures:
|
||||
- _node_2846: {fileID: 2800000, guid: 81ae15997cb9d9e429a8bedf6099d2a4, type: 3}
|
||||
- _node_2094: {fileID: 2800000, guid: 78358780d5b46ff4d822cc40aec67e32, type: 3}
|
||||
- _node_7300: {fileID: 2800000, guid: ad34d2bca67b615439f6608dd7a30498, type: 3}
|
||||
- _node_2077: {fileID: 2800000, guid: 54bbca7ae723ac04f9e947001e70bd57, type: 3}
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,393 @@
|
|||
// Shader created with Shader Forge v1.38
|
||||
// Shader Forge (c) Neat Corporation / Joachim Holmer - http://www.acegikmo.com/shaderforge/
|
||||
// Note: Manually altering this data may prevent you from opening it in Shader Forge
|
||||
/*SF_DATA;ver:1.38;sub:START;pass:START;ps:flbk:,iptp:0,cusa:False,bamd:0,cgin:,lico:1,lgpr:1,limd:3,spmd:1,trmd:1,grmd:0,uamb:True,mssp:True,bkdf:True,hqlp:False,rprd:True,enco:False,rmgx:True,imps:True,rpth:0,vtps:0,hqsc:True,nrmq:1,nrsp:0,vomd:0,spxs:False,tesm:0,olmd:1,culm:0,bsrc:0,bdst:0,dpts:2,wrdp:False,dith:0,atcv:False,rfrpo:True,rfrpn:Refraction,coma:15,ufog:True,aust:True,igpj:True,qofs:0,qpre:3,rntp:2,fgom:False,fgoc:False,fgod:False,fgor:False,fgmd:0,fgcr:0.5,fgcg:0.5,fgcb:0.5,fgca:1,fgde:0.01,fgrn:0,fgrf:300,stcl:False,atwp:False,stva:128,stmr:255,stmw:255,stcp:6,stps:0,stfa:0,stfz:0,ofsf:0,ofsu:0,f2p0:False,fnsp:False,fnfb:False,fsmp:False;n:type:ShaderForge.SFN_Final,id:2865,x:32719,y:32712,varname:node_2865,prsc:2|diff-4999-OUT,spec-358-OUT,gloss-1813-OUT,alpha-7774-OUT;n:type:ShaderForge.SFN_Color,id:6665,x:32069,y:32596,ptovrint:False,ptlb:Color,ptin:_Color,varname:_Color,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,c1:1,c2:1,c3:1,c4:1;n:type:ShaderForge.SFN_Slider,id:358,x:32250,y:32780,ptovrint:False,ptlb:Metallic,ptin:_Metallic,varname:node_358,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0,max:1;n:type:ShaderForge.SFN_Slider,id:1813,x:32250,y:32882,ptovrint:False,ptlb:Gloss,ptin:_Gloss,varname:_Metallic_copy,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0.9,max:1;n:type:ShaderForge.SFN_Slider,id:7774,x:32328,y:33254,ptovrint:False,ptlb:Gloss_copy,ptin:_Gloss_copy,varname:_Gloss_copy,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:1,max:1;n:type:ShaderForge.SFN_LightColor,id:7917,x:32353,y:32539,varname:node_7917,prsc:2;n:type:ShaderForge.SFN_Vector1,id:5171,x:32515,y:32682,varname:node_5171,prsc:2,v1:0;n:type:ShaderForge.SFN_Fresnel,id:4999,x:32337,y:33011,varname:node_4999,prsc:2;proporder:6665-358-1813-7774;pass:END;sub:END;*/
|
||||
|
||||
Shader "Shader Forge/Otto_Retina" {
|
||||
Properties {
|
||||
_Color ("Color", Color) = (1,1,1,1)
|
||||
_Metallic ("Metallic", Range(0, 1)) = 0
|
||||
_Gloss ("Gloss", Range(0, 1)) = 0.9
|
||||
_Gloss_copy ("Gloss_copy", Range(0, 1)) = 1
|
||||
[HideInInspector]_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
|
||||
}
|
||||
SubShader {
|
||||
Tags {
|
||||
"IgnoreProjector"="True"
|
||||
"Queue"="Transparent"
|
||||
"RenderType"="Transparent"
|
||||
}
|
||||
Pass {
|
||||
Name "FORWARD"
|
||||
Tags {
|
||||
"LightMode"="ForwardBase"
|
||||
}
|
||||
Blend One One
|
||||
ZWrite Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#define UNITY_PASS_FORWARDBASE
|
||||
#define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )
|
||||
#define _GLOSSYENV 1
|
||||
#include "UnityCG.cginc"
|
||||
#include "Lighting.cginc"
|
||||
#include "UnityPBSLighting.cginc"
|
||||
#include "UnityStandardBRDF.cginc"
|
||||
#pragma multi_compile_fwdbase
|
||||
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
|
||||
#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE
|
||||
#pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
|
||||
#pragma multi_compile_fog
|
||||
#pragma only_renderers d3d9 d3d11 glcore gles
|
||||
#pragma target 3.0
|
||||
uniform float _Metallic;
|
||||
uniform float _Gloss;
|
||||
uniform float _Gloss_copy;
|
||||
struct VertexInput {
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float4 tangent : TANGENT;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float2 texcoord2 : TEXCOORD2;
|
||||
};
|
||||
struct VertexOutput {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv1 : TEXCOORD0;
|
||||
float2 uv2 : TEXCOORD1;
|
||||
float4 posWorld : TEXCOORD2;
|
||||
float3 normalDir : TEXCOORD3;
|
||||
float3 tangentDir : TEXCOORD4;
|
||||
float3 bitangentDir : TEXCOORD5;
|
||||
UNITY_FOG_COORDS(6)
|
||||
#if defined(LIGHTMAP_ON) || defined(UNITY_SHOULD_SAMPLE_SH)
|
||||
float4 ambientOrLightmapUV : TEXCOORD7;
|
||||
#endif
|
||||
};
|
||||
VertexOutput vert (VertexInput v) {
|
||||
VertexOutput o = (VertexOutput)0;
|
||||
o.uv1 = v.texcoord1;
|
||||
o.uv2 = v.texcoord2;
|
||||
#ifdef LIGHTMAP_ON
|
||||
o.ambientOrLightmapUV.xy = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
|
||||
o.ambientOrLightmapUV.zw = 0;
|
||||
#elif UNITY_SHOULD_SAMPLE_SH
|
||||
#endif
|
||||
#ifdef DYNAMICLIGHTMAP_ON
|
||||
o.ambientOrLightmapUV.zw = v.texcoord2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
|
||||
#endif
|
||||
o.normalDir = UnityObjectToWorldNormal(v.normal);
|
||||
o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz );
|
||||
o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
|
||||
o.posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||
float3 lightColor = _LightColor0.rgb;
|
||||
o.pos = UnityObjectToClipPos( v.vertex );
|
||||
UNITY_TRANSFER_FOG(o,o.pos);
|
||||
return o;
|
||||
}
|
||||
float4 frag(VertexOutput i) : COLOR {
|
||||
i.normalDir = normalize(i.normalDir);
|
||||
float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);
|
||||
float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
|
||||
float3 normalDirection = i.normalDir;
|
||||
float3 viewReflectDirection = reflect( -viewDirection, normalDirection );
|
||||
float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);
|
||||
float3 lightColor = _LightColor0.rgb;
|
||||
float3 halfDirection = normalize(viewDirection+lightDirection);
|
||||
////// Lighting:
|
||||
float attenuation = 1;
|
||||
float3 attenColor = attenuation * _LightColor0.xyz;
|
||||
float Pi = 3.141592654;
|
||||
float InvPi = 0.31830988618;
|
||||
///////// Gloss:
|
||||
float gloss = _Gloss;
|
||||
float perceptualRoughness = 1.0 - _Gloss;
|
||||
float roughness = perceptualRoughness * perceptualRoughness;
|
||||
float specPow = exp2( gloss * 10.0 + 1.0 );
|
||||
/////// GI Data:
|
||||
UnityLight light;
|
||||
#ifdef LIGHTMAP_OFF
|
||||
light.color = lightColor;
|
||||
light.dir = lightDirection;
|
||||
light.ndotl = LambertTerm (normalDirection, light.dir);
|
||||
#else
|
||||
light.color = half3(0.f, 0.f, 0.f);
|
||||
light.ndotl = 0.0f;
|
||||
light.dir = half3(0.f, 0.f, 0.f);
|
||||
#endif
|
||||
UnityGIInput d;
|
||||
d.light = light;
|
||||
d.worldPos = i.posWorld.xyz;
|
||||
d.worldViewDir = viewDirection;
|
||||
d.atten = attenuation;
|
||||
#if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)
|
||||
d.ambient = 0;
|
||||
d.lightmapUV = i.ambientOrLightmapUV;
|
||||
#else
|
||||
d.ambient = i.ambientOrLightmapUV;
|
||||
#endif
|
||||
#if UNITY_SPECCUBE_BLENDING || UNITY_SPECCUBE_BOX_PROJECTION
|
||||
d.boxMin[0] = unity_SpecCube0_BoxMin;
|
||||
d.boxMin[1] = unity_SpecCube1_BoxMin;
|
||||
#endif
|
||||
#if UNITY_SPECCUBE_BOX_PROJECTION
|
||||
d.boxMax[0] = unity_SpecCube0_BoxMax;
|
||||
d.boxMax[1] = unity_SpecCube1_BoxMax;
|
||||
d.probePosition[0] = unity_SpecCube0_ProbePosition;
|
||||
d.probePosition[1] = unity_SpecCube1_ProbePosition;
|
||||
#endif
|
||||
d.probeHDR[0] = unity_SpecCube0_HDR;
|
||||
d.probeHDR[1] = unity_SpecCube1_HDR;
|
||||
Unity_GlossyEnvironmentData ugls_en_data;
|
||||
ugls_en_data.roughness = 1.0 - gloss;
|
||||
ugls_en_data.reflUVW = viewReflectDirection;
|
||||
UnityGI gi = UnityGlobalIllumination(d, 1, normalDirection, ugls_en_data );
|
||||
lightDirection = gi.light.dir;
|
||||
lightColor = gi.light.color;
|
||||
////// Specular:
|
||||
float NdotL = saturate(dot( normalDirection, lightDirection ));
|
||||
float LdotH = saturate(dot(lightDirection, halfDirection));
|
||||
float3 specularColor = _Metallic;
|
||||
float specularMonochrome;
|
||||
float node_4999 = (1.0-max(0,dot(normalDirection, viewDirection)));
|
||||
float3 diffuseColor = float3(node_4999,node_4999,node_4999); // Need this for specular when using metallic
|
||||
diffuseColor = DiffuseAndSpecularFromMetallic( diffuseColor, specularColor, specularColor, specularMonochrome );
|
||||
specularMonochrome = 1.0-specularMonochrome;
|
||||
float NdotV = abs(dot( normalDirection, viewDirection ));
|
||||
float NdotH = saturate(dot( normalDirection, halfDirection ));
|
||||
float VdotH = saturate(dot( viewDirection, halfDirection ));
|
||||
float visTerm = SmithJointGGXVisibilityTerm( NdotL, NdotV, roughness );
|
||||
float normTerm = GGXTerm(NdotH, roughness);
|
||||
float specularPBL = (visTerm*normTerm) * UNITY_PI;
|
||||
#ifdef UNITY_COLORSPACE_GAMMA
|
||||
specularPBL = sqrt(max(1e-4h, specularPBL));
|
||||
#endif
|
||||
specularPBL = max(0, specularPBL * NdotL);
|
||||
#if defined(_SPECULARHIGHLIGHTS_OFF)
|
||||
specularPBL = 0.0;
|
||||
#endif
|
||||
half surfaceReduction;
|
||||
#ifdef UNITY_COLORSPACE_GAMMA
|
||||
surfaceReduction = 1.0-0.28*roughness*perceptualRoughness;
|
||||
#else
|
||||
surfaceReduction = 1.0/(roughness*roughness + 1.0);
|
||||
#endif
|
||||
specularPBL *= any(specularColor) ? 1.0 : 0.0;
|
||||
float3 directSpecular = attenColor*specularPBL*FresnelTerm(specularColor, LdotH);
|
||||
half grazingTerm = saturate( gloss + specularMonochrome );
|
||||
float3 indirectSpecular = (gi.indirect.specular);
|
||||
indirectSpecular *= FresnelLerp (specularColor, grazingTerm, NdotV);
|
||||
indirectSpecular *= surfaceReduction;
|
||||
float3 specular = (directSpecular + indirectSpecular);
|
||||
/////// Diffuse:
|
||||
NdotL = max(0.0,dot( normalDirection, lightDirection ));
|
||||
half fd90 = 0.5 + 2 * LdotH * LdotH * (1-gloss);
|
||||
float nlPow5 = Pow5(1-NdotL);
|
||||
float nvPow5 = Pow5(1-NdotV);
|
||||
float3 directDiffuse = ((1 +(fd90 - 1)*nlPow5) * (1 + (fd90 - 1)*nvPow5) * NdotL) * attenColor;
|
||||
float3 indirectDiffuse = float3(0,0,0);
|
||||
indirectDiffuse += gi.indirect.diffuse;
|
||||
float3 diffuse = (directDiffuse + indirectDiffuse) * diffuseColor;
|
||||
/// Final Color:
|
||||
float3 finalColor = diffuse * _Gloss_copy + specular;
|
||||
fixed4 finalRGBA = fixed4(finalColor,_Gloss_copy);
|
||||
UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
|
||||
return finalRGBA;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
Pass {
|
||||
Name "FORWARD_DELTA"
|
||||
Tags {
|
||||
"LightMode"="ForwardAdd"
|
||||
}
|
||||
Blend One One
|
||||
ZWrite Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#define UNITY_PASS_FORWARDADD
|
||||
#define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )
|
||||
#define _GLOSSYENV 1
|
||||
#include "UnityCG.cginc"
|
||||
#include "AutoLight.cginc"
|
||||
#include "Lighting.cginc"
|
||||
#include "UnityPBSLighting.cginc"
|
||||
#include "UnityStandardBRDF.cginc"
|
||||
#pragma multi_compile_fwdadd
|
||||
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
|
||||
#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE
|
||||
#pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
|
||||
#pragma multi_compile_fog
|
||||
#pragma only_renderers d3d9 d3d11 glcore gles
|
||||
#pragma target 3.0
|
||||
uniform float _Metallic;
|
||||
uniform float _Gloss;
|
||||
uniform float _Gloss_copy;
|
||||
struct VertexInput {
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float4 tangent : TANGENT;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float2 texcoord2 : TEXCOORD2;
|
||||
};
|
||||
struct VertexOutput {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv1 : TEXCOORD0;
|
||||
float2 uv2 : TEXCOORD1;
|
||||
float4 posWorld : TEXCOORD2;
|
||||
float3 normalDir : TEXCOORD3;
|
||||
float3 tangentDir : TEXCOORD4;
|
||||
float3 bitangentDir : TEXCOORD5;
|
||||
LIGHTING_COORDS(6,7)
|
||||
UNITY_FOG_COORDS(8)
|
||||
};
|
||||
VertexOutput vert (VertexInput v) {
|
||||
VertexOutput o = (VertexOutput)0;
|
||||
o.uv1 = v.texcoord1;
|
||||
o.uv2 = v.texcoord2;
|
||||
o.normalDir = UnityObjectToWorldNormal(v.normal);
|
||||
o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz );
|
||||
o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
|
||||
o.posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||
float3 lightColor = _LightColor0.rgb;
|
||||
o.pos = UnityObjectToClipPos( v.vertex );
|
||||
UNITY_TRANSFER_FOG(o,o.pos);
|
||||
TRANSFER_VERTEX_TO_FRAGMENT(o)
|
||||
return o;
|
||||
}
|
||||
float4 frag(VertexOutput i) : COLOR {
|
||||
i.normalDir = normalize(i.normalDir);
|
||||
float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);
|
||||
float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
|
||||
float3 normalDirection = i.normalDir;
|
||||
float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - i.posWorld.xyz,_WorldSpaceLightPos0.w));
|
||||
float3 lightColor = _LightColor0.rgb;
|
||||
float3 halfDirection = normalize(viewDirection+lightDirection);
|
||||
////// Lighting:
|
||||
float attenuation = LIGHT_ATTENUATION(i);
|
||||
float3 attenColor = attenuation * _LightColor0.xyz;
|
||||
float Pi = 3.141592654;
|
||||
float InvPi = 0.31830988618;
|
||||
///////// Gloss:
|
||||
float gloss = _Gloss;
|
||||
float perceptualRoughness = 1.0 - _Gloss;
|
||||
float roughness = perceptualRoughness * perceptualRoughness;
|
||||
float specPow = exp2( gloss * 10.0 + 1.0 );
|
||||
////// Specular:
|
||||
float NdotL = saturate(dot( normalDirection, lightDirection ));
|
||||
float LdotH = saturate(dot(lightDirection, halfDirection));
|
||||
float3 specularColor = _Metallic;
|
||||
float specularMonochrome;
|
||||
float node_4999 = (1.0-max(0,dot(normalDirection, viewDirection)));
|
||||
float3 diffuseColor = float3(node_4999,node_4999,node_4999); // Need this for specular when using metallic
|
||||
diffuseColor = DiffuseAndSpecularFromMetallic( diffuseColor, specularColor, specularColor, specularMonochrome );
|
||||
specularMonochrome = 1.0-specularMonochrome;
|
||||
float NdotV = abs(dot( normalDirection, viewDirection ));
|
||||
float NdotH = saturate(dot( normalDirection, halfDirection ));
|
||||
float VdotH = saturate(dot( viewDirection, halfDirection ));
|
||||
float visTerm = SmithJointGGXVisibilityTerm( NdotL, NdotV, roughness );
|
||||
float normTerm = GGXTerm(NdotH, roughness);
|
||||
float specularPBL = (visTerm*normTerm) * UNITY_PI;
|
||||
#ifdef UNITY_COLORSPACE_GAMMA
|
||||
specularPBL = sqrt(max(1e-4h, specularPBL));
|
||||
#endif
|
||||
specularPBL = max(0, specularPBL * NdotL);
|
||||
#if defined(_SPECULARHIGHLIGHTS_OFF)
|
||||
specularPBL = 0.0;
|
||||
#endif
|
||||
specularPBL *= any(specularColor) ? 1.0 : 0.0;
|
||||
float3 directSpecular = attenColor*specularPBL*FresnelTerm(specularColor, LdotH);
|
||||
float3 specular = directSpecular;
|
||||
/////// Diffuse:
|
||||
NdotL = max(0.0,dot( normalDirection, lightDirection ));
|
||||
half fd90 = 0.5 + 2 * LdotH * LdotH * (1-gloss);
|
||||
float nlPow5 = Pow5(1-NdotL);
|
||||
float nvPow5 = Pow5(1-NdotV);
|
||||
float3 directDiffuse = ((1 +(fd90 - 1)*nlPow5) * (1 + (fd90 - 1)*nvPow5) * NdotL) * attenColor;
|
||||
float3 diffuse = directDiffuse * diffuseColor;
|
||||
/// Final Color:
|
||||
float3 finalColor = diffuse * _Gloss_copy + specular;
|
||||
fixed4 finalRGBA = fixed4(finalColor,0);
|
||||
UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
|
||||
return finalRGBA;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
Pass {
|
||||
Name "Meta"
|
||||
Tags {
|
||||
"LightMode"="Meta"
|
||||
}
|
||||
Cull Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#define UNITY_PASS_META 1
|
||||
#define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )
|
||||
#define _GLOSSYENV 1
|
||||
#include "UnityCG.cginc"
|
||||
#include "Lighting.cginc"
|
||||
#include "UnityPBSLighting.cginc"
|
||||
#include "UnityStandardBRDF.cginc"
|
||||
#include "UnityMetaPass.cginc"
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma multi_compile_shadowcaster
|
||||
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
|
||||
#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE
|
||||
#pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
|
||||
#pragma multi_compile_fog
|
||||
#pragma only_renderers d3d9 d3d11 glcore gles
|
||||
#pragma target 3.0
|
||||
uniform float _Metallic;
|
||||
uniform float _Gloss;
|
||||
struct VertexInput {
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float2 texcoord2 : TEXCOORD2;
|
||||
};
|
||||
struct VertexOutput {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv1 : TEXCOORD0;
|
||||
float2 uv2 : TEXCOORD1;
|
||||
float4 posWorld : TEXCOORD2;
|
||||
float3 normalDir : TEXCOORD3;
|
||||
};
|
||||
VertexOutput vert (VertexInput v) {
|
||||
VertexOutput o = (VertexOutput)0;
|
||||
o.uv1 = v.texcoord1;
|
||||
o.uv2 = v.texcoord2;
|
||||
o.normalDir = UnityObjectToWorldNormal(v.normal);
|
||||
o.posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||
o.pos = UnityMetaVertexPosition(v.vertex, v.texcoord1.xy, v.texcoord2.xy, unity_LightmapST, unity_DynamicLightmapST );
|
||||
return o;
|
||||
}
|
||||
float4 frag(VertexOutput i) : SV_Target {
|
||||
i.normalDir = normalize(i.normalDir);
|
||||
float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
|
||||
float3 normalDirection = i.normalDir;
|
||||
UnityMetaInput o;
|
||||
UNITY_INITIALIZE_OUTPUT( UnityMetaInput, o );
|
||||
|
||||
o.Emission = 0;
|
||||
|
||||
float node_4999 = (1.0-max(0,dot(normalDirection, viewDirection)));
|
||||
float3 diffColor = float3(node_4999,node_4999,node_4999);
|
||||
float specularMonochrome;
|
||||
float3 specColor;
|
||||
diffColor = DiffuseAndSpecularFromMetallic( diffColor, _Metallic, specColor, specularMonochrome );
|
||||
float roughness = 1.0 - _Gloss;
|
||||
o.Albedo = diffColor + specColor * roughness * roughness * 0.5;
|
||||
|
||||
return UnityMetaFragment( o );
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
CustomEditor "ShaderForgeMaterialInspector"
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 382e40ad1afdd294483931b8f57133f5
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,181 @@
|
|||
// Shader created with Shader Forge v1.38
|
||||
// Shader Forge (c) Neat Corporation / Joachim Holmer - http://www.acegikmo.com/shaderforge/
|
||||
// Note: Manually altering this data may prevent you from opening it in Shader Forge
|
||||
/*SF_DATA;ver:1.38;sub:START;pass:START;ps:flbk:,iptp:0,cusa:False,bamd:0,cgin:,lico:1,lgpr:1,limd:0,spmd:1,trmd:0,grmd:1,uamb:True,mssp:True,bkdf:True,hqlp:False,rprd:True,enco:False,rmgx:True,imps:True,rpth:0,vtps:0,hqsc:True,nrmq:1,nrsp:0,vomd:0,spxs:False,tesm:0,olmd:1,culm:0,bsrc:0,bdst:1,dpts:2,wrdp:True,dith:0,atcv:False,rfrpo:True,rfrpn:Refraction,coma:15,ufog:True,aust:True,igpj:False,qofs:0,qpre:1,rntp:1,fgom:False,fgoc:False,fgod:False,fgor:False,fgmd:0,fgcr:0.5,fgcg:0.5,fgcb:0.5,fgca:1,fgde:0.01,fgrn:0,fgrf:300,stcl:False,atwp:False,stva:128,stmr:255,stmw:255,stcp:6,stps:0,stfa:0,stfz:0,ofsf:0,ofsu:0,f2p0:False,fnsp:False,fnfb:False,fsmp:False;n:type:ShaderForge.SFN_Final,id:2865,x:32719,y:32712,varname:node_2865,prsc:2|normal-5353-RGB,lwrap-8364-RGB,difocc-4051-R,spcocc-4051-R,custl-565-OUT;n:type:ShaderForge.SFN_Tex2d,id:1546,x:33347,y:32003,ptovrint:False,ptlb:BaseColor,ptin:_BaseColor,varname:node_1546,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:54bbca7ae723ac04f9e947001e70bd57,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Tex2d,id:5353,x:32245,y:32784,ptovrint:False,ptlb:Normal,ptin:_Normal,varname:node_5353,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:c48fb049779234742a17514944ecad6d,ntxv:3,isnm:True;n:type:ShaderForge.SFN_Tex2d,id:4051,x:33347,y:31814,ptovrint:False,ptlb:AO,ptin:_AO,varname:node_4051,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:81ae15997cb9d9e429a8bedf6099d2a4,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Tex2d,id:8364,x:33146,y:32096,ptovrint:False,ptlb:Transmission,ptin:_Transmission,varname:node_8364,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:78358780d5b46ff4d822cc40aec67e32,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Tex2d,id:9597,x:32664,y:31827,ptovrint:False,ptlb:Curvature,ptin:_Curvature,varname:node_9597,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:ad34d2bca67b615439f6608dd7a30498,ntxv:0,isnm:False;n:type:ShaderForge.SFN_NormalVector,id:2589,x:32739,y:32247,prsc:2,pt:False;n:type:ShaderForge.SFN_LightVector,id:4908,x:32739,y:32388,varname:node_4908,prsc:2;n:type:ShaderForge.SFN_ViewVector,id:9435,x:32739,y:32516,varname:node_9435,prsc:2;n:type:ShaderForge.SFN_Dot,id:8239,x:33003,y:32246,varname:node_8239,prsc:2,dt:0|A-2589-OUT,B-4908-OUT;n:type:ShaderForge.SFN_Dot,id:972,x:32997,y:32519,varname:node_972,prsc:2,dt:0|A-2589-OUT,B-9435-OUT;n:type:ShaderForge.SFN_Multiply,id:199,x:33247,y:32256,varname:node_199,prsc:2|A-8239-OUT,B-3587-OUT;n:type:ShaderForge.SFN_Add,id:6442,x:33457,y:32256,varname:node_6442,prsc:2|A-199-OUT,B-2972-OUT;n:type:ShaderForge.SFN_Vector1,id:3587,x:33136,y:32378,varname:node_3587,prsc:2,v1:0.3;n:type:ShaderForge.SFN_Vector1,id:2972,x:33336,y:32378,varname:node_2972,prsc:2,v1:0.5;n:type:ShaderForge.SFN_Multiply,id:9733,x:33229,y:32527,varname:node_9733,prsc:2|A-972-OUT,B-9671-OUT;n:type:ShaderForge.SFN_Vector1,id:9671,x:33118,y:32649,varname:node_9671,prsc:2,v1:0.8;n:type:ShaderForge.SFN_Append,id:5599,x:33624,y:32406,varname:node_5599,prsc:2|A-9733-OUT,B-6442-OUT;n:type:ShaderForge.SFN_Tex2d,id:6102,x:33792,y:32453,ptovrint:False,ptlb:SSS_Ramp,ptin:_SSS_Ramp,varname:node_6102,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:b0bdd1290b57b984f9b1567007d48e3b,ntxv:0,isnm:False|UVIN-5599-OUT;n:type:ShaderForge.SFN_Multiply,id:8343,x:34407,y:32474,varname:node_8343,prsc:2|A-2814-OUT,B-3738-RGB,C-2647-OUT,D-757-OUT;n:type:ShaderForge.SFN_LightColor,id:3738,x:33792,y:32619,varname:node_3738,prsc:2;n:type:ShaderForge.SFN_LightAttenuation,id:2647,x:33803,y:32752,varname:node_2647,prsc:2;n:type:ShaderForge.SFN_Multiply,id:1662,x:34012,y:32359,varname:node_1662,prsc:2|A-6102-R,B-8364-R,C-757-OUT,D-2350-OUT;n:type:ShaderForge.SFN_Lerp,id:2814,x:34205,y:32223,varname:node_2814,prsc:2|A-8687-OUT,B-5170-OUT,T-1662-OUT;n:type:ShaderForge.SFN_Power,id:8687,x:33842,y:31954,varname:node_8687,prsc:2|VAL-1546-RGB,EXP-2243-OUT;n:type:ShaderForge.SFN_Vector1,id:2243,x:33647,y:31988,varname:node_2243,prsc:2,v1:2;n:type:ShaderForge.SFN_Multiply,id:7957,x:33647,y:32170,varname:node_7957,prsc:2|A-1546-RGB,B-8364-R;n:type:ShaderForge.SFN_Add,id:5170,x:33809,y:32111,varname:node_5170,prsc:2|A-1546-RGB,B-7957-OUT;n:type:ShaderForge.SFN_Power,id:757,x:33746,y:31764,varname:node_757,prsc:2|VAL-4051-R,EXP-1951-OUT;n:type:ShaderForge.SFN_Vector1,id:1951,x:33551,y:31798,varname:node_1951,prsc:2,v1:0.5;n:type:ShaderForge.SFN_Vector1,id:2350,x:33936,y:32491,varname:node_2350,prsc:2,v1:2;n:type:ShaderForge.SFN_Add,id:565,x:34549,y:32356,varname:node_565,prsc:2|A-8343-OUT,B-7404-OUT;n:type:ShaderForge.SFN_Power,id:7404,x:34365,y:32824,varname:node_7404,prsc:2|VAL-6102-B,EXP-8710-OUT;n:type:ShaderForge.SFN_Vector1,id:8710,x:34170,y:32858,varname:node_8710,prsc:2,v1:4;proporder:1546-4051-5353-8364-9597-6102;pass:END;sub:END;*/
|
||||
|
||||
Shader "Shader Forge/Otto_SSS" {
|
||||
Properties {
|
||||
_BaseColor ("BaseColor", 2D) = "white" {}
|
||||
_AO ("AO", 2D) = "white" {}
|
||||
_Normal ("Normal", 2D) = "bump" {}
|
||||
_Transmission ("Transmission", 2D) = "white" {}
|
||||
_Curvature ("Curvature", 2D) = "white" {}
|
||||
_SSS_Ramp ("SSS_Ramp", 2D) = "white" {}
|
||||
}
|
||||
SubShader {
|
||||
Tags {
|
||||
"RenderType"="Opaque"
|
||||
}
|
||||
Pass {
|
||||
Name "FORWARD"
|
||||
Tags {
|
||||
"LightMode"="ForwardBase"
|
||||
}
|
||||
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#define UNITY_PASS_FORWARDBASE
|
||||
#define _GLOSSYENV 1
|
||||
#include "UnityCG.cginc"
|
||||
#include "AutoLight.cginc"
|
||||
#include "Lighting.cginc"
|
||||
#include "UnityPBSLighting.cginc"
|
||||
#include "UnityStandardBRDF.cginc"
|
||||
#pragma multi_compile_fwdbase_fullshadows
|
||||
#pragma multi_compile_fog
|
||||
#pragma only_renderers d3d9 d3d11 glcore gles
|
||||
#pragma target 3.0
|
||||
uniform sampler2D _BaseColor; uniform float4 _BaseColor_ST;
|
||||
uniform sampler2D _Normal; uniform float4 _Normal_ST;
|
||||
uniform sampler2D _AO; uniform float4 _AO_ST;
|
||||
uniform sampler2D _Transmission; uniform float4 _Transmission_ST;
|
||||
uniform sampler2D _SSS_Ramp; uniform float4 _SSS_Ramp_ST;
|
||||
struct VertexInput {
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float4 tangent : TANGENT;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
};
|
||||
struct VertexOutput {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv0 : TEXCOORD0;
|
||||
float4 posWorld : TEXCOORD1;
|
||||
float3 normalDir : TEXCOORD2;
|
||||
float3 tangentDir : TEXCOORD3;
|
||||
float3 bitangentDir : TEXCOORD4;
|
||||
LIGHTING_COORDS(5,6)
|
||||
UNITY_FOG_COORDS(7)
|
||||
};
|
||||
VertexOutput vert (VertexInput v) {
|
||||
VertexOutput o = (VertexOutput)0;
|
||||
o.uv0 = v.texcoord0;
|
||||
o.normalDir = UnityObjectToWorldNormal(v.normal);
|
||||
o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz );
|
||||
o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
|
||||
o.posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||
float3 lightColor = _LightColor0.rgb;
|
||||
o.pos = UnityObjectToClipPos( v.vertex );
|
||||
UNITY_TRANSFER_FOG(o,o.pos);
|
||||
TRANSFER_VERTEX_TO_FRAGMENT(o)
|
||||
return o;
|
||||
}
|
||||
float4 frag(VertexOutput i) : COLOR {
|
||||
i.normalDir = normalize(i.normalDir);
|
||||
float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);
|
||||
float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
|
||||
float3 _Normal_var = UnpackNormal(tex2D(_Normal,TRANSFORM_TEX(i.uv0, _Normal)));
|
||||
float3 normalLocal = _Normal_var.rgb;
|
||||
float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals
|
||||
float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);
|
||||
float3 lightColor = _LightColor0.rgb;
|
||||
////// Lighting:
|
||||
float attenuation = LIGHT_ATTENUATION(i);
|
||||
float4 _BaseColor_var = tex2D(_BaseColor,TRANSFORM_TEX(i.uv0, _BaseColor));
|
||||
float4 _Transmission_var = tex2D(_Transmission,TRANSFORM_TEX(i.uv0, _Transmission));
|
||||
float2 node_5599 = float2((dot(i.normalDir,viewDirection)*0.8),((dot(i.normalDir,lightDirection)*0.3)+0.5));
|
||||
float4 _SSS_Ramp_var = tex2D(_SSS_Ramp,TRANSFORM_TEX(node_5599, _SSS_Ramp));
|
||||
float4 _AO_var = tex2D(_AO,TRANSFORM_TEX(i.uv0, _AO));
|
||||
float node_757 = pow(_AO_var.r,0.5);
|
||||
float3 finalColor = ((lerp(pow(_BaseColor_var.rgb,2.0),(_BaseColor_var.rgb+(_BaseColor_var.rgb*_Transmission_var.r)),(_SSS_Ramp_var.r*_Transmission_var.r*node_757*2.0))*_LightColor0.rgb*attenuation*node_757)+pow(_SSS_Ramp_var.b,4.0));
|
||||
fixed4 finalRGBA = fixed4(finalColor,1);
|
||||
UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
|
||||
return finalRGBA;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
Pass {
|
||||
Name "FORWARD_DELTA"
|
||||
Tags {
|
||||
"LightMode"="ForwardAdd"
|
||||
}
|
||||
Blend One One
|
||||
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#define UNITY_PASS_FORWARDADD
|
||||
#define _GLOSSYENV 1
|
||||
#include "UnityCG.cginc"
|
||||
#include "AutoLight.cginc"
|
||||
#include "Lighting.cginc"
|
||||
#include "UnityPBSLighting.cginc"
|
||||
#include "UnityStandardBRDF.cginc"
|
||||
#pragma multi_compile_fwdadd_fullshadows
|
||||
#pragma multi_compile_fog
|
||||
#pragma only_renderers d3d9 d3d11 glcore gles
|
||||
#pragma target 3.0
|
||||
uniform sampler2D _BaseColor; uniform float4 _BaseColor_ST;
|
||||
uniform sampler2D _Normal; uniform float4 _Normal_ST;
|
||||
uniform sampler2D _AO; uniform float4 _AO_ST;
|
||||
uniform sampler2D _Transmission; uniform float4 _Transmission_ST;
|
||||
uniform sampler2D _SSS_Ramp; uniform float4 _SSS_Ramp_ST;
|
||||
struct VertexInput {
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float4 tangent : TANGENT;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
};
|
||||
struct VertexOutput {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv0 : TEXCOORD0;
|
||||
float4 posWorld : TEXCOORD1;
|
||||
float3 normalDir : TEXCOORD2;
|
||||
float3 tangentDir : TEXCOORD3;
|
||||
float3 bitangentDir : TEXCOORD4;
|
||||
LIGHTING_COORDS(5,6)
|
||||
UNITY_FOG_COORDS(7)
|
||||
};
|
||||
VertexOutput vert (VertexInput v) {
|
||||
VertexOutput o = (VertexOutput)0;
|
||||
o.uv0 = v.texcoord0;
|
||||
o.normalDir = UnityObjectToWorldNormal(v.normal);
|
||||
o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz );
|
||||
o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
|
||||
o.posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||
float3 lightColor = _LightColor0.rgb;
|
||||
o.pos = UnityObjectToClipPos( v.vertex );
|
||||
UNITY_TRANSFER_FOG(o,o.pos);
|
||||
TRANSFER_VERTEX_TO_FRAGMENT(o)
|
||||
return o;
|
||||
}
|
||||
float4 frag(VertexOutput i) : COLOR {
|
||||
i.normalDir = normalize(i.normalDir);
|
||||
float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);
|
||||
float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
|
||||
float3 _Normal_var = UnpackNormal(tex2D(_Normal,TRANSFORM_TEX(i.uv0, _Normal)));
|
||||
float3 normalLocal = _Normal_var.rgb;
|
||||
float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals
|
||||
float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - i.posWorld.xyz,_WorldSpaceLightPos0.w));
|
||||
float3 lightColor = _LightColor0.rgb;
|
||||
////// Lighting:
|
||||
float attenuation = LIGHT_ATTENUATION(i);
|
||||
float4 _BaseColor_var = tex2D(_BaseColor,TRANSFORM_TEX(i.uv0, _BaseColor));
|
||||
float4 _Transmission_var = tex2D(_Transmission,TRANSFORM_TEX(i.uv0, _Transmission));
|
||||
float2 node_5599 = float2((dot(i.normalDir,viewDirection)*0.8),((dot(i.normalDir,lightDirection)*0.3)+0.5));
|
||||
float4 _SSS_Ramp_var = tex2D(_SSS_Ramp,TRANSFORM_TEX(node_5599, _SSS_Ramp));
|
||||
float4 _AO_var = tex2D(_AO,TRANSFORM_TEX(i.uv0, _AO));
|
||||
float node_757 = pow(_AO_var.r,0.5);
|
||||
float3 finalColor = ((lerp(pow(_BaseColor_var.rgb,2.0),(_BaseColor_var.rgb+(_BaseColor_var.rgb*_Transmission_var.r)),(_SSS_Ramp_var.r*_Transmission_var.r*node_757*2.0))*_LightColor0.rgb*attenuation*node_757)+pow(_SSS_Ramp_var.b,4.0));
|
||||
fixed4 finalRGBA = fixed4(finalColor * 1,0);
|
||||
UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
|
||||
return finalRGBA;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
CustomEditor "ShaderForgeMaterialInspector"
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e6a9f5fc5de48cd4da3e05fc539fb5ae
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures:
|
||||
- _BaseColor: {fileID: 2800000, guid: 54bbca7ae723ac04f9e947001e70bd57, type: 3}
|
||||
- _Normal: {fileID: 2800000, guid: c48fb049779234742a17514944ecad6d, type: 3}
|
||||
- _AO: {fileID: 2800000, guid: 81ae15997cb9d9e429a8bedf6099d2a4, type: 3}
|
||||
- _Transmission: {fileID: 2800000, guid: 78358780d5b46ff4d822cc40aec67e32, type: 3}
|
||||
- _Curvature: {fileID: 2800000, guid: ad34d2bca67b615439f6608dd7a30498, type: 3}
|
||||
- _SSS_Ramp: {fileID: 2800000, guid: b0bdd1290b57b984f9b1567007d48e3b, type: 3}
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,440 @@
|
|||
// Shader created with Shader Forge v1.38
|
||||
// Shader Forge (c) Neat Corporation / Joachim Holmer - http://www.acegikmo.com/shaderforge/
|
||||
// Note: Manually altering this data may prevent you from opening it in Shader Forge
|
||||
/*SF_DATA;ver:1.38;sub:START;pass:START;ps:flbk:,iptp:0,cusa:False,bamd:0,cgin:,lico:1,lgpr:1,limd:3,spmd:0,trmd:0,grmd:1,uamb:True,mssp:True,bkdf:True,hqlp:False,rprd:True,enco:False,rmgx:True,imps:True,rpth:0,vtps:0,hqsc:True,nrmq:1,nrsp:0,vomd:0,spxs:False,tesm:0,olmd:1,culm:0,bsrc:0,bdst:1,dpts:2,wrdp:True,dith:0,atcv:False,rfrpo:True,rfrpn:Refraction,coma:15,ufog:True,aust:True,igpj:False,qofs:0,qpre:1,rntp:1,fgom:False,fgoc:False,fgod:False,fgor:False,fgmd:0,fgcr:0.5,fgcg:0.5,fgcb:0.5,fgca:1,fgde:0.01,fgrn:0,fgrf:300,stcl:False,atwp:False,stva:128,stmr:255,stmw:255,stcp:6,stps:0,stfa:0,stfz:0,ofsf:0,ofsu:0,f2p0:False,fnsp:False,fnfb:False,fsmp:False;n:type:ShaderForge.SFN_Final,id:2865,x:32719,y:32712,varname:node_2865,prsc:2|diff-4664-OUT,diffpow-9236-OUT,spec-4664-OUT,gloss-3338-OUT,normal-9299-RGB,emission-7195-OUT,transm-4361-R,amdfl-5013-OUT,amspl-5013-OUT,difocc-3067-R,spcocc-3067-R;n:type:ShaderForge.SFN_Tex2d,id:9299,x:31803,y:32625,ptovrint:False,ptlb:Normal,ptin:_Normal,varname:node_9299,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:c48fb049779234742a17514944ecad6d,ntxv:3,isnm:True;n:type:ShaderForge.SFN_Tex2d,id:3461,x:31803,y:32812,ptovrint:False,ptlb:BaseColor,ptin:_BaseColor,varname:_node_9299_copy,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:54bbca7ae723ac04f9e947001e70bd57,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Tex2d,id:3067,x:31803,y:33011,ptovrint:False,ptlb:Occlusion,ptin:_Occlusion,varname:_node_9299_copy_copy,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:81ae15997cb9d9e429a8bedf6099d2a4,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Tex2d,id:4361,x:31803,y:33203,ptovrint:False,ptlb:Transmission,ptin:_Transmission,varname:_node_9299_copy_copy_copy,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:78358780d5b46ff4d822cc40aec67e32,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Tex2d,id:4647,x:31803,y:33405,ptovrint:False,ptlb:Convexity,ptin:_Convexity,varname:_node_9299_copy_copy_copy_copy,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:ad34d2bca67b615439f6608dd7a30498,ntxv:0,isnm:False;n:type:ShaderForge.SFN_Vector1,id:8106,x:32442,y:32581,varname:node_8106,prsc:2,v1:0.75;n:type:ShaderForge.SFN_Subtract,id:9236,x:32135,y:32896,varname:node_9236,prsc:2|A-734-OUT,B-3067-R;n:type:ShaderForge.SFN_Vector1,id:734,x:31961,y:32896,varname:node_734,prsc:2,v1:4;n:type:ShaderForge.SFN_Power,id:4664,x:32245,y:32774,varname:node_4664,prsc:2|VAL-3461-RGB,EXP-1227-OUT;n:type:ShaderForge.SFN_Subtract,id:1227,x:32166,y:33396,varname:node_1227,prsc:2|A-1919-OUT,B-4647-R;n:type:ShaderForge.SFN_Vector1,id:1919,x:31980,y:33374,varname:node_1919,prsc:2,v1:2.5;n:type:ShaderForge.SFN_Multiply,id:7195,x:32265,y:33031,varname:node_7195,prsc:2|A-3461-RGB,B-4361-R,C-9032-OUT;n:type:ShaderForge.SFN_Fresnel,id:9032,x:32498,y:33163,varname:node_9032,prsc:2|EXP-9331-OUT;n:type:ShaderForge.SFN_Subtract,id:6966,x:32060,y:33553,varname:node_6966,prsc:2|A-4647-R,B-1885-OUT;n:type:ShaderForge.SFN_Vector1,id:1885,x:31906,y:33711,varname:node_1885,prsc:2,v1:0.5;n:type:ShaderForge.SFN_Multiply,id:8153,x:32258,y:33553,varname:node_8153,prsc:2|A-6966-OUT,B-6525-OUT;n:type:ShaderForge.SFN_Vector1,id:6525,x:32136,y:33711,varname:node_6525,prsc:2,v1:0.5;n:type:ShaderForge.SFN_Add,id:3338,x:32443,y:33553,varname:node_3338,prsc:2|A-8153-OUT,B-8505-OUT;n:type:ShaderForge.SFN_Vector1,id:8505,x:32330,y:33711,varname:node_8505,prsc:2,v1:0.75;n:type:ShaderForge.SFN_Vector1,id:9331,x:32343,y:33234,varname:node_9331,prsc:2,v1:2;n:type:ShaderForge.SFN_Add,id:5249,x:32459,y:32982,varname:node_5249,prsc:2|A-7195-OUT,B-5013-OUT;n:type:ShaderForge.SFN_Multiply,id:5013,x:32896,y:33276,varname:node_5013,prsc:2|A-4664-OUT,B-6880-OUT,C-4589-OUT;n:type:ShaderForge.SFN_Fresnel,id:6880,x:32710,y:33347,varname:node_6880,prsc:2|EXP-8974-OUT;n:type:ShaderForge.SFN_Vector1,id:8974,x:32478,y:33370,varname:node_8974,prsc:2,v1:1;n:type:ShaderForge.SFN_Vector1,id:4589,x:32779,y:33512,varname:node_4589,prsc:2,v1:0.5;proporder:3461-3067-9299-4361-4647;pass:END;sub:END;*/
|
||||
|
||||
Shader "Shader Forge/Otto_Showcase" {
|
||||
Properties {
|
||||
_BaseColor ("BaseColor", 2D) = "white" {}
|
||||
_Occlusion ("Occlusion", 2D) = "white" {}
|
||||
_Normal ("Normal", 2D) = "bump" {}
|
||||
_Transmission ("Transmission", 2D) = "white" {}
|
||||
_Convexity ("Convexity", 2D) = "white" {}
|
||||
}
|
||||
SubShader {
|
||||
Tags {
|
||||
"RenderType"="Opaque"
|
||||
}
|
||||
Pass {
|
||||
Name "FORWARD"
|
||||
Tags {
|
||||
"LightMode"="ForwardBase"
|
||||
}
|
||||
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#define UNITY_PASS_FORWARDBASE
|
||||
#define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )
|
||||
#define _GLOSSYENV 1
|
||||
#include "UnityCG.cginc"
|
||||
#include "AutoLight.cginc"
|
||||
#include "Lighting.cginc"
|
||||
#include "UnityPBSLighting.cginc"
|
||||
#include "UnityStandardBRDF.cginc"
|
||||
#pragma multi_compile_fwdbase_fullshadows
|
||||
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
|
||||
#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE
|
||||
#pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
|
||||
#pragma multi_compile_fog
|
||||
#pragma only_renderers d3d9 d3d11 glcore gles
|
||||
#pragma target 3.0
|
||||
uniform sampler2D _Normal; uniform float4 _Normal_ST;
|
||||
uniform sampler2D _BaseColor; uniform float4 _BaseColor_ST;
|
||||
uniform sampler2D _Occlusion; uniform float4 _Occlusion_ST;
|
||||
uniform sampler2D _Transmission; uniform float4 _Transmission_ST;
|
||||
uniform sampler2D _Convexity; uniform float4 _Convexity_ST;
|
||||
struct VertexInput {
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float4 tangent : TANGENT;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float2 texcoord2 : TEXCOORD2;
|
||||
};
|
||||
struct VertexOutput {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv0 : TEXCOORD0;
|
||||
float2 uv1 : TEXCOORD1;
|
||||
float2 uv2 : TEXCOORD2;
|
||||
float4 posWorld : TEXCOORD3;
|
||||
float3 normalDir : TEXCOORD4;
|
||||
float3 tangentDir : TEXCOORD5;
|
||||
float3 bitangentDir : TEXCOORD6;
|
||||
LIGHTING_COORDS(7,8)
|
||||
UNITY_FOG_COORDS(9)
|
||||
#if defined(LIGHTMAP_ON) || defined(UNITY_SHOULD_SAMPLE_SH)
|
||||
float4 ambientOrLightmapUV : TEXCOORD10;
|
||||
#endif
|
||||
};
|
||||
VertexOutput vert (VertexInput v) {
|
||||
VertexOutput o = (VertexOutput)0;
|
||||
o.uv0 = v.texcoord0;
|
||||
o.uv1 = v.texcoord1;
|
||||
o.uv2 = v.texcoord2;
|
||||
#ifdef LIGHTMAP_ON
|
||||
o.ambientOrLightmapUV.xy = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
|
||||
o.ambientOrLightmapUV.zw = 0;
|
||||
#elif UNITY_SHOULD_SAMPLE_SH
|
||||
#endif
|
||||
#ifdef DYNAMICLIGHTMAP_ON
|
||||
o.ambientOrLightmapUV.zw = v.texcoord2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
|
||||
#endif
|
||||
o.normalDir = UnityObjectToWorldNormal(v.normal);
|
||||
o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz );
|
||||
o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
|
||||
o.posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||
float3 lightColor = _LightColor0.rgb;
|
||||
o.pos = UnityObjectToClipPos( v.vertex );
|
||||
UNITY_TRANSFER_FOG(o,o.pos);
|
||||
TRANSFER_VERTEX_TO_FRAGMENT(o)
|
||||
return o;
|
||||
}
|
||||
float4 frag(VertexOutput i) : COLOR {
|
||||
i.normalDir = normalize(i.normalDir);
|
||||
float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);
|
||||
float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
|
||||
float3 _Normal_var = UnpackNormal(tex2D(_Normal,TRANSFORM_TEX(i.uv0, _Normal)));
|
||||
float3 normalLocal = _Normal_var.rgb;
|
||||
float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals
|
||||
float3 viewReflectDirection = reflect( -viewDirection, normalDirection );
|
||||
float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);
|
||||
float3 lightColor = _LightColor0.rgb;
|
||||
float3 halfDirection = normalize(viewDirection+lightDirection);
|
||||
////// Lighting:
|
||||
float attenuation = LIGHT_ATTENUATION(i);
|
||||
float3 attenColor = attenuation * _LightColor0.xyz;
|
||||
float Pi = 3.141592654;
|
||||
float InvPi = 0.31830988618;
|
||||
///////// Gloss:
|
||||
float4 _Convexity_var = tex2D(_Convexity,TRANSFORM_TEX(i.uv0, _Convexity));
|
||||
float gloss = 1.0 - (((_Convexity_var.r-0.5)*0.5)+0.75); // Convert roughness to gloss
|
||||
float perceptualRoughness = (((_Convexity_var.r-0.5)*0.5)+0.75);
|
||||
float roughness = perceptualRoughness * perceptualRoughness;
|
||||
float specPow = exp2( gloss * 10.0 + 1.0 );
|
||||
/////// GI Data:
|
||||
UnityLight light;
|
||||
#ifdef LIGHTMAP_OFF
|
||||
light.color = lightColor;
|
||||
light.dir = lightDirection;
|
||||
light.ndotl = LambertTerm (normalDirection, light.dir);
|
||||
#else
|
||||
light.color = half3(0.f, 0.f, 0.f);
|
||||
light.ndotl = 0.0f;
|
||||
light.dir = half3(0.f, 0.f, 0.f);
|
||||
#endif
|
||||
UnityGIInput d;
|
||||
d.light = light;
|
||||
d.worldPos = i.posWorld.xyz;
|
||||
d.worldViewDir = viewDirection;
|
||||
d.atten = attenuation;
|
||||
#if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)
|
||||
d.ambient = 0;
|
||||
d.lightmapUV = i.ambientOrLightmapUV;
|
||||
#else
|
||||
d.ambient = i.ambientOrLightmapUV;
|
||||
#endif
|
||||
#if UNITY_SPECCUBE_BLENDING || UNITY_SPECCUBE_BOX_PROJECTION
|
||||
d.boxMin[0] = unity_SpecCube0_BoxMin;
|
||||
d.boxMin[1] = unity_SpecCube1_BoxMin;
|
||||
#endif
|
||||
#if UNITY_SPECCUBE_BOX_PROJECTION
|
||||
d.boxMax[0] = unity_SpecCube0_BoxMax;
|
||||
d.boxMax[1] = unity_SpecCube1_BoxMax;
|
||||
d.probePosition[0] = unity_SpecCube0_ProbePosition;
|
||||
d.probePosition[1] = unity_SpecCube1_ProbePosition;
|
||||
#endif
|
||||
d.probeHDR[0] = unity_SpecCube0_HDR;
|
||||
d.probeHDR[1] = unity_SpecCube1_HDR;
|
||||
Unity_GlossyEnvironmentData ugls_en_data;
|
||||
ugls_en_data.roughness = 1.0 - gloss;
|
||||
ugls_en_data.reflUVW = viewReflectDirection;
|
||||
UnityGI gi = UnityGlobalIllumination(d, 1, normalDirection, ugls_en_data );
|
||||
lightDirection = gi.light.dir;
|
||||
lightColor = gi.light.color;
|
||||
////// Specular:
|
||||
float NdotL = saturate(dot( normalDirection, lightDirection ));
|
||||
float4 _Occlusion_var = tex2D(_Occlusion,TRANSFORM_TEX(i.uv0, _Occlusion));
|
||||
float3 specularAO = _Occlusion_var.r;
|
||||
float4 _BaseColor_var = tex2D(_BaseColor,TRANSFORM_TEX(i.uv0, _BaseColor));
|
||||
float3 node_4664 = pow(_BaseColor_var.rgb,(2.5-_Convexity_var.r));
|
||||
float3 node_5013 = (node_4664*pow(1.0-max(0,dot(normalDirection, viewDirection)),1.0)*0.5);
|
||||
float LdotH = saturate(dot(lightDirection, halfDirection));
|
||||
float3 specularColor = node_4664;
|
||||
float specularMonochrome;
|
||||
float3 diffuseColor = node_4664; // Need this for specular when using metallic
|
||||
diffuseColor = EnergyConservationBetweenDiffuseAndSpecular(diffuseColor, specularColor, specularMonochrome);
|
||||
specularMonochrome = 1.0-specularMonochrome;
|
||||
float NdotV = abs(dot( normalDirection, viewDirection ));
|
||||
float NdotH = saturate(dot( normalDirection, halfDirection ));
|
||||
float VdotH = saturate(dot( viewDirection, halfDirection ));
|
||||
float visTerm = SmithJointGGXVisibilityTerm( NdotL, NdotV, roughness );
|
||||
float normTerm = GGXTerm(NdotH, roughness);
|
||||
float specularPBL = (visTerm*normTerm) * UNITY_PI;
|
||||
#ifdef UNITY_COLORSPACE_GAMMA
|
||||
specularPBL = sqrt(max(1e-4h, specularPBL));
|
||||
#endif
|
||||
specularPBL = max(0, specularPBL * NdotL);
|
||||
#if defined(_SPECULARHIGHLIGHTS_OFF)
|
||||
specularPBL = 0.0;
|
||||
#endif
|
||||
half surfaceReduction;
|
||||
#ifdef UNITY_COLORSPACE_GAMMA
|
||||
surfaceReduction = 1.0-0.28*roughness*perceptualRoughness;
|
||||
#else
|
||||
surfaceReduction = 1.0/(roughness*roughness + 1.0);
|
||||
#endif
|
||||
specularPBL *= any(specularColor) ? 1.0 : 0.0;
|
||||
float3 directSpecular = attenColor*specularPBL*FresnelTerm(specularColor, LdotH);
|
||||
half grazingTerm = saturate( gloss + specularMonochrome );
|
||||
float3 indirectSpecular = (gi.indirect.specular + node_5013) * specularAO;
|
||||
indirectSpecular *= FresnelLerp (specularColor, grazingTerm, NdotV);
|
||||
indirectSpecular *= surfaceReduction;
|
||||
float3 specular = (directSpecular + indirectSpecular);
|
||||
/////// Diffuse:
|
||||
NdotL = dot( normalDirection, lightDirection );
|
||||
float3 forwardLight = pow(max(0.0, NdotL ), (4.0-_Occlusion_var.r));
|
||||
float4 _Transmission_var = tex2D(_Transmission,TRANSFORM_TEX(i.uv0, _Transmission));
|
||||
float3 backLight = pow(max(0.0, -NdotL ), (4.0-_Occlusion_var.r)) * float3(_Transmission_var.r,_Transmission_var.r,_Transmission_var.r);
|
||||
NdotL = max(0.0,dot( normalDirection, lightDirection ));
|
||||
half fd90 = 0.5 + 2 * LdotH * LdotH * (1-gloss);
|
||||
float3 NdotLWrap = max(0,NdotL);
|
||||
float nlPow5 = Pow5(1-NdotLWrap);
|
||||
float nvPow5 = Pow5(1-NdotV);
|
||||
float3 directDiffuse = ((forwardLight+backLight) + ((1 +(fd90 - 1)*nlPow5) * (1 + (fd90 - 1)*nvPow5) * NdotL)) * attenColor;
|
||||
float3 indirectDiffuse = float3(0,0,0);
|
||||
indirectDiffuse += node_5013; // Diffuse Ambient Light
|
||||
indirectDiffuse += gi.indirect.diffuse;
|
||||
indirectDiffuse *= _Occlusion_var.r; // Diffuse AO
|
||||
diffuseColor *= 1-specularMonochrome;
|
||||
float3 diffuse = (directDiffuse + indirectDiffuse) * diffuseColor;
|
||||
////// Emissive:
|
||||
float3 node_7195 = (_BaseColor_var.rgb*_Transmission_var.r*pow(1.0-max(0,dot(normalDirection, viewDirection)),2.0));
|
||||
float3 emissive = node_7195;
|
||||
/// Final Color:
|
||||
float3 finalColor = diffuse + specular + emissive;
|
||||
fixed4 finalRGBA = fixed4(finalColor,1);
|
||||
UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
|
||||
return finalRGBA;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
Pass {
|
||||
Name "FORWARD_DELTA"
|
||||
Tags {
|
||||
"LightMode"="ForwardAdd"
|
||||
}
|
||||
Blend One One
|
||||
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#define UNITY_PASS_FORWARDADD
|
||||
#define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )
|
||||
#define _GLOSSYENV 1
|
||||
#include "UnityCG.cginc"
|
||||
#include "AutoLight.cginc"
|
||||
#include "Lighting.cginc"
|
||||
#include "UnityPBSLighting.cginc"
|
||||
#include "UnityStandardBRDF.cginc"
|
||||
#pragma multi_compile_fwdadd_fullshadows
|
||||
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
|
||||
#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE
|
||||
#pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
|
||||
#pragma multi_compile_fog
|
||||
#pragma only_renderers d3d9 d3d11 glcore gles
|
||||
#pragma target 3.0
|
||||
uniform sampler2D _Normal; uniform float4 _Normal_ST;
|
||||
uniform sampler2D _BaseColor; uniform float4 _BaseColor_ST;
|
||||
uniform sampler2D _Occlusion; uniform float4 _Occlusion_ST;
|
||||
uniform sampler2D _Transmission; uniform float4 _Transmission_ST;
|
||||
uniform sampler2D _Convexity; uniform float4 _Convexity_ST;
|
||||
struct VertexInput {
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float4 tangent : TANGENT;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float2 texcoord2 : TEXCOORD2;
|
||||
};
|
||||
struct VertexOutput {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv0 : TEXCOORD0;
|
||||
float2 uv1 : TEXCOORD1;
|
||||
float2 uv2 : TEXCOORD2;
|
||||
float4 posWorld : TEXCOORD3;
|
||||
float3 normalDir : TEXCOORD4;
|
||||
float3 tangentDir : TEXCOORD5;
|
||||
float3 bitangentDir : TEXCOORD6;
|
||||
LIGHTING_COORDS(7,8)
|
||||
UNITY_FOG_COORDS(9)
|
||||
};
|
||||
VertexOutput vert (VertexInput v) {
|
||||
VertexOutput o = (VertexOutput)0;
|
||||
o.uv0 = v.texcoord0;
|
||||
o.uv1 = v.texcoord1;
|
||||
o.uv2 = v.texcoord2;
|
||||
o.normalDir = UnityObjectToWorldNormal(v.normal);
|
||||
o.tangentDir = normalize( mul( unity_ObjectToWorld, float4( v.tangent.xyz, 0.0 ) ).xyz );
|
||||
o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w);
|
||||
o.posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||
float3 lightColor = _LightColor0.rgb;
|
||||
o.pos = UnityObjectToClipPos( v.vertex );
|
||||
UNITY_TRANSFER_FOG(o,o.pos);
|
||||
TRANSFER_VERTEX_TO_FRAGMENT(o)
|
||||
return o;
|
||||
}
|
||||
float4 frag(VertexOutput i) : COLOR {
|
||||
i.normalDir = normalize(i.normalDir);
|
||||
float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);
|
||||
float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
|
||||
float3 _Normal_var = UnpackNormal(tex2D(_Normal,TRANSFORM_TEX(i.uv0, _Normal)));
|
||||
float3 normalLocal = _Normal_var.rgb;
|
||||
float3 normalDirection = normalize(mul( normalLocal, tangentTransform )); // Perturbed normals
|
||||
float3 lightDirection = normalize(lerp(_WorldSpaceLightPos0.xyz, _WorldSpaceLightPos0.xyz - i.posWorld.xyz,_WorldSpaceLightPos0.w));
|
||||
float3 lightColor = _LightColor0.rgb;
|
||||
float3 halfDirection = normalize(viewDirection+lightDirection);
|
||||
////// Lighting:
|
||||
float attenuation = LIGHT_ATTENUATION(i);
|
||||
float3 attenColor = attenuation * _LightColor0.xyz;
|
||||
float Pi = 3.141592654;
|
||||
float InvPi = 0.31830988618;
|
||||
///////// Gloss:
|
||||
float4 _Convexity_var = tex2D(_Convexity,TRANSFORM_TEX(i.uv0, _Convexity));
|
||||
float gloss = 1.0 - (((_Convexity_var.r-0.5)*0.5)+0.75); // Convert roughness to gloss
|
||||
float perceptualRoughness = (((_Convexity_var.r-0.5)*0.5)+0.75);
|
||||
float roughness = perceptualRoughness * perceptualRoughness;
|
||||
float specPow = exp2( gloss * 10.0 + 1.0 );
|
||||
////// Specular:
|
||||
float NdotL = saturate(dot( normalDirection, lightDirection ));
|
||||
float LdotH = saturate(dot(lightDirection, halfDirection));
|
||||
float4 _BaseColor_var = tex2D(_BaseColor,TRANSFORM_TEX(i.uv0, _BaseColor));
|
||||
float3 node_4664 = pow(_BaseColor_var.rgb,(2.5-_Convexity_var.r));
|
||||
float3 specularColor = node_4664;
|
||||
float specularMonochrome;
|
||||
float3 diffuseColor = node_4664; // Need this for specular when using metallic
|
||||
diffuseColor = EnergyConservationBetweenDiffuseAndSpecular(diffuseColor, specularColor, specularMonochrome);
|
||||
specularMonochrome = 1.0-specularMonochrome;
|
||||
float NdotV = abs(dot( normalDirection, viewDirection ));
|
||||
float NdotH = saturate(dot( normalDirection, halfDirection ));
|
||||
float VdotH = saturate(dot( viewDirection, halfDirection ));
|
||||
float visTerm = SmithJointGGXVisibilityTerm( NdotL, NdotV, roughness );
|
||||
float normTerm = GGXTerm(NdotH, roughness);
|
||||
float specularPBL = (visTerm*normTerm) * UNITY_PI;
|
||||
#ifdef UNITY_COLORSPACE_GAMMA
|
||||
specularPBL = sqrt(max(1e-4h, specularPBL));
|
||||
#endif
|
||||
specularPBL = max(0, specularPBL * NdotL);
|
||||
#if defined(_SPECULARHIGHLIGHTS_OFF)
|
||||
specularPBL = 0.0;
|
||||
#endif
|
||||
specularPBL *= any(specularColor) ? 1.0 : 0.0;
|
||||
float3 directSpecular = attenColor*specularPBL*FresnelTerm(specularColor, LdotH);
|
||||
float3 specular = directSpecular;
|
||||
/////// Diffuse:
|
||||
NdotL = dot( normalDirection, lightDirection );
|
||||
float4 _Occlusion_var = tex2D(_Occlusion,TRANSFORM_TEX(i.uv0, _Occlusion));
|
||||
float3 forwardLight = pow(max(0.0, NdotL ), (4.0-_Occlusion_var.r));
|
||||
float4 _Transmission_var = tex2D(_Transmission,TRANSFORM_TEX(i.uv0, _Transmission));
|
||||
float3 backLight = pow(max(0.0, -NdotL ), (4.0-_Occlusion_var.r)) * float3(_Transmission_var.r,_Transmission_var.r,_Transmission_var.r);
|
||||
NdotL = max(0.0,dot( normalDirection, lightDirection ));
|
||||
half fd90 = 0.5 + 2 * LdotH * LdotH * (1-gloss);
|
||||
float3 NdotLWrap = max(0,NdotL);
|
||||
float nlPow5 = Pow5(1-NdotLWrap);
|
||||
float nvPow5 = Pow5(1-NdotV);
|
||||
float3 directDiffuse = ((forwardLight+backLight) + ((1 +(fd90 - 1)*nlPow5) * (1 + (fd90 - 1)*nvPow5) * NdotL)) * attenColor;
|
||||
diffuseColor *= 1-specularMonochrome;
|
||||
float3 diffuse = directDiffuse * diffuseColor;
|
||||
/// Final Color:
|
||||
float3 finalColor = diffuse + specular;
|
||||
fixed4 finalRGBA = fixed4(finalColor * 1,0);
|
||||
UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
|
||||
return finalRGBA;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
Pass {
|
||||
Name "Meta"
|
||||
Tags {
|
||||
"LightMode"="Meta"
|
||||
}
|
||||
Cull Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#define UNITY_PASS_META 1
|
||||
#define SHOULD_SAMPLE_SH ( defined (LIGHTMAP_OFF) && defined(DYNAMICLIGHTMAP_OFF) )
|
||||
#define _GLOSSYENV 1
|
||||
#include "UnityCG.cginc"
|
||||
#include "Lighting.cginc"
|
||||
#include "UnityPBSLighting.cginc"
|
||||
#include "UnityStandardBRDF.cginc"
|
||||
#include "UnityMetaPass.cginc"
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma multi_compile_shadowcaster
|
||||
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
|
||||
#pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE
|
||||
#pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
|
||||
#pragma multi_compile_fog
|
||||
#pragma only_renderers d3d9 d3d11 glcore gles
|
||||
#pragma target 3.0
|
||||
uniform sampler2D _BaseColor; uniform float4 _BaseColor_ST;
|
||||
uniform sampler2D _Transmission; uniform float4 _Transmission_ST;
|
||||
uniform sampler2D _Convexity; uniform float4 _Convexity_ST;
|
||||
struct VertexInput {
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float2 texcoord2 : TEXCOORD2;
|
||||
};
|
||||
struct VertexOutput {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv0 : TEXCOORD0;
|
||||
float2 uv1 : TEXCOORD1;
|
||||
float2 uv2 : TEXCOORD2;
|
||||
float4 posWorld : TEXCOORD3;
|
||||
float3 normalDir : TEXCOORD4;
|
||||
};
|
||||
VertexOutput vert (VertexInput v) {
|
||||
VertexOutput o = (VertexOutput)0;
|
||||
o.uv0 = v.texcoord0;
|
||||
o.uv1 = v.texcoord1;
|
||||
o.uv2 = v.texcoord2;
|
||||
o.normalDir = UnityObjectToWorldNormal(v.normal);
|
||||
o.posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||
o.pos = UnityMetaVertexPosition(v.vertex, v.texcoord1.xy, v.texcoord2.xy, unity_LightmapST, unity_DynamicLightmapST );
|
||||
return o;
|
||||
}
|
||||
float4 frag(VertexOutput i) : SV_Target {
|
||||
i.normalDir = normalize(i.normalDir);
|
||||
float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);
|
||||
float3 normalDirection = i.normalDir;
|
||||
UnityMetaInput o;
|
||||
UNITY_INITIALIZE_OUTPUT( UnityMetaInput, o );
|
||||
|
||||
float4 _BaseColor_var = tex2D(_BaseColor,TRANSFORM_TEX(i.uv0, _BaseColor));
|
||||
float4 _Transmission_var = tex2D(_Transmission,TRANSFORM_TEX(i.uv0, _Transmission));
|
||||
float3 node_7195 = (_BaseColor_var.rgb*_Transmission_var.r*pow(1.0-max(0,dot(normalDirection, viewDirection)),2.0));
|
||||
o.Emission = node_7195;
|
||||
|
||||
float4 _Convexity_var = tex2D(_Convexity,TRANSFORM_TEX(i.uv0, _Convexity));
|
||||
float3 node_4664 = pow(_BaseColor_var.rgb,(2.5-_Convexity_var.r));
|
||||
float3 diffColor = node_4664;
|
||||
float3 specColor = node_4664;
|
||||
float specularMonochrome = max(max(specColor.r, specColor.g),specColor.b);
|
||||
diffColor *= (1.0-specularMonochrome);
|
||||
float roughness = (((_Convexity_var.r-0.5)*0.5)+0.75);
|
||||
o.Albedo = diffColor + specColor * roughness * roughness * 0.5;
|
||||
|
||||
return UnityMetaFragment( o );
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
CustomEditor "ShaderForgeMaterialInspector"
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6bfc734452d772f40b6f5ea8ff6b6656
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures:
|
||||
- _Normal: {fileID: 2800000, guid: c48fb049779234742a17514944ecad6d, type: 3}
|
||||
- _BaseColor: {fileID: 2800000, guid: 54bbca7ae723ac04f9e947001e70bd57, type: 3}
|
||||
- _Occlusion: {fileID: 2800000, guid: 81ae15997cb9d9e429a8bedf6099d2a4, type: 3}
|
||||
- _Transmission: {fileID: 2800000, guid: 78358780d5b46ff4d822cc40aec67e32, type: 3}
|
||||
- _Convexity: {fileID: 2800000, guid: ad34d2bca67b615439f6608dd7a30498, type: 3}
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,77 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Otto_temp
|
||||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 0.5019608, g: 0.5019608, b: 0.5019608, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: dd754045491940e4093775d4300e909b
|
||||
timeCreated: 1507577881
|
||||
licenseType: Pro
|
||||
NativeFormatImporter:
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,45 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Shader Forge_Otto
|
||||
m_Shader: {fileID: 4800000, guid: 7a3407103bb9e314485a1918c1afb6e1, type: 3}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 2800000, guid: c48fb049779234742a17514944ecad6d, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _node_2077:
|
||||
m_Texture: {fileID: 2800000, guid: 54bbca7ae723ac04f9e947001e70bd57, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _node_2094:
|
||||
m_Texture: {fileID: 2800000, guid: 78358780d5b46ff4d822cc40aec67e32, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _node_2846:
|
||||
m_Texture: {fileID: 2800000, guid: 81ae15997cb9d9e429a8bedf6099d2a4, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _node_7300:
|
||||
m_Texture: {fileID: 2800000, guid: ad34d2bca67b615439f6608dd7a30498, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _Gloss: 0.4153846
|
||||
- _Metallic: 0
|
||||
m_Colors: []
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 31859c2e902662f4ab03e2202098d65c
|
||||
timeCreated: 1502993308
|
||||
licenseType: Pro
|
||||
NativeFormatImporter:
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,36 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Shader Forge_Otto_Retina
|
||||
m_Shader: {fileID: 4800000, guid: 382e40ad1afdd294483931b8f57133f5, type: 3}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _Cutoff: 0.5
|
||||
- _Gloss: 0.8
|
||||
- _Gloss_copy: 1
|
||||
- _Metallic: 0
|
||||
m_Colors:
|
||||
- _Color: {r: 0.5019608, g: 0.5019608, b: 0.5019608, a: 1}
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 19777f36a016de84eb829997ca9a9d3a
|
||||
timeCreated: 1504043064
|
||||
licenseType: Pro
|
||||
NativeFormatImporter:
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,70 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Shader Forge_Otto_SSS
|
||||
m_Shader: {fileID: 4800000, guid: e6a9f5fc5de48cd4da3e05fc539fb5ae, type: 3}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _AO:
|
||||
m_Texture: {fileID: 2800000, guid: 81ae15997cb9d9e429a8bedf6099d2a4, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BaseColor:
|
||||
m_Texture: {fileID: 2800000, guid: 54bbca7ae723ac04f9e947001e70bd57, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _Curvature:
|
||||
m_Texture: {fileID: 2800000, guid: ad34d2bca67b615439f6608dd7a30498, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _Normal:
|
||||
m_Texture: {fileID: 2800000, guid: c48fb049779234742a17514944ecad6d, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SSS_Ramp:
|
||||
m_Texture: {fileID: 2800000, guid: b0bdd1290b57b984f9b1567007d48e3b, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _Transmission:
|
||||
m_Texture: {fileID: 2800000, guid: 78358780d5b46ff4d822cc40aec67e32, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _node_1546:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _node_4051:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _node_5353:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _Gloss: 0.8
|
||||
- _Metallic: 0
|
||||
m_Colors:
|
||||
- _Color: {r: 0.5019608, g: 0.5019608, b: 0.5019608, a: 1}
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5155021abea18094fa1eb5cba623e0eb
|
||||
timeCreated: 1504044413
|
||||
licenseType: Pro
|
||||
NativeFormatImporter:
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче