Sign in to follow this  
Buttacup

Rendering Editeable Geometry via HLSL

Recommended Posts

I'm working on a level/model editor and I want to draw vertex and edge markers as is common in any geometry based editor. I'm not sure how this is normally approached but IMHO a good way would be to just render them out through the shader. Alas /me is an HLSL nub and am having trouble understanding the flow as a whole. I'm not looking for tuts on this... Was just wondering what the basic approach would be on making this happen. I like the idea of doing it this way because states like actively_selected_geometry can be readily switched on and off and represented as the typical change in colour. It also reduces my need to match markers to the model, create new data streams, store more data points and implement rasterization of said data! I do understand the basics, but everytime(<= is not a word lol) I look at the shader I feel like I'm having a dyslectic episode. [edit] which of the three stages would this best be done in? I assume not pixel! [/edit]

Share this post


Link to post
Share on other sites
I dont see how you want to draw these markers in a shader?

My suggestion would be to render quads for each vertex, and then size them in relation to the distance to the camera.

For the edges, just render the original mesh afterwards, but set the fillmode to wireframe, and apply a color-only material/shader.

Share this post


Link to post
Share on other sites
I had considered statement number two... but... how would the rasterization of such an implementation occur?

As for point number one yeah I guess it could be quads but again

"I like the idea of doing it this way because states like actively_selected_geometry can be readily switched on and off and represented as the typical change in colour. It also reduces my need to match markers to the model, create new data streams, store more data points and implement rasterization of said data!"

-BekaD

Is what I'm attempting not possible? I'm pretty sure it is! :P

[edit] Top line clarification... If I render textured and then render wireframe?? <= issues no?? [/edit]

Share this post


Link to post
Share on other sites
Well I guess I could narrow this to some approaches off the top of my head yus? o.o

Edges:
-Fill triangle solid
-Fill triangle solid a second time but x pixels in from the edge???

Vertex:
-This maybe would have to be in pixel shader <= self explanatory, mb??

unsure how I would handle rasterization in example Vertex.....

Share this post


Link to post
Share on other sites
Found it!

Quote:

5 Conclusions and Future Work
In this paper we have advocated the use of prefiltered lines for wireframe
rendering and demonstrated that the prefiltered lines can easily
be drawn on the polygons in the pass also employed for rendering
the filled polygons. This leads to a simple, single pass method
which
is far more efficient than the offset based methods,
does not suffer from the same artifacts,
produces lines which do not need hardware antialiasing, and
can easily be adapted to various line styles.
Our results indicate that the gap between polygon and line rendering
is widening and, in terms of performance, the strength of the
single pass method is that no line primitive is required.

Share this post


Link to post
Share on other sites
I'm still a little unclear on how to approach this as I do not fully comprehend where the interpolation step occurs with respect to the pixel shader. Is the data interpolated and handed per pixel to the pixel shader where in the pixel shader the information is then processed and drawn on the render target?



Texture2DArray g_txDiffuse;

SamplerState gTriLinearSam
{
Filter = MIN_MAG_MIP_LINEAR;
AddressU = Wrap;
AddressV = Wrap;
};

cbuffer cbConstant
{
float3 vLightDir = float3(.5, 1, 1);
};

cbuffer cbChangesEveryFrame
{
matrix World;
matrix View;
matrix Projection;
};

cbuffer cbUserChanges
{
};

struct VS_INPUT
{
float3 Pos : POSITION;
float3 Norm : NORMAL;
float2 Tex : TEXCOORD;
unsigned int Mat : MATERIAL;
};

struct GS_INPUT
{
float4 Pos : POSITION;
float3 Norm : NORMAL;
float2 Tex : TEXCOORD;
unsigned int Mat : MATERIAL;
};

struct PS_INPUT
{
float4 Pos : SV_POSITION;
float3 Norm : NORMAL;
float2 Tex : TEXCOORD;
unsigned int Mat : MATERIAL;
float3 stuff : TEXCOORD1;
};

//--------------------------------------------------------------------------------------
// Vertex Shader
//--------------------------------------------------------------------------------------
GS_INPUT VS( VS_INPUT input )
{
GS_INPUT output;

output.Pos = mul( float4(input.Pos.x, input.Pos.y, input.Pos.z, 1.0), World );
output.Pos = mul( output.Pos, View );
output.Pos = mul( output.Pos, Projection );
output.Norm = mul( input.Norm, World );
output.Tex = input.Tex;
output.Mat = input.Mat;

return output;
}

