@@ 94,6 94,8 @@ SECTOR_CAPACITY := MAX_CASCADE_DEPTH * 1
CASCADE_SIZE := (1 << MAX_CASCADE_DEPTH)
CASCADE_CENTER := (CASCADE_SIZE // 2)
+InstanceVertexCount := 4
+
let BINDING_BUF_SECTOR_IN = 1
let BINDING_BUF_SECTOR_INOUT = 2
let BINDING_BUF_VERTEX_IN = 3
@@ 1142,10 1144,10 @@ fn generate-quad (v00 v01 v10 v11)
_ v00 v10 v11 v01
# generate quad
- let ofs = (atomicAdd vertex-out.count 6)
+ let ofs = (atomicAdd vertex-out.count 4)
sector := (sector-inout.keys @ gl_WorkGroupID.x)
atomicMin sector.offset-min ofs
- atomicMax sector.offset-max (ofs + 6)
+ atomicMax sector.offset-max (ofs + 4)
entries := vertex-out.entries
static-if USE_FLAT_SHADING
n0 := (triangle-normal v00.pos v11.pos v10.pos)
@@ 1153,18 1155,16 @@ fn generate-quad (v00 v01 v10 v11)
#n1 := (normal v00.pos v11.pos v01.pos)
entries @ (ofs + 0) = (swapnormal v00 n0)
- entries @ (ofs + 1) = (swapnormal v10 n0)
+ entries @ (ofs + 1) = (swapnormal v10 n1)
entries @ (ofs + 2) = (swapnormal v11 n0)
- entries @ (ofs + 3) = (swapnormal v11 n1)
- entries @ (ofs + 4) = (swapnormal v01 n1)
- entries @ (ofs + 5) = (swapnormal v00 n1)
+ #entries @ (ofs + 3) = (swapnormal v11 n1)
+ entries @ (ofs + 3) = (swapnormal v01 n1)
+ #entries @ (ofs + 5) = (swapnormal v00 n1)
else
entries @ (ofs + 0) = v00
entries @ (ofs + 1) = v10
entries @ (ofs + 2) = v11
- entries @ (ofs + 3) = v11
- entries @ (ofs + 4) = v01
- entries @ (ofs + 5) = v00
+ entries @ (ofs + 3) = v01
;
let
@@ 1480,7 1480,8 @@ inout depthval : f32
inout albedo : vec4
inout matdata : vec4
fn rasterize-vert ()
- let vertex-index = ((deref gl_VertexID) as u32)
+ #let vertex-index = ((deref gl_VertexID) as u32)
+ vertex-index := gl_InstanceID * InstanceVertexCount + gl_VertexID
let vin = (deref (vertex-in.entries @ vertex-index))
let coord = (vec3 vin.pos.xyz)
let lod = (vin.pos.w as f32)
@@ 1990,8 1991,8 @@ inline main ()
indirect-draw-arrays-setup
inline ()
_
- deref vertex-in.count
- 1
+ InstanceVertexCount
+ (deref vertex-in.count) // InstanceVertexCount
0
0
@@ 2022,7 2023,9 @@ inline main ()
GL.UseProgram pg-rasterize
GL.BindVertexArray vao-empty
- exec-draw-arrays GL.TRIANGLES
+ #exec-draw-arrays GL.TRIANGLES
+ exec-draw-arrays GL.TRIANGLE_FAN
+ #exec-draw-arrays GL.TRIANGLE_LINES
GL.Disable GL.DEPTH_TEST
GL.Disable GL.CULL_FACE