This file is indexed.

/usr/share/doc/love/html/love.graphics.newShader.html is in love-doc 0.9.1-4ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<meta name="generator" content="MediaWiki 1.16.2" />
<link rel="shortcut icon" href="favicon.ico" />
<link rel="search" type="application/opensearchdescription+xml" href="https://love2d.org/w/opensearch_desc.php" title="LOVE (en)" />
<link title="Creative Commons" type="application/rdf+xml" href="https://love2d.org/w/index.php?title=love.graphics.newShader&amp;action=creativecommons" rel="meta" />
<link rel="copyright" href="http://www.gnu.org/copyleft/fdl.html" />
<link rel="alternate" type="application/atom+xml" title="LOVE Atom feed" href="https://love2d.org/w/index.php?title=Special:RecentChanges&amp;feed=atom" />		<title>love.graphics.newShader - LOVE</title>
		<link rel="stylesheet" href="shared.css" media="screen" />
<link rel="stylesheet" href="commonPrint.css" media="print" />
<link rel="stylesheet" href="main.css" media="screen" />
<link rel="stylesheet" href="MediaWiki%3aCommon.css" />
<link rel="stylesheet" href="MediaWiki%3aPrint.css" media="print" />
<link rel="stylesheet" href="MediaWiki%3aLove.css" />
<link rel="stylesheet" href="user.css" />
		<!--[if lt IE 7]><script type="text/javascript" src="https://love2d.org/w/skins/common/IEFixes.js?270"></script>
		<meta http-equiv="imagetoolbar" content="no" /><![endif]-->

		<script>
var skin="love",
stylepath="https://love2d.org/w/skins",
wgUrlProtocols="http\\:\\/\\/|https\\:\\/\\/|ftp\\:\\/\\/|irc\\:\\/\\/|gopher\\:\\/\\/|telnet\\:\\/\\/|nntp\\:\\/\\/|worldwind\\:\\/\\/|mailto\\:|news\\:|svn\\:\\/\\/",
wgArticlePath="https://love2d.org/wiki/$1",
wgScriptPath="/w",
wgScriptExtension=".php",
wgScript="https://love2d.org/w/index.php",
wgVariantArticlePath=false,
wgActionPaths={},
wgServer="https://www.love2d.org",
wgCanonicalNamespace="",
wgCanonicalSpecialPageName=false,
wgNamespaceNumber=0,
wgPageName="love.graphics.newShader",
wgTitle="love.graphics.newShader",
wgAction="view",
wgArticleId=2872,
wgIsArticle=true,
wgUserName=null,
wgUserGroups=null,
wgUserLanguage="en",
wgContentLanguage="en",
wgBreakFrames=false,
wgCurRevisionId=12151,
wgVersion="1.16.2",
wgEnableAPI=true,
wgEnableWriteAPI=true,
wgSeparatorTransformTable=["", ""],
wgDigitTransformTable=["", ""],
wgMainPageTitle="Main Page",
wgFormattedNamespaces={"-2": "Media", "-1": "Special", "0": "", "1": "Talk", "2": "User", "3": "User talk", "4": "LOVE", "5": "LOVE talk", "6": "File", "7": "File talk", "8": "MediaWiki", "9": "MediaWiki talk", "10": "Template", "11": "Template talk", "12": "Help", "13": "Help talk", "14": "Category", "15": "Category talk", "102": "Property", "103": "Property talk", "104": "Type", "105": "Type talk", "108": "Concept", "109": "Concept talk", "500": "Tutorial", "501": "Tutorial talk"},
wgNamespaceIds={"media": -2, "special": -1, "": 0, "talk": 1, "user": 2, "user_talk": 3, "love": 4, "love_talk": 5, "file": 6, "file_talk": 7, "mediawiki": 8, "mediawiki_talk": 9, "template": 10, "template_talk": 11, "help": 12, "help_talk": 13, "category": 14, "category_talk": 15, "property": 102, "property_talk": 103, "type": 104, "type_talk": 105, "concept": 108, "concept_talk": 109, "tutorial": 500, "tutorial_talk": 501, "image": 6, "image_talk": 7},
wgSiteName="LOVE",
wgCategories=["Templates", "Functions"],
wgRestrictionEdit=[],
wgRestrictionMove=[];
</script>
		<script type="text/javascript" src="wikibits.js"><!-- wikibits js --></script>
		<!-- Head Scripts -->
		<link rel="alternate" type="application/rdf+xml" title="love.graphics.newShader" href="https://love2d.org/w/index.php?title=Special:ExportRDF/love.graphics.newShader&amp;xmlmime=rdf" />
		<script type="text/javascript" src="site.js"><!-- site js --></script>
  <link href="" rel="publisher" />
	</head>
