<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[GMan's Mods & Stuff — Working with shaders]]></title>
		<link>https://gprogs.com/viewtopic.php?id=433</link>
		<atom:link href="https://gprogs.com/extern.php?action=feed&amp;tid=433&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Working with shaders.]]></description>
		<lastBuildDate>Sun, 20 Mar 2011 16:40:06 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Working with shaders]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=1655#p1655</link>
			<description><![CDATA[<p>greetings!&nbsp; could you whip up a quick running example?</p>]]></description>
			<author><![CDATA[null@example.com (gman)]]></author>
			<pubDate>Sun, 20 Mar 2011 16:40:06 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=1655#p1655</guid>
		</item>
		<item>
			<title><![CDATA[Working with shaders]]></title>
			<link>https://gprogs.com/viewtopic.php?pid=1649#p1649</link>
			<description><![CDATA[<div class="codebox"><pre><code>Type MyShaderCallBack Extends IShaderConstantSetCallBack
    Field fLightStrength1:Float
    Field fLightStrength2:Float
    Field fLightStrength3:Float
    Field fLightStrength4:Float
    
    Field fvLightPosition1:Float[3]
    Field fvLightPosition2:Float[3]
    Field fvLightPosition3:Float[3]
    Field fvLightPosition4:Float[3]
    
    Field fvLightColor1:Float[4]
    Field fvLightColor2:Float[4]
    Field fvLightColor3:Float[4]
    Field fvLightColor4:Float[4]
    
    Field fvAmbientColor:Float[4]
    
    Field fSpecularPower:Float = 0.0        &#039;S=pow(fDiffuseIntensity,fSpecularPower)*fSpecularStrength;
    Field fSpecularStrength:Float = 0.0    &#039;will result in less glossing surfaces
    Field fBumpStrength:Float = 0.8        &#039;strength of the bumpmapping.. higher values will result in more &quot;bumpy&quot; surfaces 
    
    Method OnSetConstants(services:IMaterialRendererServices,userdata:Int)
        Local driver:IVideoDriver = services.getVideoDriver()
        
        Local var0:Float = 0
        Local var1:Float = 1
        
        services.setPixelShaderConstantFromName(&quot;baseMap&quot;, Varptr var0, 1)
        services.setPixelShaderConstantFromName(&quot;bumpMap&quot;, Varptr var1, 1)
        
        Local invWorld:matrix4 = driver.getTransform(ETS_WORLD)
        invWorld.makeInverse()
        services.setPixelShaderConstantFromName(&quot;matWorldInverse&quot;, invWorld.pointer(), 16)
        
        services.setPixelShaderConstantFromName(&quot;fLightStrength1&quot;, Varptr(fLightStrength1), 1)
        services.setPixelShaderConstantFromName(&quot;fLightStrength2&quot;, Varptr(fLightStrength2), 1)
        services.setPixelShaderConstantFromName(&quot;fLightStrength3&quot;, Varptr(fLightStrength3), 1)
        services.setPixelShaderConstantFromName(&quot;fLightStrength4&quot;, Varptr(fLightStrength4), 1)
        
        services.setPixelShaderConstantFromName(&quot;fvLightPosition1&quot;, Varptr(fvLightPosition1)[0], 3)
        services.setPixelShaderConstantFromName(&quot;fvLightPosition2&quot;, Varptr(fvLightPosition2)[0], 3)
        services.setPixelShaderConstantFromName(&quot;fvLightPosition3&quot;, Varptr(fvLightPosition3)[0], 3)
        services.setPixelShaderConstantFromName(&quot;fvLightPosition4&quot;, Varptr(fvLightPosition4)[0], 3)
        
        services.setPixelShaderConstantFromName(&quot;fvAmbient&quot;, Varptr(fvAmbientColor)[0], 4)
        services.setPixelShaderConstantFromName(&quot;fvLight1Color&quot;, Varptr(fvLightColor1)[0], 4)
        services.setPixelShaderConstantFromName(&quot;fvLight2Color&quot;, Varptr(fvLightColor2)[0], 4)
        services.setPixelShaderConstantFromName(&quot;fvLight3Color&quot;, Varptr(fvLightColor3)[0], 4)
        services.setPixelShaderConstantFromName(&quot;fvLight4Color&quot;, Varptr(fvLightColor4)[0], 4)
        
        services.setPixelShaderConstantFromName(&quot;fSpecularPower&quot;, Varptr(fSpecularPower), 1)
        services.setPixelShaderConstantFromName(&quot;fSpecularStrength&quot;, Varptr(fSpecularStrength), 1)
        services.setPixelShaderConstantFromName(&quot;fBumpStrength&quot;, Varptr(fBumpStrength), 1)
    EndMethod

    &#039; we must override the generate function in order for instantiation to work properly
    Function generate:IShaderConstantSetCallBack()
        Return New MyShaderCallBack
    EndFunction
EndType</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Kernle 32DLL)]]></author>
			<pubDate>Wed, 19 Jan 2011 23:09:08 +0000</pubDate>
			<guid>https://gprogs.com/viewtopic.php?pid=1649#p1649</guid>
		</item>
	</channel>
</rss>
