- Home /
Question by
drudiverse · Mar 14, 2016 at 08:15 AM ·
shadercompute shaderhlslfragment
fragment shader different color for every vertex?
can i make different colors fore every instance of this shader? do i have to send instance to o.output or something? how can i do it?
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.5f,0.0f,1);
}
ENDCG
Comment
Answer by drudiverse · Mar 15, 2016 at 11:27 AM
solved it. its possible:"
struct ps_input {
float4 pos : SV_POSITION ;
float4 col : COLOR;
};
ps_input vert (uint id : SV_VertexID, uint inst : SV_InstanceID)
{
bla
o.pos = mul (UNITY_MATRIX_VP, float4(worldPos,1.0f));
o.col = float4(sin(inst),0,0,1);
return o;
}
float4 frag (ps_input i) : COLOR
{
return i.col;//float4(0.7f,.7f,.7f,1);
}
ENDCG
Your answer
Follow this Question
Related Questions
ComputeShader: Accessing array elements within a StructuredBuffer 1 Answer
How do int textures work in ComputeShaders? 2 Answers
Where Is UNITY_POSITION(pos) Defined? 1 Answer
Fog shader 2 Answers
2D Water top surface profile 1 Answer