aboutsummaryrefslogtreecommitdiff
path: root/CgFx
diff options
context:
space:
mode:
authorBen Marsh <[email protected]>2019-10-22 09:07:59 -0400
committerBen Marsh <[email protected]>2019-10-22 09:07:59 -0400
commitbd0027e737c6512397f841c22786274ed74b927f (patch)
treef7ffbdb8f3741bb7f24635616cc189cba5cb865c /CgFx
downloadshave-and-a-haircut-bd0027e737c6512397f841c22786274ed74b927f.tar.xz
shave-and-a-haircut-bd0027e737c6512397f841c22786274ed74b927f.zip
Adding Shave-and-a-Haircut 9.6
Diffstat (limited to 'CgFx')
-rw-r--r--CgFx/shaveHair.cgfx883
-rw-r--r--CgFx/shaveInst.cgfx0
2 files changed, 883 insertions, 0 deletions
diff --git a/CgFx/shaveHair.cgfx b/CgFx/shaveHair.cgfx
new file mode 100644
index 0000000..ba5806c
--- /dev/null
+++ b/CgFx/shaveHair.cgfx
@@ -0,0 +1,883 @@
+///////////////////////////////////////////////////////////////////////
+// Shaders for regular hair
+//
+// Shave and a Haircut
+// (c) 2019 Epic Games
+// US Patent 6720962
+//////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////
+// Constants
+////////////////////////////////////////////////////////////////////////////////
+
+
+const float4 guideCol = float4(0.0, 0.6, 0.32, 1.0);
+const float4 guideSel = float4(0.26, 1.0, 0.63, 1.0);
+const float4 knotCol = float4(0.78, 0.0, 0.78, 1.0);
+const float4 knotSel = float4(1.0, 1.0, 0.0, 1.0);
+const float4 brushCol = float4(1.0, 0.0, 0.0, 1.0);
+const float3 greyCol = float3(0.7, 0.7, 0.7);
+
+const float pi = 3.14159;
+const int nsegs = 24;
+
+////////////////////////////////////////////////////////////////////////////////
+// Parameters
+////////////////////////////////////////////////////////////////////////////////
+
+
+float4x4 WorldITXf : WorldInverseTranspose <string UIWidget = "none";>;
+float4x4 WVPXf : WorldViewProjection <string UIWidget = "none";>;
+float4x4 WVXf : WorldView <string UIWidget = "none";>;
+float4x4 WorldXf : World <string UIWidget = "none";>;
+float4x4 ViewIXf : ViewInverse <string UIWidget = "none";>;
+//float3x3 NormalXf : Normal <string UIWidget = "none";>;
+
+bool gDimmed <
+ string UIWidget = "Checkbox";
+ string UIName = "UseSolidColor";
+> = false;
+
+bool gUseColor <
+ string UIWidget = "Checkbox";
+ string UIName = "UseSolidColor";
+> = true;
+
+bool gUseTexture <
+ string UIWidget = "Checkbox";
+ string UIName = "UseTexture";
+> = false;
+
+
+texture gTexture : Texture
+<
+ string UIName = "Diffuse";
+>;
+
+
+sampler2D gSampler : TextureSampler = sampler_state
+{
+ Texture = <gTexture>;
+};
+
+
+float4 gColor <
+ string UIWidget = "Color";
+ string UIName = "HairColor";
+> = {0.0f, 0.01f, 0.27f, 1.0f};
+
+float gAmbdiff <
+ string UIWidget = "slider";
+ string UIName = "Ambdiff";
+> = 0.4f;
+
+float gSpecular <
+ string UIWidget = "slider";
+ string UIName = "Specular";
+> = 0.089f;
+
+float gSpecularAmt <
+ string UIWidget = "slider";
+ string UIName = "Gloss";
+> = 0.01; // 0.992f;
+
+float3 gSpecularTint <
+ string UIWidget = "Color";
+ string UIName = "Specular Tint";
+> = {1.0f, 1.0f, 1.0f};
+
+float3 gSpecularTint2 <
+ string UIWidget = "Color";
+ string UIName = "Secondary Specular Tint";
+> = {1.0f, 1.0f, 1.0f};
+
+float3 gLightDir <
+ string UIWidget = "none";
+> = {0.0f, 0.0f, -1.0f};
+
+float gGuideWidth <
+ string UIWidget = "slider";
+ string UIName = "GuideWidth";
+> = 0.05f;
+
+////////////////////////////////////////////////////////////////////////////////
+// Structures
+////////////////////////////////////////////////////////////////////////////////
+
+// Vertex shader input structure.
+struct VS_INPUT_Hair
+{
+ float3 Position : POSITION;
+ float4 Color : COLOR0;
+ float2 UV : TEXCOORD0;
+ float3 Tangent : NORMAL;
+};
+
+//Geometry shader
+struct GS_INPUT_Hair
+{
+ float3 Position : POSITION;
+ float4 Color : COLOR0;
+ float2 UV : TEXCOORD0;
+ float3 Tangent : TEXCOORD1;
+};
+
+// Fragment shader input
+struct FS_INPUT_Hair
+{
+ float4 Position : POSITION;
+ float4 Color : COLOR0;
+ float3 Tangent : TEXCOORD0;
+ float3 View : TEXCOORD1;
+
+};
+
+/////////////////////////////////////////////////
+
+struct VS_INPUT_instWire
+{
+ float3 Position : POSITION;
+
+};
+
+struct FS_INPUT_instWire
+{
+ float4 Position : POSITION;
+
+};
+
+/////////////////////////////////////////////////
+
+struct VS_INPUT_instSolid
+{
+ float3 Position : POSITION;
+ float3 Normal : NORMAL;
+ float2 UV : TEXCOORD0;
+};
+
+struct FS_INPUT_instSolid
+{
+ float4 Position : POSITION;
+ float2 UV : TEXCOORD0;
+ float3 Normal : TEXCOORD1;
+};
+
+/////////////////////////////////////////////////
+
+struct VS_INPUT_Guides
+{
+ float3 Position : POSITION; /*NORMAL;*/
+ float4 Color : COLOR0;
+};
+
+struct GS_INPUT_Guides
+{
+ float3 Position : POSITION;
+};
+
+struct FS_INPUT_Guides
+{
+ float4 Position : POSITION;
+ float Sel : COLOR0;
+};
+
+///////////////////////////////////////////////////
+
+
+struct VS_INPUT_Knots
+{
+ float3 Position : POSITION;
+ float4 Color : COLOR0;
+};
+
+struct GS_INPUT_Knots
+{
+ float3 Position : POSITION;
+};
+
+struct FS_INPUT_Knots
+{
+ float4 Position : POSITION;
+ float Sel : COLOR0;
+};
+
+////////////////////////////////////////////////////
+
+struct VS_INPUT_Brush
+{
+ float3 Position : POSITION;
+};
+
+struct GS_INPUT_Brush
+{
+ float3 Position : POSITION;
+};
+
+struct FS_INPUT_Brush
+{
+ float4 Position : POSITION;
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// Vertex shader - strands
+////////////////////////////////////////////////////////////////////////////////
+
+GS_INPUT_Hair vsHair (VS_INPUT_Hair In)
+{
+ GS_INPUT_Hair Out;
+
+ Out.Position = In.Position.xyz;
+ Out.Color = In.Color;
+ Out.UV = In.UV;
+ Out.Tangent = In.Tangent;
+
+
+ return Out;
+}
+
+FS_INPUT_Hair vsHairPoly (VS_INPUT_Hair In)
+{
+ FS_INPUT_Hair Out;
+
+ Out.Position = mul(WVPXf, float4(In.Position.xyz,1.0));
+ //Out.View = -normalize(mul(WVXf, float4(In.Position.xyz,1.0)).xyz);
+ //Out.View = float3(0.0,0.0,0.0);
+ Out.View = In.Position.xyz;
+
+ Out.Color = In.Color;
+
+ Out.Tangent = normalize(In.Tangent);
+ //Out.Tangent = float3(0.0,0.0,0.0);
+ //Out.Tangent = float3(1.0,0.0,0.0);
+ //Out.Tangent = float3(1.0,1.0,1.0);
+ //Out.Tangent = normalize(mul(WVXf, float4(In.Tangent,1.0)).xyz);
+ //Out.Tangent = normalize(mul(NormalXf,In.Tangent));
+
+ return Out;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// geometry shader - strands
+////////////////////////////////////////////////////////////////////////////////
+
+LINE TRIANGLE_OUT /*QUAD_OUT*/ void gsHair (AttribArray<GS_INPUT_Hair> In)
+{
+
+ FS_INPUT_Hair Out;
+
+ float r0 = In[0].UV.x; //1.0;
+ float r1 = In[1].UV.x; //1.0;
+
+ float3 dp = In[1].Position.xyz - In[0].Position.xyz;
+
+ float4 vi = mul(ViewIXf, float4(0.0, 0.0, -1.0,1.0));
+ float4 vii = mul(ViewIXf, float4(0.0, 0.0, 0.0,1.0));
+ float3 vn = normalize(vi.xyz-vii.xyz);
+
+ float3 or0 = cross(In[0].Tangent, vn);
+ float3 nr0 = normalize(or0);
+
+ float3 or1 = cross(In[1].Tangent, vn);
+ float3 nr1 = normalize(or1);
+
+
+ float4 p0 = float4(In[0].Position - (nr0*r0), 1.0);
+ float4 pw0 = mul(WVPXf, p0);
+ float3 pv0 = -normalize(mul(WVXf, p0).xyz);
+
+
+ float4 p1 = float4(In[1].Position - (nr1*r1), 1.0);
+ float4 pw1 = mul(WVPXf, p1);
+ float3 pv1 = -normalize(mul(WVXf, p1).xyz);
+
+ float4 p2 = float4(In[0].Position + nr0*r0, 1.0);
+ float4 pw2 = mul(WVPXf, p2);
+ float3 pv2 = -normalize(mul(WVXf, p2).xyz);
+
+ float4 p3 = float4(In[1].Position + nr1*r1, 1.0);
+ float4 pw3 = mul(WVPXf, p3);
+ float3 pv3 = -normalize(mul(WVXf, p3).xyz);
+
+ //is something is wrong with NormalXf
+ //float3 t0 = mul(NormalXf, In[0].Tangent);
+ //float3 t1 = mul(NormalXf, In[1].Tangent);
+
+ float3 pt0 = mul(WVXf, float4(In[0].Position,1.0)).xyz;
+ float3 pt01 = mul(WVXf, float4(In[0].Position+In[0].Tangent,1.0)).xyz;
+ float3 pt1 = mul(WVXf, float4(In[1].Position,1.0)).xyz;
+ float3 pt11 = mul(WVXf, float4(In[1].Position+In[1].Tangent,1.0)).xyz;
+
+ float3 t0 = normalize(pt01-pt0);
+ float3 t1 = normalize(pt11-pt1);
+
+ //first triangle
+ Out.Position = pw0;
+ Out.View = pv0;
+ Out.Color = In[0].Color;
+ Out.Tangent = t0;
+ emitVertex(Out);
+
+ Out.Position = pw1;
+ Out.View = pv1;
+ Out.Color = In[1].Color;
+ Out.Tangent = t1;
+ emitVertex(Out);
+
+ Out.Position = pw2;
+ Out.View = pv2;
+ Out.Color = In[0].Color;
+ Out.Tangent = t0;
+ emitVertex(Out);
+
+ //second triangle
+
+ Out.Position = pw3;
+ Out.View = pv3;
+ Out.Color = In[1].Color;
+ emitVertex(Out);
+/*
+ Out.Position = pw2;
+ Out.View = pv2;
+ Out.Color = In[0].Color;
+ emitVertex(Out);
+
+ Out.Position = pw1;
+ Out.View = pv1;
+ Out.Color = In[1].Color;
+ Out.Tangent = t1;
+ emitVertex(Out);
+ */
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Fragment shader - strands
+////////////////////////////////////////////////////////////////////////////////
+
+float4 fsHair (FS_INPUT_Hair In) : COLOR0
+{
+ if(gUseColor)
+ return gColor;
+ else {
+
+ ////////////////////////
+ // if(gDimmed)
+ // return float4(In.Color.rgb*0.8, In.Color.a);
+ // else
+ // return In.Color;
+ ////////////////////////
+
+ float3 D = {0.0f,0.0f,0.0f};
+ float3 S = {0.0f,0.0f,0.0f};
+ float3 S2 = {0.0f,0.0f,0.0f};
+
+ //float3 ldir = -gLightDir;
+ //////////////////////////////
+ float4 vi = mul(ViewIXf, float4(0.0, 0.0, 0.0, 1.0));
+ float4 vii = mul(ViewIXf, float4(gLightDir,1.0));
+ float3 ldir = -normalize(vi.xyz-vii.xyz);
+ //float3 V = normalize(vi-In.View);
+ float3 V = {0.0f,0.0f,0.0f};
+ //////////////////////////////
+
+ //diffuse
+ float diff = 0.3f;
+ float ltdot = dot(ldir, In.Tangent);
+ //ltdot = 0.0f;
+ float tsq = ltdot*ltdot;
+ float shd2 = sqrt(1.0f - tsq);
+ float shd = max(shd2, 0.0f);
+ shd *= gAmbdiff;
+ shd += (1.0f - gAmbdiff);
+ D += shd;
+
+ //specular
+
+ float K = 1.0f/(3.0f*(0.101f - gSpecular));
+ float vtdot = dot(V, In.Tangent);
+
+ float sqr_vdot2 = sqrt(1.0f - vtdot*vtdot);
+ float sp = max(shd2*sqr_vdot2 - ltdot*vtdot, 0.0f);
+ float spec = max(pow(sp, K), 0.0f);
+ S += spec*float3(1.0,1.0,1.0);
+
+
+ //secondary specular
+
+ float3 ldir2 = normalize(ldir*0.7f+V*0.3f);
+ float ltdot2 = dot(ldir2, In.Tangent);
+ float sp2 = max(shd2*sqr_vdot2 - ltdot2*vtdot, 0.0f);
+ float spec2 = max(pow(sp2, K), 0.0f);
+ S2 += spec2*float3(1.0,1.0,1.0);
+
+
+ if(D.r > 1.0f) D.r = 1.0f;
+ if(D.g > 1.0f) D.g = 1.0f;
+ if(D.b > 1.0f) D.b = 1.0f;
+
+ if(S.r > 1.0f) S.r = 1.0f;
+ if(S.g > 1.0f) S.g = 1.0f;
+ if(S.b > 1.0f) S.b = 1.0f;
+
+ if(S2.r > 1.0f) S2.r = 1.0f;
+ if(S2.g > 1.0f) S2.g = 1.0f;
+ if(S2.b > 1.0f) S2.b = 1.0f;
+
+ float3 color = D*In.Color.rgb + gSpecularAmt*(S*gSpecularTint + S2*gSpecularTint2);
+ if(gDimmed) color *= 0.8f;
+
+ return float4(color, In.Color.a);
+
+ /*
+ if(gDimmed)
+ return float4(In.Color.rgb*0.8, In.Color.a);
+ else
+ return In.Color;
+ */
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Vertex shader - instances wire
+////////////////////////////////////////////////////////////////////////////////
+
+FS_INPUT_instWire vsInstWire (VS_INPUT_instWire In) : COLOR0
+{
+ FS_INPUT_instWire Out;
+ Out.Position = mul(WVPXf, float4(In.Position.xyz,1.0));
+ return Out;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Fragment shader - instances wire
+////////////////////////////////////////////////////////////////////////////////
+
+float4 fsInstWire (FS_INPUT_instWire In) : COLOR0
+{
+ return gColor;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Vertex shader - instances solid
+////////////////////////////////////////////////////////////////////////////////
+
+FS_INPUT_instSolid vsInstSolid (VS_INPUT_instSolid In) : COLOR0
+{
+ FS_INPUT_instSolid Out;
+ Out.Position = mul(WVPXf, float4(In.Position.xyz,1.0));
+ Out.Normal = In.Normal;
+ //Out.Normal = float3(1.0, 1.0, 1.0);
+ Out.UV = In.UV;
+ return Out;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Fragment shader - instances solid
+////////////////////////////////////////////////////////////////////////////////
+
+float4 fsInstSolid (FS_INPUT_instSolid In) : COLOR0
+{
+ //float3 ldir = -gLightDir;
+ //////////////////////////////
+ float4 vi = mul(ViewIXf, float4(0.0, 0.0, 0.0, 1.0));
+ float4 vii = mul(ViewIXf, float4(gLightDir,1.0));
+ float3 ldir = -normalize(vi.xyz-vii.xyz);
+ /////////////////////////////
+ float ltdot = dot(ldir, In.Normal);
+ /////////////////////////////////////
+ if(gUseTexture){
+ float4 C = tex2D(gSampler,In.UV);;
+ return float4(C.xyz*ltdot,C.w);
+ } else {
+ return float4(greyCol*ltdot,1.0);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Vertex shader - guides
+////////////////////////////////////////////////////////////////////////////////
+
+GS_INPUT_Guides vsGuides (VS_INPUT_Guides In)
+{
+ GS_INPUT_Guides Out;
+ Out.Position = In.Position.xyz;
+ return Out;
+}
+
+FS_INPUT_Guides vsGuidesPoly (VS_INPUT_Guides In)
+{
+ FS_INPUT_Guides Out;
+ Out.Position = mul(WVPXf, float4(In.Position.xyz,1.0));
+ Out.Sel = In.Color.r;
+ return Out;
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// geometry shader - guides
+////////////////////////////////////////////////////////////////////////////////
+
+LINE TRIANGLE_OUT void gsGuides (AttribArray<GS_INPUT_Guides> In)
+{
+
+ FS_INPUT_Guides Out;
+
+ float r = gGuideWidth; //0.05;
+
+
+ float3 dp = In[1].Position.xyz - In[0].Position.xyz;
+ float3 tg = normalize(dp);
+
+ float4 vi = mul(ViewIXf, float4(0.0, 0.0, -1.0,1.0));
+ float4 vii = mul(ViewIXf, float4(0.0, 0.0, 0.0,1.0));
+ float3 vn = normalize(vi.xyz-vii.xyz);
+
+ float3 or0 = cross(tg, vn);
+ float3 nr0 = normalize(or0);
+
+ //float3 or1 = cross(In[1].Tangent, vn);
+ //float3 nr1 = normalize(or1);
+ float3 nr1 = nr0;
+
+
+ float4 p0 = float4(In[0].Position - (nr0*r), 1.0);
+ float4 pw0 = mul(WVPXf, p0);
+
+ float4 p1 = float4(In[1].Position - (nr1*r), 1.0);
+ float4 pw1 = mul(WVPXf, p1);
+
+ float4 p2 = float4(In[0].Position + nr0*r, 1.0);
+ float4 pw2 = mul(WVPXf, p2);
+
+ float4 p3 = float4(In[1].Position + nr1*r, 1.0);
+ float4 pw3 = mul(WVPXf, p3);
+
+ //first triangle
+ Out.Position = pw0;
+ emitVertex(Out);
+
+ Out.Position = pw1;
+ emitVertex(Out);
+
+ Out.Position = pw2;
+ emitVertex(Out);
+
+ //second triangle
+
+ //Out.Position = pw1;
+ //emitVertex(Out);
+
+ Out.Position = pw3;
+ emitVertex(Out);
+
+ //Out.Position = pw2;
+ //emitVertex(Out);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Fragment shader - guides
+////////////////////////////////////////////////////////////////////////////////
+
+float4 fsGuides (FS_INPUT_Guides In) : COLOR0
+{
+ if(In.Sel == 0.0)
+ return guideCol;
+ else
+ return guideSel;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+// Vertex shader - knots
+////////////////////////////////////////////////////////////////////////////////
+
+GS_INPUT_Knots vsKnots (VS_INPUT_Knots In)
+{
+ GS_INPUT_Knots Out;
+ Out.Position = In.Position.xyz;//mul(WVPXf, float4(In.Position.xyz,1.0));
+ return Out;
+}
+
+
+FS_INPUT_Knots vsKnotsPoly (VS_INPUT_Knots In)
+{
+ FS_INPUT_Knots Out;
+ Out.Position = mul(WVPXf, float4(In.Position.xyz,1.0));
+ Out.Sel = In.Color.r;
+ return Out;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+// geometry shader - knots
+////////////////////////////////////////////////////////////////////////////////
+
+/*POINT*/ LINE TRIANGLE_OUT void gsKnots (AttribArray<GS_INPUT_Knots> In)
+{
+
+ FS_INPUT_Knots Out;
+
+ float r = gGuideWidth*1.4;
+
+
+ float4 u = mul(ViewIXf, float4(0.0, 1.0, 0.0,1.0));
+ float4 l = mul(ViewIXf, float4(1.0, 0.0, 0.0,1.0));
+ float4 c = mul(ViewIXf, float4(0.0, 0.0, 0.0,1.0));
+ float3 up = normalize(u.xyz-c.xyz);
+ float3 left = normalize(l.xyz-c.xyz);
+
+ float4 p0 = float4(In[0].Position + (up+left)*r, 1.0);
+ float4 pw0 = mul(WVPXf, p0);
+
+ float4 p1 = float4(In[0].Position + (up-left)*r, 1.0);
+ float4 pw1 = mul(WVPXf, p1);
+
+ float4 p2 = float4(In[0].Position + (-up-left)*r, 1.0);
+ float4 pw2 = mul(WVPXf, p2);
+
+ float4 p3 = float4(In[0].Position + (-up+left)*r, 1.0);
+ float4 pw3 = mul(WVPXf, p3);
+
+ //frist triangle
+ Out.Position = pw0;
+ Out.Position.z = 0.0;
+ emitVertex(Out);
+
+ Out.Position = pw1;
+ //Out.Position.z = 0.0;
+ emitVertex(Out);
+
+ Out.Position = pw2;
+ //Out.Position.z = 0.0;
+ emitVertex(Out);
+
+ //secon triangle
+ Out.Position = pw2;
+ //Out.Position.z = 0.0;
+ emitVertex(Out);
+
+ Out.Position = pw3;
+ //Out.Position.z = 0.0;
+ emitVertex(Out);
+
+ Out.Position = pw0;
+ //Out.Position.z = 0.0;
+ emitVertex(Out);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Fragment shader - knots
+////////////////////////////////////////////////////////////////////////////////
+
+float4 fsKnots (FS_INPUT_Knots In) : COLOR0
+{
+ if(In.Sel == 0.0)
+ return knotCol;
+ else
+ return knotSel;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Vertex shader - brush
+////////////////////////////////////////////////////////////////////////////////
+
+/*POINT*/ LINE LINE_OUT void gsBrush (AttribArray<GS_INPUT_Brush> In)
+{
+ FS_INPUT_Brush Out;
+
+ float R = 0.2;
+ float Rx = In[1].Position.x;
+ float Ry = In[1].Position.y;
+
+ float4 v = mul(ViewIXf, float4(0.0, 0.0, 1.0,1.0));
+ float4 u = mul(ViewIXf, float4(0.0, 1.0, 0.0,1.0));
+ float4 l = mul(ViewIXf, float4(1.0, 0.0, 0.0,1.0));
+ float4 c = mul(ViewIXf, float4(0.0, 0.0, 0.0,1.0));
+
+ //////////////////////////////////
+ //Out.Position = c;
+ //emitVertex(Out);
+ //Out.Position = v;
+ //emitVertex(Out);
+ //////////////////////////////////
+
+ float3 up = normalize(u.xyz-c.xyz);
+ float3 left = normalize(l.xyz-c.xyz);
+
+ float dstep = 360.0f/nsegs;
+ float rstep = dstep*pi/(180.0f);
+ int pid = 0;
+
+ for (int h = 0; h < nsegs; h++){
+ int hh = (h+1)%nsegs;
+ float a1 = rstep*(float)h;
+ float a2 = rstep*(float)hh;
+
+ float x1 = Rx*sin(a1);
+ float y1 = Ry*cos(a1);
+
+ float x2 = Rx*sin(a2);
+ float y2 = Ry*cos(a2);
+
+ // float4 p1 = mul(WVPXf, float4(x1, y1, 0.0,1.0));
+ // float4 p2 = mul(WVPXf, float4(x2, y2, 0.0,1.0));
+
+ //float4 p1 = float4(x1, y1, 0.0,1.0);
+ //float4 p2 = float4(x2, y2, 0.0,1.0);
+
+ float4 p1 = float4(In[0].Position.xyz, 0.0) + float4(x1, y1, 0.0,1.0);
+ float4 p2 = float4(In[0].Position.xyz, 0.0) + float4(x2, y2, 0.0,1.0);
+
+ //float4 p1 = float4(0.2, 0.0, 0.0, 0.0) + float4(x1, y1, 0.0,1.0);
+ //float4 p2 = float4(x2, y2, 0.0,1.0);
+
+
+ Out.Position = p1;
+ Out.Position.z = 0.0;
+ emitVertex(Out);
+
+ Out.Position = p2;
+ Out.Position.z = 0.0;
+ emitVertex(Out);
+ }
+}
+
+GS_INPUT_Brush vsBrush (VS_INPUT_Brush In)
+{
+ //FS_INPUT_Brush Out;
+ GS_INPUT_Brush Out;
+ Out.Position = In.Position.xyz; // mul(WVPXf, float4(In.Position.xyz,1.0));
+ return Out;
+}
+
+FS_INPUT_Brush vsBrushLine (VS_INPUT_Brush In)
+{
+ FS_INPUT_Brush Out;
+ Out.Position = float4(In.Position.xyz,1.0);
+ //Out.Position = mul(WVPXf, float4(In.Position.xyz,1.0));
+ Out.Position.z = 0.0;
+ return Out;
+}
+
+float4 fsBrush (FS_INPUT_Brush In) : COLOR0
+{
+ return brushCol;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+// Techniques
+////////////////////////////////////////////////////////////////////////////////
+
+technique StrandLines
+{
+ pass p0
+ {
+ AlphaBlendEnable = true;
+ AlphaTestEnable = true;
+ BlendEnable = true;
+ BlendFunc = int2(SrcAlpha, OneMinusSrcAlpha);
+ // DepthTestEnable = true;
+ // DepthMask = true;
+ CullFaceEnable = false;
+
+ //VertexShader = compile gp4vp vsHair();
+ //GeometryProgram = compile gp4gp gsHair();
+
+ //VertexShader = compile gp4vp vsHairPoly();
+ //PixelShader = compile gp4fp fsHair();
+
+ VertexShader = compile glslv vsHairPoly();
+ PixelShader = compile glslf fsHair();
+
+ }
+}
+
+technique InstanceWire
+{
+ pass p0
+ {
+ //AlphaBlendEnable = true;
+ CullFaceEnable = false;
+
+ //VertexShader = compile gp4vp vsInstWire();
+ //PixelShader = compile gp4fp fsInstWire();
+
+ VertexShader = compile glslv vsInstWire();
+ PixelShader = compile glslf fsInstWire();
+ }
+}
+
+technique InstanceSolid
+{
+ pass p0
+ {
+ CullFaceEnable = false;
+ AlphaBlendEnable = true;
+ AlphaTestEnable = true;
+ BlendEnable = true;
+ BlendFunc = int2(SrcAlpha, OneMinusSrcAlpha);
+
+ //VertexShader = compile gp4vp vsInstSolid();
+ //PixelShader = compile gp4fp fsInstSolid();
+
+ VertexShader = compile glslv vsInstSolid();
+ PixelShader = compile glslf fsInstSolid();
+ }
+}
+
+technique Guides
+{
+ pass p0
+ {
+ //AlphaBlendEnable = true;
+ CullFaceEnable = false;
+
+
+ //VertexShader = compile gp4vp vsGuides();
+ //GeometryProgram = compile gp4gp gsGuides();
+
+ //VertexShader = compile gp4vp vsGuidesPoly();
+ //PixelShader = compile gp4fp fsGuides();
+
+ VertexShader = compile glslv vsGuidesPoly();
+ PixelShader = compile glslf fsGuides();
+ }
+}
+
+technique Knots
+{
+ pass p0
+ {
+ //AlphaBlendEnable = true;
+ CullFaceEnable = false;
+
+ //VertexShader = compile gp4vp vsKnots();
+ //GeometryProgram = compile gp4gp gsKnots();
+
+ VertexShader = compile gp4vp vsKnotsPoly();
+ PixelShader = compile gp4fp fsKnots();
+
+ VertexShader = compile glslv vsKnotsPoly();
+ PixelShader = compile glslf fsKnots();
+
+ }
+}
+
+
+technique Brush
+{
+ pass p0
+ {
+ //AlphaBlendEnable = true;
+ CullFaceEnable = false;
+
+ //VertexShader = compile gp4vp vsBrush();
+ //GeometryProgram = compile gp4gp gsBrush();
+ //PixelShader = compile gp4fp fsBrush();
+
+ VertexShader = compile glslv vsBrushLine();
+ PixelShader = compile glslf fsBrush();
+ }
+}
diff --git a/CgFx/shaveInst.cgfx b/CgFx/shaveInst.cgfx
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/CgFx/shaveInst.cgfx