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;
}
vertex shader must minimally write all four components of POSITION的更多相关文章
- linearizing the depth in vertex shader
please refer to http://www.mvps.org/directx/articles/linear_z/linearz.htm When using a programmable ...
- 学习笔记:GLSL Core Tutorial – Vertex Shader(内置变量说明)
1.每个Vertex Shader都有用户定义的输入属性,例如:位置,法线向量和纹理坐标等.Vertex Shaders也接收一致变量(uniform variables). uniform vari ...
- GLSL写vertex shader和fragment shader
0.一般来说vertex shader处理顶点坐标,然后向后传输,经过光栅化之后,传给fragment shader,其负责颜色.纹理.光照等等. 前者处理之后变成裁剪坐标系(三维),光栅化之后一般认 ...
- Stage3d 由浅到深理解AGAL的管线vertex shader和fragment shader || 简易教程 学习心得 AGAL 非常非常好的入门文章
Everyday Stage3D (一) Everyday Stage3D (二) Triangle Everyday Stage3D (三) AGAL的基本概念 Everyday Stage3D ( ...
- vertex shader(4)
Swizzling and Masking 如果你使用输入.常量.临时寄存器作为源寄存器,你可以彼此独立地swizzle .x,.y,.z,.w值.如果你使用输出.临时寄存器作为目标寄存器,你可以把. ...
- vertex shader(3)
之前我们学习了如何声明顶点着色器.如何设置常量寄存器中的常量.接下来我们学习如何写和编译一个顶点着色器程序. 在我们编译一个顶点着色器之前,首先需要写一个. 有17种不同的指令(instruction ...
- vertex shader(2)
一次只有一个vertex shader是活跃的.你可以有多个vertex shader,如果一个物体特殊的变换或者灯光,你可以选择合适的vertex shader来完成这个任务. 你可能想使用vert ...
- vertex shader(1)
Vertex shader Architecture: 所有在vertex shader中的数据都用128-bit的quad-floats表示(4x32-bit). vertex shader线性地执 ...
- PlayCanvas PBR材质shader代码分析(vertex shader)
顶点shader主要对顶点坐标变换,将顶点坐标从local->world->view->clip 空间变换 local空间:模型物体坐标系 world空间:世界空间坐标系 view空 ...
随机推荐
- 面对 to B 业务该如何构建研发管理体系?
未来离我们越来越近,而过去并未走远,我们发现科技公司2B业务兴起,腾讯认为互联网下半场属于产业互联网,需要进行一次重要的战略升级.它们在国庆节最后一天进行新一轮组织架构调整,最亮眼的就是新成立云与智慧 ...
- SpringBoot编辑代码时不重启服务
@SpringBootApplication @ComponentScan("com.sicdt") public class SicSignWebApplication { pu ...
- Cocos2d-x项目移植到WP8系列之六:C#工程使用C++的DLL
原文链接: http://www.cnblogs.com/zouzf/p/3984510.html 此时,一些大问题都被解决后,整个工程基本能跑起来了,最后一个大问题是:业务层是用Lua开发的,底层的 ...
- 关于Pytorch的二维tensor的gather和scatter_操作用法分析
看得不明不白(我在下一篇中写了如何理解gather的用法) gather是一个比较复杂的操作,对一个2维tensor,输出的每个元素如下: out[i][j] = input[index[i][j]] ...
- GCC编译器入门[转载]
GCC编译器(GNU C Compiler)是GNU组织的一款开源 编译器,它是Linux环境下的默认C语言编译器.它处理能够高效的编译C语言以外,还可以编译其他语言.并且,现在的GCC已经不光包括编 ...
- SpringBoot Mybatis keyProperty和useGeneratedKeys的作用
在使用mybatis时,常常会出现这种需求: 当主键是自增的情况下,添加一条记录的同时,其主键是不能被使用的(为空),但是有时我们需要该主键,这时我们该如何处理呢?这时我们只需要在其对应xml中加入以 ...
- NLP学习常用的网页链接
[2016.7.5] 这是以前学习的时候整理的,放到博客里面,以后再有的话会更新~ 1.一个国外的学者维护的博客,介绍NLP [链接](http://nlpers.blogspot.jp/) 2.北京 ...
- 【51nod1519】拆方块[Codeforces](dp)
题目传送门:1519 拆方块 首先,我们可以发现,如果第i堆方块被消除,只有三种情况: 1.第i-1堆方块全部被消除: 2.第i+1堆方块全部被消除:(因为两侧的方块能够保护这一堆方块在两侧不暴露) ...
- mybatis 中if标签判断boolean 的写法。
mybatis 的if 比较标签在比较数值时可以这样写: <if test="value=0"> </if> 在比较字符串时可以这么写: <if te ...
- Spark-运行时架构
Spark运行时架构 在分布式环境下,Spark集群采用的时主/从结构.在一个Spark集群中,有一个节点负责中央协调,调度各个分布式工作节点.这个中央协调节点被称为驱动器(Driver),与之对应的 ...