Skip to content

Commit

Permalink
v0.521
Browse files Browse the repository at this point in the history
  • Loading branch information
ozonexo3 committed May 27, 2018
1 parent 7dc93d7 commit 52b62e6
Show file tree
Hide file tree
Showing 15 changed files with 1,300 additions and 72 deletions.
2 changes: 1 addition & 1 deletion Assets/GFX/Shaders/FaWater.shader
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Shader "MapEditor/FaWater" {
//o.mScreenPos.xy /= o.mScreenPos.w;

o.mViewVec = mul (unity_ObjectToWorld, v.vertex).xyz - _WorldSpaceCameraPos;
//o.mViewVec = normalize(o.mViewVec);
o.mViewVec = normalize(o.mViewVec);
o.AddVar = float4(length(_WorldSpaceCameraPos - mul(unity_ObjectToWorld, v.vertex).xyz), 0, 0, 0);
float4 hpos = UnityObjectToClipPos (v.vertex);
o.grabUV = ComputeGrabScreenPos(hpos);
Expand Down
51 changes: 39 additions & 12 deletions Assets/GFX/Shaders/UnitShader.shader
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,39 @@ Shader "Custom/UnitShader" {
//_Metallic ("Metallic", Range(0,1)) = 0.0
}
SubShader {
Tags { "RenderType"="TransparentCutout" "Queue" = "Geometry" }
Tags { "RenderType"="TransparentCutout" "Queue" = "Transparent+2" }
LOD 200

CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf BlinnPhong addshadow
#pragma surface surf BlinnPhong vertex:vert addshadow

// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0

sampler2D _MainTex, _BumpMap, _SpecTeam;
struct Input {
float2 uv_MainTex;
float3 mViewVec : TEXCOORD5;
float3 worldNormal;
INTERNAL_DATA
};

//fixed4 _SunColor;
fixed4 _SunColor;
//fixed4 _SunAmbience;
//fixed4 _ShadowColor;


void vert(inout appdata_full v, out Input o) {
UNITY_INITIALIZE_OUTPUT(Input, o);
o.mViewVec = normalize(mul(unity_ObjectToWorld, v.vertex).xyz - _WorldSpaceCameraPos);
}

//half _Glossiness;
//half _Metallic;
fixed4 _Color;
uniform float3 SunDirection;
uniform samplerCUBE environmentSampler;

// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
Expand All @@ -50,28 +61,44 @@ Shader "Custom/UnitShader" {
return normal.xzy;
}

static const float3 NormalMappedPhongCoeff = float3(0.6, 0.80, 0.90);

void surf (Input IN, inout SurfaceOutput o) {





// Albedo comes from a texture tinted by color
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
fixed4 albedo = tex2D (_MainTex, IN.uv_MainTex);
fixed4 bump = tex2D(_BumpMap, IN.uv_MainTex);
//B -
//A -
o.Normal = UnpackNormalDXT5nm(bump);

o.Normal = UnpackNormalDXT5nm(bump);

fixed4 s = tex2D(_SpecTeam, IN.uv_MainTex);
float3 WorldSpaceNormal = WorldNormalVector(IN, o.Normal);

fixed4 specular = tex2D(_SpecTeam, IN.uv_MainTex);
//R
//G
//B -
//A - Team

float dotLightNormal = dot(SunDirection, o.Normal);

o.Albedo += s.a * _Color.rgb;
o.Specular = 1;
o.Gloss = 0.1;
o.Emission = s.b * 4 * c.rgb;

float3 environment = texCUBE(environmentSampler, reflect(-IN.mViewVec, WorldSpaceNormal));

float phongAmount = saturate(dot(reflect(SunDirection, WorldSpaceNormal), -IN.mViewVec));
float3 phongAdditive = NormalMappedPhongCoeff * pow(phongAmount, 2) * specular.g;
float3 phongMultiplicative = clamp(float3(environment * specular.r) * Luminance(_Color.rgb), 0, 2);

o.Albedo = lerp(_Color.rgb, albedo.rgb * 0.7, 1 - specular.a);

o.Specular = specular.g;
o.Gloss = 0.1;
o.Emission = specular.b * 4 * albedo.rgb + phongAdditive * 2 * _SunColor + phongMultiplicative;
//o.Emission = environment;
}
ENDCG
}
Expand Down
Loading

0 comments on commit 52b62e6

Please sign in to comment.