<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:media="http://search.yahoo.com/mrss/"

	>
<channel>
	<title>
	Comments on: SceneKit &#038; shaders	</title>
	<atom:link href="https://wadetregaskis.com/scenekit-shaders/feed/" rel="self" type="application/rss+xml" />
	<link>https://wadetregaskis.com/scenekit-shaders/</link>
	<description></description>
	<lastBuildDate>Sat, 25 May 2019 07:08:09 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>
		By: Mark P M Lim		</title>
		<link>https://wadetregaskis.com/scenekit-shaders/#comment-3233</link>

		<dc:creator><![CDATA[Mark P M Lim]]></dc:creator>
		<pubDate>Sat, 25 May 2019 07:08:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.wadetregaskis.com/?p=2622#comment-3233</guid>

					<description><![CDATA[Have a look at the results of some of my experiments using OpenGL shader programs to perform custom rendering in SceneKit.

https://github.com/markpmlim/ExploringSceneKit-OpenGL

Initially, there was no display when some of these demos were run; others showed a distorted shape being rendered. I only managed to get the tessellation demo working recently.]]></description>
			<content:encoded><![CDATA[<p>Have a look at the results of some of my experiments using OpenGL shader programs to perform custom rendering in SceneKit.</p>
<p><a href="https://github.com/markpmlim/ExploringSceneKit-OpenGL" rel="nofollow ugc external noopener" data-wpel-link="external" target="_blank">https://github.com/markpmlim/ExploringSceneKit-OpenGL</a></p>
<p>Initially, there was no display when some of these demos were run; others showed a distorted shape being rendered. I only managed to get the tessellation demo working recently.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Anonymous		</title>
		<link>https://wadetregaskis.com/scenekit-shaders/#comment-528</link>

		<dc:creator><![CDATA[Anonymous]]></dc:creator>
		<pubDate>Mon, 04 Aug 2014 04:39:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.wadetregaskis.com/?p=2622#comment-528</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://wadetregaskis.com/scenekit-shaders/#comment-95&quot;&gt;Wade Tregaskis&lt;/a&gt;.

I think you can use handleBindingOfSymbol:usingBlock: from SCNShadable now.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://wadetregaskis.com/scenekit-shaders/#comment-95" data-wpel-link="internal">Wade Tregaskis</a>.</p>
<p>I think you can use handleBindingOfSymbol:usingBlock: from SCNShadable now.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Wade Tregaskis		</title>
		<link>https://wadetregaskis.com/scenekit-shaders/#comment-95</link>

		<dc:creator><![CDATA[Wade Tregaskis]]></dc:creator>
		<pubDate>Thu, 10 Jan 2013 05:12:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.wadetregaskis.com/?p=2622#comment-95</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://wadetregaskis.com/scenekit-shaders/#comment-88&quot;&gt;toyos&lt;/a&gt;.

One big problem though, even if you do buy into SceneKit&#039;s model:  how to determine what geometry is being processed by your SCNProgram, in order to determine what values to bind to it (e.g. colour, textures, etc).  The only identifying thing given to the SCNProgramDelegate implementor is the SCNProgram.  So you have to create a separate SCNProgram, explicitly, for every object, potentially.  And hope that SceneKit doesn&#039;t implicitly copy them at any point and break that tenuous link.

Or, I suppose, create a separate delegate instance for every variation you need.  That seems like a hack (and a lot more work).]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://wadetregaskis.com/scenekit-shaders/#comment-88" data-wpel-link="internal">toyos</a>.</p>
<p>One big problem though, even if you do buy into SceneKit&#8217;s model:  how to determine what geometry is being processed by your SCNProgram, in order to determine what values to bind to it (e.g. colour, textures, etc).  The only identifying thing given to the SCNProgramDelegate implementor is the SCNProgram.  So you have to create a separate SCNProgram, explicitly, for every object, potentially.  And hope that SceneKit doesn&#8217;t implicitly copy them at any point and break that tenuous link.</p>
<p>Or, I suppose, create a separate delegate instance for every variation you need.  That seems like a hack (and a lot more work).</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Wade Tregaskis		</title>
		<link>https://wadetregaskis.com/scenekit-shaders/#comment-89</link>

		<dc:creator><![CDATA[Wade Tregaskis]]></dc:creator>
		<pubDate>Sun, 06 Jan 2013 23:06:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.wadetregaskis.com/?p=2622#comment-89</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://wadetregaskis.com/scenekit-shaders/#comment-88&quot;&gt;toyos&lt;/a&gt;.

Yeah, that&#039;s quite right - that&#039;s what I&#039;ve started to figure out since.  I was hoping that the last piece - getting the material attributes from the SCNMaterial into the fragment shader - would come together, but you seem to be saying you have to do all that manually. :/

I wondered if there was some &quot;new world order&quot; in OpenGL of not using intrinsics (e.g. gl_Color) in the face of more generic systems involving shaders.  But that&#039;s not the case today with run-of-the-mill OpenGL and GLSL code, so I&#039;m a bit frustrated by it - I don&#039;t really care what system SceneKit wants to use, but if it&#039;s not the pervasive one it really should be documented.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://wadetregaskis.com/scenekit-shaders/#comment-88" data-wpel-link="internal">toyos</a>.</p>
<p>Yeah, that&#8217;s quite right &#8211; that&#8217;s what I&#8217;ve started to figure out since.  I was hoping that the last piece &#8211; getting the material attributes from the SCNMaterial into the fragment shader &#8211; would come together, but you seem to be saying you have to do all that manually. :/</p>
<p>I wondered if there was some &#8220;new world order&#8221; in OpenGL of not using intrinsics (e.g. gl_Color) in the face of more generic systems involving shaders.  But that&#8217;s not the case today with run-of-the-mill OpenGL and GLSL code, so I&#8217;m a bit frustrated by it &#8211; I don&#8217;t really care what system SceneKit wants to use, but if it&#8217;s not the pervasive one it really should be documented.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: toyos		</title>
		<link>https://wadetregaskis.com/scenekit-shaders/#comment-88</link>

		<dc:creator><![CDATA[toyos]]></dc:creator>
		<pubDate>Sun, 06 Jan 2013 19:50:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.wadetregaskis.com/?p=2622#comment-88</guid>

					<description><![CDATA[&quot;1&quot; is not completely right. Once you use custom shader it indeed overrides SceneKit&#039;s shaders. So yes you loose the lighting and texturing. What you would like here is shader injection, not just custom programs.
However you don&#039;t need to (and shouldn&#039;t)  load &#038; bind the geometry, position, projection etc… yourself. the API to bind SceneKit&#039;s attributes is:
&lt;code&gt; 
SCNProgram:
- (void)setSemantic:(NSString*)semantic forSymbol:(NSString*)symbol options:(NSDictionary *)options;
&lt;/code&gt;
for instance to bind the vertex to your custom uniform named &quot;a_position&quot; in your shader:
 
&lt;code&gt;
[myProgram setSemantic:SCNGeometrySourceSemanticVertex forSymbol:@&quot;a_position&quot; options:nil];
&lt;/code&gt; 

This is trivial for attributes(normals, texcoords, vertex) and the supported uniforms (model/view/proj/normal matrices) but harder for textures (you will have to load the texture yourself using openGL and here use the delegate methods as describes in the blog to bind it).
 
also note that variables like gl_ModelViewProjectionMatrix, gl_Color are deprecated.
 
2 and 3. The right thing to do is to share the material (not the program!). that way the shader will be built just once. Since a SCNProgram overrides the material settings, there is no reason to not share the material.

I agree that the lack of documentation and sample code (for this part of the API in particular) is something that must be fixed.]]></description>
			<content:encoded><![CDATA[<p>&#8220;1&#8221; is not completely right. Once you use custom shader it indeed overrides SceneKit&#8217;s shaders. So yes you loose the lighting and texturing. What you would like here is shader injection, not just custom programs.<br />
However you don&#8217;t need to (and shouldn&#8217;t)  load &amp; bind the geometry, position, projection etc… yourself. the API to bind SceneKit&#8217;s attributes is:<br />
<code> <br />
SCNProgram:<br />
- (void)setSemantic:(NSString*)semantic forSymbol:(NSString*)symbol options:(NSDictionary *)options;<br />
</code><br />
for instance to bind the vertex to your custom uniform named &#8220;a_position&#8221; in your shader:<br />
 <br />
<code><br />
[myProgram setSemantic:SCNGeometrySourceSemanticVertex forSymbol:@"a_position" options:nil];<br />
</code> </p>
<p>This is trivial for attributes(normals, texcoords, vertex) and the supported uniforms (model/view/proj/normal matrices) but harder for textures (you will have to load the texture yourself using openGL and here use the delegate methods as describes in the blog to bind it).<br />
 <br />
also note that variables like gl_ModelViewProjectionMatrix, gl_Color are deprecated.<br />
 <br />
2 and 3. The right thing to do is to share the material (not the program!). that way the shader will be built just once. Since a SCNProgram overrides the material settings, there is no reason to not share the material.</p>
<p>I agree that the lack of documentation and sample code (for this part of the API in particular) is something that must be fixed.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
