Shadertest resource: Difference between revisions
Jump to navigation
Jump to search
(Created page with "Example resource for testing shaders File layout: <syntaxhighlight lang="lua"> shadertest meta.xml clientscript.lua clientshader.fx hurry.png </syntaxhighlight> ...") |
No edit summary |
||
(3 intermediate revisions by one other user not shown) | |||
Line 2: | Line 2: | ||
File layout: | File layout: | ||
shadertest | shadertest | ||
meta.xml | meta.xml | ||
Line 8: | Line 7: | ||
clientshader.fx | clientshader.fx | ||
hurry.png | hurry.png | ||
meta.xml contains this: | meta.xml contains this: | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="xml"> | ||
<meta> | <meta> | ||
<script src="clientscript.lua" type="client" /> | <script src="clientscript.lua" type="client" /> | ||
Line 25: | Line 23: | ||
addEventHandler("onClientResourceStart", resourceRoot, | addEventHandler("onClientResourceStart", resourceRoot, | ||
function() | function() | ||
myShader,tecName = | myShader,tecName = dxCreateShader( "clientshader.fx" ) | ||
myImage = | myImage = dxCreateTexture( "hurry.png" ) | ||
if myShader and myImage then | if myShader and myImage then | ||
dxSetShaderValue( myShader, "tex0", myImage ) | |||
outputChatBox( "Shader using techinque " .. tecName ) | outputChatBox( "Shader using techinque " .. tecName ) | ||
else | else |
Latest revision as of 20:49, 23 September 2016
Example resource for testing shaders
File layout:
shadertest meta.xml clientscript.lua clientshader.fx hurry.png
meta.xml contains this:
<meta> <script src="clientscript.lua" type="client" /> <file src="clientshader.fx" type="client" /> <file src="hurry.png" type="client" /> </meta>
clientscript.lua contains this:
addEventHandler("onClientResourceStart", resourceRoot, function() myShader,tecName = dxCreateShader( "clientshader.fx" ) myImage = dxCreateTexture( "hurry.png" ) if myShader and myImage then dxSetShaderValue( myShader, "tex0", myImage ) outputChatBox( "Shader using techinque " .. tecName ) else outputChatBox( "Problem - use: debugscript 3" ) end end ) addEventHandler( "onClientRender", root, function() if myShader then dxDrawImage( 200, 300, 400, 200, myShader, 0, 0, 0, tocolor(255,255,0) ) end end )
clientshader.fx contains this:
// Insert your fabulous crap here
hurry.png is copied from the race resource. i.e. race/img/hurry.png