<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
		<id>https://wiki.delphigl.com/index.php?action=history&amp;feed=atom&amp;title=shader_Instancing</id>
		<title>shader Instancing - Versionsgeschichte</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.delphigl.com/index.php?action=history&amp;feed=atom&amp;title=shader_Instancing"/>
		<link rel="alternate" type="text/html" href="https://wiki.delphigl.com/index.php?title=shader_Instancing&amp;action=history"/>
		<updated>2026-04-29T19:19:31Z</updated>
		<subtitle>Versionsgeschichte dieser Seite in DGL Wiki</subtitle>
		<generator>MediaWiki 1.27.4</generator>

	<entry>
		<id>https://wiki.delphigl.com/index.php?title=shader_Instancing&amp;diff=24526&amp;oldid=prev</id>
		<title>Coolcat: /* Was ist Instancing? */</title>
		<link rel="alternate" type="text/html" href="https://wiki.delphigl.com/index.php?title=shader_Instancing&amp;diff=24526&amp;oldid=prev"/>
				<updated>2010-01-09T16:54:29Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Was ist Instancing?&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;' lang='de'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Nächstältere Version&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Version vom 9. Januar 2010, 16:54 Uhr&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l17&quot; &gt;Zeile 17:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 17:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Was ist Instancing? ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Was ist Instancing? ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Dieses Tutorial befasst sich mit dem Thema Instancing und der Extension [[GL_ARB_draw_instanced]]. Ein häufiger Anwendungsfall ist das rendern vieler gleichartiger Objekte. Hier im Beispiel geht es um das rendern von Vegetation, es gibt aber auch viele weitere Anwendungen. Man könnte die Technik beispielsweise auch für Billboards einsetzen. Die Voraussetzung für Instancing ist, dass sich die zu renderden Objekte die selben Vertex-Daten teilen. Die Primitiv-Anzahl und der Primitiv-Typ müssen identisch sein. Die Extension beschleunigt derartige Anwendungen, in dem die Anzahl der API-Aufrufe und die Menge redundanter Daten reduziert wird.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Dieses Tutorial befasst sich mit dem Thema &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[[&lt;/ins&gt;Instancing&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;]] &lt;/ins&gt;und der Extension [[GL_ARB_draw_instanced]]. Ein häufiger Anwendungsfall ist das rendern vieler gleichartiger Objekte. Hier im Beispiel geht es um das rendern von Vegetation, es gibt aber auch viele weitere Anwendungen. Man könnte die Technik beispielsweise auch für Billboards einsetzen. Die Voraussetzung für Instancing ist, dass sich die zu renderden Objekte die selben Vertex-Daten teilen. Die Primitiv-Anzahl und der Primitiv-Typ müssen identisch sein. Die Extension beschleunigt derartige Anwendungen, in dem die Anzahl der API-Aufrufe und die Menge redundanter Daten reduziert wird.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Voraussetzungen ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Voraussetzungen ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Coolcat</name></author>	</entry>

	<entry>
		<id>https://wiki.delphigl.com/index.php?title=shader_Instancing&amp;diff=24123&amp;oldid=prev</id>
		<title>Coolcat: /* Initialisierung */</title>
		<link rel="alternate" type="text/html" href="https://wiki.delphigl.com/index.php?title=shader_Instancing&amp;diff=24123&amp;oldid=prev"/>
				<updated>2009-08-13T15:04:43Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Initialisierung&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;' lang='de'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Nächstältere Version&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Version vom 13. August 2009, 15:04 Uhr&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l68&quot; &gt;Zeile 68:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 68:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;		position.y = getTerrainHeight(position.x, position.z);&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;		position.y = getTerrainHeight(position.x, position.z);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;		// &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Daten &lt;/del&gt;schreiben&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;. &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;		// &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Positionsdaten &lt;/ins&gt;schreiben&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;		data[pos++] = position.x;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;		data[pos++] = position.x;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;		data[pos++] = position.y;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;		data[pos++] = position.y;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;		data[pos++] = position.z;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;		data[pos++] = position.z;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;		data[pos++] = 1.3f + ((color - 100) / 100.0f) * (rnd() + 2.0f);&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;		// Skalierung abhängig von Steigung des Terrains und etwas Zufall.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;		data[pos++] = 1.3f + ((color - 100) / 100.0f) * (rnd() + 2.0f); &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;		++i;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;		++i;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Coolcat</name></author>	</entry>

	<entry>
		<id>https://wiki.delphigl.com/index.php?title=shader_Instancing&amp;diff=24119&amp;oldid=prev</id>
		<title>Coolcat: /* Funktionsweise */</title>
		<link rel="alternate" type="text/html" href="https://wiki.delphigl.com/index.php?title=shader_Instancing&amp;diff=24119&amp;oldid=prev"/>
				<updated>2009-08-13T14:46:55Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Funktionsweise&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;' lang='de'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Nächstältere Version&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Version vom 13. August 2009, 14:46 Uhr&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l29&quot; &gt;Zeile 29:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 29:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Funktionsweise ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Funktionsweise ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Im Beispiel werden insgesamt 1600 über das Terrain verteilte Büsche gerendert. Der Busch liegt als [[VBO]] mit [[Indices]] vor. Statt nun den Busch mit einer Schleife und &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;tt&amp;gt;&lt;/del&gt;glDrawElements&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;/tt&amp;gt; &lt;/del&gt;zu zeichnen, wird Instancing verwendet. Statt 1600 Aufrufen von &amp;lt;tt&amp;gt;glDrawElements&amp;lt;/tt&amp;gt;, wird nur ein einziger Aufruf von [[glDrawElementsInstancedARB]] benötigt.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Im Beispiel werden insgesamt 1600 über das Terrain verteilte Büsche gerendert. Der Busch liegt als [[VBO]] mit [[Indices]] vor. Statt nun den Busch mit einer Schleife und &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[[&lt;/ins&gt;glDrawElements&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;]] &lt;/ins&gt;zu zeichnen, wird Instancing verwendet. Statt 1600 Aufrufen von &amp;lt;tt&amp;gt;glDrawElements&amp;lt;/tt&amp;gt;, wird nur ein einziger Aufruf von [[glDrawElementsInstancedARB]] benötigt.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Jedes Objekt benötigt eine eigene ModelView-Matrix. Diese Matrix wird im Vertexshader erzeugt. Ein Texturbuffer-Objekt (TBO) liefert mit 4 Floats pro Objekt Daten zur Position und Skalierung. Natürlich kann man hier auch eine Rotation etc. einbauen, alles nur eine Frage der Komplexität.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Jedes Objekt benötigt eine eigene ModelView-Matrix. Diese Matrix wird im Vertexshader erzeugt. Ein Texturbuffer-Objekt (TBO) liefert mit 4 Floats pro Objekt Daten zur Position und Skalierung. Natürlich kann man hier auch eine Rotation etc. einbauen, alles nur eine Frage der Komplexität.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Coolcat</name></author>	</entry>

	<entry>
		<id>https://wiki.delphigl.com/index.php?title=shader_Instancing&amp;diff=24118&amp;oldid=prev</id>
		<title>Coolcat: /* Was ist Instancing? */</title>
		<link rel="alternate" type="text/html" href="https://wiki.delphigl.com/index.php?title=shader_Instancing&amp;diff=24118&amp;oldid=prev"/>
				<updated>2009-08-13T14:45:49Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Was ist Instancing?&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;' lang='de'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Nächstältere Version&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Version vom 13. August 2009, 14:45 Uhr&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l16&quot; &gt;Zeile 16:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Zeile 16:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Was ist Instancing?==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Was ist Instancing? ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Dieses Tutorial befasst sich mit dem Thema Instancing und der Extension [[GL_ARB_draw_instanced]]. Ein häufiger Anwendungsfall ist das rendern vieler gleichartiger Objekte. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Bei &lt;/del&gt;Beispiel &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;ist hier sicherlich &lt;/del&gt;das rendern von Vegetation, es gibt aber auch viele weitere Anwendungen. Die Voraussetzung für Instancing ist, dass sich die zu renderden Objekte die selben Vertex-Daten teilen. Die Primitiv-Anzahl und der Primitiv-Typ müssen identisch sein. Die Extension beschleunigt derartige Anwendungen, in dem die Anzahl der API-Aufrufe und die Menge redundanter Daten reduziert wird.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Dieses Tutorial befasst sich mit dem Thema Instancing und der Extension [[GL_ARB_draw_instanced]]. Ein häufiger Anwendungsfall ist das rendern vieler gleichartiger Objekte. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Hier im &lt;/ins&gt;Beispiel &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;geht es um &lt;/ins&gt;das rendern von Vegetation, es gibt aber auch viele weitere Anwendungen&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;. Man könnte die Technik beispielsweise auch für Billboards einsetzen&lt;/ins&gt;. Die Voraussetzung für Instancing ist, dass sich die zu renderden Objekte die selben Vertex-Daten teilen. Die Primitiv-Anzahl und der Primitiv-Typ müssen identisch sein. Die Extension beschleunigt derartige Anwendungen, in dem die Anzahl der API-Aufrufe und die Menge redundanter Daten reduziert wird.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;== Voraussetzungen ==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Instancing erfordert relativ neue Grafikhardware (ca. ab Geforce 8), man muss sich also überlegen, ob man diese Technik wirklich einsetzen möchte. Insbesondere beim rendern von hunderten identischer Objekte mit nur wenigen Polygonen bringt Instancing jedoch einen massiven Performance-Schub.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Instancing erfordert relativ neue Grafikhardware (ca. ab Geforce 8), man muss sich also überlegen, ob man diese Technik wirklich einsetzen möchte. Insbesondere beim rendern von hunderten identischer Objekte mit nur wenigen Polygonen bringt Instancing jedoch einen massiven Performance-Schub.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Für dieses Beispiel werden die folgenden Extensions benötigt:&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* [[GL_ARB_draw_instanced]] (klar...)&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* [[GL_EXT_gpu_shader4]] (für TBOs)&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* [[GL_EXT_texture_buffer_object]] (für TBOs)&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* [[GL_ARB_texture_float]] (32bit Float Texturen)&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;== Funktionsweise ==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Im Beispiel werden insgesamt 1600 über das Terrain verteilte Büsche gerendert. Der Busch liegt als [[VBO]] mit [[Indices]] vor. Statt nun den Busch mit einer Schleife und &amp;lt;tt&amp;gt;glDrawElements&amp;lt;/tt&amp;gt; zu zeichnen, wird Instancing verwendet. Statt 1600 Aufrufen von &amp;lt;tt&amp;gt;glDrawElements&amp;lt;/tt&amp;gt;, wird nur ein einziger Aufruf von [[glDrawElementsInstancedARB]] benötigt.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Jedes Objekt benötigt eine eigene ModelView-Matrix. Diese Matrix wird im Vertexshader erzeugt. Ein Texturbuffer-Objekt (TBO) liefert mit 4 Floats pro Objekt Daten zur Position und Skalierung. Natürlich kann man hier auch eine Rotation etc. einbauen, alles nur eine Frage der Komplexität.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Statt einem TBO kann man auch eine gewöhnliche Textur verwenden. Ein TBO eignet sich aber besser, da die Grafikkarte keine Texel-Interpolation vornimmt, sondern einfach nur einen Array-Zugriff mit Integer-Koordinaten.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Code==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Code==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Coolcat</name></author>	</entry>

	<entry>
		<id>https://wiki.delphigl.com/index.php?title=shader_Instancing&amp;diff=24116&amp;oldid=prev</id>
		<title>Coolcat: (unfertig, erstmal speichern....später mehr...)</title>
		<link rel="alternate" type="text/html" href="https://wiki.delphigl.com/index.php?title=shader_Instancing&amp;diff=24116&amp;oldid=prev"/>
				<updated>2009-08-13T12:46:58Z</updated>
		
		<summary type="html">&lt;p&gt;(unfertig, erstmal speichern....später mehr...)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=Shadername=&lt;br /&gt;
