<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[GMan's Mods & Stuff — Working with shaders]]></title>
	<link rel="self" href="https://gprogs.com/extern.php?action=feed&amp;tid=433&amp;type=atom" />
	<updated>2011-03-20T16:40:06Z</updated>
	<generator>PunBB</generator>
	<id>https://gprogs.com/viewtopic.php?id=433</id>
		<entry>
			<title type="html"><![CDATA[Re: Working with shaders]]></title>
			<link rel="alternate" href="https://gprogs.com/viewtopic.php?pid=1655#p1655" />
			<content type="html"><![CDATA[<p>greetings!&nbsp; could you whip up a quick running example?</p>]]></content>
			<author>
				<name><![CDATA[gman]]></name>
				<uri>https://gprogs.com/profile.php?id=2</uri>
			</author>
			<updated>2011-03-20T16:40:06Z</updated>
			<id>https://gprogs.com/viewtopic.php?pid=1655#p1655</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Working with shaders]]></title>
			<link rel="alternate" href="https://gprogs.com/viewtopic.php?pid=1649#p1649" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Kernle 32DLL]]></name>
				<uri>https://gprogs.com/profile.php?id=313</uri>
			</author>
			<updated>2011-01-19T23:09:08Z</updated>
			<id>https://gprogs.com/viewtopic.php?pid=1649#p1649</id>
		</entry>
</feed>