<body class="mediawiki ltr ns-0 ns-subject page-love_graphics_newShader skin-love">
	<div id="globalWrapper">
		<div id="column-content">
	<div id="content">
		<a name="top" id="top"></a>
			
		<div id="p-cactions">
			<h5>Views</h5>
			<div>
				<ul>
		
					 <li id="ca-nstab-main" class="selected"><a href="love.graphics.newShader.html" title="View the content page [c]" accesskey="c">Page</a></li>
					 <li id="ca-talk" class="new"><a href="https://love2d.org/w/index.php?title=Talk:love.graphics.newShader&amp;action=edit&amp;redlink=1" title="Discussion about the content page [t]" accesskey="t">Discussion</a></li>
					 <li id="ca-viewsource"><a href="https://love2d.org/w/index.php?title=love.graphics.newShader&amp;action=edit" title="This page is protected.&#10;You can view its source [e]" accesskey="e">View source</a></li>
					 <li id="ca-history"><a href="https://love2d.org/w/index.php?title=love.graphics.newShader&amp;action=history" title="Past revisions of this page [h]" accesskey="h">History</a></li>				</ul>
			</div>
		</div>
	
		<h1 id="firstHeading" class="firstHeading">love.graphics.newShader</h1>
		<div id="bodyContent">
			<div id="contentSub"></div>
									<!-- start content -->
			<table bgcolor="#d0d0ff" style="margin-top: 1em; padding: 3px; border-radius:5px; -moz-border-radius:5px;">
