crimsonstone Posted June 9, 2013 Share Posted June 9, 2013 Hey folks!I'm wondering if anyone has ideas for how to programmatically crop or mask TEX files?I want to be able to take an image/texture of any size and display it within a fixed boundary, even if the boundary is smaller than itself without scaling it down to the necessary size. Being able to play with different shapes of masks/cutouts would be fun, too.Additionally, is it possible to import other Lua modules/plugins for use in mods?Thanks! Link to comment https://forums.kleientertainment.com/forums/topic/20353-imagetexture-cropping/ Share on other sites More sharing options...
crimsonstone Posted June 12, 2013 Author Share Posted June 12, 2013 So...Either nobody knows how to handle this or everyone thinks I'm an idiot for asking. I accept both. Link to comment https://forums.kleientertainment.com/forums/topic/20353-imagetexture-cropping/#findComment-201592 Share on other sites More sharing options...
futaradragon Posted June 12, 2013 Share Posted June 12, 2013 I think it very hard for programming crop or mask but I have the best way for edit mask and crop scale and mod it.I use program Adobe Flash. I'm crop and mask with auto vector scale like this picture.It not correct 100% but it near.And I'm draw replace picture and Change Scale to 2x like 512Wx256H >> 1024Wx512H Link to comment https://forums.kleientertainment.com/forums/topic/20353-imagetexture-cropping/#findComment-201663 Share on other sites More sharing options...
dw420 Posted June 12, 2013 Share Posted June 12, 2013 the former Link to comment https://forums.kleientertainment.com/forums/topic/20353-imagetexture-cropping/#findComment-201721 Share on other sites More sharing options...
Arm4g3dd0nX Posted June 12, 2013 Share Posted June 12, 2013 I'm a half-decent programmer, and quite frankly, I have no idea what you are asking for. O_o Link to comment https://forums.kleientertainment.com/forums/topic/20353-imagetexture-cropping/#findComment-201741 Share on other sites More sharing options...
Lexicroft Posted June 12, 2013 Share Posted June 12, 2013 You can edit TEX file with this TEXToolCrop tex... Mask tex... You mean edit?Just open .tex file that you want to edit and then save it as .pngthen open the .png that you get with paint tools or else (I use paint.net)after you done editing, save it as .png , then open it with TexCreator, convert it to .tex again , then put it into the .rarFinish Link to comment https://forums.kleientertainment.com/forums/topic/20353-imagetexture-cropping/#findComment-201752 Share on other sites More sharing options...
futaradragon Posted June 12, 2013 Share Posted June 12, 2013 You can edit TEX file with this TEXToolCrop tex... Mask tex... You mean edit?Just open .tex file that you want to edit and then save it as .pngthen open the .png that you get with paint tools or else (I use paint.net)after you done editing, save it as .png , then open it with TexCreator, convert it to .tex again , then put it into the .rarFinishI think he said who have program that can auto crop and scale tex file to the mini picture direct form anim data scaleBut more program can auto scale like thisI use program Adobe Flash. I'm crop and mask with auto vector scale like this picture.It not correct 100% but it near.And I'm draw replace picture and Change Scale to 2x like 512Wx256H >> 1024Wx512H Link to comment https://forums.kleientertainment.com/forums/topic/20353-imagetexture-cropping/#findComment-202413 Share on other sites More sharing options...
reinert Posted June 12, 2013 Share Posted June 12, 2013 I think he said who have program that can auto crop and scale tex file to the mini picture direct form anim data scaleBut more program can auto scale like thisI use program Adobe Flash. I'm crop and mask with auto vector scale like this picture.It not correct 100% but it near.And I'm draw replace picture and Change Scale to 2x like 512Wx256H >> 1024Wx512HWould this be able to solve my problem with the rock when in hand not being totally visible?(its like cut in half) Link to comment https://forums.kleientertainment.com/forums/topic/20353-imagetexture-cropping/#findComment-202502 Share on other sites More sharing options...
crimsonstone Posted June 12, 2013 Author Share Posted June 12, 2013 Thanks for the responses, guys, but I'm actually trying to crop/mask the image within Lua.Please forgive my awful pseudo-code, but something along the lines of:function Image:Mask(tex_file, anchor_x, anchor_y, width, height) local box = Shape.box self.box.bg = tex_file self.box.anchor = (anchor_x, anchor_y) self.box.width = width self.box.height = height return boxend... later...local image = Image("path/to/file.tex")local center_x = image.width / 2local center_y = image.height / 2self.c_img = Image:Mask(image, center_x, center_y, 40, 80) Link to comment https://forums.kleientertainment.com/forums/topic/20353-imagetexture-cropping/#findComment-202595 Share on other sites More sharing options...
Developer Ipsquiggle Posted June 12, 2013 Developer Share Posted June 12, 2013 The texture-drawing stuff is down the engine, the Lua side of things doesn't even know about images, only resources that it commands the engine to render. I may be wrong but I don't think there's any way to modify a texture at runtime. For all our "masking" effects we've used animations.The Lua implementation is standard, so you should be able to include whatever libraries you like provided they are pure raw lua (no binary libraries). Link to comment https://forums.kleientertainment.com/forums/topic/20353-imagetexture-cropping/#findComment-202825 Share on other sites More sharing options...
crimsonstone Posted June 12, 2013 Author Share Posted June 12, 2013 Groovy. Thanks for the info, Ipsquiggle.When you say that you've used animations for your "masking" effects, can you point me at a particular anim/TEX that is semi-representative of what you're talking about? If I can figure out how you guys have done it, I'll see if it'll work for me.Thanks! Link to comment https://forums.kleientertainment.com/forums/topic/20353-imagetexture-cropping/#findComment-202922 Share on other sites More sharing options...
zeidrich Posted June 12, 2013 Share Posted June 12, 2013 An example of using animations for "masking" would be something like the hunger, sanity, health or spoiled_meter.I think with the way that the animations are created, you could have animations that used multiple segments of the same texture per frame. I don't know that there are any examples of this that I have seen in the game. The ones I've seen have separate regions per frame.I was trying to think about how you might be able to accomplish masking, I know that shaders are in data, and I wonder if clever shader manipulation could let you do something like that. I don't know if you can register shaders in mods, I don't know if anyone's even tried to do it yet. The ksh file looks like it's just a glsl shader package with a header. I know you can attach shaders to world entities. The other thing that might be possible, though maybe not right now, is 3d objects. While you might have trouble masking a billboard sprite, it might be possible to create some 3d object that could end up only displaying a part of the image. I don't think that there's any way to manipulate 3d objects through the scripting engine at the moment, or if they're is, it's not actively used/documented. Right now though, it's pretty much impossible apart from faking it with animations. Link to comment https://forums.kleientertainment.com/forums/topic/20353-imagetexture-cropping/#findComment-202973 Share on other sites More sharing options...
Developer Ipsquiggle Posted June 12, 2013 Developer Share Posted June 12, 2013 zeidrich hit the nail on the head. The health/etc. animations are the closest thing we've got, and looking at the data for those, we actually just animated each value in a gradient, no trickery whatsoever.The tentacle_pillar (Big Tentacle) also has a faked masking effect when it emerges/retracts, that was just some clever animation and scaling.This very much fits into the category that we haven't built a Game Engine here, we've built a Don't Starve Engine. Things that haven't been needed don't exist.Yes, the ksh files are just packaged shaders. I don't believe there are any generalized hooks on the lua side for controlling parameters though. :\ And I've never seen anything which gives 3D access to Lua, it's the whole resource-vs-data thing again.On a positive note: The reason we've used animations for these kinds of effects is because it gives us artistic precision: Rather than relying on the kinds of masking one can accomplish with polygon tricks, the art team can create exactly the effect they want with any kinds of crazy shapes, colours, etc. and it's exactly what they get. Link to comment https://forums.kleientertainment.com/forums/topic/20353-imagetexture-cropping/#findComment-203019 Share on other sites More sharing options...
zeidrich Posted June 13, 2013 Share Posted June 13, 2013 [MENTION=55]Ipsquiggle[/MENTION] I think the time that I've wanted to be able to mask something is pretty much when I've wanted to do something like show a partial minimap, which was really only important because MiniMap is userdata and special.For shaders, I just didn't want to rule it out. I can imagine making a variety of shaders and cycling through them. An example might be something like the way that snow cover gets played with. I don't know how I'd implement it, but you can do some fancy stuff with shaders so it might be possible.I guess I should have brought up the snow as a neat example of a sort-of-mask scenario, I forgot about it until now. Snow cover is a single texture, but it uses the R,G,B channels to show different snow patterns with different combinations. You might be able to use some composition using the same tactics to do something similar on a more colorful scale, but still, anims are probably easier. Link to comment https://forums.kleientertainment.com/forums/topic/20353-imagetexture-cropping/#findComment-203154 Share on other sites More sharing options...
crimsonstone Posted June 13, 2013 Author Share Posted June 13, 2013 You hit it, Zeidrich. :(I've been trying to figure out how to make a real mini-map.. and the first idea I had was to mask out the majority of the existing minimap object and change its anchor points.I definitely see the difference in building a game engine versus building a Don't Starve engine in this particular regard.. I was thinking about that earlier today, actually.The issue with using RGB channels with this application is that there's no room for transparency in that world.To make matters worse, I just sneezed with my jaw slightly apart and bit the hell out of my tongue...Thanks for your responses, gents! Link to comment https://forums.kleientertainment.com/forums/topic/20353-imagetexture-cropping/#findComment-203202 Share on other sites More sharing options...
zeidrich Posted June 13, 2013 Share Posted June 13, 2013 You hit it, Zeidrich. :(I've been trying to figure out how to make a real mini-map.. and the first idea I had was to mask out the majority of the existing minimap object and change its anchor points.I definitely see the difference in building a game engine versus building a Don't Starve engine in this particular regard.. I was thinking about that earlier today, actually.The issue with using RGB channels with this application is that there's no room for transparency in that world.To make matters worse, I just sneezed with my jaw slightly apart and bit the hell out of my tongue...Thanks for your responses, gents!If I wanted to make my own minimap in this engine, I think I would make a 2d array of image objects. I'd make animations that let each ground type be partially hidden, from the top, bottom, and corners. I'd fill the array with images from the map data surrounding the player. As the player moved north-south, the row of images would shift up or down. Likewise, east-west and the left and right rows. When the player crossed to a new tile, the images, and parent position would shift to reflect that. You could hide the furthest edges under another image with its center cut out so that the user doesn't see the control snapping and jerking around. I'd be most concerned about adding too many UI elements that move around with the player slowing the game down. Link to comment https://forums.kleientertainment.com/forums/topic/20353-imagetexture-cropping/#findComment-203253 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now