- 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
I wrote a simple shader for Unity to make a stylized fog like Fire Watch's fog. The idea is to get a pixel on the texture depending on the pixel depth, if the fog is near, a pixel on the left on the texture uv will be picked, if the fog is far, a pixel on the right on the texture uv will be picked. Features Choose between a linear fog and an exponential fog Choose between a simple color or a texture Screenshots Video Source Code Image Effect Version (Unity 2017 and older if not using Stack) [+] Shader Shader "Hidden/Shader_StylizedFog" { Properties { _MainTex("Texture", 2D) = "white" {} _FogColor("Fog Color", Color) = (1, 1, 1, 1) _UseStylizedFogTexture("Use Stylized Fog Texture", Int) = 0 _StylizedFogTexture("Stylized Fog Texture", 2D) = "white" {} _FogMinDistance("Fog Min Distance", Float) = 0 _FogMaxDistance("Fog Max Distance",...
Today, I'll show you a good exercise I made to manipulate quaternions. In extra you got a 3C structure for a flight game. I chose to make a flight behavior because of rotation complexity. Today we always use physics to drive vehicles in video games, but this exercise is focused on quaternions manipulations, so all the behavior is driven by quaternions. Main Features: - Smooth TPS camera - Camera switch (FPS / TPS) - Auto replace character rotation: 3 different ways to smoothly reset character rotation (All Axis, Per Axis, None) Video Controls: - Z/S: pitch - Q/D: roll - Shift: boost - Left click / Right click: dodge left / right (lateral movement with roll as in some Star Wars video games) Download: - Download Windows standalone - Download Unity project
This comment has been removed by the author.
ReplyDelete