博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
vertex shader must minimally write all four components of POSITION
阅读量:5952 次
发布时间:2019-06-19

本文共 1363 字,大约阅读时间需要 4 分钟。

 

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

 

转载于:https://www.cnblogs.com/alps/p/7257282.html

你可能感兴趣的文章
linux中cacti和nagios整合
查看>>
Parallels Desktop12推出 新增Parallels Toolbox
查看>>
正则表达式验证身份证格式是否正确
查看>>
Firebird(全功能的,免维护的数据库,能够管理多个独立的数据库) V2.1.3 英文特别版...
查看>>
xml格式文件解析
查看>>
ios百度地图-路径规划
查看>>
Python高效编程技巧
查看>>
配置Eclipse使用maven构建项目默认JDK为1.8
查看>>
jsp内置对象以及jsp动作
查看>>
Struts上路_09-数据类型转换
查看>>
CMake与动态链接库(dll, so, dylib)
查看>>
myeclipse(eclipse)乱码处理
查看>>
SpringBoot 过滤器, 拦截器, 监听器 对比及使用场景
查看>>
数据库索引探索
查看>>
struts2使用json需要注意的问题
查看>>
gitlab runner 优化
查看>>
快速添加百度网盘文件到Aria2 猴油脚本
查看>>
mac 无法登录mysql的解决办法
查看>>
Shiro权限判断异常之命名导致的subject.isPermitted 异常
查看>>
Hello world travels in cpp - 字符串(2)
查看>>