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();
     }
    }

  • 相关阅读:
    thinkphp在wamp 配置去掉url中index.php方法
    mysql新监语句需要前面加SET FOREIGN_KEY_CHECKS=0;
    ini_set的用法介绍
    SpringBoot项目启动报错:java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    我的分享:第八章: 用Redis轻松实现秒杀系统
    项目分享:第一章:个人电商项目
    SpringBoot框架:第二章:SpringBoot中static和templates二个目录下的页面和静态资源访问的三个常见问题
    我的分析:第八章:JAVA高级工程师知识点
    Springboot项目启动报org.springframework.beans.factory.UnsatisfiedDependencyException
    Disconnected from the target VM, address: '127.0.0.1:56577', transport: 'socket'
  • 原文地址:https://www.cnblogs.com/softimagewht/p/2099024.html
Copyright © 2011-2022 走看看