public Vector4 FS(FSIn input) { Vector4 outFragColor; Vector2 projCoord = ClipToTextureCoordinates(input.Position); // Slow single pass blur // For demonstration purposes only const float blurSize = 1f / 512f; Vector4 color = Sample(ColorMap, ColorMapSampler, input.UV); outFragColor = color * 0.25f; if (IsFrontFace) { // Only render mirrored scene on front facing (upper) side of mirror surface Vector4 reflection = new Vector4(0.0f); for (int x = -3; x <= 3; x++) { for (int y = -3; y <= 3; y++) { reflection += Sample( ReflectionMap, ReflectionMapSampler, new Vector2(projCoord.X + x * blurSize, projCoord.Y + y * blurSize)) / 49.0f; } } outFragColor += reflection * 1.5f * (color.X); } return(outFragColor); }
public Vector4 FS(FSIn input) { Vector3 Eye = Vector3.Normalize(-input.EyePos); Vector3 Reflected = Vector3.Normalize(Vector3.Reflect(-input.LightVec, input.Normal)); Vector4 IAmbient = new Vector4(0.1f, 0.1f, 0.1f, 1.0f); Vector4 IDiffuse = new Vector4(MathF.Max(Vector3.Dot(input.Normal, input.LightVec), 0f)); float specular = 0.75f; Vector4 ISpecular = new Vector4(0.0f); if (Vector3.Dot(input.EyePos, input.Normal) < 0.0) { ISpecular = new Vector4(0.5f, 0.5f, 0.5f, 1.0f) * MathF.Pow(MathF.Max(Vector3.Dot(Reflected, Eye), 0.0f), 16.0f) * specular; } return((IAmbient + IDiffuse) * new Vector4(input.Color, 1.0f) + ISpecular); }