[maxvertexcount(3)]
//--------------------------------------------------------------------------------------
// Geometry Shader
//--------------------------------------------------------------------------------------
void GS(triangle GS_INPUT input[3], inout TriangleStream<PS_INPUT> OutputStream )
{
PS_INPUT output = (PS_INPUT)0;

for( uint i = 0; i < 3; i++ )
{
output.Pos = input[i].Pos;
output.Norm = input[i].Norm;
output.Tex = input[i].Tex;
output.Mat = input[i].Mat;

//calculate stuff and send it to PS()

OutputStream.Append( output );
}

OutputStream.RestartStrip();
}

//--------------------------------------------------------------------------------------
// Pixel Shader
//--------------------------------------------------------------------------------------
float4 PS( PS_INPUT input ) : SV_Target
{
float fLighting = saturate( dot( input.Norm, vLightDir ) );
float4 outputColour = g_txDiffuse.Sample( gTriLinearSam, float3(input.Tex, input.Mat) ) * fLighting;
outputColour.a = 1;
return outputColour;
}

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





If I output values in my 'stuff' buffer will the information be interpolated per pixel and then processed by PS()?

Share this post


Link to post
Share on other sites
Well it's a little ugly but..... and I'm still not entirely clear on the stuff I posted above this! o.o


Texture2DArray g_txDiffuse;

SamplerState gTriLinearSam
{
Filter = MIN_MAG_MIP_LINEAR;
AddressU = Wrap;
AddressV = Wrap;
};

cbuffer cbConstant
{
float3 vLightDir = float3(.5, 1, 1);
};

cbuffer cbChangesEveryFrame
{
matrix World;
matrix View;
matrix Projection;
};

cbuffer cbUserChanges
{
};

struct VS_INPUT
{
float3 Pos : POSITION;
float3 Norm : NORMAL;
float2 Tex : TEXCOORD;
unsigned int Mat : MATERIAL;
};

struct GS_INPUT
{
float4 Pos : POSITION;
float3 Norm : NORMAL;
float2 Tex : TEXCOORD;
unsigned int Mat : MATERIAL;
};

struct PS_INPUT
{
float4 Pos : SV_POSITION;
float3 Norm : NORMAL;
float2 Tex : TEXCOORD;
unsigned int Mat : MATERIAL;
float3 distance : TEXCOORD1;
};

//--------------------------------------------------------------------------------------
// Vertex Shader
//--------------------------------------------------------------------------------------
GS_INPUT VS( VS_INPUT input )
{
GS_INPUT output;

output.Pos = mul( float4(input.Pos.x, input.Pos.y, input.Pos.z, 1.0), World );
output.Pos = mul( output.Pos, View );
output.Pos = mul( output.Pos, Projection );
output.Norm = mul( input.Norm, World );
output.Tex = input.Tex;
output.Mat = input.Mat;

return output;
}

[maxvertexcount(3)]
//--------------------------------------------------------------------------------------
// Geometry Shader
//--------------------------------------------------------------------------------------
void GS(triangle GS_INPUT input[3], inout TriangleStream<PS_INPUT> OutputStream )
{
PS_INPUT output = (PS_INPUT)0;

for( uint i = 0; i < 3; i++ )
{
output.Pos = input[i].Pos;
output.Norm = input[i].Norm;
output.Tex = input[i].Tex;
output.Mat = input[i].Mat;

//calculate stuff and send it to PS()
if(i==0)
output.distance = float3(length(input[2].Pos-input[1].Pos),0,0);
else if(i==1)
output.distance = float3(0,length(input[2].Pos-input[0].Pos),0);
else if(i==2)
output.distance = float3(0,0,length(input[1].Pos-input[0].Pos));

OutputStream.Append( output );
}

OutputStream.RestartStrip();
}

//--------------------------------------------------------------------------------------
// Pixel Shader
//--------------------------------------------------------------------------------------
float4 PS( PS_INPUT input ) : SV_Target
{
float fLighting = saturate( dot( input.Norm, vLightDir ) );
float4 output = g_txDiffuse.Sample( gTriLinearSam, float3(input.Tex, input.Mat) ) * fLighting;
output.a = 1;

float dist = min(input.distance[0],min(input.distance[1],input.distance[2]));
float intensity = exp2(-10000*dist*dist);
output = intensity*float4(0,1.0,0,1.0) + (1.0 - intensity)*output;
return output;
}

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









