'Shader error in 'DX11/GreenScreenShader': Fragment program 'frag': sampler 'SampleType' has no matc
来源:互联网 发布:天猫国际和淘宝全球购 编辑:程序博客网 时间:2024/05/18 22:44
- Shader "DX11/GreenScreenShader" {
- SubShader {
- Pass {
- CGPROGRAM
- #pragma target 5.0
- #pragma vertex vert
- #pragma fragment frag
- #include "UnityCG.cginc"
- Texture2D _MainTex;
- sampler SampleType;
- struct vs_input {
- float4 pos : POSITION;
- float2 tex : TEXCOORD0;
- };
- StructuredBuffer<float2> depthCoordinates;
- StructuredBuffer<float> bodyIndexBuffer;
- struct ps_input {
- float4 pos : SV_POSITION;
- float2 tex : TEXCOORD0;
- };
- ps_input vert (vs_input v)
- {
- ps_input o;
- o.pos = mul (UNITY_MATRIX_MVP, v.pos);
- o.tex = v.tex;
- // Flip x texture coordinate to mimic mirror.
- o.tex.x = 1 - v.tex.x;
- return o;
- }
- float4 frag (ps_input i, in uint id : SV_InstanceID) : COLOR
- {
- float4 o;
- int colorWidth = (int)(i.tex.x * (float)1920);
- int colorHeight = (int)(i.tex.y * (float)1080);
- int colorIndex = (int)(colorWidth + colorHeight * (float)1920);
- o = float4(0, 1, 0, 1);
- if ((!isinf(depthCoordinates[colorIndex].x) && !isnan(depthCoordinates[colorIndex].x) && depthCoordinates[colorIndex].x != 0) ||
- !isinf(depthCoordinates[colorIndex].y) && !isnan(depthCoordinates[colorIndex].y) && depthCoordinates[colorIndex].y != 0)
- {
- // We have valid depth data coordinates from our coordinate mapper. Find player mask from corresponding depth points.
- float player = bodyIndexBuffer[(int)depthCoordinates[colorIndex].x + (int)(depthCoordinates[colorIndex].y * 512)];
- if (player != 255)
- {
- o = _MainTex.Sample(SampleType, i.tex);
- }
- }
- return o;
- }
- ENDCG
- }
- }
- Fallback Off
- }
Rename "SampleType" to "sampler_MainTex":
Code (CSharp):
- //sampler SampleType;
- sampler sampler_MainTex;
- ...
- //o = _MainTex.Sample(SampleType, i.tex);
- o = _MainTex.Sample(sampler_MainTex, i.tex);
0 0
- 'Shader error in 'DX11/GreenScreenShader': Fragment program 'frag': sampler 'SampleType' has no matc
- Different sampler types for same sample texture unit in fragment shader.
- Fragment Shader Program
- Compute Shader (DX11)
- symbian error stary in program
- Syntax error in program SAPLSFES.
- error: stray ‘/357’ in program
- error: stray '357' in program
- error: stray ‘\1’ in program
- error: stray ‘\302’ in program
- error: stray '\161' in program
- error: stray ‘\302’ in program
- error: stray ‘\357’ in program
- error: stray '\357' in program
- error: stray '\302' in program
- error: stray ‘\302’ in program
- error:stray'\243'in program
- error:stray \357’ in program
- 1064. 朋友数(20)
- 检测数组、函数、正则表达式比较好的方法
- Git详解(二):1. 起步(1.4 ~ 1.8)
- File操作(2)------文件夹
- 《异类》
- 'Shader error in 'DX11/GreenScreenShader': Fragment program 'frag': sampler 'SampleType' has no matc
- Java应用基础:进阶篇 习题——单词长度
- [BZOJ 1878]HH的项链(树状数组+离线)
- 一个不错的shell 脚本入门教程
- 【数据结构与算法】二叉树 遍历
- std::mutex的用法
- iOS的三种动画
- switch-case_成绩等级查询系统
- POJ 2431 Expedition (优先队列