Boat Attack使用了Universal RP的许多新图形功能,可以用于探索 Universal RP 的使用方式和技巧。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

1.7 KiB

Normal From Texture Node

Description

Converts a height map defined by input Texture into a normal map. UV values and sampler state can be defined by inputs UV and Sampler respectively. If nothing is connected to these ports they will use default values from the inputs. See Port Bindings for more information.

The strength of the created normal map can be defined by inputs Offset and Strength, where Offset defines the maximum distance of a normal detail and Strength acts as a multiplier to the result.

Ports

Name Direction Type Binding Description
Texture Input Texture None Height map
UV Input Vector 2 UV Texture coordinates
Sampler Input Sampler State None Sampler for Texture
Offset Input Vector 1 None Amount to offset samples
Strength Input Vector 1 None Strength multiplier
Out Output Vector 3 None Output value

Generated Code Example

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

void Unity_NormalFromTexture_float(Texture texture, SamplerState Sampler, float2 UV, float Offset, float Strength, out float3 Out)
{
    Offset = pow(Offset, 3) * 0.1;
    float2 offsetU = float2(UV.x + Offset, UV.y);
    float2 offsetV = float2(UV.x, UV.y + Offset);
    float normalSample = Texture.Sample(Sampler, UV);
    float uSample = Texture.Sample(Sampler, offsetU);
    float vSample = Texture.Sample(Sampler, offsetV);
    float3 va = float3(1, 0, (uSample - normalSample) * Strength);
    float3 vb = float3(0, 1, (vSample - normalSample) * Strength);
    Out = normalize(cross(va, vb));
}