Skip to content

Commit

Permalink
v0.700 WIP6
Browse files Browse the repository at this point in the history
  • Loading branch information
ozonexo3 committed Jan 12, 2021
1 parent 123e005 commit 79e5710
Show file tree
Hide file tree
Showing 18 changed files with 3,963 additions and 2,037 deletions.
152 changes: 152 additions & 0 deletions Assets/GFX/Shaders/WaveShader.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
// Upgrade NOTE: replaced 'UNITY_INSTANCE_ID' with 'UNITY_VERTEX_INPUT_INSTANCE_ID'

// Upgrade NOTE: replaced 'UNITY_INSTANCE_ID' with 'UNITY_VERTEX_INPUT_INSTANCE_ID'
// Upgrade NOTE: upgraded instancing buffer 'MyProperties' to new syntax.

// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'

Shader "MapEditor/Wave" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Ramp("Ramp", 2D) = "white" {}
_Cutoff("Alpha cutoff", Range(0,1)) = 0.5
_Velocity("Velocity", Vector) = (0,0,0,0)
_First("First", Vector) = (0,0,0,0)
_Second("Second", Vector) = (0,0,0,0)
_Frames("Frames", Vector) = (0,0,0,0)
}
SubShader{
Tags {"Queue" = "Transparent+5" "IgnoreProjector" = "True" "RenderType" = "Transparent"}
LOD 100

Lighting Off
//ZTest Always
ZWrite Off
Blend One OneMinusSrcAlpha
Offset 0.00001, 0.00001
Cull Off

Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_instancing
#include "UnityCG.cginc"

struct appdata_t {
float4 vertex : POSITION;
float3 normal : NORMAL;
float2 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};

struct v2f {
float4 vertex : SV_POSITION;
half2 texcoord : TEXCOORD0;
half3 lifetime : TEXCOORD1;
//UNITY_VERTEX_INPUT_INSTANCE_ID // necessary only if you want to access instanced properties in the fragment Shader.
};

fixed4 _Color;
sampler2D _MainTex;
sampler2D _Ramp;
float4 _MainTex_ST;
fixed _Cutoff;

float _SupComTime;

UNITY_INSTANCING_BUFFER_START(MyProperties)
UNITY_DEFINE_INSTANCED_PROP(float4, _Velocity)
#define _Velocity_arr MyProperties
UNITY_DEFINE_INSTANCED_PROP(float4, _First)
#define _First_arr MyProperties
UNITY_DEFINE_INSTANCED_PROP(float4, _Second)
#define _Second_arr MyProperties
UNITY_DEFINE_INSTANCED_PROP(float4, _Frames)
#define _Frames_arr MyProperties
UNITY_INSTANCING_BUFFER_END(MyProperties)

v2f vert (appdata_t v)
{
v2f o;

UNITY_SETUP_INSTANCE_ID(v);
//UNITY_TRANSFER_INSTANCE_ID(v, o); // necessary only if you want to access instanced properties in the fragment Shader.

float4 first = UNITY_ACCESS_INSTANCED_PROP(_First_arr, _First);
float4 second = UNITY_ACCESS_INSTANCED_PROP(_Second_arr, _Second);
float4 frames = UNITY_ACCESS_INSTANCED_PROP(_Frames_arr, _Frames);

//o.lifetime.x = ((_SupComTime * 10 + frames.w + first.y) % first.x) / first.x;
//o.lifetime.y = (_SupComTime * 10 + frames.w + second.y - first.x) % second.x / second.x;

//float secondOffset = first.y;
//float totalTime = (_SupComTime - frames.w) % (secondOffset + second.x / 60. + second.y);
float localTime = clamp(_SupComTime - frames.w, 0.0, 1000000.0);
float totalTime = localTime % (first.y + second.y);

o.lifetime.x = saturate(totalTime / first.y);
o.lifetime.y = saturate((totalTime - first.y) / second.y);
//o.lifetime.y = 1;

o.lifetime.z = saturate(v.normal.y * 1000.0);

//UNITY_BRANCH
if (o.lifetime.z > 0.5) {

if (o.lifetime.x < 1.0) {
float4 vel = float4(UNITY_ACCESS_INSTANCED_PROP(_Velocity_arr, _Velocity).xyz, 0);
//vel.x *= -1;
vel = mul(unity_WorldToObject, vel);
//vel.z *= -1;

v.vertex.xyz *= lerp(first.z, second.z, o.lifetime.x);
v.vertex.xyz -= vel.xyz * (o.lifetime.x);

}
}
else {
v.normal.y = -v.normal.y;
if (o.lifetime.y < 1.0) {
float4 vel = float4(UNITY_ACCESS_INSTANCED_PROP(_Velocity_arr, _Velocity).xyz, 0);
//vel.x *= -1;
vel = mul(unity_WorldToObject, vel);
//vel.z *= -1;
v.vertex.xyz *= lerp(first.z, second.z, o.lifetime.y);
v.vertex.xyz -= vel.xyz * (o.lifetime.y);

//v.vertex.xyz *= second.z * 2;


}
}

o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);

return o;
}