Screen

[edit]
2nd Pass 2nd Pass
[/edit]

[Edited by - Buttacup on December 23, 2009 11:12:58 AM]

Share this post


Link to post
Share on other sites
Vertice markers in HLSL Geometry Shader stage added in a Geometry Output Stream. I think, but am not sure, that I should probably do something with Instancing here?? That's an added 6 verts per vert but it is in edit and they don't need special shading or alpha.... I would have liked to have added a sprite inside HLSL but I cannot see a reasonable way of doing this either...

[edit] stripped it down to four if that makes a difference.. [/edit]

Vertice Markers HLSL Vertice Markers


Texture2DArray g_txDiffuse;

SamplerState gTriLinearSam
{
Filter = MIN_MAG_MIP_LINEAR;
AddressU = Wrap;
AddressV = Wrap;
};

cbuffer cbConstant
{
float3 vLightDir = float3(.5, 1, 1);
};

cbuffer cbChangesEveryFrame
{
matrix World;
matrix View;
matrix Projection;
};

cbuffer cbUserChanges
{
};

struct VS_INPUT
{
float3 Pos : POSITION;
float3 Norm : NORMAL;
float2 Tex : TEXCOORD;
unsigned int Mat : MATERIAL;
};

struct GS_INPUT
{
float4 Pos : POSITION;
float3 Norm : NORMAL;
float2 Tex : TEXCOORD;
unsigned int Mat : MATERIAL;
};

struct PS_INPUT
{
float4 Pos : SV_POSITION;
float3 Norm : NORMAL;
float2 Tex : TEXCOORD;
unsigned int Mat : MATERIAL;
noperspective float3 distance : TEXCOORD1;
bool is_marker : TEXCOORD2;
};

//--------------------------------------------------------------------------------------
// Vertex Shader
//--------------------------------------------------------------------------------------
GS_INPUT VS( VS_INPUT input )
{
GS_INPUT output;

output.Pos = mul( float4(input.Pos.x, input.Pos.y, input.Pos.z, 1.0), World );
output.Pos = mul( output.Pos, View );
output.Pos = mul( output.Pos, Projection );
output.Norm = mul( input.Norm, World );
output.Tex = input.Tex;
output.Mat = input.Mat;

return output;
}

[maxvertexcount(21)]
//--------------------------------------------------------------------------------------
// Geometry Shader
//--------------------------------------------------------------------------------------
void GS(triangle GS_INPUT input[3], inout TriangleStream<PS_INPUT> OutputStream )
{
PS_INPUT output = (PS_INPUT)0;
PS_INPUT vertice_marker = (PS_INPUT)0;

for( uint i = 0; i < 3; i++ )
{
output.Pos = input[i].Pos;
output.Norm = input[i].Norm;
output.Tex = input[i].Tex;
output.Mat = input[i].Mat;
output.is_marker = false;

float2 v0 = input[2].Pos-input[1].Pos;
float2 v1 = input[2].Pos-input[0].Pos;
float2 v2 = input[1].Pos-input[0].Pos;

float area = abs(v1.x*v2.y - v1.y*v2.x);

if(i==0)
output.distance = float3(area/length(v0),0,0);
else if(i==1)
output.distance = float3(0,area/length(v1),0);
else if(i==2)
output.distance = float3(0,0,area/length(v2));

OutputStream.Append( output );
}
for( uint i = 0; i < 3; i++ )
{
OutputStream.RestartStrip();
vertice_marker.Pos = input[i].Pos;
vertice_marker.Pos.z-=.0001;
vertice_marker.Norm = float3(0,0,1.0);
vertice_marker.Tex = input[i].Tex;
vertice_marker.Mat = 1;
vertice_marker.distance = float3(0,0,0);
vertice_marker.is_marker = true;

vertice_marker.Pos.x+=.0075;
vertice_marker.Pos.y+=.01;
vertice_marker.Mat = 1;
OutputStream.Append( vertice_marker );
vertice_marker.Pos.y-=.02;
vertice_marker.Mat = 1;
OutputStream.Append( vertice_marker );
vertice_marker.Pos.x-=.015;
vertice_marker.Mat = 1;
OutputStream.Append( vertice_marker );
OutputStream.RestartStrip();
OutputStream.Append( vertice_marker );
vertice_marker.Pos.y+=.02;
vertice_marker.Mat = 1;
OutputStream.Append( vertice_marker );
vertice_marker.Pos.x+=.015;
vertice_marker.Mat = 1;
OutputStream.Append( vertice_marker );
}

OutputStream.RestartStrip();
}

