Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block to combine with a solid colour using standard blend modes #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Editor/Blocks/Color.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

100 changes: 100 additions & 0 deletions Editor/Blocks/Color/ColorBlend.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace UnityEditor.VFX.Block
{
[VFXInfo(category = "Color")]
class ColorBlend : VFXBlock
{

public enum BlendMode
{
Darken,
Multiply,
ColorBurn,
LinearBurn,
Lighten,
Screen,
ColorDodge,
LinearDodge,
Overlay,
SoftLight,
HardLight,
VividLight,
LinearLight,
PinLight,
Difference,
Exclusion
}

[SerializeField, VFXSetting, Tooltip("The blend mode to use")]
private BlendMode blendMode = BlendMode.Screen;

public override string name {get{return "Color Blend";}}
public override VFXContextType compatibleContexts {get{return VFXContextType.kInitAndUpdateAndOutput;}}
public override VFXDataType compatibleData {get{return VFXDataType.kParticle;}}

public class InputProperties
{
public Color blendColor;
}



public override IEnumerable<VFXAttributeInfo> attributes
{
get
{
yield return new VFXAttributeInfo(VFXAttribute.Color, VFXAttributeMode.ReadWrite);
}
}


public override string source
{
get
{
switch (blendMode)
{
case BlendMode.Darken:
return @"color = min(blendColor,color);";
case BlendMode.Multiply:
return @"color = blendColor * color;";
case BlendMode.ColorBurn:
return @"color = 1.0 - (1.0-blendColor) / color;";
case BlendMode.LinearBurn:
return @"color = blendColor + color - 1.0;";
case BlendMode.Lighten:
return @"color = max(blendColor,color);";
case BlendMode.Screen:
return @"color = 1.0 - (1.0-blendColor) * (1.0-color);";
case BlendMode.ColorDodge:
return @"color = blendColor / (1.0-color);";
case BlendMode.LinearDodge:
return @"color = blendColor + color;";
case BlendMode.Overlay:
return @"color = (blendColor > 0.5) * (1.0 - (1.0-2.0*(blendColor-0.5)) * (1.0-color)) + (blendColor <= 0.5) * ((2.0*blendColor) * color);";
case BlendMode.SoftLight:
return @"color = (color > 0.5) * (1.0 - (1.0-blendColor) * (1.0-(color-0.5))) + (color <= 0.5) * (blendColor * (color+0.5));";
case BlendMode.HardLight:
return @"color = (color > 0.5) * (1.0 - (1.0-blendColor) * (1.0-2.0*(color-0.5))) + (color <= 0.5) * (blendColor * (2.0*color));";
case BlendMode.VividLight:
return @"color = (color > 0.5) * (1.0 - (1.0-blendColor) / (2.0*(color-0.5))) + (color <= 0.5) * (blendColor / (1.0-2.0*color));";
case BlendMode.LinearLight:
return @"color = (color > 0.5) * (blendColor + 2.0*(color-0.5)) + (color <= 0.5) * (blendColor + 2.0*color - 1.0);";
case BlendMode.PinLight:
return @"color = (color > 0.5) * (max(blendColor,2.0*(color-0.5))) + (color <= 0.5) * (min(blendColor,2.0*color));";
case BlendMode.Difference:
return @"color = abs(blendColor - color);";
case BlendMode.Exclusion:
return @"color = 0.5 - 2.0*(blendColor-0.5)*(color-0.5);";
default:
return "";
}
}
}
}

}

11 changes: 11 additions & 0 deletions Editor/Blocks/Color/ColorBlend.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 6 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,16 @@
# Visual Effect Graph - Extras

Raw bunch of featre prototypes for use with Visual Effect Graph. Some probably broken, totally non-official and unsupported by Unity. Use at your own risk.
I forked https://github.com/peeweek/net.peeweek.vfxgraph-extras/ to allow me to easily experiment with my own custom blocks and nodes.

## Features
* Initial State (MonoBehaviour) : Enables the effect to start in a Stopped State.
* Blocks
* GPU Event : Spawn Rate (Over time or distance)
* Custom Code Block
* Position on Terrain
* Contexts
* Distortion Quad (HDRP)
* Operators
* Get Spawn Count
* Get Spawn Time (used with SetSpawnTime custom spawner)
* Custom Spawners
* Set Spawn Time
* Count over Time
* VFX Volume Mixer
* Volume Component to set up to 8 float, 8 vector3 and 8 colors
* Preferences to set the counts and names of every float, vector3 and color by project
* Parameter Binder for every property
* Parameter Binders
* Audio Spectrum to Map
* GameObject
* Hierarchy Attribute Map
* Velocity
* Previous Position
* Input
* Axis
* Button
* Mouse
* Keyboard
* Touch
* Terrain
* UI
* Toggle
* Slider

## Requirements

* Unity 2018.3
* Latest 4.x VisualEffectGraph package
* Latest 4.x HD Render Pipeline package

## Install

You can use a manual, local package installation if you need to alter the code locally or automate the fetch of the repository by using a git adress directly. The latter option shall download and manage automatically the repository, with the drawback of being read-only.

### Manual Version

* Clone repository somewhere of your liking
* Make sure your project is correctly configured with both HDRP and VFX Graph at correct revisions
* In your project, open the `Window/Package Manager` window and use the + button to select the `Add Package from Disk...` option.
* Navigate to your repository folder and select the `package.json` file
* The repository shall be added
See https://github.com/peeweek/net.peeweek.vfxgraph-extras/blob/master/README.md for the original notes. The last bit of the installation differs thus (updated urls and package names):

### Git reference version

* Make sure your project is correctly configured with both HDRP and VFX Graph at correct revisions
* With unity closed, edit the `Packages/manifest.json` with a text editor
* append the line ` "net.peeweek.vfxgraph-extras": "https://github.com/peeweek/net.peeweek.vfxgraph-extras.git",` under `dependencies`
* append the line ` "net.ixxy.vfxgraph-extras": "https://github.com/IxxyXR/net.ixxy.vfxgraph-extras.git",` under `dependencies`


### Additions:

Currently just a new block "Color/Color Blend" which supports Photoshop style blend modes.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "net.peeweek.vfxgraph-extras",
"displayName": "Visual Effect Graph (Extras)",
"name": "net.ixxy.vfxgraph-extras",
"displayName": "Ixxy Visual Effect Graph (Extras)",
"version": "0.0.1",
"unity": "2018.3",
"description": "Visual Effect Graph (Extras)"
}
}