[Add] Synaptic AI Pro
https://assetstore.unity.com/packages/tools/generative-ai/synaptic-ai-pro-natural-language-control-for-unity-336030
This commit is contained in:
@@ -0,0 +1,520 @@
|
||||
Shader "Synaptic/DissolvePro"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[Header(Base)]
|
||||
_MainTex ("Albedo", 2D) = "white" {}
|
||||
_BaseColor ("Base Color", Color) = (1, 1, 1, 1)
|
||||
_Metallic ("Metallic", Range(0, 1)) = 0
|
||||
_Smoothness ("Smoothness", Range(0, 1)) = 0.5
|
||||
_BumpMap ("Normal Map", 2D) = "bump" {}
|
||||
_BumpScale ("Normal Scale", Float) = 1
|
||||
|
||||
[Header(Dissolve)]
|
||||
_DissolveAmount ("Dissolve Amount", Range(0, 1)) = 0
|
||||
_DissolveNoise ("Dissolve Noise", 2D) = "white" {}
|
||||
_DissolveScale ("Noise Scale", Float) = 1
|
||||
_DissolveDirection ("Direction (XYZ)", Vector) = (0, 1, 0, 0)
|
||||
[Toggle(_DIRECTIONAL_DISSOLVE)] _DirectionalDissolve ("Directional", Float) = 0
|
||||
_DirectionalBias ("Directional Bias", Range(0, 1)) = 0.5
|
||||
|
||||
[Header(Edge Effect)]
|
||||
_EdgeColor1 ("Edge Color 1", Color) = (1, 0.5, 0, 1)
|
||||
_EdgeColor2 ("Edge Color 2", Color) = (1, 0, 0, 1)
|
||||
_EdgeWidth ("Edge Width", Range(0, 0.5)) = 0.1
|
||||
_EdgeIntensity ("Edge Intensity", Range(0, 10)) = 3
|
||||
[Toggle(_EDGE_GLOW)] _EdgeGlow ("Edge Glow", Float) = 1
|
||||
|
||||
[Header(Particles)]
|
||||
[Toggle(_PARTICLES_ON)] _ParticlesEnabled ("Enable Particles", Float) = 1
|
||||
_ParticleColor ("Particle Color", Color) = (1, 0.7, 0.3, 1)
|
||||
_ParticleSize ("Particle Size", Range(0, 0.1)) = 0.02
|
||||
_ParticleSpeed ("Particle Speed", Float) = 2
|
||||
_ParticleDensity ("Particle Density", Range(0, 1)) = 0.5
|
||||
|
||||
[Header(Vertex Displacement)]
|
||||
[Toggle(_VERTEX_DISPLACEMENT)] _VertexDisplacement ("Vertex Displacement", Float) = 0
|
||||
_DisplacementStrength ("Displacement Strength", Float) = 0.5
|
||||
_DisplacementDirection ("Displacement Dir", Vector) = (0, 1, 0, 0)
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
PackageRequirements { "com.unity.render-pipelines.universal" }
|
||||
Tags
|
||||
{
|
||||
"RenderType" = "Opaque"
|
||||
"Queue" = "Geometry"
|
||||
"RenderPipeline" = "UniversalPipeline"
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "DissolveForward"
|
||||
Tags { "LightMode" = "UniversalForward" }
|
||||
|
||||
Cull Back
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma target 4.0
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE
|
||||
#pragma multi_compile_fragment _ _SHADOWS_SOFT
|
||||
#pragma multi_compile_fog
|
||||
|
||||
#pragma shader_feature_local _DIRECTIONAL_DISSOLVE
|
||||
#pragma shader_feature_local _EDGE_GLOW
|
||||
#pragma shader_feature_local _PARTICLES_ON
|
||||
#pragma shader_feature_local _VERTEX_DISPLACEMENT
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
|
||||
TEXTURE2D(_MainTex);
|
||||
TEXTURE2D(_BumpMap);
|
||||
TEXTURE2D(_DissolveNoise);
|
||||
SAMPLER(sampler_MainTex);
|
||||
SAMPLER(sampler_BumpMap);
|
||||
SAMPLER(sampler_DissolveNoise);
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _MainTex_ST;
|
||||
float4 _BaseColor;
|
||||
float _Metallic;
|
||||
float _Smoothness;
|
||||
float4 _BumpMap_ST;
|
||||
float _BumpScale;
|
||||
|
||||
float _DissolveAmount;
|
||||
float4 _DissolveNoise_ST;
|
||||
float _DissolveScale;
|
||||
float4 _DissolveDirection;
|
||||
float _DirectionalBias;
|
||||
|
||||
float4 _EdgeColor1;
|
||||
float4 _EdgeColor2;
|
||||
float _EdgeWidth;
|
||||
float _EdgeIntensity;
|
||||
|
||||
float4 _ParticleColor;
|
||||
float _ParticleSize;
|
||||
float _ParticleSpeed;
|
||||
float _ParticleDensity;
|
||||
|
||||
float _DisplacementStrength;
|
||||
float4 _DisplacementDirection;
|
||||
CBUFFER_END
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float3 normalOS : NORMAL;
|
||||
float4 tangentOS : TANGENT;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float3 worldPos : TEXCOORD1;
|
||||
float3 worldNormal : TEXCOORD2;
|
||||
float3 worldTangent : TEXCOORD3;
|
||||
float3 worldBitangent : TEXCOORD4;
|
||||
float4 shadowCoord : TEXCOORD5;
|
||||
float fogFactor : TEXCOORD6;
|
||||
float3 objectPos : TEXCOORD7;
|
||||
};
|
||||
|
||||
// Hash for particles
|
||||
float Hash(float2 p)
|
||||
{
|
||||
return frac(sin(dot(p, float2(12.9898, 78.233))) * 43758.5453);
|
||||
}
|
||||
|
||||
Varyings vert(Attributes IN)
|
||||
{
|
||||
Varyings OUT;
|
||||
|
||||
float3 posOS = IN.positionOS.xyz;
|
||||
OUT.objectPos = posOS;
|
||||
|
||||
// Sample noise for vertex displacement
|
||||
#if defined(_VERTEX_DISPLACEMENT)
|
||||
float2 noiseUV = IN.uv * _DissolveScale;
|
||||
float noise = SAMPLE_TEXTURE2D_LOD(_DissolveNoise, sampler_DissolveNoise, noiseUV, 0).r;
|
||||
|
||||
float dissolveEdge = 1 - _DissolveAmount;
|
||||
float edgeFactor = saturate((noise - dissolveEdge) / _EdgeWidth);
|
||||
|
||||
if (edgeFactor > 0)
|
||||
{
|
||||
float3 dispDir = normalize(_DisplacementDirection.xyz);
|
||||
posOS += dispDir * edgeFactor * _DisplacementStrength;
|
||||
}
|
||||
#endif
|
||||
|
||||
OUT.worldPos = TransformObjectToWorld(posOS);
|
||||
OUT.positionCS = TransformWorldToHClip(OUT.worldPos);
|
||||
OUT.uv = TRANSFORM_TEX(IN.uv, _MainTex);
|
||||
|
||||
OUT.worldNormal = TransformObjectToWorldNormal(IN.normalOS);
|
||||
OUT.worldTangent = TransformObjectToWorldDir(IN.tangentOS.xyz);
|
||||
OUT.worldBitangent = cross(OUT.worldNormal, OUT.worldTangent) * IN.tangentOS.w;
|
||||
|
||||
OUT.shadowCoord = TransformWorldToShadowCoord(OUT.worldPos);
|
||||
OUT.fogFactor = ComputeFogFactor(OUT.positionCS.z);
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
float4 frag(Varyings IN) : SV_Target
|
||||
{
|
||||
// Sample dissolve noise
|
||||
float2 noiseUV = IN.uv * _DissolveScale;
|
||||
float noise = SAMPLE_TEXTURE2D(_DissolveNoise, sampler_DissolveNoise, noiseUV).r;
|
||||
|
||||
// Directional dissolve
|
||||
#if defined(_DIRECTIONAL_DISSOLVE)
|
||||
float3 dir = normalize(_DissolveDirection.xyz);
|
||||
float dirFactor = dot(normalize(IN.objectPos), dir) * 0.5 + 0.5;
|
||||
noise = lerp(noise, dirFactor, _DirectionalBias);
|
||||
#endif
|
||||
|
||||
// Dissolve threshold
|
||||
float dissolveThreshold = 1 - _DissolveAmount;
|
||||
clip(noise - dissolveThreshold);
|
||||
|
||||
// Edge detection
|
||||
float edge = 1 - saturate((noise - dissolveThreshold) / _EdgeWidth);
|
||||
|
||||
// Sample textures
|
||||
float4 albedo = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, IN.uv) * _BaseColor;
|
||||
float3 normalTS = UnpackNormalScale(SAMPLE_TEXTURE2D(_BumpMap, sampler_BumpMap, IN.uv), _BumpScale);
|
||||
|
||||
// Transform normal
|
||||
float3x3 TBN = float3x3(IN.worldTangent, IN.worldBitangent, IN.worldNormal);
|
||||
float3 worldNormal = normalize(mul(normalTS, TBN));
|
||||
|
||||
// Lighting
|
||||
Light mainLight = GetMainLight(IN.shadowCoord);
|
||||
float3 lightDir = mainLight.direction;
|
||||
float3 lightColor = mainLight.color * mainLight.shadowAttenuation;
|
||||
float3 viewDir = normalize(_WorldSpaceCameraPos - IN.worldPos);
|
||||
|
||||
float NdotL = saturate(dot(worldNormal, lightDir));
|
||||
float3 diffuse = albedo.rgb * lightColor * NdotL;
|
||||
|
||||
// Specular
|
||||
float3 halfDir = normalize(lightDir + viewDir);
|
||||
float NdotH = saturate(dot(worldNormal, halfDir));
|
||||
float spec = pow(NdotH, _Smoothness * 128);
|
||||
float3 specular = spec * lightColor * _Metallic;
|
||||
|
||||
// Ambient
|
||||
float3 ambient = albedo.rgb * 0.1;
|
||||
|
||||
float3 finalColor = diffuse + specular + ambient;
|
||||
|
||||
// Edge glow
|
||||
#if defined(_EDGE_GLOW)
|
||||
float3 edgeColor = lerp(_EdgeColor2.rgb, _EdgeColor1.rgb, edge);
|
||||
float edgeGlow = edge * _EdgeIntensity;
|
||||
finalColor += edgeColor * edgeGlow;
|
||||
#endif
|
||||
|
||||
// Particles
|
||||
#if defined(_PARTICLES_ON)
|
||||
float particleHash = Hash(IN.uv * 100 + _Time.y * _ParticleSpeed);
|
||||
if (particleHash > 1 - _ParticleDensity && edge > 0.5)
|
||||
{
|
||||
float particleBrightness = particleHash * edge * 2;
|
||||
finalColor += _ParticleColor.rgb * particleBrightness;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Fog
|
||||
finalColor = MixFog(finalColor, IN.fogFactor);
|
||||
|
||||
return float4(finalColor, albedo.a);
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
// Shadow caster
|
||||
Pass
|
||||
{
|
||||
Name "ShadowCaster"
|
||||
Tags { "LightMode" = "ShadowCaster" }
|
||||
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
ColorMask 0
|
||||
Cull Back
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex ShadowVert
|
||||
#pragma fragment ShadowFrag
|
||||
|
||||
#pragma shader_feature_local _DIRECTIONAL_DISSOLVE
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
|
||||
float3 _LightDirection;
|
||||
|
||||
float3 ApplyShadowBiasCustom(float3 positionWS, float3 normalWS, float3 lightDirection)
|
||||
{
|
||||
float invNdotL = 1.0 - saturate(dot(lightDirection, normalWS));
|
||||
float scale = invNdotL * 0.001;
|
||||
positionWS = lightDirection * 0.001 + positionWS;
|
||||
positionWS = normalWS * scale.xxx + positionWS;
|
||||
return positionWS;
|
||||
}
|
||||
|
||||
TEXTURE2D(_DissolveNoise);
|
||||
SAMPLER(sampler_DissolveNoise);
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _MainTex_ST;
|
||||
float _DissolveAmount;
|
||||
float _DissolveScale;
|
||||
float4 _DissolveDirection;
|
||||
float _DirectionalBias;
|
||||
CBUFFER_END
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float3 normalOS : NORMAL;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float3 objectPos : TEXCOORD1;
|
||||
};
|
||||
|
||||
Varyings ShadowVert(Attributes IN)
|
||||
{
|
||||
Varyings OUT;
|
||||
|
||||
float3 worldPos = TransformObjectToWorld(IN.positionOS.xyz);
|
||||
float3 worldNormal = TransformObjectToWorldNormal(IN.normalOS);
|
||||
|
||||
worldPos = ApplyShadowBiasCustom(worldPos, worldNormal, _LightDirection);
|
||||
OUT.positionCS = TransformWorldToHClip(worldPos);
|
||||
#if UNITY_REVERSED_Z
|
||||
OUT.positionCS.z = min(OUT.positionCS.z, UNITY_NEAR_CLIP_VALUE);
|
||||
#else
|
||||
OUT.positionCS.z = max(OUT.positionCS.z, UNITY_NEAR_CLIP_VALUE);
|
||||
#endif
|
||||
OUT.uv = TRANSFORM_TEX(IN.uv, _MainTex);
|
||||
OUT.objectPos = IN.positionOS.xyz;
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
float4 ShadowFrag(Varyings IN) : SV_Target
|
||||
{
|
||||
float noise = SAMPLE_TEXTURE2D(_DissolveNoise, sampler_DissolveNoise, IN.uv * _DissolveScale).r;
|
||||
|
||||
#if defined(_DIRECTIONAL_DISSOLVE)
|
||||
float3 dir = normalize(_DissolveDirection.xyz);
|
||||
float dirFactor = dot(normalize(IN.objectPos), dir) * 0.5 + 0.5;
|
||||
noise = lerp(noise, dirFactor, _DirectionalBias);
|
||||
#endif
|
||||
|
||||
clip(noise - (1 - _DissolveAmount));
|
||||
return 0;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== Built-in Pipeline SubShader ====================
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType" = "Opaque" "Queue" = "Geometry" }
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "DissolveBuiltIn"
|
||||
Tags { "LightMode" = "ForwardBase" }
|
||||
Cull Back
|
||||
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_fwdbase
|
||||
#pragma multi_compile_fog
|
||||
|
||||
#pragma shader_feature_local _DIRECTIONAL_DISSOLVE
|
||||
#pragma shader_feature_local _EDGE_GLOW
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "Lighting.cginc"
|
||||
#include "AutoLight.cginc"
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _DissolveNoise;
|
||||
float4 _MainTex_ST;
|
||||
float4 _BaseColor;
|
||||
float _DissolveAmount;
|
||||
float _DissolveScale;
|
||||
float4 _DissolveDirection;
|
||||
float _DirectionalBias;
|
||||
float4 _EdgeColor1;
|
||||
float4 _EdgeColor2;
|
||||
float _EdgeWidth;
|
||||
float _EdgeIntensity;
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float3 worldPos : TEXCOORD1;
|
||||
float3 worldNormal : TEXCOORD2;
|
||||
float3 objectPos : TEXCOORD3;
|
||||
SHADOW_COORDS(4)
|
||||
UNITY_FOG_COORDS(5)
|
||||
};
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||
o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
|
||||
o.worldNormal = UnityObjectToWorldNormal(v.normal);
|
||||
o.objectPos = v.vertex.xyz;
|
||||
TRANSFER_SHADOW(o)
|
||||
UNITY_TRANSFER_FOG(o, o.pos);
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag(v2f i) : SV_Target
|
||||
{
|
||||
float2 noiseUV = i.uv * _DissolveScale;
|
||||
float noise = tex2D(_DissolveNoise, noiseUV).r;
|
||||
|
||||
#if defined(_DIRECTIONAL_DISSOLVE)
|
||||
float3 dir = normalize(_DissolveDirection.xyz);
|
||||
float dirFactor = dot(normalize(i.objectPos), dir) * 0.5 + 0.5;
|
||||
noise = lerp(noise, dirFactor, _DirectionalBias);
|
||||
#endif
|
||||
|
||||
float dissolveThreshold = 1 - _DissolveAmount;
|
||||
clip(noise - dissolveThreshold);
|
||||
|
||||
float edge = 1 - saturate((noise - dissolveThreshold) / _EdgeWidth);
|
||||
|
||||
float4 albedo = tex2D(_MainTex, i.uv) * _BaseColor;
|
||||
float3 normal = normalize(i.worldNormal);
|
||||
float3 lightDir = normalize(_WorldSpaceLightPos0.xyz);
|
||||
float shadow = SHADOW_ATTENUATION(i);
|
||||
|
||||
float NdotL = saturate(dot(normal, lightDir));
|
||||
float3 diffuse = albedo.rgb * _LightColor0.rgb * NdotL * shadow;
|
||||
float3 ambient = albedo.rgb * 0.1;
|
||||
float3 finalColor = diffuse + ambient;
|
||||
|
||||
#if defined(_EDGE_GLOW)
|
||||
float3 edgeColor = lerp(_EdgeColor2.rgb, _EdgeColor1.rgb, edge);
|
||||
finalColor += edgeColor * edge * _EdgeIntensity;
|
||||
#endif
|
||||
|
||||
UNITY_APPLY_FOG(i.fogCoord, finalColor);
|
||||
return float4(finalColor, albedo.a);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== HDRP SubShader ====================
|
||||
SubShader
|
||||
{
|
||||
PackageRequirements { "com.unity.render-pipelines.high-definition" }
|
||||
Tags { "RenderType" = "Opaque" "Queue" = "Geometry" "RenderPipeline" = "HDRenderPipeline" }
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "DissolveHDRP"
|
||||
Tags { "LightMode" = "Forward" }
|
||||
Cull Back
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma target 4.5
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma shader_feature_local _DIRECTIONAL_DISSOLVE
|
||||
#pragma shader_feature_local _EDGE_GLOW
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
||||
|
||||
TEXTURE2D(_MainTex);
|
||||
TEXTURE2D(_DissolveNoise);
|
||||
SAMPLER(sampler_MainTex);
|
||||
SAMPLER(sampler_DissolveNoise);
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _MainTex_ST;
|
||||
float4 _BaseColor;
|
||||
float _DissolveAmount;
|
||||
float _DissolveScale;
|
||||
float4 _DissolveDirection;
|
||||
float _DirectionalBias;
|
||||
float4 _EdgeColor1;
|
||||
float4 _EdgeColor2;
|
||||
float _EdgeWidth;
|
||||
float _EdgeIntensity;
|
||||
CBUFFER_END
|
||||
|
||||
struct Attributes { float4 positionOS : POSITION; float3 normalOS : NORMAL; float2 uv : TEXCOORD0; };
|
||||
struct Varyings { float4 positionCS : SV_POSITION; float2 uv : TEXCOORD0; float3 worldNormal : TEXCOORD1; float3 objectPos : TEXCOORD2; };
|
||||
|
||||
Varyings vert(Attributes IN)
|
||||
{
|
||||
Varyings OUT;
|
||||
OUT.positionCS = TransformObjectToHClip(IN.positionOS.xyz);
|
||||
OUT.uv = IN.uv * _MainTex_ST.xy + _MainTex_ST.zw;
|
||||
OUT.worldNormal = TransformObjectToWorldNormal(IN.normalOS);
|
||||
OUT.objectPos = IN.positionOS.xyz;
|
||||
return OUT;
|
||||
}
|
||||
|
||||
float4 frag(Varyings IN) : SV_Target
|
||||
{
|
||||
float noise = SAMPLE_TEXTURE2D(_DissolveNoise, sampler_DissolveNoise, IN.uv * _DissolveScale).r;
|
||||
#if defined(_DIRECTIONAL_DISSOLVE)
|
||||
float dirFactor = dot(normalize(IN.objectPos), normalize(_DissolveDirection.xyz)) * 0.5 + 0.5;
|
||||
noise = lerp(noise, dirFactor, _DirectionalBias);
|
||||
#endif
|
||||
clip(noise - (1 - _DissolveAmount));
|
||||
|
||||
float edge = 1 - saturate((noise - (1 - _DissolveAmount)) / _EdgeWidth);
|
||||
float4 albedo = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, IN.uv) * _BaseColor;
|
||||
float3 finalColor = albedo.rgb;
|
||||
#if defined(_EDGE_GLOW)
|
||||
finalColor += lerp(_EdgeColor2.rgb, _EdgeColor1.rgb, edge) * edge * _EdgeIntensity;
|
||||
#endif
|
||||
return float4(finalColor, albedo.a);
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
FallBack "Universal Render Pipeline/Lit"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fef1849f0393c49c0a988af724c12ffb
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 336030
|
||||
packageName: Synaptic AI Pro - Natural Language Control for Unity
|
||||
packageVersion: 1.2.23
|
||||
assetPath: Assets/Synaptic AI Pro/Shaders/Effects/SynapticDissolvePro.shader
|
||||
uploadId: 920982
|
||||
@@ -0,0 +1,458 @@
|
||||
Shader "Synaptic/ShieldPro"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[Header(Shield Color)]
|
||||
_MainColor ("Main Color", Color) = (0.2, 0.5, 1.0, 0.3)
|
||||
_EdgeColor ("Edge Color", Color) = (0.5, 0.8, 1.0, 1.0)
|
||||
_HitColor ("Hit Color", Color) = (1.0, 0.5, 0.2, 1.0)
|
||||
_FresnelColor ("Fresnel Color", Color) = (0.3, 0.6, 1.0, 1.0)
|
||||
|
||||
[Header(Pattern)]
|
||||
_PatternTex ("Pattern Texture", 2D) = "white" {}
|
||||
_PatternScale ("Pattern Scale", Float) = 1
|
||||
_PatternIntensity ("Pattern Intensity", Range(0, 2)) = 0.5
|
||||
_PatternScrollSpeed ("Pattern Scroll Speed", Vector) = (0.1, 0.1, 0, 0)
|
||||
|
||||
[Header(Hex Pattern)]
|
||||
[Toggle(_HEX_PATTERN)] _HexPattern ("Hex Pattern", Float) = 1
|
||||
_HexScale ("Hex Scale", Float) = 10
|
||||
_HexEdgeWidth ("Hex Edge Width", Range(0.01, 0.5)) = 0.1
|
||||
_HexPulseSpeed ("Hex Pulse Speed", Float) = 2
|
||||
|
||||
[Header(Fresnel)]
|
||||
_FresnelPower ("Fresnel Power", Range(0.5, 10)) = 3
|
||||
_FresnelIntensity ("Fresnel Intensity", Range(0, 5)) = 2
|
||||
|
||||
[Header(Hit Effect)]
|
||||
[Toggle(_HIT_EFFECT)] _HitEffect ("Enable Hit Effect", Float) = 1
|
||||
_HitPosition ("Hit Position", Vector) = (0, 0, 0, 0)
|
||||
_HitRadius ("Hit Radius", Float) = 0.5
|
||||
_HitIntensity ("Hit Intensity", Range(0, 1)) = 0
|
||||
_HitRippleCount ("Ripple Count", Float) = 3
|
||||
_HitRippleSpeed ("Ripple Speed", Float) = 5
|
||||
|
||||
[Header(Distortion)]
|
||||
[Toggle(_DISTORTION)] _Distortion ("Enable Distortion", Float) = 1
|
||||
_DistortionStrength ("Distortion Strength", Range(0, 0.1)) = 0.02
|
||||
_DistortionSpeed ("Distortion Speed", Float) = 1
|
||||
|
||||
[Header(Animation)]
|
||||
_PulseSpeed ("Pulse Speed", Float) = 2
|
||||
_PulseIntensity ("Pulse Intensity", Range(0, 1)) = 0.2
|
||||
_WaveSpeed ("Wave Speed", Float) = 1
|
||||
_WaveFrequency ("Wave Frequency", Float) = 5
|
||||
_WaveAmplitude ("Wave Amplitude", Range(0, 0.1)) = 0.02
|
||||
|
||||
[Header(Intersection)]
|
||||
[Toggle(_INTERSECTION)] _Intersection ("Intersection Glow", Float) = 1
|
||||
_IntersectionColor ("Intersection Color", Color) = (1, 1, 1, 1)
|
||||
_IntersectionWidth ("Intersection Width", Float) = 0.5
|
||||
_IntersectionIntensity ("Intersection Intensity", Range(0, 5)) = 2
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
PackageRequirements { "com.unity.render-pipelines.universal" }
|
||||
Tags
|
||||
{
|
||||
"RenderType" = "Transparent"
|
||||
"Queue" = "Transparent"
|
||||
"RenderPipeline" = "UniversalPipeline"
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "ShieldForward"
|
||||
Tags { "LightMode" = "UniversalForward" }
|
||||
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ZWrite Off
|
||||
Cull Back
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma target 4.0
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#pragma shader_feature_local _HEX_PATTERN
|
||||
#pragma shader_feature_local _HIT_EFFECT
|
||||
#pragma shader_feature_local _DISTORTION
|
||||
#pragma shader_feature_local _INTERSECTION
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareOpaqueTexture.hlsl"
|
||||
|
||||
TEXTURE2D(_PatternTex);
|
||||
SAMPLER(sampler_PatternTex);
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _MainColor;
|
||||
float4 _EdgeColor;
|
||||
float4 _HitColor;
|
||||
float4 _FresnelColor;
|
||||
|
||||
float4 _PatternTex_ST;
|
||||
float _PatternScale;
|
||||
float _PatternIntensity;
|
||||
float4 _PatternScrollSpeed;
|
||||
|
||||
float _HexScale;
|
||||
float _HexEdgeWidth;
|
||||
float _HexPulseSpeed;
|
||||
|
||||
float _FresnelPower;
|
||||
float _FresnelIntensity;
|
||||
|
||||
float4 _HitPosition;
|
||||
float _HitRadius;
|
||||
float _HitIntensity;
|
||||
float _HitRippleCount;
|
||||
float _HitRippleSpeed;
|
||||
|
||||
float _DistortionStrength;
|
||||
float _DistortionSpeed;
|
||||
|
||||
float _PulseSpeed;
|
||||
float _PulseIntensity;
|
||||
float _WaveSpeed;
|
||||
float _WaveFrequency;
|
||||
float _WaveAmplitude;
|
||||
|
||||
float4 _IntersectionColor;
|
||||
float _IntersectionWidth;
|
||||
float _IntersectionIntensity;
|
||||
CBUFFER_END
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float3 normalOS : NORMAL;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float3 worldPos : TEXCOORD1;
|
||||
float3 worldNormal : TEXCOORD2;
|
||||
float3 viewDir : TEXCOORD3;
|
||||
float4 screenPos : TEXCOORD4;
|
||||
float3 objectPos : TEXCOORD5;
|
||||
};
|
||||
|
||||
// Hexagonal pattern
|
||||
float HexPattern(float2 p)
|
||||
{
|
||||
const float2 s = float2(1, 1.7320508);
|
||||
p *= _HexScale;
|
||||
|
||||
float4 hC = floor(float4(p, p - float2(0.5, 1)) / s.xyxy) + 0.5;
|
||||
float4 h = float4(p - hC.xy * s, p - (hC.zw + 0.5) * s);
|
||||
|
||||
float2 nearest = dot(h.xy, h.xy) < dot(h.zw, h.zw) ? h.xy : h.zw;
|
||||
|
||||
float dist = length(nearest);
|
||||
float hexEdge = smoothstep(_HexEdgeWidth, _HexEdgeWidth + 0.02, abs(dist - 0.5));
|
||||
|
||||
return 1 - hexEdge;
|
||||
}
|
||||
|
||||
Varyings vert(Attributes IN)
|
||||
{
|
||||
Varyings OUT;
|
||||
|
||||
float3 posOS = IN.positionOS.xyz;
|
||||
OUT.objectPos = posOS;
|
||||
|
||||
// Vertex wave animation
|
||||
float wave = sin(_Time.y * _WaveSpeed + posOS.y * _WaveFrequency) * _WaveAmplitude;
|
||||
posOS += IN.normalOS * wave;
|
||||
|
||||
OUT.worldPos = TransformObjectToWorld(posOS);
|
||||
OUT.positionCS = TransformWorldToHClip(OUT.worldPos);
|
||||
OUT.uv = IN.uv;
|
||||
|
||||
OUT.worldNormal = TransformObjectToWorldNormal(IN.normalOS);
|
||||
OUT.viewDir = normalize(_WorldSpaceCameraPos - OUT.worldPos);
|
||||
OUT.screenPos = ComputeScreenPos(OUT.positionCS);
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
float4 frag(Varyings IN) : SV_Target
|
||||
{
|
||||
float3 normal = normalize(IN.worldNormal);
|
||||
float3 viewDir = normalize(IN.viewDir);
|
||||
float time = _Time.y;
|
||||
|
||||
// Screen UV
|
||||
float2 screenUV = IN.screenPos.xy / IN.screenPos.w;
|
||||
|
||||
// Fresnel
|
||||
float fresnel = pow(1 - saturate(dot(viewDir, normal)), _FresnelPower) * _FresnelIntensity;
|
||||
|
||||
// Base color with fresnel
|
||||
float4 color = lerp(_MainColor, _FresnelColor, fresnel);
|
||||
|
||||
// Hex pattern
|
||||
#if defined(_HEX_PATTERN)
|
||||
float hex = HexPattern(IN.uv);
|
||||
float hexPulse = sin(time * _HexPulseSpeed) * 0.5 + 0.5;
|
||||
color.rgb += _EdgeColor.rgb * hex * (0.5 + hexPulse * 0.5);
|
||||
color.a += hex * 0.3;
|
||||
#endif
|
||||
|
||||
// Pattern texture
|
||||
float2 patternUV = IN.uv * _PatternScale + time * _PatternScrollSpeed.xy;
|
||||
float pattern = SAMPLE_TEXTURE2D(_PatternTex, sampler_PatternTex, patternUV).r;
|
||||
color.rgb += pattern * _PatternIntensity * _EdgeColor.rgb;
|
||||
|
||||
// Hit effect
|
||||
#if defined(_HIT_EFFECT)
|
||||
if (_HitIntensity > 0.001)
|
||||
{
|
||||
float3 hitDir = IN.worldPos - _HitPosition.xyz;
|
||||
float hitDist = length(hitDir);
|
||||
|
||||
// Ripple waves
|
||||
float ripple = 0;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
float ripplePhase = time * _HitRippleSpeed - i * 0.3;
|
||||
float rippleRadius = frac(ripplePhase) * _HitRadius * 2;
|
||||
float rippleWidth = 0.1;
|
||||
ripple += (1 - abs(hitDist - rippleRadius) / rippleWidth) * saturate(1 - frac(ripplePhase));
|
||||
}
|
||||
ripple = saturate(ripple);
|
||||
|
||||
// Fade out over distance
|
||||
float hitFade = 1 - saturate(hitDist / _HitRadius);
|
||||
|
||||
color.rgb = lerp(color.rgb, _HitColor.rgb, ripple * hitFade * _HitIntensity);
|
||||
color.a += ripple * hitFade * _HitIntensity * 0.5;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Intersection glow
|
||||
#if defined(_INTERSECTION)
|
||||
float depth = SampleSceneDepth(screenUV);
|
||||
float linearDepth = LinearEyeDepth(depth, _ZBufferParams);
|
||||
float surfaceDepth = LinearEyeDepth(IN.positionCS.z, _ZBufferParams);
|
||||
float depthDiff = abs(linearDepth - surfaceDepth);
|
||||
|
||||
if (depthDiff < _IntersectionWidth)
|
||||
{
|
||||
float intersectionFactor = 1 - saturate(depthDiff / _IntersectionWidth);
|
||||
intersectionFactor = pow(intersectionFactor, 2);
|
||||
color.rgb += _IntersectionColor.rgb * intersectionFactor * _IntersectionIntensity;
|
||||
color.a += intersectionFactor * 0.5;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Distortion
|
||||
#if defined(_DISTORTION)
|
||||
float2 distortionOffset = normal.xy * _DistortionStrength;
|
||||
distortionOffset *= sin(time * _DistortionSpeed + IN.uv.y * 10) * 0.5 + 0.5;
|
||||
float3 distortedBG = SampleSceneColor(screenUV + distortionOffset);
|
||||
color.rgb = lerp(distortedBG, color.rgb, color.a);
|
||||
#endif
|
||||
|
||||
// Pulse animation
|
||||
float pulse = sin(time * _PulseSpeed) * _PulseIntensity;
|
||||
color.a += pulse;
|
||||
|
||||
// Edge highlight
|
||||
color.rgb += _EdgeColor.rgb * fresnel * 0.5;
|
||||
|
||||
// Clamp alpha
|
||||
color.a = saturate(color.a);
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== Built-in Pipeline SubShader ====================
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType" = "Transparent" "Queue" = "Transparent" }
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "ShieldBuiltIn"
|
||||
Tags { "LightMode" = "ForwardBase" }
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ZWrite Off
|
||||
Cull Back
|
||||
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma shader_feature_local _HEX_PATTERN
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
float4 _MainColor;
|
||||
float4 _EdgeColor;
|
||||
float4 _FresnelColor;
|
||||
float _FresnelPower;
|
||||
float _FresnelIntensity;
|
||||
float _HexScale;
|
||||
float _HexEdgeWidth;
|
||||
float _HexPulseSpeed;
|
||||
float _PulseSpeed;
|
||||
float _PulseIntensity;
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float3 worldNormal : TEXCOORD1;
|
||||
float3 viewDir : TEXCOORD2;
|
||||
};
|
||||
|
||||
float HexPattern(float2 p)
|
||||
{
|
||||
const float2 s = float2(1, 1.7320508);
|
||||
p *= _HexScale;
|
||||
float4 hC = floor(float4(p, p - float2(0.5, 1)) / s.xyxy) + 0.5;
|
||||
float4 h = float4(p - hC.xy * s, p - (hC.zw + 0.5) * s);
|
||||
float2 nearest = dot(h.xy, h.xy) < dot(h.zw, h.zw) ? h.xy : h.zw;
|
||||
float dist = length(nearest);
|
||||
return 1 - smoothstep(_HexEdgeWidth, _HexEdgeWidth + 0.02, abs(dist - 0.5));
|
||||
}
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
o.worldNormal = UnityObjectToWorldNormal(v.normal);
|
||||
o.viewDir = normalize(_WorldSpaceCameraPos - mul(unity_ObjectToWorld, v.vertex).xyz);
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag(v2f i) : SV_Target
|
||||
{
|
||||
float3 normal = normalize(i.worldNormal);
|
||||
float3 viewDir = normalize(i.viewDir);
|
||||
float time = _Time.y;
|
||||
|
||||
float fresnel = pow(1 - saturate(dot(viewDir, normal)), _FresnelPower) * _FresnelIntensity;
|
||||
float4 color = lerp(_MainColor, _FresnelColor, fresnel);
|
||||
|
||||
#if defined(_HEX_PATTERN)
|
||||
float hex = HexPattern(i.uv);
|
||||
float hexPulse = sin(time * _HexPulseSpeed) * 0.5 + 0.5;
|
||||
color.rgb += _EdgeColor.rgb * hex * (0.5 + hexPulse * 0.5);
|
||||
color.a += hex * 0.3;
|
||||
#endif
|
||||
|
||||
float pulse = sin(time * _PulseSpeed) * _PulseIntensity;
|
||||
color.a += pulse;
|
||||
color.rgb += _EdgeColor.rgb * fresnel * 0.5;
|
||||
color.a = saturate(color.a);
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== HDRP SubShader ====================
|
||||
SubShader
|
||||
{
|
||||
PackageRequirements { "com.unity.render-pipelines.high-definition" }
|
||||
Tags { "RenderType" = "Transparent" "Queue" = "Transparent" "RenderPipeline" = "HDRenderPipeline" }
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "ShieldHDRP"
|
||||
Tags { "LightMode" = "Forward" }
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ZWrite Off
|
||||
Cull Back
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma target 4.5
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma shader_feature_local _HEX_PATTERN
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _MainColor;
|
||||
float4 _EdgeColor;
|
||||
float4 _FresnelColor;
|
||||
float _FresnelPower;
|
||||
float _FresnelIntensity;
|
||||
float _HexScale;
|
||||
float _HexEdgeWidth;
|
||||
float _HexPulseSpeed;
|
||||
float _PulseSpeed;
|
||||
float _PulseIntensity;
|
||||
CBUFFER_END
|
||||
|
||||
struct Attributes { float4 positionOS : POSITION; float3 normalOS : NORMAL; float2 uv : TEXCOORD0; };
|
||||
struct Varyings { float4 positionCS : SV_POSITION; float2 uv : TEXCOORD0; float3 worldNormal : TEXCOORD1; float3 viewDir : TEXCOORD2; };
|
||||
|
||||
float HexPattern(float2 p, float scale, float edgeWidth)
|
||||
{
|
||||
const float2 s = float2(1, 1.7320508);
|
||||
p *= scale;
|
||||
float4 hC = floor(float4(p, p - float2(0.5, 1)) / s.xyxy) + 0.5;
|
||||
float4 h = float4(p - hC.xy * s, p - (hC.zw + 0.5) * s);
|
||||
float2 nearest = dot(h.xy, h.xy) < dot(h.zw, h.zw) ? h.xy : h.zw;
|
||||
return 1 - smoothstep(edgeWidth, edgeWidth + 0.02, abs(length(nearest) - 0.5));
|
||||
}
|
||||
|
||||
Varyings vert(Attributes IN)
|
||||
{
|
||||
Varyings OUT;
|
||||
float3 worldPos = TransformObjectToWorld(IN.positionOS.xyz);
|
||||
OUT.positionCS = TransformWorldToHClip(worldPos);
|
||||
OUT.uv = IN.uv;
|
||||
OUT.worldNormal = TransformObjectToWorldNormal(IN.normalOS);
|
||||
OUT.viewDir = GetWorldSpaceNormalizeViewDir(worldPos);
|
||||
return OUT;
|
||||
}
|
||||
|
||||
float4 frag(Varyings IN) : SV_Target
|
||||
{
|
||||
float3 normal = normalize(IN.worldNormal);
|
||||
float3 viewDir = normalize(IN.viewDir);
|
||||
float fresnel = pow(1 - saturate(dot(viewDir, normal)), _FresnelPower) * _FresnelIntensity;
|
||||
float4 color = lerp(_MainColor, _FresnelColor, fresnel);
|
||||
|
||||
#if defined(_HEX_PATTERN)
|
||||
float hex = HexPattern(IN.uv, _HexScale, _HexEdgeWidth);
|
||||
float hexPulse = sin(_Time.y * _HexPulseSpeed) * 0.5 + 0.5;
|
||||
color.rgb += _EdgeColor.rgb * hex * (0.5 + hexPulse * 0.5);
|
||||
color.a += hex * 0.3;
|
||||
#endif
|
||||
|
||||
color.a += sin(_Time.y * _PulseSpeed) * _PulseIntensity;
|
||||
color.rgb += _EdgeColor.rgb * fresnel * 0.5;
|
||||
color.a = saturate(color.a);
|
||||
return color;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
FallBack "Universal Render Pipeline/Unlit"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bd72a59a6dbde45f8bf617b27ba32f94
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 336030
|
||||
packageName: Synaptic AI Pro - Natural Language Control for Unity
|
||||
packageVersion: 1.2.23
|
||||
assetPath: Assets/Synaptic AI Pro/Shaders/Effects/SynapticShieldPro.shader
|
||||
uploadId: 920982
|
||||
Reference in New Issue
Block a user