void GS_Circle(VS_GS[] input, TriangleStream <PS_IN> spriteStream) { PS_IN v = new PS_IN(); // center vertex v.Color = input[0].Color; v.UV = new Vector4(); Vector4 center = new Vector4(input[0].Pos, 0, 1); float segs = input[0].Rotation; Vector2 radius = input[0].Size; Vector2 startEnd = input[0].Origin; float range = startEnd.Y - startEnd.X; float angleInc = degToRad360 / segs; float angle = startEnd.X; float remaining = range; float inc = 0; float doEdge = 0; // if 0, we place a center point for the strip to orient around. float vCount = (segs * 2) + 2; for (int i = 0; i < vCount; i++) { v.Pos = center + (doEdge * new Vector4(Sin(angle) * radius.X, Cos(angle) * radius.Y, 0, 0)); v.Pos = Mul(v.Pos, wvp); inc = Min(angleInc, remaining); angle += inc * doEdge; remaining -= inc * doEdge; doEdge = 1 - doEdge; spriteStream.Append(v); } }
void GS_Line(VS_GS[] input, TriangleStream <PS_IN> spriteStream) { PS_IN v = new PS_IN(); v.Color = input[0].Color; v.UV = new Vector4(); Vector2 p1 = input[0].Pos; Vector2 p2 = input[0].Size; Vector2 dir = p2 - p1; Vector2 normal = Normalize(new Vector2(-dir.Y, dir.X)); float thickness = input[0].Rotation * 0.5f; // Vertex p1 vertex 0 (v0) v.Pos = new Vector4(p1 - (thickness * normal), 0, 1); v.Pos = Mul(v.Pos, wvp); spriteStream.Append(v); // Vertex p1 vertex 1 (v1) v.Pos = new Vector4(p1 + (thickness * normal), 0, 1); v.Pos = Mul(v.Pos, wvp); spriteStream.Append(v); // Vertex p2 vertex 0 (v2) v.Color = input[0].UV; v.Pos = new Vector4(p2 - (thickness * normal), 0, 1); v.Pos = Mul(v.Pos, wvp); spriteStream.Append(v); // Vertex p2 vertex 1 (v3) v.Pos = new Vector4(p2 + (thickness * normal), 0, 1); v.Pos = Mul(v.Pos, wvp); spriteStream.Append(v); }
void GS(VS_GS[] input, TriangleStream <PS_IN> spriteStream) { PS_IN v = new PS_IN(); VS_GS g = input[0]; v.Color = g.Color; Matrix2x2 rot = GetRotation(input[0].Rotation); Vector2 origin = g.Origin.XY; Vector2 pos = g.Pos.XY; Vector2 size = g.Size.XY; Vector2 uv = g.UV.XY; Vector2 p; for (int i = 0; i < 4; i++) { p = Mul(size * (spriteCorners[i] - origin), rot); p += pos; v.Pos = new Vector4(p, 0, 1); v.Pos = Mul(v.Pos, wvp); v.UV.X = uv[uvTable[i].X]; v.UV.Y = uv[uvTable[i].Y]; v.UV.Z = g.ArraySlice; spriteStream.Append(v); } }
Texture2D<float4> _TexSpecularAlbedo; //: register( t11 ); #endregion Fields #region Methods PS_OUT PS( PS_IN _In ) { PS_OUT Out; Out.DiffuseAlbedo = _DiffuseAlbedo; if ( _HasDiffuseTexture ) Out.DiffuseAlbedo = _TexDiffuseAlbedo.Sample( LinearWrap, _In.UV ).xyz; // Out.NormalDistance = _float4( normalize( _In.Normal ), length( _In.Position - _Camera2World[3].xyz ) ); // Store distance Out.NormalDistance = _float4( normalize( _In.Normal ), dot( _In.Position - _Camera2World[3].xyz, _Camera2World[2].xyz ) ); // Store Z return Out; }
PS_OUT PS(PS_IN _In) { PS_OUT Out; Out.DiffuseAlbedo = _DiffuseAlbedo; if (_HasDiffuseTexture) { Out.DiffuseAlbedo = _TexDiffuseAlbedo.Sample(LinearWrap, _In.UV).xyz; } // Out.NormalDistance = _float4( normalize( _In.Normal ), length( _In.Position - _Camera2World[3].xyz ) ); // Store distance Out.NormalDistance = _float4(normalize(_In.Normal), dot(_In.Position - _Camera2World[3].xyz, _Camera2World[2].xyz)); // Store Z return(Out); }
void GS_Tri(VS_GS[] input, TriangleStream <PS_IN> spriteStream) { PS_IN v = new PS_IN(); v.Color = input[0].Color; v.UV = new Vector4(); // p1 v.Pos = Mul(new Vector4(input[0].Pos, 0, 1), wvp); spriteStream.Append(v); // p3 v.Pos = Mul(new Vector4(input[0].Origin, 0, 1), wvp); spriteStream.Append(v); // p2 v.Pos = Mul(new Vector4(input[0].Size, 0, 1), wvp); spriteStream.Append(v); }
Vector4 PS_NoTexture(PS_IN input) { return(input.Color); }
Vector4 PS(PS_IN input) { Vector4 col = mapDiffuse.Sample(diffuseSampler, input.UV.XYZ); return(col * input.Color); }