Roland Posted September 22, 2014 Share Posted September 22, 2014 Is there any draw texture function that can tile the texture, or do I have to make a loop drawing my texture to create the effect. Context:DrawTexture does not seem to handle tiling. Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
tjheldna Posted September 23, 2014 Share Posted September 23, 2014 Haven't tried this out, so let me know if it works. http://www.leadwerks.com/werkspace/topic/9913-drawimage-tiled/ 1 Quote Link to comment Share on other sites More sharing options...
Roland Posted September 23, 2014 Author Share Posted September 23, 2014 Will check tonight then. Thanks Quote Roland Strålberg Website: https://rstralberg.com Link to comment Share on other sites More sharing options...
macklebee Posted September 23, 2014 Share Posted September 23, 2014 For this I would just make a slight change to the existing shader used for DrawImage by adding a scale uniform to it since the command GraphicsDriver::TileImage is not official and is not available for lua. Also the post that TJ links to asked about clipping a drawn image. It could be done via drawing to a buffer but you could also just make another slight modification to the 'drawimage.shader' by adding another uniform to set the X&Y start of the clipped image used in conjunction with the scale uniform. Fragment portion of the 'drawimage.shader': #version 400 uniform vec4 drawcolor; uniform sampler2D texture0; uniform vec2 scale = vec2(1.0,1.0); //added for tiling uniform vec2 clipcoords = vec2(0.0,0.0); //added for clipping in vec2 vTexCoords0; out vec4 fragData0; void main(void) { fragData0 = drawcolor * texture(texture0, vTexCoords0 *scale + clipcoords); } Then to use: shader = Shader:Load("Shaders/Drawing/drawimage.shader") shader:SetVec2("scale", Vec2(#,#)) --the default is vec2(1.0,1.0) so it doesn't effect the normal drawimage command shader:SetVec2("clipcoords", Vec2(#,#)) --the default is vec2(0.0,0.0) so it doesn't effect the normal drawimage command context:DrawImage() Edit -- I changed the above shader code to make the scale a Vec2 value in case you only wished to tile the image in one direction. Edit2 - I changed the fragData0 line to multiply by scale prior to adding the clipccords. 3 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.