Рубрики
Surface

SurfaceOutputStandardSpecular

[post10644 surface]

struct SurfaceOutputStandardSpecular
{
    fixed3 Albedo;      // diffuse color
    fixed3 Specular;    // specular color
    fixed3 Normal;      // tangent space normal, if written
    half3 Emission;
    half Smoothness;    // 0=rough, 1=smooth
    half Occlusion;     // occlusion (default 1)
    fixed Alpha;        // alpha for transparencies
};
Рубрики
Standard Surface

SurfaceOutputStandard

  • выходная структура поверхностного шейдера
    встроенный код HLSL

[post10644 surface]

struct SurfaceOutputStandard

{
    fixed3 Albedo;      // base (diffuse or specular) color
    fixed3 Normal;      // tangent space normal, if written
    half3 Emission;
    half Metallic;      // 0=non-metal, 1=metal
    half Smoothness;    // 0=rough, 1=smooth
    half Occlusion;     // occlusion (default 1)
    fixed Alpha;        // alpha for transparencies
};
Рубрики
Custom Surface

«Объект красного цвета»

[post10644 surfaceshader]

#pragma surface surf Standard
Shader "Custom/SH_surf"
{
    SubShader
    {
        CGPROGRAM
        #pragma surface surf Standard
        sampler2D _MainTex;

        struct Input
        {
            float3 color : RED;
        };
        void surf (Input IN, inout SurfaceOutputStandard o)
        {
            o.Albedo = IN.color;
            o.Alpha = 1;
        }
        ENDCG
    }
}
Рубрики
ShaderLab Surface

#pragma surface

Поверхностный шейдер

#pragma surface <surface function> <lighting model> <optional parameters>
  • <surface function> своя процедура отрисовки поверхности

[post10604 pragma]

[post10639 lightingmodel]

Рубрики
CgFx Examples "ShaderLab (CgFx,HLSL)" HLSL Surface Texture Unity

Шейдер «Срез Текстуры»

Shader "Custom/World/Cut"
{
    Properties
    {
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
	_pov("pov", int) = 0
        _pos("Vector",vector) = (0,0,0,0)
    }
    SubShader
    {
    CGPROGRAM
    //surface
    #pragma surface surf Lambert
    //model
    #pragma target 3.0
    //vars
    sampler2D _MainTex;

    int _pov;
    fixed4 _pos;

    struct Input
    {
        float2 uv_MainTex;
        float3 worldPos;
    };

    void surf(Input IN, inout SurfaceOutput o)
    {
        switch (_pov)
        {
        case 0:
            clip(IN.worldPos.z > _pos.z ? 1 : -1);
            break;
        case 1:
            clip(IN.worldPos.x < _pos.x ? 1 : -1);
            break;
        case 2:
            clip(IN.worldPos.z > _pos.z ? 1 : -1);
            break;
        case 3:
            clip(IN.worldPos.x < _pos.x ? 1 : -1);
            break;
        }

        o.Albedo = tex2D(_MainTex, IN.uv_MainTex).rgb;
    }
    ENDCG
}
FallBack "Diffuse"
}