Delaunay color buffer dx11

Hello,

I have been unsuccessfully trying to modify the DX11 vuxs delaunay vertex colour shader to allow me to add a colour buffer rather than sample a texture.

Could any shader ninja’s lend a hand?

I’ve uploaded what I’ve cobbled together so far

Thanks!

Delaunay_VertexColorbuffer.fx (2.1 kB)

float4 c = color; should be float4 c = input0.col

then you should do

output.pos = mul(t1,tWVP);	
output.col = c;
gsout.Append(output);

for each vertex

Hi antokhio,

I’ve implimented those changes but the shader is still returning 'invalid subscript ‘col’ at line 47

Any thoughts?

Thanks

Delaunay_VertexColorbuffer.fx (2.1 kB)

Yea, missed it, so you have incorrect assignments:

vsin VS(vsin input)

this means that instead of using “struct vs2ps” you are using “vsin”
this should be changed to:

**vs2ps** VS(vsin input)
{
	vs2ps output = (vs2ps)0;
...
}

then you have the same in GS

void GS( triangle **vsin** input[3](3), inout TriangleStream<gs2ps> gsout )

should be

void GS( triangle **vs2ps** input[3](3), inout TriangleStream<gs2ps> gsout )

then in the from line remove line 72

float4 c = input[0](0).col**;**
	//Since we assign once, triangle will have a single color
	**//**output.col = c;

P.S doesn’t do bold for some reason so look __ symbols marks mistakes.

Still getting the same error, I think the invalid subscript ‘col’ is because ‘col’ is undeclared, it is declared here, is this correct?

struct vs2ps
{
float4 pos : POSITION;

//float4 uv : TEXCOORD0;
float4 col: COLOR0;

};

I am new to DX11 and coding in general, so I still have a lot to learn and appreciate your help.

Thanks

Delaunay_VertexColorbuf3.fx (1.9 kB)

vs2ps VS(vs2ps input)

this isn’t correct…

vs2ps VS(vsin input)

then in the end:

float4 PS(gs2ps input) : SV_Target
{
	
}




return input.col;

there are two pdf’s on this page u should read General DX9 -> DX11 shader migration approach? [spez. atmoshpere and ocean shader]

Hello antokhio,

I made your suggested changes but it’s still returning invalid subscript ‘col’ at line 77?

Thanks also for the links to the PDFs that clarify some of the semantic changes…

Delaunay_VertexColorbuf4.fx (2.0 kB)

//@author: vux
//@help: Per vertex color using texture sampling in geometry shader
//@tags: color
//@credits:
StructuredBuffer<float4> color <bool color=true;>;

float4x4 tW : WORLD;
float4x4 tVP : VIEWPROJECTION;
float4x4 tWVP : WORLDVIEWPROJECTION;


Texture2D tex <string uiname="Texture";>;

SamplerState sam : IMMUTABLE
{
    Filter = MIN_MAG_MIP_LINEAR;
    AddressU = Clamp;
    AddressV = Clamp;
};

struct vsin
{
	float4 pos : POSITION;
	
	//float4 uv : TEXCOORD0;
	float4 col: COLOR;
	
};

struct gs2ps
{
    float4 pos: SV_POSITION;
	float4 col: COLOR;
    
};

struct vs2ps
{
    float4 pos: SV_POSITION;
    //float4 uv: TEXCOORD0;
	float4 col: COLOR0;
};

vs2ps VS(vsin input)
{
	vs2ps output = (vs2ps)0;
	uint count, dummy;
	color.GetDimensions(count,dummy);
    output.pos  = mul(input.pos,mul(tW,tVP));
    //output.uv = mul(input.uv, tTex);
	
    return output;
}

float lthr;
[maxvertexcount(3)](maxvertexcount(3))

void GS( triangle vs2ps input[3](3), inout TriangleStream<gs2ps> gsout )
{
	gs2ps output;
	
	//Get triangle positions
	float4 t1 = input[0](0).pos.xyzw;
	float4 t2 = input[1](1).pos.xyzw;
	float4 t3 = input[2](2).pos.xyzw;
	
	//Calculate center position
	float3 ce = t1.xyz + t2.xyz + t3.xyz ;
	ce *= 0.3333333f;
	
	//Convert center into uv space
	ce *= 0.5f;
	ce += 0.5f;
	ce.y = 1.0f -ce.y;
	
//Sample color from buffer
float4 c = input[0](0).col;
	
//output.col = c;
	
	//Tranform positions and output new triangle
	
	output.pos = mul(t1,tWVP);
	output.col = c;
	gsout.Append(output);
		
	output.pos = mul(t2,tWVP);    
	output.col = c;
	gsout.Append(output);
	
	output.pos = mul(t3,tWVP);
	output.col = c;
	gsout.Append(output);
	
}

float4 PS(vs2ps input) : SV_Target
{
	return input.col;
}



technique10 Render
{
	pass P0
	{
		SetVertexShader( CompileShader( vs_4_0, VS() ) );
		SetGeometryShader( CompileShader(gs_4_0,GS()));
		SetPixelShader( CompileShader( ps_4_0, PS() ) );
	}
}

that should do it
you have to study codding a bit, you break the parts that was working before…
i prolly should do something on shader basics
u might wanna look https://www.youtube.com/watch?v=6YMb0jtUtfo and also https://www.youtube.com/watch?v=emaKnIX4Dr8

Thanks again, I think this was too advanced for me and should have started on something simpler. I’ll take your advice and check out the links