zoukankan      html  css  js  c++  java
  • vertex shader must minimally write all four components of POSITION

    Though the POSITION semantic must be written out by the vertex shader, it cannot be read in by the pixel shader in ps_2_0. So, the fix is to write out the position twice, but one of those is not labeled as POSITION, it is instead labeled as a TEXCOORD0. Then, the pixel shader does not use the POSITION semantic variable, but uses the TEXCOORD0 instead. To the compiler it effectively means that the POSITION input to the pixel shader can be ignored.

    right code:

    float4x4 ViewProjection;

    struct VS_INPUT
    {
    float4 Position : POSITION0;
    float3 Normal : NORMAL0;
    float2 tcBase:TEXCOORD0;
    };

    struct VS_OUTPUT
    {
    float4 Position : POSITION0;
    float3 Normal : TEXCOORD1;
    float2 tcBase:TEXCOORD2;
    };

    }

    VS_OUTPUT vs_main( VS_INPUT Input )
    {
    VS_OUTPUT Output;

    Output.Position = mul( Input.Position, ViewProjection );
    Output.Normal = Input.Normal;
    Output.tcBase = Input.tcBase;
    return( Output );
    }

    sampler AmbOcclusion;
    sampler DiffuseEnvironment;

    struct PS_OUTPUT
    {
    float4 Position : TEXCOORD0;
    float3 Normal : TEXCOORD1;
    float2 tcBase:TEXCOORD2;
    };

    float4 ps_main(PS_OUTPUT Input) : COLOR0
    {
    // Sample the filtered environment map
    float4 ambient = texCUBE(DiffuseEnvironment, Input.Normal);

    // Sample the ambient occlusion map
    float ambientOcclusion = tex2D(AmbOcclusion, Input.tcBase).r;
    return ambient * ambientOcclusion;
    }

  • 相关阅读:
    Python 实现AEC CBC 加密解密方式
    redis 发布订阅方法与缺陷
    python paramiko 传输下载文件
    Redis 配置文件
    Redis 命令
    window11 | 虚拟机vmWare安装windows11
    十万个为什么 | 文化001-为什么猜灯谜又叫做打灯谜
    ffmpeg | 常用命令使用
    ffmpeg | 常用命令使用
    Adobe系列 | Animate(01)-软件安装
  • 原文地址:https://www.cnblogs.com/alps/p/7257282.html
Copyright © 2011-2022 走看看