FShade icon indicating copy to clipboard operation
FShade copied to clipboard

Cannot pass tessellation levels from TCS to TES

Open madorjan opened this issue 4 years ago • 0 comments

In order to visualize the derived tessellation level using vertex colors I wanted to pass an outer tessellation level from the control shader to the evaluation shader.

Unfortunately the shader code produced by FShade isn't correct.

let heightTess (t : Triangle<Vertex>) =
        tessellation {
            //TCS part
            let outer01 = tessScreenSpaceSphere t.P0.pos t.P1.pos t.P0.tc t.P1.tc
            let outer12 = tessScreenSpaceSphere t.P1.pos t.P2.pos t.P1.tc t.P2.tc
            let outer20 = tessScreenSpaceSphere t.P2.pos t.P0.pos t.P2.tc t.P0.tc

            let inner = (outer01 + outer12 + outer20) / 3.0

            let! coord = tessellateTriangle inner (outer12, outer20, outer01)

            //TES part
            let p = coord.X * t.P0.pos + coord.Y * t.P1.pos + coord.Z * t.P2.pos
            let tc = coord.X * t.P0.tc + coord.Y * t.P1.tc + coord.Z * t.P2.tc
            let c = coord.X * t.P0.c + coord.Y * t.P1.c + coord.Z * t.P2.c

            let h0 = heightMap.Sample(tc).X

            let p0 = V3d(p.X,p.Y,h0)

            return {
                pos = uniform.ModelViewProjTrafo * V4d(p0, 1.0)
                wp = uniform.ModelTrafo * V4d(p0, 1.0)
                n = V3d.OOI
                tc = tc
                c = c
                level = outer01
            }
        }

This correctly produces patch out float te_outer01; for the outer01 attribute in the control shader. Instead of patch in float te_outer01; just in float te_outer01; is produced for the evaluation shader.

I think this leads to the following error message when compiling the shader code:

[GL] shader compiler returned errors: "Tessellation evaluation info
----------------------------
0(141) : error C7544: OpenGL requires tessellation evaluation inputs to be arrays
"

madorjan avatar Feb 02 '21 15:02 madorjan