//--------------------------------------------------------------------------------------
// Pixel Shader
//--------------------------------------------------------------------------------------
float4 PS( PS_INPUT input ) : SV_Target
{
float fLighting = saturate( dot( input.Norm, vLightDir ) );
float4 output = g_txDiffuse.Sample( gTriLinearSam, float3(input.Tex, input.Mat) ) * fLighting;
output.a = 1;

if(!input.is_marker)
{
float dist = min(input.distance[0],min(input.distance[1],input.distance[2]));
float intensity = exp2(-40000*dist*dist);
output = intensity*float4(0,1.0,0,1.0) + (1.0 - intensity)*output;
}
return output;
}

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





[Edited by - Buttacup on December 24, 2009 3:20:22 AM]

Share this post


Link to post
Share on other sites
Well I'm not so sure about the above method anymore... I can probably fix most of the issues like the stretching of the texture as one or two vertices of a tri pass behind the camera....

I understand now that if I do a pass shaded and then a pass with fill set to wireframe it will render with depth which I didn't understand before. This said I'm not switching the fillmode this would be too easy yus? o.o

I have instead decided, at least for wireframe with no shading, to set the primitive topology to line list. This is an issue because my primitive topology is currently a triangle list and the mesh data is stored as such. Geometry Shader also only takes in two vertices at a time when it is set to line list. So I shuffled the deck and pumped out a new set of data to correspond to a proper line list. It still doesn't work atm but I just started on it and it's probably something little... the lines aren't sequencing properly.. I figure this way I can do a quick pass and then change the topology back to a triangle list temporarily to add the vertices in after also via GS();

I still like the single pass method above for one reason, I can modulate some interesting lines for selection sequences.... :P

Wireframe.fx

Texture2DArray txDiffuse;

SamplerState gTriLinearSam
{
Filter = MIN_MAG_MIP_LINEAR;
AddressU = Wrap;
AddressV = Wrap;
};

cbuffer cbConstant
{
float3 vLightDir = float3(.75, .75, 1.0);
};

cbuffer cbChangesEveryFrame
{
matrix World;
matrix View;
matrix Projection;
matrix ProjectionUI;
};

cbuffer cbUserChanges
{
};

struct VS_INPUT
{
float3 Pos : POSITION;
float3 Norm : NORMAL;
float2 Tex : TEXCOORD;
nointerpolation unsigned int Mat : MATERIAL;
nointerpolation unsigned int Flags : FLAGS;
};

struct GS_INPUT
{
float4 Pos : POSITION;
float3 Norm : NORMAL;
float2 Tex : TEXCOORD;
nointerpolation unsigned int Mat : MATERIAL;
nointerpolation unsigned int Flags : FLAGS;
};

struct PS_INPUT
{
float4 Pos : SV_POSITION;
float3 Norm : NORMAL;
float2 Tex : TEXCOORD;
nointerpolation unsigned int Mat : MATERIAL;
nointerpolation unsigned int Flags : FLAGS;
noperspective float3 distance : TEXCOORD1;
bool is_marker : TEXCOORD2;
};

//--------------------------------------------------------------------------------------
// Vertex Shader
//--------------------------------------------------------------------------------------
GS_INPUT VS( VS_INPUT input )
{
GS_INPUT output;

output.Pos = mul( float4(input.Pos.x, input.Pos.y, input.Pos.z, 1.0), World );
output.Pos = mul( output.Pos, View );
output.Pos = mul( output.Pos, Projection );
output.Norm = mul( input.Norm, World );
output.Tex = input.Tex;
output.Mat = input.Mat;
output.Flags = input.Flags;

return output;
}

static int Set = 0;
static GS_INPUT Shuffle[4];

