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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 B

View File

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