我可以为这个着色器的每个顶点实例制作不同的颜色吗?我是否必须将实例发送到o.output到frag颜色?这是运行 Graphics.DrawProcedural(MeshTopology.LineStrip)的HLSL的Unity3d实现;
#pragma fragment frag
#include "UnityCG.cginc"
StructuredBuffer<float3> buf_Points;
StructuredBuffer<float3> buf_Positions;
struct ps_input {
float4 pos : SV_POSITION;
};
ps_input vert (uint id : SV_VertexID, uint inst : SV_InstanceID)
{
ps_input o;
float3 worldPos = buf_Points[id] + buf_Positions[inst];
o.pos = mul (UNITY_MATRIX_VP, float4(worldPos,1.0f));
return o;
}
float4 frag (ps_input i) : COLOR
{
return float4(1,0,0,1);
}
ENDCG
答案 0 :(得分:0)
我解决了,这是类似的东西:
1