[maxvertexcount(6)]
//--------------------------------------------------------------------------------------
// Geometry Shader
//--------------------------------------------------------------------------------------
void GS(line GS_INPUT input[2], inout LineStream<PS_INPUT> OutputStream )
{
PS_INPUT output = (PS_INPUT)0;
PS_INPUT vertice_marker = (PS_INPUT)0;

if(Set == 0)
{
Set = 1;

Shuffle[0] = input[0];
Shuffle[1] = input[1];

output.Pos = input[0].Pos;
output.Norm = input[0].Norm;
output.Tex = input[0].Tex;
output.Mat = input[0].Mat;
output.is_marker = false;
output.Flags = input[0].Flags;

OutputStream.Append( output );

output.Pos = input[1].Pos;
output.Norm = input[1].Norm;
output.Tex = input[1].Tex;
output.Mat = input[1].Mat;
output.is_marker = false;
output.Flags = input[1].Flags;

OutputStream.Append( output );
}
else if(Set == 1)
{
Set = 2;

output.Pos = Shuffle[1].Pos;
output.Norm = Shuffle[1].Norm;
output.Tex = Shuffle[1].Tex;
output.Mat = Shuffle[1].Mat;
output.is_marker = false;
output.Flags = Shuffle[1].Flags;

OutputStream.Append( output );

output.Pos = input[0].Pos;
output.Norm = input[0].Norm;
output.Tex = input[0].Tex;
output.Mat = input[0].Mat;
output.is_marker = false;
output.Flags = input[0].Flags;

OutputStream.Append( output );

output.Pos = input[0].Pos;
output.Norm = input[0].Norm;
output.Tex = input[0].Tex;
output.Mat = input[0].Mat;
output.is_marker = false;
output.Flags = input[0].Flags;

OutputStream.Append( output );

output.Pos = Shuffle[0].Pos;
output.Norm = Shuffle[0].Norm;
output.Tex = Shuffle[0].Tex;
output.Mat = Shuffle[0].Mat;
output.is_marker = false;
output.Flags = Shuffle[0].Flags;

OutputStream.Append( output );

Shuffle[0] = input[0];
Shuffle[1] = input[1];
}
else if(Set == 2)
{
Set = 0;

output.Pos = Shuffle[1].Pos;
output.Norm = Shuffle[1].Norm;
output.Tex = Shuffle[1].Tex;
output.Mat = Shuffle[1].Mat;
output.is_marker = false;
output.Flags = Shuffle[1].Flags;

OutputStream.Append( output );

output.Pos = input[0].Pos;
output.Norm = input[0].Norm;
output.Tex = input[0].Tex;
output.Mat = input[0].Mat;
output.is_marker = false;
output.Flags = input[0].Flags;

OutputStream.Append( output );

output.Pos = input[0].Pos;
output.Norm = input[0].Norm;
output.Tex = input[0].Tex;
output.Mat = input[0].Mat;
output.is_marker = false;
output.Flags = input[0].Flags;

OutputStream.Append( output );

output.Pos = input[1].Pos;
output.Norm = input[1].Norm;
output.Tex = input[1].Tex;
output.Mat = input[1].Mat;
output.is_marker = false;
output.Flags = input[1].Flags;

OutputStream.Append( output );

output.Pos = input[1].Pos;
output.Norm = input[1].Norm;
output.Tex = input[1].Tex;
output.Mat = input[1].Mat;
output.is_marker = false;
output.Flags = input[1].Flags;

OutputStream.Append( output );

output.Pos = Shuffle[1].Pos;
output.Norm = Shuffle[1].Norm;
output.Tex = Shuffle[1].Tex;
output.Mat = Shuffle[1].Mat;
output.is_marker = false;
output.Flags = Shuffle[1].Flags;

OutputStream.Append( output );
}

OutputStream.RestartStrip();
}

//--------------------------------------------------------------------------------------
// Pixel Shader
//--------------------------------------------------------------------------------------
float4 PS( PS_INPUT input ) : SV_Target
{
float fLighting = saturate( dot( input.Norm, vLightDir ) );
float4 output = float4(0.0, 0.0, 0.75, 0.75);

return output;
}

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





This was inspired by my need to create a depth enabled perspective grid... I was trying to think of a way to work depth into D2D but well......

[Edited by - Buttacup on January 21, 2010 9:48:15 PM]

Share this post


Link to post
Share on other sites
So static does not work the way I thought a certain post elsewhere suggested... /me shakes fist!

but this does:

Texture2DArray txDiffuse;

SamplerState gTriLinearSam
{
Filter = MIN_MAG_MIP_LINEAR;
AddressU = Wrap;
AddressV = Wrap;
};

