You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.2 KiB
JavaScript
51 lines
1.2 KiB
JavaScript
1 month ago
|
|
||
|
#pragma strict
|
||
|
|
||
|
@script ExecuteInEditMode
|
||
|
@script RequireComponent (Camera)
|
||
|
@script AddComponentMenu ("Image Effects/Screen Overlay")
|
||
|
|
||
|
class ScreenOverlay extends PostEffectsBase {
|
||
|
|
||
|
enum OverlayBlendMode {
|
||
|
AddSub = 0,
|
||
|
ScreenBlend = 1,
|
||
|
Multiply = 2,
|
||
|
Overlay = 3,
|
||
|
AlphaBlend = 4,
|
||
|
}
|
||
|
|
||
|
public var blendMode : OverlayBlendMode = OverlayBlendMode.Overlay;
|
||
|
public var intensity : float = 1.0f;
|
||
|
public var texture : Texture2D;
|
||
|
|
||
|
public var overlayShader : Shader;
|
||
|
|
||
|
private var overlayMaterial : Material = null;
|
||
|
|
||
|
function OnDisable()
|
||
|
{
|
||
|
if (overlayMaterial)
|
||
|
DestroyImmediate(overlayMaterial);
|
||
|
}
|
||
|
|
||
|
function CheckResources () : boolean {
|
||
|
CheckSupport (false);
|
||
|
|
||
|
overlayMaterial = CheckShaderAndCreateMaterial (overlayShader, overlayMaterial);
|
||
|
|
||
|
if(!isSupported)
|
||
|
ReportAutoDisable ();
|
||
|
return isSupported;
|
||
|
}
|
||
|
|
||
|
function OnRenderImage (source : RenderTexture, destination : RenderTexture) {
|
||
|
if(CheckResources()==false) {
|
||
|
Graphics.Blit (source, destination);
|
||
|
return;
|
||
|
}
|
||
|
overlayMaterial.SetFloat ("_Intensity", intensity);
|
||
|
overlayMaterial.SetTexture ("_Overlay", texture);
|
||
|
Graphics.Blit (source, destination, overlayMaterial, blendMode);
|
||
|
}
|
||
|
}
|