yum-mirror/glslang
git clone https://git.yummers.dev/yum-mirror/glslang
6e49c76e
16.4.0
1cbuffer UniformBlock0 : register ( b0 ) 2{ 3float4x4 model_view_matrix ; 4float4x4 proj_matrix ; 5float4x4 model_view_proj_matrix ; 6float3x3 normal_matrix ; 7float3 color ; 8float3 view_dir ; 9float3 tess_factor ; 10} ; 11 12// ============================================================================= 13// Hull Shader 14// ============================================================================= 15struct HSInput { 16float3 PositionWS : POSITION ; 17float3 NormalWS : NORMAL ; 18} ; 19 20struct HSOutput { 21float3 PositionWS : POSITION ; 22} ; 23 24struct HSTrianglePatchConstant { 25float EdgeTessFactor [ 3 ] : SV_TessFactor ; 26float InsideTessFactor : SV_InsideTessFactor ; 27float3 NormalWS [ 3 ] : NORMAL ; 28} ; 29 30HSTrianglePatchConstant HSPatchConstant ( InputPatch < HSInput , 3 > patch ) 31{ 32float3 roundedEdgeTessFactor = tess_factor ; 33float roundedInsideTessFactor = 3 ; 34float insideTessFactor = 1 ; 35 36HSTrianglePatchConstant result ; 37 38// Edge and inside tessellation factors 39result . EdgeTessFactor [ 0 ] = roundedEdgeTessFactor . x ; 40result . EdgeTessFactor [ 1 ] = roundedEdgeTessFactor . y ; 41result . EdgeTessFactor [ 2 ] = roundedEdgeTessFactor . z ; 42result . InsideTessFactor = roundedInsideTessFactor ; 43 44// Constant data 45result . NormalWS [ 0 ] = patch [ 0 ] . NormalWS ; 46result . NormalWS [ 1 ] = patch [ 1 ] . NormalWS ; 47result . NormalWS [ 2 ] = patch [ 2 ] . NormalWS ; 48 49return result ; 50} 51 52[ domain ( "tri" )] 53[ partitioning ( "fractional_odd" )] 54[ outputtopology ( "triangle_ccw" )] 55[ outputcontrolpoints ( 3 )] 56[ patchconstantfunc ( "HSPatchConstant" )] 57HSOutput HSMain ( 58InputPatch < HSInput , 3 > patch , 59uint id : SV_OutputControlPointID 60) 61{ 62HSOutput output ; 63output . PositionWS = patch [ id ] . PositionWS ; 64return output ; 65} 66 67// ============================================================================= 68// Geometry Shader 69// ============================================================================= 70struct GSVertexInput { 71float3 PositionWS : POSITION ; 72float3 NormalWS : NORMAL ; 73} ; 74 75struct GSVertexOutput { 76float4 PositionCS : SV_POSITION ; 77} ; 78 79[ maxvertexcount ( 6 )] 80void GSMain ( 81triangle GSVertexInput input [ 3 ] , 82inout LineStream < GSVertexOutput > output 83) 84{ 85 86float3 P0 = input [ 0 ] . PositionWS . xyz ; 87float3 P1 = input [ 1 ] . PositionWS . xyz ; 88float3 P2 = input [ 2 ] . PositionWS . xyz ; 89 90GSVertexOutput vertex ; 91// Totally hacky... 92P0 . z += 0.001 ; 93P1 . z += 0.001 ; 94P2 . z += 0.001 ; 95float4 Q0 = mul ( proj_matrix , float4 ( P0 , 1.0 )) ; 96float4 Q1 = mul ( proj_matrix , float4 ( P1 , 1.0 )) ; 97float4 Q2 = mul ( proj_matrix , float4 ( P2 , 1.0 )) ; 98 99// Edge 0 100vertex . PositionCS = Q0 ; 101output . Append ( vertex ) ; 102vertex . PositionCS = Q1 ; 103output . Append ( vertex ) ; 104output . RestartStrip () ; 105 106// Edge 1 107vertex . PositionCS = Q1 ; 108output . Append ( vertex ) ; 109vertex . PositionCS = Q2 ; 110output . Append ( vertex ) ; 111output . RestartStrip () ; 112 113// Edge 2 114vertex . PositionCS = Q2 ; 115output . Append ( vertex ) ; 116vertex . PositionCS = Q0 ; 117output . Append ( vertex ) ; 118output . RestartStrip () ; 119}