diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index f0855921..43f697e8 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,6 @@ +### 5.4.10-prerelease0005 +- [Text] added option to disable sample shading + ### 5.4.10-prerelease0004 - [GL] added flag to disable multidraw (experimental) diff --git a/src/Aardvark.Rendering.Text/Font.fs b/src/Aardvark.Rendering.Text/Font.fs index 8d31044c..34731a13 100644 --- a/src/Aardvark.Rendering.Text/Font.fs +++ b/src/Aardvark.Rendering.Text/Font.fs @@ -502,6 +502,11 @@ type Font private(impl : FontImpl, family : string) = new(family : string) = Font(family, 400, false) + +module FontRenderingSettings = + let mutable DisableSampleShading = false + + type ShapeCache(r : IRuntime) = static let cache = ConcurrentDictionary() @@ -519,19 +524,26 @@ type ShapeCache(r : IRuntime) = let boundarySurfaceCache = ConcurrentDictionary() let billboardSurfaceCache = ConcurrentDictionary() + + let pathShader = + if FontRenderingSettings.DisableSampleShading then + Path.Shader.pathFragmentNoSampleShading |> toEffect + else + Path.Shader.pathFragment |> toEffect + let effect = FShade.Effect.compose [ Path.Shader.pathVertex |> toEffect //Path.Shader.pathTrafo |> toEffect Path.Shader.depthBiasVs |> toEffect - Path.Shader.pathFragment |> toEffect + pathShader ] let instancedEffect = FShade.Effect.compose [ Path.Shader.pathVertexInstanced |> toEffect Path.Shader.depthBiasVs |> toEffect - Path.Shader.pathFragment |> toEffect + pathShader ] let boundaryEffect = @@ -551,14 +563,14 @@ type ShapeCache(r : IRuntime) = FShade.Effect.compose [ Path.Shader.pathVertexBillboard |> toEffect Path.Shader.depthBiasVs |> toEffect - Path.Shader.pathFragment |> toEffect + pathShader ] let instancedBillboardEffect = FShade.Effect.compose [ Path.Shader.pathVertexInstancedBillboard |> toEffect Path.Shader.depthBiasVs |> toEffect - Path.Shader.pathFragment |> toEffect + pathShader ] let surface (s : IFramebufferSignature) = @@ -566,7 +578,7 @@ type ShapeCache(r : IRuntime) = r.PrepareEffect( s, [ Path.Shader.pathVertex |> toEffect - Path.Shader.pathFragment |> toEffect + pathShader ] ) ) diff --git a/src/Aardvark.Rendering.Text/Path.fs b/src/Aardvark.Rendering.Text/Path.fs index 6aa46f31..02d7125b 100644 --- a/src/Aardvark.Rendering.Text/Path.fs +++ b/src/Aardvark.Rendering.Text/Path.fs @@ -55,6 +55,22 @@ module Path = [] layer : float + [] instanceTrafo : M34d + } + + type VertexNoSampleShading = + { + [] p : V4d + [] klmKind : V4d + [] tr0 : V4d + [] tr1 : V4d + [] color : V4d + + [] samplePos : V2d + + [] layer : float + + [] instanceTrafo : M34d } @@ -240,6 +256,45 @@ module Path = } + let pathFragmentNoSampleShading(v : VertexNoSampleShading) = + fragment { + let kind = v.klmKind.W + + let mutable color = v.color + + if uniform.FillGlyphs then + if kind > 1.5 && kind < 3.5 then + // bezier2 + let ci = v.klmKind.XYZ + let f = (ci.X * ci.X - ci.Y) * ci.Z + if f > 0.0 then + discard() + + elif kind > 3.5 && kind < 5.5 then + // arc + let ci = v.klmKind.XYZ + let f = ((ci.X * ci.X + ci.Y*ci.Y) - 1.0) * ci.Z + + if f > 0.0 then + discard() + + elif kind > 5.5 then + let ci = v.klmKind.XYZ + let f = ci.X * ci.X * ci.X - ci.Y * ci.Z + if f > 0.0 then + discard() + else + if kind > 1.5 && kind < 3.5 then + color <- V4d.IOOI + elif kind > 3.5 && kind < 5.5 then + color <- V4d.OIOI + elif kind > 5.5 then + color <- V4d.OOII + + return color + + } + let boundaryVertex (v : Vertex) = vertex { return { v with p = uniform.ModelViewProjTrafo * v.p }