public SSF FS(SSV2F v) { SSF o = new SSF(); foreach (PointLight item in Lighting.PointLights) { Vector3 i = item.Position - v.WorldPosition; //Vector3 re = Vector3.Normalize(ShaderMath.GetReflection(i, v.Normal)); Vector3 view = Vector3.Normalize(Matrixs.CameraPosition - v.WorldPosition); Vector3 h = Vector3.Normalize(view + i); //Phong //o.Color += ShaderMath.ColorMul(item.Color, Spscular) * MathF.Pow(ShaderMath.Max(0, Vector3.Dot(re, view)), Gloss); //Blinn-Phong o.Color += ShaderMath.ColorMul(item.Color, Spscular) * MathF.Pow(ShaderMath.Max(0, Vector3.Dot(v.Normal, h)), Gloss); //Diffuse o.Color += item.Color * Diffuse * ShaderMath.Max(0, Vector3.Dot(v.Normal, i)); } o.Color += Lighting.AmbientColor; //Console.WriteLine(o.Color); o.Color = ShaderMath.ColorMul(o.Color, Tex.Value(v.UV)); return(o); }
public VSOutput VS(VSInput input) { return(new VSOutput() { Position = ShaderMath.Mul(Matrixs.MVP, new Vector4(input.Position, 1)), Color = input.Color }); }
public V2F VS(A2V a) { return(new V2F() { Position = ShaderMath.Mul(Matrixs.MVP, new Vector4(a.Position, 1)), UV = a.UV }); }
public V2F VS(A2V a) { Vector4 pos = ShaderMath.Mul(Matrixs.Entity2World, new Vector4(a.Position, 1)); return(new V2F { Position = ShaderMath.Mul(Matrixs.MVP, new Vector4(a.Position, 1)), WorldPosition = new Vector3(pos.X, pos.Y, pos.Z), Normal = Vector3.Normalize(ShaderMath.Mul(Matrixs.Entity2World, a.Normal)), }); }
// Start is called before the first frame update void Start() { Debug.Log(ShaderMath.fract(10.12345f)); Debug.Log(ShaderMath.smoothstep(-1.0f, 1.0f, 0.5f)); Debug.Log(ShaderMath.step(3.3f, 1.0f)); Assert.IsTrue((ShaderMath.step(0.2f, 1.0f) == 1f), "should be 1"); Assert.IsTrue((ShaderMath.step(1.0f, 1.0f) == 1f), "should be 1"); Assert.IsTrue((ShaderMath.step(1.1f, 1.0f) == 0f), "should be 0"); Debug.Log(ShaderMath.mix(-0.2f, 0.3f, 0.5f)); Debug.Log(ShaderMath.mix(new Vector3(-0.5f, -0.5f, -0.5f), new Vector3(1f, 1f, 1f), 0.5f)); }
public SSV2F VS(SSA2V a) { Vector4 pos = ShaderMath.Mul(Matrixs.Entity2World, a.Position.XYZ1()); Matrix3x3 rotation = new Matrix3x3(a.Tangent, a.Bitangent, a.Normal); return(new SSV2F { Position = ShaderMath.Mul(Matrixs.MVP, a.Position.XYZ1()), WorldPosition = new Vector3(pos.X, pos.Y, pos.Z), Normal = Vector3.Normalize(ShaderMath.Mul(Matrixs.Entity2World, a.Normal)), UV = a.UV, }); }
private void AnimationTest() { float t = ShaderMath.mod(m_Time, 5f); float sc = 0.0f; sc += ShaderEasings.cubicInOut(ShaderMath.scene(t, 1.0f, 0.7f)) * 1.5f; sc -= ShaderEasings.cubicInOut(ShaderMath.scene(t, 4.0f, 0.7f)) * 1.5f; //Debug.Log(sc); Vector3 pos = m_target.transform.position; pos.x = sc; m_target.transform.position = pos; }
// Update is called once per frame void Update() { m_Time += Time.deltaTime; int ind = 0; for (float y = 2f; y <= 7f; y++) { for (float x = 2f; x <= 7f; x++) { if (ind < m_List.Count) { Vector2 n = ShaderMath.N22(new Vector2(x, y)) * 2f; Vector2 p = new Vector2(Mathf.Sin(n.x * m_Time), Mathf.Sin(n.y * m_Time)); GameObject go = m_List[ind]; Vector3 pos = go.transform.position; pos.x = p.x; pos.y = p.y; go.transform.position = pos; } ind++; } } }