<tr>
<td><i> <b>Available since LÖVE <a href="https://love2d.org/wiki/0.9.0" title="0.9.0">0.9.0</a></b> </i>
</td></tr>
<tr>
<td> <small>It has been renamed from <a href="love.graphics.newPixelEffect.html" title="love.graphics.newPixelEffect">love.graphics.newPixelEffect</a>.</small>
</td></tr></table>
<p>Creates a new Shader object for hardware-accelerated vertex and pixel effects. A Shader contains either vertex shader code, pixel shader code, or both.
</p><p>Shaders are small programs which are run on the video card when drawing. Vertex shaders are run once for each vertex (for example, an image has 4 vertices - one at each corner. A <a href="Mesh.html" title="Mesh">Mesh</a> might have many more.) Pixel shaders are run once for each pixel on the screen which the drawn object touches. Pixel shader code is executed after all the object's vertices have been processed by the vertex shader.
</p>
<h2> <span class="mw-headline" id="Function"> Function </span></h2>
<h3> <span class="mw-headline" id="Synopsis"> Synopsis </span></h3>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="lua source-lua">shader <span class="sy0">=</span> love.graphics.newShader<span class="br0">&#40;</span> code <span class="br0">&#41;</span></div></div>
<h3> <span class="mw-headline" id="Arguments"> Arguments </span></h3>
<dl><dt><code><a href="string.html" title="string">string</a> code</code></dt><dd> The pixel shader or vertex shader code, or a filename pointing to a file with the code.
</dd></dl>
<h3> <span class="mw-headline" id="Returns"> Returns </span></h3>
<dl><dt><code><a href="Shader.html" title="Shader">Shader</a> shader</code></dt><dd> A Shader object for use in drawing operations.
</dd></dl>
<h2> <span class="mw-headline" id="Function_2"> Function </span></h2>
<h3> <span class="mw-headline" id="Synopsis_2"> Synopsis </span></h3>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="lua source-lua">shader <span class="sy0">=</span> love.graphics.newShader<span class="br0">&#40;</span> pixelcode, vertexcode <span class="br0">&#41;</span></div></div>
<h3> <span class="mw-headline" id="Arguments_2"> Arguments </span></h3>
<dl><dt><code><a href="string.html" title="string">string</a> pixelcode</code></dt><dd> The pixel shader code, or a filename pointing to a file with the code.
</dd><dt><code><a href="string.html" title="string">string</a> vertexcode</code></dt><dd> The vertex shader code, or a filename pointing to a file with the code.
</dd></dl>
<h3> <span class="mw-headline" id="Returns_2"> Returns </span></h3>
<dl><dt><code><a href="Shader.html" title="Shader">Shader</a> shader</code></dt><dd> A Shader object for use in drawing operations.
</dd></dl>
<h3> <span class="mw-headline" id="Notes"> Notes </span></h3>
<p>The pixelcode and vertexcode arguments can be in any order.
</p>
<h2> <span class="mw-headline" id="Shader_Language"> Shader Language </span></h2>
<p>Shaders are not programmed in Lua, but by using a special shader language instead. The shader language is basically <a href="http://www.opengl.org/sdk/docs/manglsl/" class="external text" rel="nofollow">GLSL 1.20</a> (<a href="http://www.opengl.org/registry/doc/GLSLangSpec.Full.1.20.8.pdf" class="external text" rel="nofollow">specs</a>) with a few aliases added for existing types:
</p>
<table cellpadding="5">
<tr>
<th>GLSL               </th><th> LÖVE shader language
</th></tr>
<tr>
<td>float              </td><td> number
</td></tr>
<tr>
<td>sampler2D          </td><td> Image
</td></tr>
<tr>
<td>uniform            </td><td> extern
</td></tr>
<tr>
<td>texture2D(tex, uv) </td><td> Texel(tex, uv)
</td></tr></table>
<p>Vertex shader code must contain at least one function, named <code>position</code>, which is the function that will produce transformed vertex positions of drawn objects in screen-space.
</p><p>Pixel shader code must contain at least one function, named <code>effect</code>, which is the function that will produce the color which is blended onto the screen for each pixel a drawn object touches.
</p>
<h2> <span class="mw-headline" id="Pixel_Shader_Function"> Pixel Shader Function </span></h2>
<h3> <span class="mw-headline" id="Synopsis_3"> Synopsis </span></h3>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="glsl source-glsl"><span class="kw3">vec4</span> effect<span class="br0">&#40;</span> <span class="kw3">vec4</span> color<span class="sy0">,</span> Image texture<span class="sy0">,</span> <span class="kw3">vec2</span> texture_coords<span class="sy0">,</span> <span class="kw3">vec2</span> screen_coords <span class="br0">&#41;</span></div></div>
<h3> <span class="mw-headline" id="Arguments_3"> Arguments </span></h3>
<dl><dt><code><a href="https://love2d.org/w/index.php?title=vec4&amp;action=edit&amp;redlink=1" class="new" title="vec4 (page does not exist)">vec4</a> color</code></dt><dd> The drawing color set with <a href="love.graphics.setColor.html" title="love.graphics.setColor">love.graphics.setColor</a> or the per-vertex <a href="Mesh.html" title="Mesh">Mesh</a> color.
</dd><dt><code><a href="Image.html" title="Image">Image</a> texture</code></dt><dd> The texture of the image or canvas being drawn.
</dd><dt><code><a href="https://love2d.org/w/index.php?title=vec2&amp;action=edit&amp;redlink=1" class="new" title="vec2 (page does not exist)">vec2</a> texture_coords</code></dt><dd> Coordinates of the pixel relative to the texture. The y-axis of canvases are inverted. Coordinates (1,1) would be the top right corner of the canvas.
</dd><dt><code><a href="https://love2d.org/w/index.php?title=vec2&amp;action=edit&amp;redlink=1" class="new" title="vec2 (page does not exist)">vec2</a> screen_coords</code></dt><dd> Coordinates of the pixel on the screen. Pixel coordinates are not normalized (unlike texture coordinates)
</dd></dl>
<h3> <span class="mw-headline" id="Returns_3"> Returns </span></h3>
<dl><dt><code><a href="https://love2d.org/w/index.php?title=vec4&amp;action=edit&amp;redlink=1" class="new" title="vec4 (page does not exist)">vec4</a> output_color</code></dt><dd> The color of the pixel.
</dd></dl>
<h3> <span class="mw-headline" id="Notes_2"> Notes </span></h3>
<p>If multiple canvases are being rendered to simultaneously (by giving multiple Canvas parameters to <a href="love.graphics.setCanvas.html" title="love.graphics.setCanvas">love.graphics.setCanvas</a>), you can use the <b>effects</b> function instead of <b>effect</b> in order to output a separate color to each Canvas. It has the following prototype:
</p>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="glsl source-glsl"><span class="kw3">void</span> effects<span class="br0">&#40;</span> <span class="kw3">vec4</span> color<span class="sy0">,</span> Image texture<span class="sy0">,</span> <span class="kw3">vec2</span> texture_coords<span class="sy0">,</span> <span class="kw3">vec2</span> screen_coords <span class="br0">&#41;</span><br /><span class="br0">&#123;</span><br />&nbsp; &nbsp; <span class="co1">// love_Canvases is a writable array of vec4 colors. Each index corresponds to a Canvas. If you don't assign a value to all active canvases, bad things might happen.</span><br />&nbsp; &nbsp; love_Canvases<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span> <span class="sy0">=</span> color<span class="sy0">;</span><br /><span class="br0">&#125;</span></div></div>
<h2> <span class="mw-headline" id="Vertex_Shader_Function"> Vertex Shader Function </span></h2>
<h3> <span class="mw-headline" id="Synopsis_4"> Synopsis </span></h3>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="glsl source-glsl"><span class="kw3">vec4</span> position<span class="br0">&#40;</span> <span class="kw3">mat4</span> transform_projection<span class="sy0">,</span> <span class="kw3">vec4</span> vertex_position <span class="br0">&#41;</span></div></div>
<h3> <span class="mw-headline" id="Arguments_4"> Arguments </span></h3>
<dl><dt><code><a href="https://love2d.org/w/index.php?title=mat4&amp;action=edit&amp;redlink=1" class="new" title="mat4 (page does not exist)">mat4</a> transform_projection</code></dt><dd> The transformation matrix affected by <a href="love.graphics.translate.html" title="love.graphics.translate">love.graphics.translate</a> and friends combined with the orthographic projection matrix.
</dd><dt><code><a href="https://love2d.org/w/index.php?title=vec4&amp;action=edit&amp;redlink=1" class="new" title="vec4 (page does not exist)">vec4</a> vertex_position</code></dt><dd> The raw un-transformed position of the current vertex.
</dd></dl>
<h3> <span class="mw-headline" id="Returns_4"> Returns </span></h3>
<dl><dt><code><a href="https://love2d.org/w/index.php?title=vec4&amp;action=edit&amp;redlink=1" class="new" title="vec4 (page does not exist)">vec4</a> output_pos</code></dt><dd> The final transformed position of the current vertex.
</dd></dl>
<h2> <span class="mw-headline" id="Notes_3"> Notes </span></h2>
<p>Vertex shader code is run for every vertex drawn to the screen (for example, love.graphics.rectangle will produce 4 vertices) and is used to transform the vertex positions from their original coordinates into screen-space, as well as to send information such as per-vertex color and texture coordinate values to the pixel shader.
</p><p>Pixel shader code is run for every pixel on the screen that a drawn object touches, and is used to produce the color that will be blended onto the screen at that pixel, often by reading from an image. Pixel shaders are sometimes called fragment shaders.
</p><p>The <code>varying</code> keyword can be used to set a value in the vertex shader and have it interpolated in between vertices and passed down to the pixel shader.
</p><p>Vertex and Pixel shader code can be combined into one file or string if you wrap the vertex-specific code in <code>#ifdef VERTEX .. #endif</code> and the pixel-specific code in <code>#ifdef PIXEL .. #endif</code>.
</p>
<h2> <span class="mw-headline" id="Built-in_variables"> Built-in variables </span></h2>
<p>LÖVE provides several built-in variables for both pixel and vertex shaders. The full list can be found here: <a href="https://love2d.org/wiki/Shader_Variables" title="Shader Variables">Shader Variables</a>.
</p>
<h2> <span class="mw-headline" id="Examples"> Examples </span></h2>
<h3> <span class="mw-headline" id="Create_a_shader_using_vertex_and_pixel_shader_code_which_behaves_as_if_no_shader_is_set."> Create a shader using vertex and pixel shader code which behaves as if no shader is set. </span></h3>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="lua source-lua"><span class="kw1">function</span> love.load<span class="br0">&#40;</span><span class="br0">&#41;</span><br />&nbsp; &nbsp; <span class="kw1">local</span> pixelcode <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; vec4 effect<span class="br0">&#40;</span> vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords <span class="br0">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vec4 texcolor <span class="sy0">=</span> Texel<span class="br0">&#40;</span>texture, texture_coords<span class="br0">&#41;</span><span class="sy0">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> texcolor <span class="sy0">*</span> color<span class="sy0">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />&nbsp; &nbsp; <span class="br0">&#93;</span><span class="br0">&#93;</span><br /><br />&nbsp; &nbsp; <span class="kw1">local</span> vertexcode <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; vec4 position<span class="br0">&#40;</span> mat4 transform_projection, vec4 vertex_position <span class="br0">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> transform_projection <span class="sy0">*</span> vertex_position<span class="sy0">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />&nbsp; &nbsp; <span class="br0">&#93;</span><span class="br0">&#93;</span><br /><br />&nbsp; &nbsp; shader <span class="sy0">=</span> love.graphics.newShader<span class="br0">&#40;</span>pixelcode, vertexcode<span class="br0">&#41;</span><br /><span class="kw1">end</span><br /><br /><span class="kw1">function</span> love.draw<span class="br0">&#40;</span><span class="br0">&#41;</span><br />&nbsp; &nbsp; love.graphics.setShader<span class="br0">&#40;</span>shader<span class="br0">&#41;</span><br />&nbsp; &nbsp; <span class="co1">-- draw things</span><br />&nbsp; &nbsp; love.graphics.setShader<span class="br0">&#40;</span><span class="br0">&#41;</span><br />&nbsp; &nbsp; <span class="co1">-- draw more things</span><br /><span class="kw1">end</span></div></div>
<h3> <span class="mw-headline" id="Access_the_pre-transformed_vertex_position_in_the_pixel_shader_with_the_varying_keyword."> Access the pre-transformed vertex position in the pixel shader with the <b>varying</b> keyword. </span></h3>
<h4> <span class="mw-headline" id="vertex_shader_code"> vertex shader code </span></h4>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="glsl source-glsl"><span class="kw2">varying</span> <span class="kw3">vec4</span> vpos<span class="sy0">;</span><br /><br /><span class="kw3">vec4</span> position<span class="br0">&#40;</span> <span class="kw3">mat4</span> transform_projection<span class="sy0">,</span> <span class="kw3">vec4</span> vertex_position <span class="br0">&#41;</span><br /><span class="br0">&#123;</span><br />&nbsp; &nbsp; vpos <span class="sy0">=</span> vertex_position<span class="sy0">;</span><br />&nbsp; &nbsp; <span class="kw1">return</span> transform_projection <span class="sy0">*</span> vertex_position<span class="sy0">;</span><br /><span class="br0">&#125;</span></div></div>
<h4> <span class="mw-headline" id="pixel_shader_code"> pixel shader code </span></h4>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="glsl source-glsl"><span class="kw2">varying</span> <span class="kw3">vec4</span> vpos<span class="sy0">;</span><br /><br /><span class="kw3">vec4</span> effect<span class="br0">&#40;</span> <span class="kw3">vec4</span> color<span class="sy0">,</span> Image texture<span class="sy0">,</span> <span class="kw3">vec2</span> texture_coords<span class="sy0">,</span> <span class="kw3">vec2</span> screen_coords <span class="br0">&#41;</span><br /><span class="br0">&#123;</span><br />&nbsp; &nbsp; texture_coords <span class="sy0">+=</span> <span class="kw3">vec2</span><span class="br0">&#40;</span><span class="kw5">cos</span><span class="br0">&#40;</span>vpos<span class="sy0">.</span><span class="me1">x</span><span class="br0">&#41;</span><span class="sy0">,</span> <span class="kw5">sin</span><span class="br0">&#40;</span>vpos<span class="sy0">.</span><span class="me1">y</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />&nbsp; &nbsp; <span class="kw3">vec4</span> texcolor <span class="sy0">=</span> Texel<span class="br0">&#40;</span>texture<span class="sy0">,</span> texture_coords<span class="br0">&#41;</span><span class="sy0">;</span><br />&nbsp; &nbsp; <span class="kw1">return</span> texcolor <span class="sy0">*</span> color<span class="sy0">;</span><br /><span class="br0">&#125;</span></div></div>
<h3> <span class="mw-headline" id="Combine_the_above_example_into_one_string_or_file_with_the_help_of_.23ifdef."> Combine the above example into one string or file with the help of <b>#ifdef</b>. </span></h3>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="glsl source-glsl"><span class="kw2">varying</span> <span class="kw3">vec4</span> vpos<span class="sy0">;</span><br /><br /><span class="co2">#ifdef VERTEX</span><br /><span class="kw3">vec4</span> position<span class="br0">&#40;</span> <span class="kw3">mat4</span> transform_projection<span class="sy0">,</span> <span class="kw3">vec4</span> vertex_position <span class="br0">&#41;</span><br /><span class="br0">&#123;</span><br />&nbsp; &nbsp; vpos <span class="sy0">=</span> vertex_position<span class="sy0">;</span><br />&nbsp; &nbsp; <span class="kw1">return</span> transform_projection <span class="sy0">*</span> vertex_position<span class="sy0">;</span><br /><span class="br0">&#125;</span><br /><span class="co2">#endif</span><br /><br /><span class="co2">#ifdef PIXEL</span><br /><span class="kw3">vec4</span> effect<span class="br0">&#40;</span> <span class="kw3">vec4</span> color<span class="sy0">,</span> Image texture<span class="sy0">,</span> <span class="kw3">vec2</span> texture_coords<span class="sy0">,</span> <span class="kw3">vec2</span> screen_coords <span class="br0">&#41;</span><br /><span class="br0">&#123;</span><br />&nbsp; &nbsp; texture_coord <span class="sy0">+=</span> <span class="kw3">vec2</span><span class="br0">&#40;</span><span class="kw5">cos</span><span class="br0">&#40;</span>vpos<span class="sy0">.</span><span class="me1">x</span><span class="br0">&#41;</span><span class="sy0">,</span> <span class="kw5">sin</span><span class="br0">&#40;</span>vpos<span class="sy0">.</span><span class="me1">y</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />&nbsp; &nbsp; <span class="kw3">vec4</span> texcolor <span class="sy0">=</span> Texel<span class="br0">&#40;</span>texture<span class="sy0">,</span> texture_coords<span class="br0">&#41;</span><span class="sy0">;</span><br />&nbsp; &nbsp; <span class="kw1">return</span> texcolor <span class="sy0">*</span> color<span class="sy0">;</span><br /><span class="br0">&#125;</span><br /><span class="co2">#endif</span></div></div>
<h2> <span class="mw-headline" id="See_Also"> See Also </span></h2>
<ul><li> <a href="love.graphics.html" title="love.graphics">love.graphics</a>
</li><li> <a href="Shader.html" title="Shader">Shader</a>
</li><li> <a href="love.graphics.setShader.html" title="love.graphics.setShader">love.graphics.setShader</a>
</li><li> <a href="https://love2d.org/wiki/Shader_Variables" title="Shader Variables">Shader Variables</a>
</li></ul>
<p><br />
</p>
<h2> <span class="mw-headline" id="Other_Languages"> Other Languages </span></h2>
<div class="i18n">
<p><a href="https://love2d.org/w/index.php?title=love.graphics.newShader_(Dansk)&amp;action=edit&amp;redlink=1" class="new" title="love.graphics.newShader (Dansk) (page does not exist)">Dansk</a>&nbsp;&ndash;
<a href="https://love2d.org/w/index.php?title=love.graphics.newShader_(Deutsch)&amp;action=edit&amp;redlink=1" class="new" title="love.graphics.newShader (Deutsch) (page does not exist)">Deutsch</a>&nbsp;&ndash;
<strong class="selflink">English</strong>&nbsp;&ndash; 
<a href="https://love2d.org/w/index.php?title=love.graphics.newShader_(Espa%C3%B1ol)&amp;action=edit&amp;redlink=1" class="new" title="love.graphics.newShader (Español) (page does not exist)">Español</a>&nbsp;&ndash;
<a href="https://love2d.org/w/index.php?title=love.graphics.newShader_(Fran%C3%A7ais)&amp;action=edit&amp;redlink=1" class="new" title="love.graphics.newShader (Français) (page does not exist)">Français</a>&nbsp;&ndash;
<a href="https://love2d.org/w/index.php?title=love.graphics.newShader_(Indonesia)&amp;action=edit&amp;redlink=1" class="new" title="love.graphics.newShader (Indonesia) (page does not exist)">Indonesia</a>&nbsp;&ndash;
<a href="https://love2d.org/w/index.php?title=love.graphics.newShader_(Italiano)&amp;action=edit&amp;redlink=1" class="new" title="love.graphics.newShader (Italiano) (page does not exist)">Italiano</a>&nbsp;&ndash;
<a href="https://love2d.org/w/index.php?title=love.graphics.newShader_(Lietuvi%C5%A1kai)&amp;action=edit&amp;redlink=1" class="new" title="love.graphics.newShader (Lietuviškai) (page does not exist)">Lietuviškai</a>&nbsp;&ndash;
<a href="https://love2d.org/w/index.php?title=love.graphics.newShader_(Magyar)&amp;action=edit&amp;redlink=1" class="new" title="love.graphics.newShader (Magyar) (page does not exist)">Magyar</a>&nbsp;&ndash;
<a href="https://love2d.org/w/index.php?title=love.graphics.newShader_(Nederlands)&amp;action=edit&amp;redlink=1" class="new" title="love.graphics.newShader (Nederlands) (page does not exist)">Nederlands</a>&nbsp;&ndash;
<a href="https://love2d.org/w/index.php?title=love.graphics.newShader_(Polski)&amp;action=edit&amp;redlink=1" class="new" title="love.graphics.newShader (Polski) (page does not exist)">Polski</a>&nbsp;&ndash;
<a href="https://love2d.org/w/index.php?title=love.graphics.newShader_(Portugu%C3%AAs)&amp;action=edit&amp;redlink=1" class="new" title="love.graphics.newShader (Português) (page does not exist)">Português</a>&nbsp;&ndash;
<a href="https://love2d.org/w/index.php?title=love.graphics.newShader_(Rom%C3%A2n%C4%83)&amp;action=edit&amp;redlink=1" class="new" title="love.graphics.newShader (Română) (page does not exist)">Română</a>&nbsp;&ndash;
<a href="https://love2d.org/w/index.php?title=love.graphics.newShader_(Slovensk%C3%BD)&amp;action=edit&amp;redlink=1" class="new" title="love.graphics.newShader (Slovenský) (page does not exist)">Slovenský</a>&nbsp;&ndash;
<a href="https://love2d.org/w/index.php?title=love.graphics.newShader_(Suomi)&amp;action=edit&amp;redlink=1" class="new" title="love.graphics.newShader (Suomi) (page does not exist)">Suomi</a>&nbsp;&ndash;
<a href="https://love2d.org/w/index.php?title=love.graphics.newShader_(Svenska)&amp;action=edit&amp;redlink=1" class="new" title="love.graphics.newShader (Svenska) (page does not exist)">Svenska</a>&nbsp;&ndash;
<a href="https://love2d.org/w/index.php?title=love.graphics.newShader_(T%C3%BCrk%C3%A7e)&amp;action=edit&amp;redlink=1" class="new" title="love.graphics.newShader (Türkçe) (page does not exist)">Türkçe</a>&nbsp;&ndash;
<a href="https://love2d.org/w/index.php?title=love.graphics.newShader_(%C4%8Cesky)&amp;action=edit&amp;redlink=1" class="new" title="love.graphics.newShader (Česky) (page does not exist)">Česky</a>&nbsp;&ndash;
<a href="https://love2d.org/w/index.php?title=love.graphics.newShader_(%CE%95%CE%BB%CE%BB%CE%B7%CE%BD%CE%B9%CE%BA%CE%AC)&amp;action=edit&amp;redlink=1" class="new" title="love.graphics.newShader (Ελληνικά) (page does not exist)">Ελληνικά</a>&nbsp;&ndash;
<a href="https://love2d.org/w/index.php?title=love.graphics.newShader_(%D0%91%D1%8A%D0%BB%D0%B3%D0%B0%D1%80%D1%81%D0%BA%D0%B8)&amp;action=edit&amp;redlink=1" class="new" title="love.graphics.newShader (Български) (page does not exist)">Български</a>&nbsp;&ndash;
<a href="https://love2d.org/w/index.php?title=love.graphics.newShader_(%D0%A0%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9)&amp;action=edit&amp;redlink=1" class="new" title="love.graphics.newShader (Русский) (page does not exist)">Русский</a>&nbsp;&ndash;
<a href="https://love2d.org/w/index.php?title=love.graphics.newShader_(%D0%A1%D1%80%D0%BF%D1%81%D0%BA%D0%B8)&amp;action=edit&amp;redlink=1" class="new" title="love.graphics.newShader (Српски) (page does not exist)">Српски</a>&nbsp;&ndash;
<a href="https://love2d.org/w/index.php?title=love.graphics.newShader_(%D0%A3%D0%BA%D1%80%D0%B0%D1%97%D0%BD%D1%81%D1%8C%D0%BA%D0%B0)&amp;action=edit&amp;redlink=1" class="new" title="love.graphics.newShader (Українська) (page does not exist)">Українська</a>&nbsp;&ndash;
<a href="https://love2d.org/w/index.php?title=love.graphics.newShader_(%D7%A2%D7%91%D7%A8%D7%99%D7%AA)&amp;action=edit&amp;redlink=1" class="new" title="love.graphics.newShader (עברית) (page does not exist)">עברית</a>&nbsp;&ndash;
<a href="https://love2d.org/w/index.php?title=love.graphics.newShader_(%E0%B9%84%E0%B8%97%E0%B8%A2)&amp;action=edit&amp;redlink=1" class="new" title="love.graphics.newShader (ไทย) (page does not exist)">ไทย</a>&nbsp;&ndash;
<a href="https://love2d.org/w/index.php?title=love.graphics.newShader_(%E6%97%A5%E6%9C%AC%E8%AA%9E)&amp;action=edit&amp;redlink=1" class="new" title="love.graphics.newShader (日本語) (page does not exist)">日本語</a>&nbsp;&ndash;
<a href="https://love2d.org/w/index.php?title=love.graphics.newShader_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)&amp;action=edit&amp;redlink=1" class="new" title="love.graphics.newShader (正體中文) (page does not exist)">正體中文</a>&nbsp;&ndash;
<a href="https://love2d.org/w/index.php?title=love.graphics.newShader_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&amp;action=edit&amp;redlink=1" class="new" title="love.graphics.newShader (简体中文) (page does not exist)">简体中文</a>&nbsp;&ndash;
<a href="https://love2d.org/w/index.php?title=love.graphics.newShader_(Ti%E1%BA%BFng_Vi%E1%BB%87t)&amp;action=edit&amp;redlink=1" class="new" title="love.graphics.newShader (Tiếng Việt) (page does not exist)">Tiếng Việt</a>&nbsp;&ndash;
<a href="https://love2d.org/w/index.php?title=love.graphics.newShader_(%ED%95%9C%EA%B5%AD%EC%96%B4)&amp;action=edit&amp;redlink=1" class="new" title="love.graphics.newShader (한국어) (page does not exist)">한국어</a> 
<br />
<span style="text-align:right;"><i><a href="https://love2d.org/wiki/Help:i18n" title="Help:i18n">More info</a></i></span>
</p>
</div>

