Commit 0c8762d7 authored by Tommé Nöll's avatar Tommé Nöll
Browse files

added new version of corruption shader based on sprite shader instead of on...

added new version of corruption shader based on sprite shader instead of on surface shader, to fix change in color when used on sprite
parent 6261d508
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: PlantSpriteMaterial
m_Shader: {fileID: 4800000, guid: c431bbac2febcc775a9398329a8acaf6, type: 3}
m_ShaderKeywords: ETC1_EXTERNAL_ALPHA
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _AlphaTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- PixelSnap: 0
- _BumpScale: 1
- _ColorStrengthExponent: 5
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _EnableExternalAlpha: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _PulsatingSpeed: 1.3
- _PulsatingStrength: 0.8
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _ColorOutFactors: {r: 10, g: -20, b: 9, a: 0}
- _ColorStrengthFactors: {r: 0, g: 1, b: 0, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _Flip: {r: 1, g: 1, b: 1, a: 1}
- _RendererColor: {r: 1, g: 1, b: 1, a: 1}
fileFormatVersion: 2
guid: 2356837d39687a37cbcfb6a223a9c313
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:
......@@ -46,7 +46,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
globalCorruption: 0
mapTexture: {fileID: 0}
plantSurfaceMaterial: {fileID: 2100000, guid: ac1fcd6dcb153b8b3bb2c6ca837296ff,
plantSurfaceMaterial: {fileID: 2100000, guid: 2356837d39687a37cbcfb6a223a9c313,
type: 2}
--- !u!1001 &5692394672654869799
PrefabInstance:
......
......@@ -48,7 +48,7 @@ SpriteRenderer:
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: ac1fcd6dcb153b8b3bb2c6ca837296ff, type: 2}
- {fileID: 2100000, guid: 2356837d39687a37cbcfb6a223a9c313, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
......
......@@ -1403,7 +1403,7 @@ PrefabInstance:
- target: {fileID: 2554834490484476826, guid: 7ef06ffc179d97098a6c30d5f8570a4e,
type: 3}
propertyPath: m_LocalPosition.y
value: 0.48207158
value: 0.4820716
objectReference: {fileID: 0}
- target: {fileID: 2554834490484476826, guid: 7ef06ffc179d97098a6c30d5f8570a4e,
type: 3}
......@@ -2812,6 +2812,21 @@ PrefabInstance:
propertyPath: m_TagString
value: Player
objectReference: {fileID: 0}
- target: {fileID: 3724751736021467387, guid: a1e0107a2375e1140a669c1da0647f9a,
type: 3}
propertyPath: m_RootOrder
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3724751736021467387, guid: a1e0107a2375e1140a669c1da0647f9a,
type: 3}
propertyPath: m_LocalPosition.y
value: 1.85
objectReference: {fileID: 0}
- target: {fileID: 3724751736021467387, guid: a1e0107a2375e1140a669c1da0647f9a,
type: 3}
propertyPath: m_LocalPosition.x
value: 1.12
objectReference: {fileID: 0}
- target: {fileID: 264577551908436831, guid: a1e0107a2375e1140a669c1da0647f9a,
type: 3}
propertyPath: m_Name
......@@ -2928,21 +2943,6 @@ PrefabInstance:
propertyPath: m_Size.y
value: 1.22
objectReference: {fileID: 0}
- target: {fileID: 3724751736021467387, guid: a1e0107a2375e1140a669c1da0647f9a,
type: 3}
propertyPath: m_RootOrder
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3724751736021467387, guid: a1e0107a2375e1140a669c1da0647f9a,
type: 3}
propertyPath: m_LocalPosition.y
value: 0.21
objectReference: {fileID: 0}
- target: {fileID: 3724751736021467387, guid: a1e0107a2375e1140a669c1da0647f9a,
type: 3}
propertyPath: m_LocalPosition.x
value: -18.92
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: a1e0107a2375e1140a669c1da0647f9a, type: 3}
--- !u!1001 &1206557182
......@@ -3908,6 +3908,40 @@ Transform:
type: 3}
m_PrefabInstance: {fileID: 1549918673}
m_PrefabAsset: {fileID: 0}
--- !u!84 &1550914428
RenderTexture:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
serializedVersion: 3
m_Width: 1209
m_Height: 545
m_AntiAliasing: 1
m_DepthFormat: 0
m_ColorFormat: 21
m_MipMap: 0
m_GenerateMips: 1
m_SRGB: 0
m_UseDynamicScale: 0
m_BindMS: 0
m_EnableCompatibleFormat: 1
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 1
m_MipBias: 0
m_WrapU: 1
m_WrapV: 1
m_WrapW: 1
m_Dimension: 2
m_VolumeDepth: 1
--- !u!1001 &1551787235
PrefabInstance:
m_ObjectHideFlags: 0
......@@ -4052,40 +4086,6 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 7ef06ffc179d97098a6c30d5f8570a4e, type: 3}
--- !u!84 &1658530543
RenderTexture:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
serializedVersion: 3
m_Width: 1261
m_Height: 563
m_AntiAliasing: 1
m_DepthFormat: 0
m_ColorFormat: 21
m_MipMap: 0
m_GenerateMips: 1
m_SRGB: 0
m_UseDynamicScale: 0
m_BindMS: 0
m_EnableCompatibleFormat: 1
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 1
m_MipBias: 0
m_WrapU: 1
m_WrapV: 1
m_WrapW: 1
m_Dimension: 2
m_VolumeDepth: 1
--- !u!1001 &1673005932
PrefabInstance:
m_ObjectHideFlags: 0
......@@ -4331,12 +4331,12 @@ PrefabInstance:
- target: {fileID: 146384502658720480, guid: 47edb6c4e8357676a9cb004f1655d229,
type: 3}
propertyPath: m_LocalPosition.x
value: 11.02
value: 11.24
objectReference: {fileID: 0}
- target: {fileID: 146384502658720480, guid: 47edb6c4e8357676a9cb004f1655d229,
type: 3}
propertyPath: m_LocalPosition.y
value: 0.62
value: 3.12
objectReference: {fileID: 0}
- target: {fileID: 146384502658720480, guid: 47edb6c4e8357676a9cb004f1655d229,
type: 3}
......@@ -4465,40 +4465,6 @@ Transform:
type: 3}
m_PrefabInstance: {fileID: 1788602749}
m_PrefabAsset: {fileID: 0}
--- !u!84 &1809172834
RenderTexture:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
serializedVersion: 3
m_Width: 1209
m_Height: 545
m_AntiAliasing: 1
m_DepthFormat: 0
m_ColorFormat: 21
m_MipMap: 0
m_GenerateMips: 1
m_SRGB: 0
m_UseDynamicScale: 0
m_BindMS: 0
m_EnableCompatibleFormat: 1
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 1
m_MipBias: 0
m_WrapU: 1
m_WrapV: 1
m_WrapW: 1
m_Dimension: 2
m_VolumeDepth: 1
--- !u!1001 &1818914861
PrefabInstance:
m_ObjectHideFlags: 0
......@@ -4868,6 +4834,40 @@ Transform:
type: 3}
m_PrefabInstance: {fileID: 1854361418}
m_PrefabAsset: {fileID: 0}
--- !u!84 &1859889566
RenderTexture:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
serializedVersion: 3
m_Width: 1209
m_Height: 545
m_AntiAliasing: 1
m_DepthFormat: 0
m_ColorFormat: 21
m_MipMap: 0
m_GenerateMips: 1
m_SRGB: 0
m_UseDynamicScale: 0
m_BindMS: 0
m_EnableCompatibleFormat: 1
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 1
m_MipBias: 0
m_WrapU: 1
m_WrapV: 1
m_WrapW: 1
m_Dimension: 2
m_VolumeDepth: 1
--- !u!1001 &1974111396
PrefabInstance:
m_ObjectHideFlags: 0
......@@ -5487,7 +5487,7 @@ PrefabInstance:
type: 3}
propertyPath: mapTexture
value:
objectReference: {fileID: 1658530543}
objectReference: {fileID: 1859889566}
- target: {fileID: 8565205532968054277, guid: 5f19e99694f67a245b4244a6b9f38023,
type: 3}
propertyPath: zones.Array.data[0]
......@@ -5501,12 +5501,12 @@ PrefabInstance:
- target: {fileID: 5524515208459548046, guid: 5f19e99694f67a245b4244a6b9f38023,
type: 3}
propertyPath: m_LocalPosition.x
value: -2.64
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5524515208459548046, guid: 5f19e99694f67a245b4244a6b9f38023,
type: 3}
propertyPath: m_LocalPosition.y
value: 1.04
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5524515208459548046, guid: 5f19e99694f67a245b4244a6b9f38023,
type: 3}
......@@ -5553,20 +5553,15 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6635821371766515317, guid: 5f19e99694f67a245b4244a6b9f38023,
type: 3}
propertyPath: m_Layer
value: 12
objectReference: {fileID: 0}
- target: {fileID: 5546039070061430727, guid: 5f19e99694f67a245b4244a6b9f38023,
type: 3}
propertyPath: m_LocalPosition.x
value: 6.01
value: 4.32
objectReference: {fileID: 0}
- target: {fileID: 5546039070061430727, guid: 5f19e99694f67a245b4244a6b9f38023,
type: 3}
propertyPath: m_LocalPosition.y
value: 1.89
value: -0.06
objectReference: {fileID: 0}
- target: {fileID: 5546039070061430727, guid: 5f19e99694f67a245b4244a6b9f38023,
type: 3}
......@@ -5578,6 +5573,11 @@ PrefabInstance:
propertyPath: m_LocalScale.y
value: 3.1
objectReference: {fileID: 0}
- target: {fileID: 6635821371766515317, guid: 5f19e99694f67a245b4244a6b9f38023,
type: 3}
propertyPath: m_Layer
value: 12
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 5f19e99694f67a245b4244a6b9f38023, type: 3}
--- !u!1001 &8811539148946952083
......@@ -5596,16 +5596,16 @@ PrefabInstance:
type: 3}
propertyPath: m_TargetTexture
value:
objectReference: {fileID: 1809172834}
objectReference: {fileID: 1550914428}
- target: {fileID: 8811539149977030266, guid: 388a7af523fdebaafad4a5d1ae1a896b,
type: 3}
propertyPath: m_LocalPosition.x
value: 5.21
value: 6.3
objectReference: {fileID: 0}
- target: {fileID: 8811539149977030266, guid: 388a7af523fdebaafad4a5d1ae1a896b,
type: 3}
propertyPath: m_LocalPosition.y
value: 1.72
value: 3.22
objectReference: {fileID: 0}
- target: {fileID: 8811539149977030266, guid: 388a7af523fdebaafad4a5d1ae1a896b,
type: 3}
......@@ -5652,15 +5652,20 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8811539149977030261, guid: 388a7af523fdebaafad4a5d1ae1a896b,
- target: {fileID: 8811539148413200140, guid: 388a7af523fdebaafad4a5d1ae1a896b,
type: 3}
propertyPath: player
propertyPath: corruptionMap
value:
objectReference: {fileID: 0}
- target: {fileID: 8811539148413200140, guid: 388a7af523fdebaafad4a5d1ae1a896b,
objectReference: {fileID: 120497678}
- target: {fileID: 8811539149977030271, guid: 388a7af523fdebaafad4a5d1ae1a896b,
type: 3}
propertyPath: corruptionMap
value:
objectReference: {fileID: 120497678}
- target: {fileID: 8811539149977030261, guid: 388a7af523fdebaafad4a5d1ae1a896b,
type: 3}
propertyPath: player
value:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 388a7af523fdebaafad4a5d1ae1a896b, type: 3}
......@@ -3,6 +3,7 @@ using System.Collections.Generic;
using UnityEngine;
[ExecuteInEditMode]
[SelectionBase]
public class CorruptionZone : MonoBehaviour
{
[Range (0f, 1f)] public float maxStrength;
......
......@@ -6,7 +6,7 @@ using UnityEngine;
public class PostEffectScript : MonoBehaviour
{
public Material material;
[HideInInspector] public CorruptionMap corruptionMap;
public CorruptionMap corruptionMap;
public bool showCorruptionMap;
public bool applyPostEffect;
......
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Custom/PlantSpriteShader"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
[MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
[HideInInspector] _RendererColor ("RendererColor", Color) = (1,1,1,1)
[HideInInspector] _Flip ("Flip", Vector) = (1,1,1,1)
[PerRendererData] _AlphaTex ("External Alpha", 2D) = "white" {}
[PerRendererData] _EnableExternalAlpha ("Enable External Alpha", Float) = 0
_ColorStrengthFactors("ColorStrengthFactors", Vector) = (0, 1, 0, 0)
_ColorStrengthExponent("ColorStrengthExponent", Float) = 5.0
_ColorOutFactors("ColorChangeFactors", Vector) = (10, -20, 9, 0)
_PulsatingSpeed("PulsatingSpeed", Float) = 1.3
_PulsatingStrength("PulsatingStrength", Float) = 0.8
}
SubShader
{
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
"CanUseSpriteAtlas"="True"
}
Cull Off
Lighting Off
ZWrite Off
Blend One OneMinusSrcAlpha
Pass
{
CGPROGRAM
#pragma vertex p_SpriteVert
#pragma fragment p_SpriteFrag
#pragma target 2.0
#pragma multi_compile_instancing
#pragma multi_compile _ ETC1_EXTERNAL_ALPHA
#pragma multi_compile EDITOR_ON EDITOR_OFF
#include "UnitySprites.cginc"
struct p_v2f
{
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
float4 clipPos : SV_POSITION;
float4 localPos : LOCALPOS;
UNITY_VERTEX_OUTPUT_STEREO
};
p_v2f p_SpriteVert(appdata_t IN)
{
p_v2f OUT;
UNITY_SETUP_INSTANCE_ID (IN);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
OUT.clipPos = UnityFlipSprite(IN.vertex, _Flip);
OUT.clipPos = UnityObjectToClipPos(OUT.clipPos);
OUT.localPos = IN.vertex; // mul(UNITY_MATRIX_M, IN.vertex);
OUT.texcoord = IN.texcoord;
OUT.color = IN.color * _Color * _RendererColor;
//OUT.worldPos = UnityObjectToClipPos(IN.vertex);
return OUT;
}
sampler2D _CorruptionMap;
float4 _ColorStrengthFactors;
float _ColorStrengthExponent;
float4 _ColorOutFactors;
float4x4 _ToMainCameraMatrix;
float _PulsatingSpeed;
float _PulsatingStrength;
fixed4 p_SpriteFrag(p_v2f IN) : SV_Target
{
fixed4 color = SampleSpriteTexture (IN.texcoord) * IN.color;
//float2 screenPos = ComputeScreenPos(IN.clipPos);
float2 screenPos = ComputeScreenPos(UnityObjectToClipPos(IN.localPos));
#if EDITOR_ON
//broken
// screenPos = ComputeScreenPos(mul(_ToMainCameraMatrix, float4 (UnityObjectToClipPos(IN.localPos))));
#endif
float corruption = tex2D(_CorruptionMap, screenPos) * 3;
float colorstrength = dot(_ColorStrengthFactors, color);
float colorshift = max(pow(colorstrength, _ColorStrengthExponent) * corruption * (0.5 + _PulsatingStrength / 50 * (sin(_Time[1] * _PulsatingSpeed) / 2)), 0);
color += colorshift * _ColorOutFactors;
color.rgb *= color.a;
//color.rgb = UnityObjectToClipPos(IN.localPos.xyz);
return color;
}
#define UnitySprites
#ifndef UnitySprites
// UnitySprites.cginc, for reference
#ifndef UNITY_SPRITES_INCLUDED
#define UNITY_SPRITES_INCLUDED
#include "UnityCG.cginc"
#ifdef UNITY_INSTANCING_ENABLED
UNITY_INSTANCING_BUFFER_START(PerDrawSprite)
// SpriteRenderer.Color while Non-Batched/Instanced.
UNITY_DEFINE_INSTANCED_PROP(fixed4, unity_SpriteRendererColorArray)
// this could be smaller but that's how bit each entry is regardless of type
UNITY_DEFINE_INSTANCED_PROP(fixed2, unity_SpriteFlipArray)
UNITY_INSTANCING_BUFFER_END(PerDrawSprite)
#define _RendererColor UNITY_ACCESS_INSTANCED_PROP(PerDrawSprite, unity_SpriteRendererColorArray)
#define _Flip UNITY_ACCESS_INSTANCED_PROP(PerDrawSprite, unity_SpriteFlipArray)
#endif // instancing
CBUFFER_START(UnityPerDrawSprite)
#ifndef UNITY_INSTANCING_ENABLED
fixed4 _RendererColor;
fixed2 _Flip;
#endif
float _EnableExternalAlpha;
CBUFFER_END