zoukankan      html  css  js  c++  java
  • Phone Shader

    //UI interface
    float4 AmbientColor : Ambient
    <
      string UIName = "Ambient";
    > = (0.25f,0.25f,0.25f,0.1f);

    float4 DiffuseColor : Diffuse
    <
      string UIName = "Diffuse";
    > = (0.25f,0.25f,0.25f,0.1f);

    texture diffuseMap : DiffuseMap
    <
       string name = "defaut";
       string UIName = "Diffuse Textrue";
       string TextureType = "2D";
    >;
    texture normalMap : NormalMap
    <
        string name = "default_bump_normal.dds";
     string UIName = "Normal Map";
        string TextureType = "2D";
    >;


    float4 light1Pos : POSITION
    <
     string UIName = "Light Position";
     string Object = "PointLight";
     string Space = "World";
     int refID = 0;
    > = {100.0f, 100.0f, 100.0f, 0.0f};

    float4 light1Color : LIGHTCOLOR
    <
     int LightRef = 0;
    > = { 1.0f, 1.0f, 1.0f, 0.0f };

    /****************************************************/
    /********** SAMPLERS ********************************/
    /****************************************************/

    sampler2D diffuseMapSampler = sampler_state
    {
     Texture = <diffuseMap>;
     MinFilter = Linear;
     MagFilter = Linear;
     MipFilter = Anisotropic;
     ADDRESSU = WRAP;
        ADDRESSV = WRAP;
    };

    sampler2D normalMapSampler = sampler_state
    {
     Texture = <normalMap>;
     MinFilter = Linear;
     MagFilter = Linear;
     MipFilter = Anisotropic;
     ADDRESSU = WRAP;
        ADDRESSV = WRAP;
    };

    float4x4 WorldViewProj : WorldViewProjection< string UIWidget = "None"; >;
    float4x4 World      :   WORLD< string UIWidget = "None"; >;


    struct VS_out
    {
     float4 oposition : POSITION;
     float3 onormal : NORMAL;
     float2 otexcoord : TEXCOORD0;
     float4 diffuse     : COLOR;
    };

    struct VS_IN
    {
     float4 position : POSITION;
     float3 texcoord : TEXCOORD0;
     float3 normal :NORMAL;
     float2 Norm : NORMAL;
    };

    /**************************************/
    /***** VERTEX SHADER ******************/
    /**************************************/

    VS_out mainVS(VS_IN Input)
    {
     VS_out Output =(VS_out)0;
     
     Output.oposition = mul(Input.position, WorldViewProj);// transform vert position to homogeneous clip space
     Output.otexcoord = Input.texcoord;
     
        float3 worldSpacePos = mul(Input.position, World);
     float3 L = normalize(light1Pos - worldSpacePos);
     float3 N = normalize(Input.normal);
     float diffuseLight = max(dot(N,L),0);
     
     Output.diffuse = diffuseLight;
     return Output; 
    }

    /**************************************/
    /***** PIXEL SHADER *******************/
    /**************************************/

    float4 mainPS(VS_out PS_Input) : COLOR
    {
     float4 ColorTexture = tex2D(diffuseMapSampler,PS_Input.otexcoord);
     float4 diffuse = PS_Input.diffuse*ColorTexture*DiffuseColor*light1Color;
     return  AmbientColor+diffuse;
    }

    technique technique0
    {
     pass p0
     {
      ZEnable = true;
         ZWriteEnable = true;
          CullMode = cw;
         AlphaBlendEnable = false;
      VertexShader = compile vs_3_0 mainVS();
      PixelShader = compile ps_3_0 mainPS();
     }
    }

  • 相关阅读:
    DJANGO入门系列之(模型层:跨表操作)
    DJANGO入门系列之(模型层:单表操作)
    DJANGO入门系列之(模板层)
    DJANGO入门系列之(视图层)
    DJANGO入门系列之(模板层的简单介绍和视图层的扫尾)
    DJANGO入门系列之(虚拟环境的配置与安装)
    Django入门系列之(视图层基本概念)
    DJANGO入门系列之(路由控制)
    DJANGO入门系列之(Django请求生命周期and路由层)
    orm
  • 原文地址:https://www.cnblogs.com/softimagewht/p/2099024.html
Copyright © 2011-2022 走看看