<!-- 
NewPP limit report
Preprocessor node count: 633/1000000
Post-expand include size: 5944/2097152 bytes
Template argument size: 3208/2097152 bytes
Expensive parser function count: 0/100
-->

<!-- Saved in parser cache with key love2d_wiki:pcache:idhash:2872-0!1!0!!en!2!edit=0 and timestamp 20140411005616 -->
<div class="printfooter">
Retrieved from "<a href="https://www.love2d.org/wiki/love.graphics.newShader">https://www.love2d.org/wiki/love.graphics.newShader</a>"</div>
			<div id='catlinks' class='catlinks'><div id="mw-normal-catlinks"><a href="https://love2d.org/wiki/Special:Categories" title="Special:Categories">Categories</a>: <span dir='ltr'><a href="https://love2d.org/wiki/Category:Templates" title="Category:Templates">Templates</a></span> | <span dir='ltr'><a href="https://love2d.org/wiki/Category:Functions" title="Category:Functions">Functions</a></span></div></div>			<!-- end content -->
						<div class="visualClear"></div>
		</div>
	</div>
		</div>
		<div id="column-one">

	<div class="portlet" id="p-personal">
		<h5>Personal tools</h5>
		<div class="pBody">
			<ul>
				<li id="pt-login"><a href="https://love2d.org/w/index.php?title=Special:UserLogin&amp;returnto=love.graphics.newShader" title="You are encouraged to log in; however, it is not mandatory [o]" accesskey="o">Log in</a></li>
			</ul>
		</div>
	</div>
	<div class="portlet" id="p-logo">
		<a style="background-image: url(wiki.png);" href="https://love2d.org/wiki/Main_Page" title="Visit the main page"></a>
	</div>
