22
Real-Time Stroke Textures Bert Freudenberg Bert Freudenberg Institut für Simulation und Institut für Simulation und Graphik Graphik Universität Magdeburg Universität Magdeburg

Real-Time Stroke Textures Bert Freudenberg Institut für Simulation und Graphik Universität Magdeburg

Embed Size (px)

Citation preview

Page 1: Real-Time Stroke Textures Bert Freudenberg Institut für Simulation und Graphik Universität Magdeburg

Real-Time Stroke Textures

Real-Time Stroke Textures

Bert FreudenbergBert Freudenberg

Institut für Simulation und Institut für Simulation und GraphikGraphik

Universität MagdeburgUniversität Magdeburg

Page 2: Real-Time Stroke Textures Bert Freudenberg Institut für Simulation und Graphik Universität Magdeburg

Real-Time Stroke TexturesReal-Time Stroke TexturesOverviewOverview

•Pen-and-ink style in CG

•Texture based real-time approaches

•Basic stroke-map technique

•Extensions

•Conclusion

Page 3: Real-Time Stroke Textures Bert Freudenberg Institut für Simulation und Graphik Universität Magdeburg

Pen-and-ink style in CGPen-and-ink style in CG

Winkenbach and Salesin, 1994

Page 4: Real-Time Stroke Textures Bert Freudenberg Institut für Simulation und Graphik Universität Magdeburg

Real-Time TechniquesReal-Time TechniquesLine basedLine based

• Lines drawn individually

• To slow for shading

• Outline only

Texture basedTexture based• Multiple lines drawn at once

• Suited for shading

Page 5: Real-Time Stroke Textures Bert Freudenberg Institut für Simulation und Graphik Universität Magdeburg

Texture based approachesTexture based approachesLake et al., 2000Lake et al., 2000

•1 texture per triangle

•Lit and split by CPU

•Flat shading

Page 6: Real-Time Stroke Textures Bert Freudenberg Institut für Simulation und Graphik Universität Magdeburg

Texture based approachesTexture based approachesPraun et al., 2001 Praun et al., 2001 (presented (presented

tomorrow)tomorrow)

•2 textures per vertex = 6 per face

•Lit by Vertex Program

•Blended by GPU

•Gouraud shading

Page 7: Real-Time Stroke Textures Bert Freudenberg Institut für Simulation und Graphik Universität Magdeburg

Texture based approachesTexture based approachesFreudenberg, 2001 Freudenberg, 2001 (presented (presented

now)now)

•Multiple layers per pixel

•Lit completely by GPU

•Per-pixel shading

Page 8: Real-Time Stroke Textures Bert Freudenberg Institut für Simulation und Graphik Universität Magdeburg

Varying Line-Width ShadingVarying Line-Width ShadingIdeaIdea

• Create half-toning pattern T

• Per-pixel compare to target intensity I

• Output black or white pixels

T

T > I

I

Page 9: Real-Time Stroke Textures Bert Freudenberg Institut für Simulation und Graphik Universität Magdeburg

Varying Line-Width ShadingVarying Line-Width ShadingIdeaIdea

• Create half-toning pattern T

• Per-pixel compare to target intensity I

• Output black or white pixels

ProblemProblem• Aliasing

SolutionSolution• Scaling instead of thresholding

Page 10: Real-Time Stroke Textures Bert Freudenberg Institut für Simulation und Graphik Universität Magdeburg

Varying Line-Width ShadingVarying Line-Width ShadingScalingScaling

TIT + I1 – (T + I)44 (1 – (T + I))1 – 44 (1 – (T + I))Anti-aliased result

Page 11: Real-Time Stroke Textures Bert Freudenberg Institut für Simulation und Graphik Universität Magdeburg

Varying Line-Width ShadingVarying Line-Width Shading

Page 12: Real-Time Stroke Textures Bert Freudenberg Institut für Simulation und Graphik Universität Magdeburg

Stroke MapsStroke Maps

IdeaIdea•Strokes are drawn in layers

•Encoded into one texture

•Expanded at run-time

•Selected by reference intensity

Page 13: Real-Time Stroke Textures Bert Freudenberg Institut für Simulation und Graphik Universität Magdeburg

Stroke MapsStroke Maps

Layering of Strokes Layering of Strokes

Page 14: Real-Time Stroke Textures Bert Freudenberg Institut für Simulation und Graphik Universität Magdeburg

Stroke MapsStroke Maps

EncodingEncoding•Pre-processing step

•Encode layers as gray

•1st layer black•2nd layer 66% gray•3rd layer 33% gray

•Paint last-to-first into texture = Stroke Map

Page 15: Real-Time Stroke Textures Bert Freudenberg Institut für Simulation und Graphik Universität Magdeburg

Stroke MapsStroke Maps

ExpansionExpansion• At run-time

• Using per-pixel operations

• EXACT same formula as for line-width variation

• 1 – 44 (1 – (T + I))• General combiner:

r0 = scale_by_4( sum( invert( t ) , negate( i ) ) )

• Final combiner:out = invert(r0)

Page 16: Real-Time Stroke Textures Bert Freudenberg Institut für Simulation und Graphik Universität Magdeburg

I T sum scaled

Stroke MapsStroke Maps

Page 17: Real-Time Stroke Textures Bert Freudenberg Institut für Simulation und Graphik Universität Magdeburg

Stroke MapsStroke Maps

NVPARSE codeNVPARSE code{ rgb { discard = unsigned_invert(tex0); // 1-T discard = -col0; // -I spare0 = sum(); // 1-T-I scale_by_four(); // 4(1-T-I) }}out.rgb = unsigned_invert(spare0); // 1-4(1-(T+I))

Page 18: Real-Time Stroke Textures Bert Freudenberg Institut für Simulation und Graphik Universität Magdeburg

ExtensionsExtensions

Indication MappingIndication Mapping•Enabled by per-pixel evaluation

•Bias intensity by indication

•Needs one additional combiner stage

Page 19: Real-Time Stroke Textures Bert Freudenberg Institut für Simulation und Graphik Universität Magdeburg

ExtensionsExtensions

ShadowsShadows•Combinable with most shadow algorithms

•Adds greatly to realism

Page 20: Real-Time Stroke Textures Bert Freudenberg Institut für Simulation und Graphik Universität Magdeburg

Conclusion Conclusion

ShortcomingsShortcomings•Limited accuracy

•Layers not strictly separated

•Only one-pass shading supported

•Multiple passes via render-to-texture

Page 21: Real-Time Stroke Textures Bert Freudenberg Institut für Simulation und Graphik Universität Magdeburg

ConclusionConclusion

AdvantagesAdvantages•Cheap:

•no CPU effort

•one texture unit

•one register combiner

•one pass

•Even works on “old” GeForce

•Well suited for highly interactive environments

Page 22: Real-Time Stroke Textures Bert Freudenberg Institut für Simulation und Graphik Universität Magdeburg

Real-Time Stroke TexturesReal-Time Stroke TexturesQuestions?Questions?