cbuffer cbConstant
{
float3 vLightDir = float3(.75, .75, 1.0);
};

cbuffer cbChangesEveryFrame
{
matrix World;
matrix View;
matrix Projection;
matrix ProjectionUI;
};

cbuffer cbUserChanges
{
};

struct VS_INPUT
{
float3 Pos : POSITION;
float3 Norm : NORMAL;
float2 Tex : TEXCOORD;
nointerpolation unsigned int Mat : MATERIAL;
nointerpolation unsigned int Flags : FLAGS;
};

struct GS_INPUT
{
float4 Pos : POSITION;
float3 Norm : NORMAL;
float2 Tex : TEXCOORD;
nointerpolation unsigned int Mat : MATERIAL;
nointerpolation unsigned int Flags : FLAGS;
};

struct PS_INPUT
{
float4 Pos : SV_POSITION;
float3 Norm : NORMAL;
float2 Tex : TEXCOORD;
nointerpolation unsigned int Mat : MATERIAL;
nointerpolation unsigned int Flags : FLAGS;
noperspective float3 distance : TEXCOORD1;
bool is_marker : TEXCOORD2;
};

//--------------------------------------------------------------------------------------
// Vertex Shader
//--------------------------------------------------------------------------------------
GS_INPUT VS( VS_INPUT input )
{
GS_INPUT output;

output.Pos = mul( float4(input.Pos.x, input.Pos.y, input.Pos.z, 1.0), World );
output.Pos = mul( output.Pos, View );
output.Pos = mul( output.Pos, Projection );
output.Norm = mul( input.Norm, World );
output.Tex = input.Tex;
output.Mat = input.Mat;
output.Flags = input.Flags;

return output;
}

[maxvertexcount(6)]
//--------------------------------------------------------------------------------------
// Geometry Shader
//--------------------------------------------------------------------------------------
void GS(triangle GS_INPUT input[3], inout LineStream<PS_INPUT> OutputStream )
{
PS_INPUT output = (PS_INPUT)0;
PS_INPUT vertice_marker = (PS_INPUT)0;

output.Pos = input[0].Pos;
output.Norm = input[0].Norm;
output.Tex = input[0].Tex;
output.Mat = input[0].Mat;
output.is_marker = false;
output.Flags = input[0].Flags;

OutputStream.Append( output );

output.Pos = input[1].Pos;
output.Norm = input[1].Norm;
output.Tex = input[1].Tex;
output.Mat = input[1].Mat;
output.is_marker = false;
output.Flags = input[1].Flags;

OutputStream.Append( output );

output.Pos = input[1].Pos;
output.Norm = input[1].Norm;
output.Tex = input[1].Tex;
output.Mat = input[1].Mat;
output.is_marker = false;
output.Flags = input[1].Flags;

OutputStream.Append( output );

output.Pos = input[2].Pos;
output.Norm = input[2].Norm;
output.Tex = input[2].Tex;
output.Mat = input[2].Mat;
output.is_marker = false;
output.Flags = input[2].Flags;

OutputStream.Append( output );

output.Pos = input[2].Pos;
output.Norm = input[2].Norm;
output.Tex = input[2].Tex;
output.Mat = input[2].Mat;
output.is_marker = false;
output.Flags = input[2].Flags;

OutputStream.Append( output );

output.Pos = input[0].Pos;
output.Norm = input[0].Norm;
output.Tex = input[0].Tex;
output.Mat = input[0].Mat;
output.is_marker = false;
output.Flags = input[0].Flags;

OutputStream.Append( output );

OutputStream.RestartStrip();
}

//--------------------------------------------------------------------------------------
// Pixel Shader
//--------------------------------------------------------------------------------------
float4 PS( PS_INPUT input ) : SV_Target
{
float fLighting = saturate( dot( input.Norm, vLightDir ) );
float4 output = float4(0.0, 0.0, 0.75, 0.75);

return output;
}

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



which is way cooler :P

I leave the Single Pass variables also in the pass to PS() as I think I may be able to triple up on lines and do some filtering and modulation of the line.... I guess this now said I still have a single pass as I'm pretty sure I can pass out both Triangle and Lines at the same time from GS(). I would also like to point out the built in ability to handle rendering of Quads.... I'm sure this is all nuffin new but I is contented..........

I'll stop posting to this thread now, k!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this