mirror of
https://github.com/drewcassidy/KSP-Conformal-Decals.git
synced 2024-09-01 18:23:54 +00:00
More decal shader reorganization
This commit is contained in:
parent
ce55f07150
commit
946975249d
156
Assets/ConformalDecals/Shaders/Decal/DecalBase.shader.template
Normal file
156
Assets/ConformalDecals/Shaders/Decal/DecalBase.shader.template
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
Shader "ConformalDecals/Decal/{% block shader_name %}UNKNOWN{% endblock %}"
|
||||||
|
{
|
||||||
|
Properties
|
||||||
|
{
|
||||||
|
|
||||||
|
// Shader-specific properties
|
||||||
|
{% block properties %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
// Common decal properties
|
||||||
|
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
|
||||||
|
_DecalOpacity("Opacity", Range(0,1) ) = 1
|
||||||
|
_Background("Background Color", Color) = (0.9,0.9,0.9,0.7)
|
||||||
|
|
||||||
|
[Enum(UnityEngine.Rendering.CullMode)] _Cull ("Cull", int) = 2
|
||||||
|
[Toggle] _ZWrite ("ZWrite", Float) = 1.0
|
||||||
|
|
||||||
|
[Toggle(DECAL_PREVIEW)] _Preview ("Preview", int) = 0
|
||||||
|
|
||||||
|
[Header(Effects)]
|
||||||
|
[PerRendererData]_Opacity("_Opacity", Range(0,1) ) = 1
|
||||||
|
[PerRendererData]_Color("_Color", Color) = (1,1,1,1)
|
||||||
|
[PerRendererData]_RimFalloff("_RimFalloff", Range(0.01,5) ) = 0.1
|
||||||
|
[PerRendererData]_RimColor("_RimColor", Color) = (0,0,0,0)
|
||||||
|
[PerRendererData]_UnderwaterFogFactor ("Underwater Fog Factor", Range(0,1)) = 0
|
||||||
|
}
|
||||||
|
SubShader
|
||||||
|
{
|
||||||
|
Tags
|
||||||
|
{
|
||||||
|
"Queue" = "Geometry+100" "IgnoreProjector" = "true" "DisableBatching" = "true"
|
||||||
|
}
|
||||||
|
Cull [_Cull]
|
||||||
|
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "FORWARD"
|
||||||
|
Tags
|
||||||
|
{
|
||||||
|
"LightMode" = "ForwardBase"
|
||||||
|
}
|
||||||
|
ZWrite [_ZWrite]
|
||||||
|
ZTest LEqual
|
||||||
|
Blend SrcAlpha OneMinusSrcAlpha
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma vertex vert
|
||||||
|
#pragma fragment frag_forward
|
||||||
|
|
||||||
|
#pragma multi_compile_fwdbase
|
||||||
|
#pragma skip_variants LIGHTMAP_ON DIRLIGHTMAP_COMBINED DYNAMICLIGHTMAP_ON LIGHTMAP_SHADOW_MIXING
|
||||||
|
#pragma multi_compile_local __ DECAL_PREVIEW
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
#error No body provided
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "FORWARD"
|
||||||
|
Tags
|
||||||
|
{
|
||||||
|
"LightMode" = "ForwardAdd"
|
||||||
|
}
|
||||||
|
ZWrite Off
|
||||||
|
ZTest LEqual
|
||||||
|
Blend SrcAlpha One
|
||||||
|
Offset -1, -1
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma vertex vert
|
||||||
|
#pragma fragment frag_forward
|
||||||
|
|
||||||
|
#pragma multi_compile DIRECTIONAL SPOT POINT
|
||||||
|
#pragma multi_compile __ LIGHTPROBE_SH
|
||||||
|
#pragma multi_compile_local __ DECAL_PREVIEW
|
||||||
|
|
||||||
|
{{ self.body() }}
|
||||||
|
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "DEFERRED_PREPASS"
|
||||||
|
Tags
|
||||||
|
{
|
||||||
|
"LightMode" = "Deferred"
|
||||||
|
}
|
||||||
|
ZWrite Off
|
||||||
|
ZTest LEqual
|
||||||
|
Offset -1, -1
|
||||||
|
Blend 1 Zero OneMinusSrcColor, Zero OneMinusSrcAlpha
|
||||||
|
|
||||||
|
Stencil
|
||||||
|
{
|
||||||
|
Ref 1
|
||||||
|
Comp Equal
|
||||||
|
Pass Keep
|
||||||
|
}
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma vertex vert
|
||||||
|
#pragma fragment frag_deferred_prepass
|
||||||
|
#pragma target 3.0
|
||||||
|
|
||||||
|
#pragma multi_compile_local __ DECAL_PREVIEW
|
||||||
|
|
||||||
|
{{ self.body() }}
|
||||||
|
|
||||||
|
{% block pragmas_deferred_prepass %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "DEFERRED"
|
||||||
|
Tags
|
||||||
|
{
|
||||||
|
"LightMode" = "Deferred"
|
||||||
|
}
|
||||||
|
ZWrite Off
|
||||||
|
ZTest LEqual
|
||||||
|
Offset -1, -1
|
||||||
|
Blend 0 SrcAlpha OneMinusSrcAlpha, Zero One
|
||||||
|
Blend 1 One One
|
||||||
|
Blend 2 SrcAlpha OneMinusSrcAlpha, Zero One
|
||||||
|
Blend 3 SrcAlpha OneMinusSrcAlpha, Zero One
|
||||||
|
|
||||||
|
Stencil
|
||||||
|
{
|
||||||
|
Ref 1
|
||||||
|
Comp Equal
|
||||||
|
Pass Keep
|
||||||
|
}
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma vertex vert
|
||||||
|
#pragma fragment frag_deferred
|
||||||
|
#pragma target 3.0
|
||||||
|
|
||||||
|
#pragma multi_compile __ LIGHTPROBE_SH
|
||||||
|
#pragma multi_compile __ UNITY_HDR_ON
|
||||||
|
#pragma multi_compile_local __ DECAL_PREVIEW
|
||||||
|
|
||||||
|
{{ self.body() }}
|
||||||
|
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "AutoLight.cginc"
|
#include "AutoLight.cginc"
|
||||||
#include "Lighting.cginc"
|
#include "Lighting.cginc"
|
||||||
#include "LightingKSPDeferred.cginc"
|
#include "../LightingKSPDeferred.cginc"
|
||||||
|
|
||||||
#define CLIP_MARGIN 0.05
|
#define CLIP_MARGIN 0.05
|
||||||
#define EDGE_MARGIN 0.01
|
#define EDGE_MARGIN 0.01
|
@ -1,4 +1,4 @@
|
|||||||
#include "../DecalsCommon.cginc"
|
#include "DecalsCommon.cginc"
|
||||||
#include "../SDF.cginc"
|
#include "../SDF.cginc"
|
||||||
|
|
||||||
void surf(DecalSurfaceInput IN, inout SurfaceOutput o) {
|
void surf(DecalSurfaceInput IN, inout SurfaceOutput o) {
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
Shader "{% block shader_name %}ConformalDecals/Decal/Standard{% endblock %}"
|
{% extends "DecalBase.shader.template" %}
|
||||||
{
|
{% block shader_name %}Standard{% endblock %}
|
||||||
Properties
|
|
||||||
{
|
{% block properties %}
|
||||||
// Shader-specific properties
|
|
||||||
//{% block properties %}
|
|
||||||
[Header(Decal)]
|
[Header(Decal)]
|
||||||
_Decal("Decal Texture", 2D) = "gray" {}
|
_Decal("Decal Texture", 2D) = "gray" {}
|
||||||
[Toggle(DECAL_SDF_ALPHA)] _Decal_SDF_Alpha ("SDF in Alpha", int) = 0
|
[Toggle(DECAL_SDF_ALPHA)] _Decal_SDF_Alpha ("SDF in Alpha", int) = 0
|
||||||
@ -17,7 +15,7 @@
|
|||||||
|
|
||||||
[Header(Specularity)]
|
[Header(Specularity)]
|
||||||
[Toggle(DECAL_SPECMAP)] _Decal_SpecMap ("Has SpecMap", int) = 0
|
[Toggle(DECAL_SPECMAP)] _Decal_SpecMap ("Has SpecMap", int) = 0
|
||||||
_SpecMap ("Specular Map)", 2D) = "black" {}
|
_SpecMap ("Specular Map", 2D) = "black" {}
|
||||||
_SpecColor ("_SpecColor", Color) = (0.25, 0.25, 0.25, 1)
|
_SpecColor ("_SpecColor", Color) = (0.25, 0.25, 0.25, 1)
|
||||||
_Shininess ("Shininess", Range (0.03, 10)) = 0.3
|
_Shininess ("Shininess", Range (0.03, 10)) = 0.3
|
||||||
|
|
||||||
@ -25,161 +23,18 @@
|
|||||||
[Toggle(DECAL_EMISSIVE)] _Decal_Emissive ("Has Emissive", int) = 0
|
[Toggle(DECAL_EMISSIVE)] _Decal_Emissive ("Has Emissive", int) = 0
|
||||||
_Emissive("_Emissive", 2D) = "black" {}
|
_Emissive("_Emissive", 2D) = "black" {}
|
||||||
_EmissiveColor("_EmissiveColor", Color) = (0,0,0,1)
|
_EmissiveColor("_EmissiveColor", Color) = (0,0,0,1)
|
||||||
//{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
// Common decal properties
|
{% block body %}
|
||||||
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
|
#pragma multi_compile_local __ DECAL_BASE_NORMAL
|
||||||
_DecalOpacity("Opacity", Range(0,1) ) = 1
|
|
||||||
_Background("Background Color", Color) = (0.9,0.9,0.9,0.7)
|
|
||||||
|
|
||||||
[Enum(UnityEngine.Rendering.CullMode)] _Cull ("Cull", int) = 2
|
|
||||||
[Toggle] _ZWrite ("ZWrite", Float) = 1.0
|
|
||||||
|
|
||||||
[Toggle(DECAL_PREVIEW)] _Preview ("Preview", int) = 0
|
|
||||||
|
|
||||||
[Header(Effects)]
|
|
||||||
[PerRendererData]_Opacity("_Opacity", Range(0,1) ) = 1
|
|
||||||
[PerRendererData]_Color("_Color", Color) = (1,1,1,1)
|
|
||||||
[PerRendererData]_RimFalloff("_RimFalloff", Range(0.01,5) ) = 0.1
|
|
||||||
[PerRendererData]_RimColor("_RimColor", Color) = (0,0,0,0)
|
|
||||||
[PerRendererData]_UnderwaterFogFactor ("Underwater Fog Factor", Range(0,1)) = 0
|
|
||||||
}
|
|
||||||
SubShader
|
|
||||||
{
|
|
||||||
Tags
|
|
||||||
{
|
|
||||||
"Queue" = "Geometry+100" "IgnoreProjector" = "true" "DisableBatching" = "true"
|
|
||||||
}
|
|
||||||
Cull [_Cull]
|
|
||||||
|
|
||||||
Pass
|
|
||||||
{
|
|
||||||
Name "FORWARD"
|
|
||||||
Tags
|
|
||||||
{
|
|
||||||
"LightMode" = "ForwardBase"
|
|
||||||
}
|
|
||||||
ZWrite [_ZWrite]
|
|
||||||
ZTest LEqual
|
|
||||||
Blend SrcAlpha OneMinusSrcAlpha
|
|
||||||
|
|
||||||
CGPROGRAM
|
|
||||||
#pragma vertex vert
|
|
||||||
#pragma fragment frag_forward
|
|
||||||
|
|
||||||
#pragma multi_compile DIRECTIONAL
|
|
||||||
#pragma multi_compile_local __ DECAL_PREVIEW
|
|
||||||
#pragma multi_compile_local __ DECAL_BASE_NORMAL DECAL_BUMPMAP
|
|
||||||
//{% block pragmas %}
|
|
||||||
#pragma multi_compile_local __ DECAL_SPECMAP
|
#pragma multi_compile_local __ DECAL_SPECMAP
|
||||||
#pragma multi_compile_local __ DECAL_EMISSIVE
|
#pragma multi_compile_local __ DECAL_EMISSIVE
|
||||||
#pragma multi_compile_local __ DECAL_SDF_ALPHA
|
#pragma multi_compile_local __ DECAL_SDF_ALPHA
|
||||||
//{% endblock %}
|
|
||||||
|
|
||||||
//{% block body %}
|
|
||||||
#include "StandardDecal.cginc"
|
#include "StandardDecal.cginc"
|
||||||
//{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
ENDCG
|
|
||||||
}
|
|
||||||
|
|
||||||
Pass
|
{% block pragmas_deferred_prepass %}
|
||||||
{
|
#pragma skip_variants DECAL_SPECMAP DECAL_EMISSIVE DECAL_BUMPMAP
|
||||||
Name "FORWARD"
|
{% endblock %}
|
||||||
Tags
|
|
||||||
{
|
|
||||||
"LightMode" = "ForwardAdd"
|
|
||||||
}
|
|
||||||
ZWrite Off
|
|
||||||
ZTest LEqual
|
|
||||||
Blend SrcAlpha One
|
|
||||||
Offset -1, -1
|
|
||||||
|
|
||||||
CGPROGRAM
|
|
||||||
#pragma vertex vert
|
|
||||||
#pragma fragment frag_forward
|
|
||||||
|
|
||||||
#pragma multi_compile DIRECTIONAL SPOT POINT
|
|
||||||
#pragma multi_compile_local __ DECAL_PREVIEW
|
|
||||||
#pragma multi_compile_local __ DECAL_BASE_NORMAL DECAL_BUMPMAP
|
|
||||||
//{{ self.pragmas() }}
|
|
||||||
|
|
||||||
//{{ self.body() }}
|
|
||||||
ENDCG
|
|
||||||
}
|
|
||||||
|
|
||||||
Pass
|
|
||||||
{
|
|
||||||
Name "DEFERRED_PREPASS"
|
|
||||||
Tags
|
|
||||||
{
|
|
||||||
"LightMode" = "Deferred"
|
|
||||||
}
|
|
||||||
ZWrite Off
|
|
||||||
ZTest LEqual
|
|
||||||
Offset -1, -1
|
|
||||||
Blend 1 Zero OneMinusSrcColor, Zero OneMinusSrcAlpha
|
|
||||||
|
|
||||||
Stencil
|
|
||||||
{
|
|
||||||
Ref 1
|
|
||||||
Comp Equal
|
|
||||||
Pass Keep
|
|
||||||
}
|
|
||||||
|
|
||||||
CGPROGRAM
|
|
||||||
#pragma vertex vert
|
|
||||||
#pragma fragment frag_deferred_prepass
|
|
||||||
#pragma target 3.0
|
|
||||||
|
|
||||||
#pragma multi_compile_local __ DECAL_PREVIEW
|
|
||||||
#pragma multi_compile_local __ DECAL_BASE_NORMAL
|
|
||||||
//{{ self.pragmas() }}
|
|
||||||
|
|
||||||
//{% block prepass_skip_variants %}
|
|
||||||
#pragma skip_variants DECAL_SPECMAP DECAL_EMISSIVE
|
|
||||||
//{% endblock %}
|
|
||||||
|
|
||||||
#define DECAL_PREPASS
|
|
||||||
|
|
||||||
//{{ self.body() }}
|
|
||||||
ENDCG
|
|
||||||
}
|
|
||||||
|
|
||||||
Pass
|
|
||||||
{
|
|
||||||
Name "DEFERRED"
|
|
||||||
Tags
|
|
||||||
{
|
|
||||||
"LightMode" = "Deferred"
|
|
||||||
}
|
|
||||||
ZWrite Off
|
|
||||||
ZTest LEqual
|
|
||||||
Offset -1, -1
|
|
||||||
Blend 0 SrcAlpha OneMinusSrcAlpha, Zero One
|
|
||||||
Blend 1 One One
|
|
||||||
Blend 2 SrcAlpha OneMinusSrcAlpha, Zero One
|
|
||||||
Blend 3 SrcAlpha OneMinusSrcAlpha, Zero One
|
|
||||||
|
|
||||||
Stencil
|
|
||||||
{
|
|
||||||
Ref 1
|
|
||||||
Comp Equal
|
|
||||||
Pass Keep
|
|
||||||
}
|
|
||||||
|
|
||||||
CGPROGRAM
|
|
||||||
#pragma vertex vert
|
|
||||||
#pragma fragment frag_deferred
|
|
||||||
#pragma target 3.0
|
|
||||||
|
|
||||||
#pragma multi_compile __ UNITY_HDR_ON
|
|
||||||
#pragma multi_compile_local __ DECAL_PREVIEW
|
|
||||||
#pragma multi_compile_local __ DECAL_BASE_NORMAL DECAL_BUMPMAP
|
|
||||||
//{{ self.pragmas() }}
|
|
||||||
|
|
||||||
//{{ self.body() }}
|
|
||||||
ENDCG
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
#include "../DecalsCommon.cginc"
|
#include "DecalsCommon.cginc"
|
||||||
#include "../SDF.cginc"
|
#include "../SDF.cginc"
|
||||||
|
|
||||||
float4 _DecalColor;
|
float4 _DecalColor;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{% extends "StandardDecal.shader.template" %}
|
{% extends "DecalBase.shader.template" %}
|
||||||
{% block shader_name %}ConformalDecals/Decal/Text{% endblock %}
|
{% block shader_name %}Text{% endblock %}
|
||||||
|
|
||||||
{% block properties %}
|
{% block properties %}
|
||||||
[Header(Decal)]
|
[Header(Decal)]
|
||||||
@ -27,13 +27,15 @@
|
|||||||
_Shininess ("Shininess", Range (0.03, 10)) = 0.3
|
_Shininess ("Shininess", Range (0.03, 10)) = 0.3
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block pragmas %}
|
{% block body %}
|
||||||
|
#pragma multi_compile_local __ DECAL_BASE_NORMAL
|
||||||
#pragma multi_compile_local __ DECAL_SPECMAP
|
#pragma multi_compile_local __ DECAL_SPECMAP
|
||||||
#pragma multi_compile_local __ DECAL_OUTLINE
|
#pragma multi_compile_local __ DECAL_OUTLINE
|
||||||
#pragma multi_compile_local __ DECAL_FILL
|
#pragma multi_compile_local __ DECAL_FILL
|
||||||
#pragma skip_variants DECAL_BUMPMAP
|
|
||||||
|
#include "TextDecal.cginc"
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block body %}
|
{% block pragmas_deferred_prepass %}
|
||||||
#include "TextDecal.cginc"
|
#pragma skip_variants DECAL_SPECMAP
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -63,12 +63,12 @@ Shader "ConformalDecals/Decal Back"
|
|||||||
// 45° rotation
|
// 45° rotation
|
||||||
uv_MainTex.x = IN.uv_MainTex.x - IN.uv_MainTex.y;
|
uv_MainTex.x = IN.uv_MainTex.x - IN.uv_MainTex.y;
|
||||||
uv_MainTex.y = IN.uv_MainTex.x + IN.uv_MainTex.y;
|
uv_MainTex.y = IN.uv_MainTex.x + IN.uv_MainTex.y;
|
||||||
|
|
||||||
// stagger every other row
|
// stagger every other row
|
||||||
|
uv_MainTex.y *= 2;
|
||||||
int row = floor(uv_MainTex.y);
|
int row = floor(uv_MainTex.y);
|
||||||
uv_MainTex.x += row * _RowOffset;
|
uv_MainTex.x += row * _RowOffset;
|
||||||
uv_MainTex.y *= 2;
|
|
||||||
|
|
||||||
float4 color = _Color * tex2D(_MainTex,(uv_MainTex));
|
float4 color = _Color * tex2D(_MainTex,(uv_MainTex));
|
||||||
float3 normal = UnpackNormal(tex2D(_BumpMap, uv_BumpMap));
|
float3 normal = UnpackNormal(tex2D(_BumpMap, uv_BumpMap));
|
||||||
|
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
// Taken from https://github.com/LGhassen/Deferred
|
|
||||||
|
|
||||||
//TODO: remove this debug settings
|
|
||||||
float blinnPhongShininessPower = 0.215f;
|
|
||||||
|
|
||||||
// An exact conversion from blinn-phong to PBR is impossible, but the look can be approximated perceptually
|
|
||||||
// and by observing how blinn-phong looks and feels at various settings, although it can never be perfect
|
|
||||||
// 1) The specularColor can be used as is in the PBR specular flow, just needs to be divided by PI so it sums up to 1 over the hemisphere
|
|
||||||
// 2) Blinn-phong shininess doesn't stop feeling shiny unless at very low values, like below 0.04
|
|
||||||
// while the PBR smoothness feels more linear -> map shininess to smoothness accordingly using a function
|
|
||||||
// that increases very quickly at first then slows down, I went with something like x^(1/4) or x^(1/6) then made the power configurable
|
|
||||||
// I tried various mappings from the literature but nothing really worked as well as this
|
|
||||||
// 3) Finally I noticed that some parts still looked very shiny like the AV-R8 winglet while in stock they looked rough thanks a low
|
|
||||||
// specularColor but high shininess and specularMap, so I multiplied the smoothness by the sqrt of the specularColor and that caps
|
|
||||||
// the smoothness when specularColor is low
|
|
||||||
void GetStandardSpecularPropertiesFromLegacy(float legacyShininess, float specularMap, float3 legacySpecularColor,
|
|
||||||
out float smoothness, out float3 specular)
|
|
||||||
{
|
|
||||||
legacySpecularColor = saturate(legacySpecularColor);
|
|
||||||
|
|
||||||
smoothness = pow(legacyShininess, 0.215) * specularMap;
|
|
||||||
smoothness *= sqrt(length(legacySpecularColor));
|
|
||||||
|
|
||||||
specular = legacySpecularColor * (1 / UNITY_PI);
|
|
||||||
}
|
|
@ -1,102 +0,0 @@
|
|||||||
#ifndef LIGHTING_KSP_INCLUDED
|
|
||||||
#define LIGHTING_KSP_INCLUDED
|
|
||||||
|
|
||||||
inline fixed4 LightingBlinnPhongSmooth(SurfaceOutput s, fixed3 lightDir, half3 viewDir, fixed atten)
|
|
||||||
{
|
|
||||||
s.Normal = normalize(s.Normal);
|
|
||||||
half3 h = normalize(lightDir + viewDir);
|
|
||||||
|
|
||||||
fixed diff = max(0, dot(s.Normal, lightDir));
|
|
||||||
|
|
||||||
float nh = max(0, dot(s.Normal, h));
|
|
||||||
float spec = pow(nh, s.Specular*128.0) * s.Gloss;
|
|
||||||
|
|
||||||
fixed4 c;
|
|
||||||
c.rgb = (s.Albedo * _LightColor0.rgb * diff + _LightColor0.rgb * _SpecColor.rgb * spec) * (atten);
|
|
||||||
c.a = s.Alpha + _LightColor0.a * _SpecColor.a * spec * atten;
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
inline half4 LightingUnlit(SurfaceOutput s, half3 lightDir, half atten)
|
|
||||||
{
|
|
||||||
// half diff = max (0, dot (s.Normal, lightDir));
|
|
||||||
|
|
||||||
half4 c;
|
|
||||||
c.rgb = s.Albedo;
|
|
||||||
c.a = s.Alpha;
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
inline half4 LightingUnlit_PrePass(SurfaceOutput s, half4 light)
|
|
||||||
{
|
|
||||||
half4 c;
|
|
||||||
c.rgb = s.Albedo;
|
|
||||||
c.a = s.Alpha;
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fixed4 LightingNoLighting(SurfaceOutput s, fixed3 lightDir, fixed atten) { return fixed4(0, 0, 0, 0); }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float4 _Color;
|
|
||||||
half _LightBoost;
|
|
||||||
half4 LightingLightWrapped(SurfaceOutput s, half3 lightDir, half3 viewDir, half atten) {
|
|
||||||
float3 w = _Color.rgb*0.5;
|
|
||||||
half3 NdotL = dot(s.Normal, lightDir);
|
|
||||||
|
|
||||||
//Specular term
|
|
||||||
half3 h = normalize(lightDir + viewDir);
|
|
||||||
s.Normal = normalize(s.Normal);
|
|
||||||
float NdotH = dot(s.Normal, h);
|
|
||||||
float spec = pow(max(NdotH, 0), s.Specular * 128.0) * s.Gloss;
|
|
||||||
fixed3 specColor = _SpecColor.rgb * _LightColor0.rgb;
|
|
||||||
|
|
||||||
half3 diff = NdotL * (1 - w) + w;
|
|
||||||
half4 c;
|
|
||||||
c.rgb = ((s.Albedo * _LightColor0.rgb * diff) + (specColor * spec)) * (atten * _LightBoost);
|
|
||||||
c.a = s.Alpha + (_LightColor0.a * _SpecColor.a * spec * atten);
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float4 _LocalCameraPos;
|
|
||||||
float4 _LocalCameraDir;
|
|
||||||
float4 _UnderwaterFogColor;
|
|
||||||
float _UnderwaterMinAlphaFogDistance;
|
|
||||||
float _UnderwaterMaxAlbedoFog;
|
|
||||||
float _UnderwaterMaxAlphaFog;
|
|
||||||
float _UnderwaterAlbedoDistanceScalar;
|
|
||||||
float _UnderwaterAlphaDistanceScalar;
|
|
||||||
float _UnderwaterFogFactor;
|
|
||||||
|
|
||||||
float4 UnderwaterFog(float3 worldPos, float3 color)
|
|
||||||
{
|
|
||||||
float3 toPixel = worldPos - _LocalCameraPos.xyz;
|
|
||||||
float toPixelLength = length(toPixel); ///< Comment out the math--looks better without it.
|
|
||||||
//float angleDot = dot(_LocalCameraDir.xyz, toPixel / toPixelLength);
|
|
||||||
//angleDot = lerp(0.00000001, angleDot, saturate(sign(angleDot)));
|
|
||||||
//float waterDist = -_LocalCameraPos.w / angleDot;
|
|
||||||
//float dist = min(toPixelLength, waterDist);
|
|
||||||
|
|
||||||
|
|
||||||
float underwaterDetection = _UnderwaterFogFactor * _LocalCameraDir.w; ///< sign(1 - sign(_LocalCameraPos.w));
|
|
||||||
float albedoLerpValue = underwaterDetection * (_UnderwaterMaxAlbedoFog * saturate(toPixelLength * _UnderwaterAlbedoDistanceScalar));
|
|
||||||
float alphaFactor = 1 - underwaterDetection * (_UnderwaterMaxAlphaFog * saturate((toPixelLength - _UnderwaterMinAlphaFogDistance) * _UnderwaterAlphaDistanceScalar));
|
|
||||||
|
|
||||||
return float4(lerp(color, _UnderwaterFogColor.rgb, albedoLerpValue), alphaFactor);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
BIN
Assets/ConformalDecals/Textures/Decal-Blank.afdesign
Normal file
BIN
Assets/ConformalDecals/Textures/Decal-Blank.afdesign
Normal file
Binary file not shown.
BIN
Assets/ConformalDecals/Textures/Decal-Blank.afdesign~lock~
Normal file
BIN
Assets/ConformalDecals/Textures/Decal-Blank.afdesign~lock~
Normal file
Binary file not shown.
BIN
Assets/ConformalDecals/Textures/Icons Generic.afdesign
Normal file
BIN
Assets/ConformalDecals/Textures/Icons Generic.afdesign
Normal file
Binary file not shown.
BIN
Assets/ConformalDecals/Textures/Munar.afdesign
Normal file
BIN
Assets/ConformalDecals/Textures/Munar.afdesign
Normal file
Binary file not shown.
BIN
Assets/ConformalDecals/Textures/Semiotic.afdesign
Normal file
BIN
Assets/ConformalDecals/Textures/Semiotic.afdesign
Normal file
Binary file not shown.
BIN
Assets/ConformalDecals/Textures/paper-spec.png
Normal file
BIN
Assets/ConformalDecals/Textures/paper-spec.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 74 KiB |
BIN
Assets/ConformalDecals/Textures/paper.png
Normal file
BIN
Assets/ConformalDecals/Textures/paper.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 48 KiB |
Binary file not shown.
Binary file not shown.
BIN
GameData/ConformalDecals/Assets/paper.dds
Normal file
BIN
GameData/ConformalDecals/Assets/paper.dds
Normal file
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user