Zurück zur [[Shadersammlung]]&lt;br /&gt;
{|{{Prettytable_B1}} width=100%&lt;br /&gt;
!width=60%|Beschreibung&lt;br /&gt;
!width=20%|Autor&lt;br /&gt;
!width=20%|Version&lt;br /&gt;
|-&lt;br /&gt;
|Benutzung von [[GL_ARB_draw_instanced]]&lt;br /&gt;
|Coolcat&lt;br /&gt;
|1.0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Bilder==&lt;br /&gt;
{|&lt;br /&gt;
| [[Bild:shader_Instancing.jpg|thumb|256px|Terrain mit per Instancing gerenderten Pflanzen.]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Was ist Instancing?==&lt;br /&gt;
Dieses Tutorial befasst sich mit dem Thema Instancing und der Extension [[GL_ARB_draw_instanced]]. Ein häufiger Anwendungsfall ist das rendern vieler gleichartiger Objekte. Bei Beispiel ist hier sicherlich das rendern von Vegetation, es gibt aber auch viele weitere Anwendungen. Die Voraussetzung für Instancing ist, dass sich die zu renderden Objekte die selben Vertex-Daten teilen. Die Primitiv-Anzahl und der Primitiv-Typ müssen identisch sein. Die Extension beschleunigt derartige Anwendungen, in dem die Anzahl der API-Aufrufe und die Menge redundanter Daten reduziert wird.&lt;br /&gt;
&lt;br /&gt;
Instancing erfordert relativ neue Grafikhardware (ca. ab Geforce 8), man muss sich also überlegen, ob man diese Technik wirklich einsetzen möchte. Insbesondere beim rendern von hunderten identischer Objekte mit nur wenigen Polygonen bringt Instancing jedoch einen massiven Performance-Schub.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
====Initialisierung====&lt;br /&gt;
Hier wird ein Vertexbuffer-Objekt erzeugt, welches Daten zur Position und Skalierung einer jeden Pflanze enthält. Auf dieses VBO wird später im Shader als Texturbuffer-Objekt (TBO) zugegriffen.&lt;br /&gt;
&lt;br /&gt;
Ich verwende hier ein Graustufen-Bild welches angibt wo Pflanzen gesetzt werden dürfen. Dieses Bild hat an den Stellen eine helle Farbe an denen das Terrain flach ist. Steile Stellen sind dunkel.&lt;br /&gt;
&lt;br /&gt;
Dieses Vertexbuffer-Objekt könnte man auch in jedem Frame neu mit Daten füllen. Es wäre also auch möglich einen Sichtbarkeitstest durchzuführen. Natürlich muss man dabei insbesondere bei sehr kleinen Objekten abwägen, ob es nicht schneller ist einfach alles zu rendern.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
	plantCount = 1600; // insgesamt werden 1600 Pflanzen erzeugt&lt;br /&gt;
&lt;br /&gt;
	// create buffer object&lt;br /&gt;
	glGenTextures(1, &amp;amp;m_tboTransform);&lt;br /&gt;
	glGenBuffers(1, &amp;amp;m_vboTransform);&lt;br /&gt;
	unsigned int data_size = plantCount*4*sizeof(float);&lt;br /&gt;
	glBindBuffer(GL_ARRAY_BUFFER, m_vboTransform);&lt;br /&gt;
	glBufferData(GL_ARRAY_BUFFER, data_size, NULL, GL_STATIC_DRAW);&lt;br /&gt;
	float* data = (float*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);&lt;br /&gt;
	int pos=0;&lt;br /&gt;
	unsigned int i = 0;&lt;br /&gt;
	while (i&amp;lt;plantCount) {&lt;br /&gt;
		// zufällige Position ausdenken&lt;br /&gt;
		CVector3f position = rndVec() * 204.0f;&lt;br /&gt;
&lt;br /&gt;
		// Darf hier eine Pflanze hingesetzt werden?&lt;br /&gt;
		CVector2f lookup;&lt;br /&gt;
		lookup.x = (position.x - TERRAIN_XSHIFT) / TERRAIN_SIZE;&lt;br /&gt;
		lookup.y = (position.z - TERRAIN_ZSHIFT) / TERRAIN_SIZE;&lt;br /&gt;
		int color = getColor(image, lookup.x, lookup.y); &lt;br /&gt;
		if (color &amp;lt; 100) { continue; }&lt;br /&gt;
&lt;br /&gt;
		// Terrainhöhe bzw. y-Koordinate ermitteln&lt;br /&gt;
		position.y = getTerrainHeight(position.x, position.z);&lt;br /&gt;
&lt;br /&gt;
		// Daten schreiben. &lt;br /&gt;
		data[pos++] = position.x;&lt;br /&gt;
		data[pos++] = position.y;&lt;br /&gt;
		data[pos++] = position.z;&lt;br /&gt;
		data[pos++] = 1.3f + ((color - 100) / 100.0f) * (rnd() + 2.0f);&lt;br /&gt;
		++i;&lt;br /&gt;
	}&lt;br /&gt;
	glUnmapBuffer(GL_ARRAY_BUFFER);&lt;br /&gt;
&lt;br /&gt;
	m_prgInstancing = 0;&lt;br /&gt;
	loadShaders(); // &amp;lt;--- sollte ja hoffentlich klar sein...&lt;br /&gt;
&lt;br /&gt;
	glUseProgram(m_prgInstancing);&lt;br /&gt;
	glUniform1i(glGetUniformLocation(m_prgInstancing, &amp;quot;texLayer0&amp;quot;), 0);&lt;br /&gt;
	glUniform1i(glGetUniformLocation(m_prgInstancing, &amp;quot;tboTransform&amp;quot;), 1);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Rendern====&lt;br /&gt;
Der folgende Code rendert alle Objekte mit einem einzigen Aufruf von [[glDrawElementsInstancedARB]]. Diverse Einstellungen bezüglich Z-Buffer und Blending habe ich hier ausgelassen, da sie nichts mit dem eigentlichen Instancing zu tun haben.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
	glUseProgram(m_prgInstancing);&lt;br /&gt;
&lt;br /&gt;
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_pMesh-&amp;gt;getIBO());&lt;br /&gt;
	glBindBuffer(GL_ARRAY_BUFFER, m_pMesh-&amp;gt;getVBO());&lt;br /&gt;
	glInterleavedArrays(GL_T2F_N3F_V3F, 0, 0);&lt;br /&gt;
&lt;br /&gt;
	glEnable(GL_TEXTURE_2D);&lt;br /&gt;
	glActiveTexture(GL_TEXTURE0);&lt;br /&gt;
	glBindTexture(GL_TEXTURE_2D, m_pMesh-&amp;gt;getTex());&lt;br /&gt;
&lt;br /&gt;
	glActiveTexture(GL_TEXTURE1);&lt;br /&gt;
	glBindTexture(GL_TEXTURE_BUFFER_EXT, m_tboTransform);&lt;br /&gt;
	glTexBufferEXT(GL_TEXTURE_BUFFER_EXT,GL_RGBA32F_ARB, m_vboTransform);&lt;br /&gt;
&lt;br /&gt;
	glDrawElementsInstancedARB(GL_TRIANGLES, m_pMesh-&amp;gt;getFaceCount()*3, GL_UNSIGNED_INT, 0, plantCount);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Vertexshader====&lt;br /&gt;
Hier versteckt sich der Trick. Der Shader liest mit Hilfe von &amp;lt;tt&amp;gt;gl_InstanceID&amp;lt;/tt&amp;gt; Informationen zur Position und Skalierung des aktuell gerenderten Objektes aus dem Textur-Buffer-Objekt &amp;lt;tt&amp;gt;tboTransform&amp;lt;/tt&amp;gt; und wendet diese auf &amp;lt;tt&amp;gt;gl_Vertex&amp;lt;/tt&amp;gt; an.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;glsl&amp;quot;&amp;gt;#extension GL_EXT_gpu_shader4 : require&lt;br /&gt;
#extension GL_ARB_draw_instanced : require&lt;br /&gt;
&lt;br /&gt;
uniform samplerBuffer tboTransform;&lt;br /&gt;
&lt;br /&gt;
varying vec3 normal;&lt;br /&gt;
varying vec3 position;&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
	vec4 transform = texelFetchBuffer(tboTransform, gl_InstanceID);&lt;br /&gt;
	vec4 vertex = vec4((gl_Vertex.xyz * transform.w + transform.xyz),gl_Vertex.w);&lt;br /&gt;
&lt;br /&gt;
	normal = normalize(gl_NormalMatrix * gl_Normal);&lt;br /&gt;
	position = vec3(gl_ModelViewMatrix * vertex);&lt;br /&gt;
	gl_Position = gl_ModelViewProjectionMatrix * vertex;&lt;br /&gt;
&lt;br /&gt;
	gl_TexCoord[0] = gl_MultiTexCoord0;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Fragmentshader====&lt;br /&gt;
Der Fragmentshader ist relativ langweilig. Es handelt sich um einen einfachen Per-Pixel-Lighting Shader.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;glsl&amp;quot;&amp;gt;uniform sampler2D texLayer0;&lt;br /&gt;
&lt;br /&gt;
varying vec3 normal;&lt;br /&gt;
varying vec3 position;&lt;br /&gt;
&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
	gl_FragColor = gl_FrontLightProduct[0].ambient;&lt;br /&gt;
&lt;br /&gt;
	float diffuse = max(dot(gl_LightSource[0].position.xyz, normal), 0.0);&lt;br /&gt;
 	gl_FragColor += vec4(diffuse,diffuse,diffuse,1);&lt;br /&gt;
&lt;br /&gt;
	vec4 texcolor = texture2D(texLayer0, gl_TexCoord[0].xy);&lt;br /&gt;
	gl_FragColor *=  texcolor;&lt;br /&gt;
&lt;br /&gt;
	if (diffuse &amp;gt; 0.0) {&lt;br /&gt;
		vec3 r = normalize(&lt;br /&gt;
			(2.0 * dot(normal, gl_LightSource[0].position.xyz) * normal)&lt;br /&gt;
			- gl_LightSource[0].position.xyz &lt;br /&gt;
		);&lt;br /&gt;
		float f = dot(r, normalize(-position));&lt;br /&gt;
		float specular = pow(max(f, 0.0), gl_FrontMaterial.shininess);&lt;br /&gt;
		gl_FragColor += gl_FrontLightProduct[0].specular * specular;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	gl_FragColor.a = texcolor.a;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Coolcat</name></author>	</entry>

	</feed>