<!--	<div class="portlet" id="p-docs">
		<h5>Documentation</h5>
		<div class="pBody">
			<ul>
				<li><a href="//love2d.org/wiki/love">love</a></li>
				<li><a href="//love2d.org/wiki/love.audio">love.audio</a></li>
				<li><a href="//love2d.org/wiki/love.event">love.event</a></li>
				<li><a href="//love2d.org/wiki/love.filesystem">love.filesystem</a></li>
				<li><a href="//love2d.org/wiki/love.graphics">love.graphics</a></li>
				<li><a href="//love2d.org/wiki/love.image">love.image</a></li>
				<li><a href="//love2d.org/wiki/love.joystick">love.joystick</a></li>
				<li><a href="//love2d.org/wiki/love.keyboard">love.keyboard</a></li>
				<li><a href="//love2d.org/wiki/love.math">love.math</a></li>
				<li><a href="//love2d.org/wiki/love.mouse">love.mouse</a></li>
				<li><a href="//love2d.org/wiki/love.physics">love.physics</a></li>
				<li><a href="//love2d.org/wiki/love.sound">love.sound</a></li>
				<li><a href="//love2d.org/wiki/love.system">love.system</a></li>
				<li><a href="//love2d.org/wiki/love.timer">love.timer</a></li>
				<li><a href="//love2d.org/wiki/love.window">love.window</a></li>
			</ul>
		</div>
	</div> -->
	<script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script>
	<div class='generated-sidebar portlet' id='p-documentation'>
		<h5>documentation</h5>
		<div class='pBody'>
			<ul>
				<li id="n-love"><a href="love.html">love</a></li>
				<li id="n-love.audio"><a href="love.audio.html">love.audio</a></li>
				<li id="n-love.event"><a href="love.event.html">love.event</a></li>
				<li id="n-love.filesystem"><a href="love.filesystem.html">love.filesystem</a></li>
				<li id="n-love.font"><a href="love.font.html">love.font</a></li>
				<li id="n-love.graphics"><a href="love.graphics.html">love.graphics</a></li>
				<li id="n-love.image"><a href="love.image.html">love.image</a></li>
				<li id="n-love.joystick"><a href="love.joystick.html">love.joystick</a></li>
				<li id="n-love.keyboard"><a href="love.keyboard.html">love.keyboard</a></li>
				<li id="n-love.math"><a href="love.math.html">love.math</a></li>
				<li id="n-love.mouse"><a href="love.mouse.html">love.mouse</a></li>
				<li id="n-love.physics"><a href="love.physics.html">love.physics</a></li>
				<li id="n-love.sound"><a href="love.sound.html">love.sound</a></li>
				<li id="n-love.system"><a href="love.system.html">love.system</a></li>
				<li id="n-love.thread"><a href="love.thread.html">love.thread</a></li>
				<li id="n-love.timer"><a href="love.timer.html">love.timer</a></li>
				<li id="n-love.window"><a href="love.window.html">love.window</a></li>
			</ul>
		</div>
	</div>
	<div class='generated-sidebar portlet' id='p-navigation'>
		<h5>Navigation</h5>
		<div class='pBody'>
			<ul>
				<li id="n-Home"><a href="http://love2d.org/">Home</a></li>
				<li id="n-Forums"><a href="http://love2d.org/forums">Forums</a></li>
				<li id="n-Issue-tracker"><a href="http://bitbucket.org/rude/love/issues">Issue tracker</a></li>
			</ul>
		</div>
	</div>
	<div class='generated-sidebar portlet' id='p-wiki_navigation'>
		<h5>wiki navigation</h5>
		<div class='pBody'>
			<ul>
				<li id="n-mainpage-description"><a href="https://love2d.org/wiki/Main_Page" title="Visit the main page [z]" accesskey="z">Main page</a></li>
				<li id="n-recentchanges"><a href="https://love2d.org/wiki/Special:RecentChanges" title="The list of recent changes in the wiki [r]" accesskey="r">Recent changes</a></li>
				<li id="n-randompage"><a href="https://love2d.org/wiki/Special:Random" title="Load a random page [x]" accesskey="x">Random page</a></li>
			</ul>
		</div>
	</div>
	<div id="p-search" class="portlet">
		<h5><label for="searchInput">Search</label></h5>
		<div id="searchBody" class="pBody">
			<form action="https://love2d.org/w/index.php" id="searchform"><div>
				<input type='hidden' name="title" value="Special:Search"/>
				<input id="searchInput" name="search" type="text" title="Search LOVE [f]" accesskey="f" value="" />
				<input type='submit' name="go" class="searchButton" id="searchGoButton"	value="Go" title="Go to a page with this exact name if exists" />&nbsp;
				<input type='submit' name="fulltext" class="searchButton" id="mw-searchButton" value="Search" title="Search the pages for this text" />
			</div></form>
		</div>
	</div>
	<div class="portlet" id="p-tb">
		<h5>Toolbox</h5>
		<div class="pBody">
			<ul>
				<li id="t-whatlinkshere"><a href="https://love2d.org/wiki/Special:WhatLinksHere/love.graphics.newShader" title="List of all wiki pages that link here [j]" accesskey="j">What links here</a></li>
				<li id="t-recentchangeslinked"><a href="https://love2d.org/wiki/Special:RecentChangesLinked/love.graphics.newShader" title="Recent changes in pages linked from this page [k]" accesskey="k">Related changes</a></li>
