BoostColors

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
(C# - BloomEffect.cs)
Line 6: Line 6:
 
==Description==
 
==Description==
 
This simple image effect subtracts a certain amount of color from your rendering, then doubles the strength.
 
This simple image effect subtracts a certain amount of color from your rendering, then doubles the strength.
 +
[[Image:BoostColors.jpg|thumb|Example of the BoostColors image effect in action.]
  
 
==Usage==
 
==Usage==

Revision as of 23:17, 11 June 2006

Author: Nicholas Francis

Description

This simple image effect subtracts a certain amount of color from your rendering, then doubles the strength. [[Image:BoostColors.jpg|thumb|Example of the BoostColors image effect in action.]

Usage

This script (and all image effects) use render textures by need and therefore require Unity Pro. There isn't a way around this!

Simply attach this script to a Camera and watch your colors go off the radar.

C# - BloomEffect.cs

<csharp>using UnityEngine; using System.Collections;

[AddComponentMenu("Image Effects/Boost Colors")] public class BoostColors : MonoBehaviour { static Material s_BoostMaterial = null; public float blackLevel = .15f; // Update is called once per frame void OnRenderImage (RenderTexture source, RenderTexture dest) { if (!s_BoostMaterial) { s_BoostMaterial = new Material ( "Shader \"\" {" + " Properties {" + " _Color (\"Color\", Color) = (.3,.3,.3,.3)" + " _RTex (\"RenderTex\", RECT) = \"\" {}" + " }" + " SubShader {" + " Cull Off ZWrite Off ZTest Always" + " Pass {" + " SetTexture [_RTex] { constantColor [_Color] combine texture - constant DOUBLE }" + " }" + " }" + "}" ); } RenderTexture.active = dest; s_BoostMaterial.SetTexture ("_RTex", source); s_BoostMaterial.SetColor ("_Color", new Color (blackLevel,blackLevel,blackLevel,blackLevel)); s_BoostMaterial.SetPass (0); // Part one: Render a white alpha quad behind GL.PushMatrix (); GL.LoadOrtho ();

GL.Begin (GL.QUADS); GL.TexCoord2 (0,0); GL.Vertex3 (0,0,1); GL.TexCoord2 (1,0); GL.Vertex3 (1,0,1); GL.TexCoord2 (1,1); GL.Vertex3 (1,1,1); GL.TexCoord2 (0,1); GL.Vertex3 (0,1,1); GL.End (); GL.PopMatrix (); } } </csharp>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox