Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Tommé Nöll
seedling
Commits
de19f7d8
Commit
de19f7d8
authored
Aug 08, 2019
by
Tommé Nöll
Browse files
fixed corruption shader for perspective camera
parent
3dc60725
Changes
2
Hide whitespace changes
Inline
Side-by-side
Assets/Scenes/TommeTest.unity
View file @
de19f7d8
...
...
@@ -2439,6 +2439,40 @@ Transform:
type
:
3
}
m_PrefabInstance
:
{
fileID
:
345354280
}
m_PrefabAsset
:
{
fileID
:
0
}
---
!u!84
&978874468
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
:
945
m_Height
:
539
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
&1071197050
PrefabInstance
:
m_ObjectHideFlags
:
0
...
...
@@ -4401,27 +4435,32 @@ PrefabInstance:
-
target
:
{
fileID
:
146384502658720480
,
guid
:
47edb6c4e8357676a9cb004f1655d229
,
type
:
3
}
propertyPath
:
m_LocalPosition.x
value
:
11.27
value
:
5.19
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
146384502658720480
,
guid
:
47edb6c4e8357676a9cb004f1655d229
,
type
:
3
}
propertyPath
:
m_LocalPosition.y
value
:
3.76
value
:
1.47
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
146384502658720480
,
guid
:
47edb6c4e8357676a9cb004f1655d229
,
type
:
3
}
propertyPath
:
m_LocalScale.y
value
:
2.1
value
:
6.592747
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
146384502658720480
,
guid
:
47edb6c4e8357676a9cb004f1655d229
,
type
:
3
}
propertyPath
:
m_LocalScale.x
value
:
4.02
value
:
10.856261
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
146384502658720480
,
guid
:
47edb6c4e8357676a9cb004f1655d229
,
type
:
3
}
propertyPath
:
m_LocalScale.z
value
:
14.403
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
1362442974637441875
,
guid
:
47edb6c4e8357676a9cb004f1655d229
,
type
:
3
}
propertyPath
:
maxStrengthDistanceFactor
value
:
0.
508
value
:
0.
99
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
1362442974637441875
,
guid
:
47edb6c4e8357676a9cb004f1655d229
,
type
:
3
}
...
...
@@ -4938,40 +4977,6 @@ RenderTexture:
m_WrapW
:
1
m_Dimension
:
2
m_VolumeDepth
:
1
---
!u!84
&1951774334
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
:
945
m_Height
:
539
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
...
...
@@ -5675,12 +5680,12 @@ PrefabInstance:
-
target
:
{
fileID
:
5546039070061430727
,
guid
:
5f19e99694f67a245b4244a6b9f38023
,
type
:
3
}
propertyPath
:
m_LocalPosition.x
value
:
4.4
1
value
:
9.7
1
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
5546039070061430727
,
guid
:
5f19e99694f67a245b4244a6b9f38023
,
type
:
3
}
propertyPath
:
m_LocalPosition.y
value
:
0.92
value
:
3.09
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
5546039070061430727
,
guid
:
5f19e99694f67a245b4244a6b9f38023
,
type
:
3
}
...
...
@@ -5715,21 +5720,26 @@ PrefabInstance:
type
:
3
}
propertyPath
:
m_TargetTexture
value
:
objectReference
:
{
fileID
:
1951774334
}
objectReference
:
{
fileID
:
978874468
}
-
target
:
{
fileID
:
8811539148413200178
,
guid
:
388a7af523fdebaafad4a5d1ae1a896b
,
type
:
3
}
propertyPath
:
orthographic size
value
:
5
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
8811539148413200178
,
guid
:
388a7af523fdebaafad4a5d1ae1a896b
,
type
:
3
}
propertyPath
:
orthographic
value
:
0
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
8811539149977030266
,
guid
:
388a7af523fdebaafad4a5d1ae1a896b
,
type
:
3
}
propertyPath
:
m_LocalPosition.x
value
:
5.3
5
value
:
5.3
1
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
8811539149977030266
,
guid
:
388a7af523fdebaafad4a5d1ae1a896b
,
type
:
3
}
propertyPath
:
m_LocalPosition.y
value
:
2.04
value
:
3.2
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
8811539149977030266
,
guid
:
388a7af523fdebaafad4a5d1ae1a896b
,
type
:
3
}
...
...
@@ -5811,6 +5821,21 @@ PrefabInstance:
propertyPath
:
orthographic size
value
:
5
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
8811539149977030267
,
guid
:
388a7af523fdebaafad4a5d1ae1a896b
,
type
:
3
}
propertyPath
:
orthographic
value
:
0
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
8811539149977030267
,
guid
:
388a7af523fdebaafad4a5d1ae1a896b
,
type
:
3
}
propertyPath
:
m_FOVAxisMode
value
:
0
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
8811539149977030267
,
guid
:
388a7af523fdebaafad4a5d1ae1a896b
,
type
:
3
}
propertyPath
:
field of view
value
:
60
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
8811539148413200141
,
guid
:
388a7af523fdebaafad4a5d1ae1a896b
,
type
:
3
}
propertyPath
:
m_LocalPosition.y
...
...
Assets/Shaders/PlantSpriteShader.shader
View file @
de19f7d8
...
...
@@ -53,10 +53,15 @@ Shader "Custom/PlantSpriteShader"
fixed4
color
:
COLOR
;
float2
texcoord
:
TEXCOORD0
;
float4
clipPos
:
SV_POSITION
;
float
4
localPos
:
LOCALPOS
;
float
2
screenPos
:
TEXCOORD1
;
UNITY_VERTEX_OUTPUT_STEREO
};
#if EDITOR_ON
float4x4
_ToMainCameraMatrix
;
float
_CorruptionCameraScaleFactor
;
#endif
p_v2f
p_SpriteVert
(
appdata_t
IN
)
{
p_v2f
OUT
;
...
...
@@ -66,10 +71,21 @@ Shader "Custom/PlantSpriteShader"
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
;
#if EDITOR_ON
const
float2
center
=
(
0
.
5
,
0
.
5
);
float4
screenPos
=
ComputeScreenPos
(
mul
(
_ToMainCameraMatrix
,
IN
.
vertex
));
screenPos
.
xy
=
screenPos
.
xy
/
screenPos
.
w
;
screenPos
.
xy
=
(
screenPos
.
xy
+
center
*
(
_CorruptionCameraScaleFactor
-
1
))
/
_CorruptionCameraScaleFactor
;
OUT
.
screenPos
=
screenPos
.
xy
;
#else
float4
screenPos
=
ComputeScreenPos
(
UnityObjectToClipPos
(
IN
.
vertex
));
OUT
.
screenPos
=
screenPos
.
xy
/
screenPos
.
w
;
#endif
//OUT.worldPos = UnityObjectToClipPos(IN.vertex);
return
OUT
;
...
...
@@ -79,25 +95,13 @@ Shader "Custom/PlantSpriteShader"
float4
_ColorStrengthFactors
;
float
_ColorStrengthExponent
;
float4
_ColorOutFactors
;
float4x4
_ToMainCameraMatrix
;
float
_PulsatingSpeed
;
float
_PulsatingStrength
;
#if EDITOR_ON
float
_CorruptionCameraScaleFactor
;
#endif
fixed4
p_SpriteFrag
(
p_v2f
IN
)
:
SV_Target
{
const
float2
center
=
(
0
.
5
,
0
.
5
);
fixed4
color
=
SampleSpriteTexture
(
IN
.
texcoord
)
*
IN
.
color
;
//float2 screenPos = ComputeScreenPos(IN.clipPos);
float2
screenPos
=
ComputeScreenPos
(
UnityObjectToClipPos
(
IN
.
localPos
));
#if EDITOR_ON
screenPos
=
ComputeScreenPos
(
mul
(
_ToMainCameraMatrix
,
IN
.
localPos
));
screenPos
=
(
screenPos
+
center
*
(
_CorruptionCameraScaleFactor
-
1
))
/
_CorruptionCameraScaleFactor
;
#endif
//screenPos += (0.25, 0.25);
float
corruption
=
tex2D
(
_CorruptionMap
,
screenPos
)
*
3
;
float
corruption
=
tex2D
(
_CorruptionMap
,
IN
.
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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment