unity 之 ShaderGraph 三

Artistic Nodes

Adjustment

Channel MixerContrast
Image
 控制输入颜色的每个通道,相当于调节每个通道的值调节对比度
HueInvert Colors
Image
 调节色调偏移,根据range的不同模式在每个通道的基础上反转输入的颜色。
Replace ColorSaturation
ImageImage

 把输入的颜色在form和to之间转换,具体转换成哪个颜色,

根据range来控制,就相当于渐变,fuzziness是羽化,就是边缘模糊

调节饱和度
White Balance 
Image 
 白平衡,调节色温色调 

Blend

Blend
Image
把输入的blend和base混合起来

Filter

Dither
Image
 产生随机噪点,也就i是随机的颜色

Mask

Channel MaskColor Mask
Image
 选定通道的遮罩值为输入值创建一个颜色遮罩

Normal

Normal BlendNormal From Height
Image
 混合ab的法线从输入贴图的高度映射纹理上创建一个法线贴图
Normal StrengthNormal Unpack
ImageImage
 调节法线的强度解压输入的法线映射

Utility

Colorspace Conversion
 返回输入颜色从一个颜色空间转换到另一个颜色空间色结果

 

 

Channel Mixer Node

Image

调节每一个通道的值. 滑块控制同导致在-2到2之间.RGB开关表示输出的控制的是哪个通道

Ports

NameDirectionTypeBindingDescription
InInputVector 3NoneInput value
OutOutputVector 3NoneOutput value

Controls

NameTypeOptionsDescription
 Toggle Button ArrayR, G, BSelects the output channel to edit.
RSlider Controls contribution of input red channel to selected output channel.
GSlider Controls contribution of input green channel to selected output channel.
BSlider Controls contribution of input blue channel to selected output channel.

Shader Function

Generated Code Example

_ChannelMixer_Red = float3 (OutRedInRed, OutRedInGreen, OutRedInBlue);
_ChannelMixer_Green = float3 (OutGreenInRed, OutGreenInGreen, OutGreenInBlue);
_ChannelMixer_Blue = float3 (OutBlueInRed, OutBlueInGreen, OutBlueInBlue);

void Unity_ChannelMixer_float(float3 In, float3 _ChannelMixer_Red, float3 _ChannelMixer_Green, float3 _ChannelMixer_Blue, out float3 Out)
{
    Out = float3(dot(In, _ChannelMixer_Red), dot(In, _ChannelMixer_Green), dot(In, _ChannelMixer_Blue));
}

Contrast Node

  调节对比度,contrast为1时表示和原图一样,为0时表示是原来对比度的一半

Ports

NameDirectionTypeBindingDescription
InInputVector 3NoneInput value
ContrastInputVector 1NoneContrast value
OutOutputVector 3NoneOutput value

Generated Code Example

The following example code represents one possible outcome of this node.

void Unity_Contrast_float(float3 In, float Contrast, out float3 Out)
{
    float midpoint = pow(0.5, 2.2);
    Out = (In - midpoint) * Contrast + midpoint;
}

 

Hue Node

 根据range的模式控制该模式下的色调偏移,就像加了一个颜色滤镜一样. Degrees 在-180 to 180. Radians it is -Pi to Pi.

Ports

NameDirectionTypeBindingDescription
InInputVector 3NoneInput value
OffsetInputVector 1NoneAmount to offset hue
OutOutputVector 3NoneOutput value

Controls

NameTypeOptionsDescription
RangeDropdownDegrees, RadiansThe unit used for the input Offset

Generated Code Example

The following example code represents one possible outcome of this node per Base mode.

Degrees

void Unity_Hue_Degrees_float(float3 In, float Offset, out float3 Out)
{
    float4 K = float4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
    float4 P = lerp(float4(In.bg, K.wz), float4(In.gb, K.xy), step(In.b, In.g));
    float4 Q = lerp(float4(P.xyw, In.r), float4(In.r, P.yzx), step(P.x, In.r));
    float D = Q.x - min(Q.w, Q.y);
    float E = 1e-10;
    float3 hsv = float3(abs(Q.z + (Q.w - Q.y)/(6.0 * D + E)), D / (Q.x + E), Q.x);

    float hue = hsv.x + Offset / 360;
    hsv.x = (hue < 0)
            ? hue + 1
            : (hue > 1)
                ? hue - 1
                : hue;

    float4 K2 = float4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
    float3 P2 = abs(frac(hsv.xxx + K2.xyz) * 6.0 - K2.www);
    Out = hsv.z * lerp(K2.xxx, saturate(P2 - K2.xxx), hsv.y);
}

Radians

void Unity_Hue_Radians_float(float3 In, float Offset, out float3 Out)
{
    float4 K = float4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
    float4 P = lerp(float4(In.bg, K.wz), float4(In.gb, K.xy), step(In.b, In.g));
    float4 Q = lerp(float4(P.xyw, In.r), float4(In.r, P.yzx), step(P.x, In.r));
    float D = Q.x - min(Q.w, Q.y);
    float E = 1e-10;
    float3 hsv = float3(abs(Q.z + (Q.w - Q.y)/(6.0 * D + E)), D / (Q.x + E), Q.x);

    float hue = hsv.x + Offset;
    hsv.x = (hue < 0)
            ? hue + 1
            : (hue > 1)
                ? hue - 1
                : hue;

    // HSV to RGB
    float4 K2 = float4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
    float3 P2 = abs(frac(hsv.xxx + K2.xyz) * 6.0 - K2.www);
    Out = hsv.z * lerp(K2.xxx, saturate(P2 - K2.xxx), hsv.y);
}

Invert Colors Node

Image

 基于各个通道的反转颜色. 此节点假设所有输入值都在0 - 1范围内。相当于ps里面的只使用单通道

Ports

NameDirectionTypeBindingDescription
InInputDynamic Vector:vector可以是1.2.3.4维的NoneInput value
OutOutputDynamic VectorNoneOutput value

Controls

NameTypeOptionsDescription
RedToggleTrue, FalseIf true red channel is inverted
GreenToggleTrue, FalseIf true green channel is inverted. Disabled if input vector dimension is less than 2
BlueToggleTrue, FalseIf true blue channel is inverted. Disabled if input vector dimension is less than 3
AlphaToggleTrue, FalseIf true alpha channel is inverted. Disabled if input vector dimension is less than 4

Generated Code Example

The following example code represents one possible outcome of this node.

float2 _InvertColors_InvertColors = float4(Red, Green, Blue, Alpha);

void Unity_InvertColors_float4(float4 In, float4 InvertColors, out float4 Out)
{
    Out = abs(InvertColors - In);
}

 

Replace Color Node

Image

Image

 把输入的值中含有的from替换为to. Range 是替换的范围.  Fuzziness边缘羽化

Ports

NameDirectionTypeBindingDescription
InInputVector 3NoneInput value
FromInputVector 3ColorColor to replace
ToInputVector 3ColorColor to replace with
RangeInputVector 1NoneReplace colors within this range from input From
FuzzinessInputVector 1NoneSoften edges around selection
OutOutputVector 3NoneOutput value

Generated Code Example

The following example code represents one possible outcome of this node.

void Unity_ReplaceColor_float(float3 In, float3 From, float3 To, float Range, float Fuzziness, out float3 Out)
{
    float Distance = distance(From, In);
    Out = lerp(To, In, saturate((Distance - Range) / max(Fuzziness, e-f)));
}

Saturation Node

Image

调节饱和度,1代表和原图一样,0代表没有饱和度,可以乘以一个数,增加饱和度

Ports

NameDirectionTypeBindingDescription
InInputVector 3NoneInput value
SaturationInputVector 1NoneSaturation value
OutOutputVector 3NoneOutput value

Generated Code Example

The following example code represents one possible outcome of this node.

void Unity_Saturation_float(float3 In, float Saturation, out float3 Out)
{
    float luma = dot(In, float3(0.2126729, 0.7151522, 0.0721750));
    Out =  luma.xxx + Saturation.xxx * (In - luma.xxx);
}

 

White Balance Node

Image

 调节色温和色调. Temperature 影响的是黄色和蓝色yellow or blue. Tint 影响的是粉红色和绿色 pink or green.

Ports

NameDirectionTypeBindingDescription
InInputVector 3NoneInput value
TemperatureInputVector 1NoneTemperature offset value
TintInputVector 1NoneTint offset value
OutOutputVector 3NoneOutput value

Generated Code Example

The following example code represents one possible outcome of this node.

void Unity_WhiteBalance_float(float3 In, float Temperature, float Tint, out float3 Out)
{
    // Range ~[-1.67;1.67] works best
    float t1 = Temperature * 10 / 6;
    float t2 = Tint * 10 / 6;

    // Get the CIE xy chromaticity of the reference white point.
    // Note: 0.31271 = x value on the D65 white point
    float x = 0.31271 - t1 * (t1 < 0 ? 0.1 : 0.05);
    float standardIlluminantY = 2.87 * x - 3 * x * x - 0.27509507;
    float y = standardIlluminantY + t2 * 0.05;

    // Calculate the coefficients in the LMS space.
    float3 w1 = float3(0.949237, 1.03542, 1.08728); // D65 white point

    // CIExyToLMS
    float Y = 1;
    float X = Y * x / y;
    float Z = Y * (1 - x - y) / y;
    float L = 0.7328 * X + 0.4296 * Y - 0.1624 * Z;
    float M = -0.7036 * X + 1.6975 * Y + 0.0061 * Z;
    float S = 0.0030 * X + 0.0136 * Y + 0.9834 * Z;
    float3 w2 = float3(L, M, S);

    float3 balance = float3(w1.x / w2.x, w1.y / w2.y, w1.z / w2.z);

    float3x3 LIN_2_LMS_MAT = {
        3.90405e-1, 5.49941e-1, 8.92632e-3,
        7.08416e-2, 9.63172e-1, 1.35775e-3,
        2.31082e-2, 1.28021e-1, 9.36245e-1
    };

    float3x3 LMS_2_LIN_MAT = {
        2.85847e+0, -1.62879e+0, -2.48910e-2,
        -2.10182e-1,  1.15820e+0,  3.24281e-4,
        -4.18120e-2, -1.18169e-1,  1.06867e+0
    };

    float3 lms = mul(LIN_2_LMS_MAT, In);
    lms *= balance;
    Out = mul(LMS_2_LIN_MAT, lms);
}

 