fixed4 frag (v2f i) : SV_Target
{
//UNITY_SETUP_INSTANCE_ID(i);
fixed4 col = tex2D(_MainTex, i.texcoord);
fixed4 ramp = tex2D(_Ramp, float2((i.lifetime.z > 0.5) ? i.lifetime.x : i.lifetime.y, 0.5));

//col.rgb *= _Color.rgb;

col.a *= ramp.a;

col.rgb *= col.a;

//clip(col.a - _Cutoff);


return col;
}
ENDCG
}
}

}
9 changes: 9 additions & 0 deletions Assets/GFX/Shaders/WaveShader.shader.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Assets/GFX/Terrain/TerrainShader.mat
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ Material:
- _Brush: 0
- _BrushPainting: 0
- _BrushSize: 0
- _BrushUvX: 0.12511635
- _BrushUvY: 0.43050808
- _BrushUvX: 0.5249967
- _BrushUvY: 0.9839142
- _BuildGrid: 0
- _DeepLevel: 1.675625
- _DepthLevel: 1.5
Expand Down
79 changes: 9 additions & 70 deletions Assets/GFX/Terrain/WaterWaves.mat
Original file line number Diff line number Diff line change
Expand Up @@ -8,91 +8,30 @@ Material:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: WaterWaves
m_Shader: {fileID: 211, guid: 0000000000000000f000000000000000, type: 0}
m_Shader: {fileID: 4800000, guid: c7ba0d5178152f44f8655319ce96939f, type: 3}
m_ShaderKeywords: _ALPHABLEND_ON _COLORCOLOR_ON
m_LightmapFlags: 0
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 0
m_CustomRenderQueue: 3000
stringTagMap:
RenderType: Transparent
disabledShaderPasses:
- ALWAYS
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _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:
- _Ramp:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BlendOp: 0
- _BumpScale: 1
- _CameraFadingEnabled: 0
- _CameraFarFadeDistance: 2
- _CameraNearFadeDistance: 1
- _ColorMode: 4
- _Cull: 2
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DistortionBlend: 0.5
- _DistortionEnabled: 0
- _DistortionStrength: 1
- _DistortionStrengthScaled: 0
- _DstBlend: 10
- _EmissionEnabled: 0
- _FlipbookMode: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _LightingEnabled: 0
- _Metallic: 0
- _Mode: 2
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SoftParticlesEnabled: 0
- _SoftParticlesFarFadeDistance: 1
- _SoftParticlesNearFadeDistance: 0
- _SpecularHighlights: 1
- _SrcBlend: 5
- _UVSec: 0
- _ZWrite: 0
m_Colors:
- _CameraFadeParams: {r: 0, g: Infinity, b: 0, a: 0}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _ColorAddSubDiff: {r: 0, g: 0, b: 0, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SoftParticleFadeParams: {r: 0, g: 0, b: 0, a: 0}
- _First: {r: 0, g: 0, b: 0, a: 0}
- _Frame: {r: 0, g: 0, b: 0, a: 0}
- _Second: {r: 0, g: 0, b: 0, a: 0}
- _Velocity: {r: 0, g: 0, b: 0, a: 0}
Loading

0 comments on commit 79e5710

Please sign in to comment.