<li id="t-specialpages"><a href="https://love2d.org/wiki/Special:SpecialPages" title="List of all special pages [q]" accesskey="q">Special pages</a></li>
				<li id="t-print"><a href="https://love2d.org/w/index.php?title=love.graphics.newShader&amp;printable=yes" rel="alternate" title="Printable version of this page [p]" accesskey="p">Printable version</a></li>				<li id="t-permalink"><a href="https://love2d.org/w/index.php?title=love.graphics.newShader&amp;oldid=12151" title="Permanent link to this revision of the page">Permanent link</a></li><li id="t-smwbrowselink"><a href="https://love2d.org/wiki/Special:Browse/love.graphics.newShader" title="Special:Browse/love.graphics.newShader">Browse properties</a></li>			</ul>
		</div>
	</div>
		</div><!-- end of the left (by default at least) column -->
			<div class="visualClear"></div>
			<div id="footer">
				<div id="f-poweredbyico"><a href="http://www.mediawiki.org/"><img src="poweredby_mediawiki_88x31.png" height="31" width="88" alt="Powered by MediaWiki" /></a></div>
				<div id="f-copyrightico"><a href="http://www.gnu.org/copyleft/fdl.html"><img src="gnu-fdl.png" alt="GNU Free Documentation License 1.3" width="88" height="31" /></a></div>
			<ul id="f-list">
					<li id="lastmod"> This page was last modified on 16 December 2013, at 03:54.</li>
					<li id="copyright">Content is available under <a href="http://www.gnu.org/copyleft/fdl.html" class="external ">GNU Free Documentation License 1.3</a>.</li>
					<li id="privacy"><a href="https://love2d.org/wiki/LOVE:Privacy_policy" title="LOVE:Privacy policy">Privacy policy</a></li>
					<li id="about"><a href="https://love2d.org/wiki/LOVE:About" title="LOVE:About">About LOVE</a></li>
					<li id="disclaimer"><a href="https://love2d.org/wiki/LOVE:General_disclaimer" title="LOVE:General disclaimer">Disclaimers</a></li>
			</ul>
		</div>
</div>

<script>if (window.runOnloadHook) runOnloadHook();</script>
<!-- Served in 0.273 secs. --></body></html>