Blend Node

Description

把Blend 根据不同的混合模式混合进BaseOpacity控制混合的强度,为0时,表示没有混合,显示的是base的颜色

Ports

NameDirectionTypeBindingDescription
BaseInputDynamic VectorNoneBase layer value
BlendInputDynamic VectorNoneBlend layer value
OpacityInputVector 1NoneStrength of blend
OutOutputDynamic VectorNoneOutput value

Controls

NameTypeOptionsDescription
ModeDropdownBurn, Darken, Difference, Dodge, Divide, Exclusion, HardLight, HardMix, Lighten, LinearBurn, LinearDodge, LinearLight, LinearLightAddSub, Multiply, Negation, Overlay, PinLight, Screen, SoftLight, Subtract, VividLight, OverwriteBlend mode to apply

Dither Node

Dither 是一种用于随机量化误差的噪声. Dither 使用 screen-space 确保均衡分配噪点. 可以通过 Screen Position调节,通常作为 Alpha Clip Threshold 输入节点,给物体一个随机的透明度显示. 它对于创建看起来透明但具有呈现为不透明的优势的对象很有用,比如写入深度和/或延迟呈现。

Ports

NameDirectionTypeBindingDescription
InInputDynamic VectorNoneInput value
Screen PositionInputVector 4Screen PositionCoordinates used to apply dither pattern
OutOutputDynamic VectorNoneOutput value

Generated Code Example

The following example code represents one possible outcome of this node.

void Unity_Dither_float4(float4 In, float4 ScreenPosition, out float4 Out)
{
    float2 uv = ScreenPosition.xy * _ScreenParams.xy;
    float DITHER_THRESHOLDS[16] =
    {
        1.0 / 17.0,  9.0 / 17.0,  3.0 / 17.0, 11.0 / 17.0,
        13.0 / 17.0,  5.0 / 17.0, 15.0 / 17.0,  7.0 / 17.0,
        4.0 / 17.0, 12.0 / 17.0,  2.0 / 17.0, 10.0 / 17.0,
        16.0 / 17.0,  8.0 / 17.0, 14.0 / 17.0,  6.0 / 17.0
    };
    uint index = (uint(uv.x) % 4) * 4 + uint(uv.y) % 4;
    Out = In - DITHER_THRESHOLDS[index];
}

 

Channel Mask Node

 选定通道的遮罩值.如果遮罩值为everything的话,就相当于没有遮罩

Ports

NameDirectionTypeBindingDescription
InInputDynamic VectorNoneInput value
OutOutputDynamic VectorNoneOutput value

Controls

NameTypeOptionsDescription
ChannelsMask DropdownDynamic选择要屏蔽的任何数量的通道

Generated Code Example

The following example code represents one possible outcome of this node.

void Unity_ChannelMask_RedGreen_float4(float4 In, out float4 Out)
{
    Out = float4(0, 0, In.b, In.a);
}

Color Mask Node

 没那么简单,看效果就好像是变成黑白通道了,不过可以做消隐效果,range是滤镜的范围或者强度.Fuzziness 羽化边缘

Ports

NameDirectionTypeBindingDescription
InInputVector 3NoneInput value.
Mask ColorInputVector 3ColorColor to use for mask.
RangeInputVector 1NoneSelect colors within this range from input Mask Color.
FuzzinessInputVector 1NoneFeather edges around selection. Higher values result in a softer selection mask.
OutOutputVector 1NoneOutput mask value.

Generated Code Example

The following example code represents one possible outcome of this node.

void Unity_ColorMask_float(float3 In, float3 MaskColor, float Range, float Fuzziness, out float4 Out)
{
    float Distance = distance(MaskColor, In);
    Out = saturate(1 - (Distance - Range) / max(Fuzziness, 1e-5));
}

 

Colorspace Conversion Node

把一个颜色从一个颜色空间转换到另一个颜色空间

Ports

NameDirectionTypeDescription
InInputVector 3Input value
OutOutputVector 3Output value

Controls

NameTypeOptionsDescription
FromDropdownRGB, Linear, HSVSelects the colorspace to convert from
ToDropdownRGB, Linear, HSVSelects the colorspace to convert to
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

TO_ZRG

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值