- Scene diffuse (unlit) and scene color (lit) buffer are blended, allow to see in the complete dark while still having luminance difference on pixel affected by lights
- Option to have pixels with high luminance tending toward white
fixed4 frag (v2f i) : SV_Target { // Get pixel color fixed4 col = tex2D(_MainTex, i.uv); fixed4 diffuse = tex2D(_CameraGBufferTexture0, i.uv); // Diffuse RGB, Occlusion A fixed4 nakedColor = col;
// Scene color - Keep only luminance fixed luminance = (col.r + col.g + col.b) * 0.333f; col.rgb = fixed3(luminance, luminance, luminance);
// GBuffer - Keep only luminance float diffuseLuminance = (diffuse.r + diffuse.g + diffuse.b) * 0.333f; diffuse.rgb = fixed3(diffuseLuminance, diffuseLuminance, diffuseLuminance); // Blend scene color with GBuffer to keep luminance when no light still preserving light col = lerp(diffuse, col * _LightSensitivity, luminance);
// Colorize pixel with a constant color col *= _ColorTint; // Blend high luminance pixel with white to empower the luminance if (luminance > _LightWhiteTreshold) col.rgb = lerp(col.rgb, fixed3(1, 1, 1) * _LightWhitePower, luminance);
public class ImageEffect_Generic : MonoBehaviour
{
#region MonoBehaviour Methods
// Use this for initialization
private void Start()
{
}
// Update is called once per frame
private void Update()
{
}
/// <summary>
/// Called when image is renderer for graphics
/// </summary>
/// <param name="_Source">Source image</param>
/// <param name="_Destination">Destination Image</param>
private void OnRenderImage(RenderTexture _Source, RenderTexture _Destination)
{
// Set the image to draw
Graphics.Blit(_Source, _Destination, m_Material);
}
#endregion
#region Attributes
[SerializeField]
public Material m_Material = null;
#endregion
}
Put the image effect script on your camera and make a material using the night vision shader. Then you just have to modify the material parameter and to enjoy it.
Note that Unity 2018 works with stack and it needs some modifications to works with stack: https://github.com/Unity-Technologies/PostProcessing/wiki/Writing-Custom-Effects
What is FPS Maker FPS Maker is a FPS game engine with no coding knowledge requirements designed for absolute newbies in game development, it looks like more a game with its own map editor. FPS Maker is written in C++ and uses Irrlicht for the rendering part and OpenAL for the audio part. I started working on it 3 months ago, of course it is still under development and my free time will be highly shortened soon, so progress will be slow but I will try to add/improve features depending on my free time. So this is how FPS Maker looks like for now, hoping I will have enough time to post updates. Main Features Editor Map editing Play current map from editor Build game in a standalone format Tile based navigation graph generation (automatic) Browse custom game assets Game Basic FPS 3C Weapons AI based on state machines Path finding based on A* algorithm Batching for static geometry Dynamic per pixel lighting (using a custom shader, not the Irrlicht built
This is a post process material I've done on Unreal 4 on my free time. To make this rendering, this is what I did: Post process material must be rendered before tone mapping to get "hard edge" on light radius attenuation Original image is desaturated to black and white Color masking, here color close enough to red is excluded from desaturation Image tresholding to keep pixels of a luminance under a predefined step black, the others become white Outline effect Sobel operator used to detect edges Keep only hard enough edge using tresholding again Edges lit by a light are blacks, others are white
This comment has been removed by the author.
ReplyDelete