Skip to content

Commit

Permalink
Added a screen shake amplitude field for kITE.
Browse files Browse the repository at this point in the history
  • Loading branch information
AkaiMage authored Mar 29, 2019
1 parent 10865bb commit a4b5a6a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 6 additions & 7 deletions Cancerspace.shader
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
[PowerSlider(2.0)]_YShake ("Y Shake", Range(0, 1)) = 0
_XShakeSpeed ("X Shake Speed", Range(0, 300)) = 200
_YShakeSpeed ("Y Shake Speed", Range(0, 300)) = 300
_ShakeAmplitude ("Shake Amplitude", Range(0, 2)) = 1

_MainTex ("Image Overlay", 2D) = "white" {}
[HDR] _OverlayColor ("Overlay Color", Color) = (1,1,1,1)
Expand Down Expand Up @@ -148,10 +149,9 @@
float4 _OverlayColor;
float4 _Color;

float _XShake;
float _YShake;
float _XShakeSpeed;
float _YShakeSpeed;
float _XShake, _YShake;
float _XShakeSpeed, _YShakeSpeed;
float _ShakeAmplitude;

float _XWobbleAmount, _YWobbleAmount, _XWobbleTiling, _YWobbleTiling, _XWobbleSpeed, _YWobbleSpeed;

Expand Down Expand Up @@ -181,8 +181,7 @@
float _ScreenXMultiplierR, _ScreenXMultiplierG, _ScreenXMultiplierB, _ScreenXMultiplierA;
float _ScreenYMultiplierR, _ScreenYMultiplierG, _ScreenYMultiplierB, _ScreenYMultiplierA;

float4 _ScreenRotationOriginX;
float4 _ScreenRotationOriginY;
float4 _ScreenRotationOriginX, _ScreenRotationOriginY;

float4 _RotationAngle;

Expand Down Expand Up @@ -264,7 +263,7 @@

float4 color = tex2D(_MainTex, TRANSFORM_TEX(computeScreenSpaceOverlayUV(i.posWorld), _MainTex)) * _OverlayColor;

float2 displace = float2(_XShake * VRFix, _YShake) * sin(_Time.yy * float2(_XShakeSpeed, _YShakeSpeed));
float2 displace = float2(_XShake * VRFix, _YShake) * sin(_Time.yy * float2(_XShakeSpeed, _YShakeSpeed)) * _ShakeAmplitude;

float2 grabUV = i.projPos.xy / i.projPos.w;

Expand Down
4 changes: 4 additions & 0 deletions Editor/CancerspaceInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public CSCategory(string nname, GUIStyle sstyle, CSCategorySetup ssetupDelegate)
protected MaterialProperty shakeYAmount;
protected MaterialProperty shakeXSpeed;
protected MaterialProperty shakeYSpeed;
protected MaterialProperty shakeAmplitude;

protected MaterialProperty overlayImage;
protected MaterialProperty overlayColor;
Expand Down Expand Up @@ -161,6 +162,7 @@ public void FindProperties(MaterialProperty[] props) {
shakeYAmount = FindProperty("_YShake", props);
shakeXSpeed = FindProperty("_XShakeSpeed", props);
shakeYSpeed = FindProperty("_YShakeSpeed", props);
shakeAmplitude = FindProperty("_ShakeAmplitude", props);

overlayImage = FindProperty("_MainTex", props);
overlayColor = FindProperty("_OverlayColor", props);
Expand Down Expand Up @@ -252,11 +254,13 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro
me.ShaderProperty(shakeYAmount, shakeYAmount.displayName);
me.ShaderProperty(shakeXSpeed, shakeXSpeed.displayName);
me.ShaderProperty(shakeYSpeed, shakeYSpeed.displayName);
me.ShaderProperty(shakeAmplitude, shakeAmplitude.displayName);
} else {
me.FloatProperty(shakeXAmount, shakeXAmount.displayName);
me.FloatProperty(shakeYAmount, shakeYAmount.displayName);
me.FloatProperty(shakeXSpeed, shakeXSpeed.displayName);
me.FloatProperty(shakeYSpeed, shakeYSpeed.displayName);
me.FloatProperty(shakeAmplitude, shakeAmplitude.displayName);
}
}),

Expand Down

0 comments on commit a4b5a6a

Please sign in to comment.