• Welcome to SC4 Devotion Forum Archives.

Texture bender

Started by rivit, April 28, 2015, 12:33:22 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

rivit

As I've been mucking about recently with transit textures again, here is a little side effect that may be of use to you.

It's a small program to use in conjunction with your favourite art tool which I've called Bender. It can quickly make bends and S-curves in one step with minimal input - the result is placed in the clipboard for further use.

Its a vb.net 2.0 exe, which can be dropped anywhere - doesn't need installing, just keep the .dll with it. No instructions for use, but I'm sure you'll figure it out by reading the tooltips and experimenting. Feedback welcome. 

cheers Ron

JoeST

awesome tool rivit :D are you willing to share the source or anything? *obsesses about code* XD
Copperminds and Cuddleswarms

eggman121

First impressions and this is amazing  :thumbsup:  &apls

This will make work on the RRW and any other textures for road so much easier  :o

+1 for you   ;)

-eggman121

noahclem

This looks very promising indeed! Memo's radial bending tool has been a lifesaver for me and after practicing with it for a while I can fairly easily and consistently get S-curves to align correctly but I do a ton of guessing as to what the radius should be and end up with tons of open files, copying, cutting, pasting, flipping, and rotating. At first glance this seems like it could take some of the guesswork and extra steps out and will surely be appreciated by Photoshop users for whom an equivalent to the radial bending tool hasn't been made.

If you need a logo :D


gn_leugim

very useful thing! not only for transit textures but for a while bunch of stuff :D

vortext

#5
This is potentially a very convenient and time-saving tool, however, it doesn't seem to handle transparency. And that's a major drawback imho. Here's an example.



On the right the original texture, on the left an s-curve with the back-fill removed, obviously. The edge of the ortho texture consist of a small gradient strip which gets an unfortunate solid fill with the Bender.

Another thing, when re-doing a curve with different settings it doesn't get stored in the clipboard consistently. Have to hit 'go' a number of times, or switch back-and-forth between settings before the new texture can be pasted, if at all. I'm using a 256px texture btw and in particular a large 1024px 90 degree curve seems to have this issue. It would also be nice to be able to preview the whole curve, though that's a minor issue really.

edit, in fact sometimes changing settings doesn't even result in a new texture being generated when hitting 'go'. For example changing 'inner/center/outer fit' for a 256px 90 degree curve doesn't seem to do anything, unless 'best whole/half/quarter' is changed simultaneously.

I really hope these issues can be addressed, transparency especially, because it's promising to be an absolutely brilliant tool!  &apls
time flies like a bird
fruit flies like a banana

rivit

Well thanks all for your feedback so far. A mixed bag but certainly useful.

I'll consider dropping the source when I'm sure its ok. The basic algorithm is deceptively simple.
For every pixel(x, y) on the resultant image, find the angle and the distance from the bottom left corner R,A say.
Use R and A to map to coordinates s (across) and t (down) on the original image. If outside do nothing, if inside i.e. 0<=s<=1, 0<=t<=Modulo sample that pixel by weighted average and put it into the result.

I agree that Transparency support may be a shortcoming/problem - I went there (coded it) and then came back, Ill explain why below. As a workaround, and in fact useful for a number of purposes, it is possible to bend the image (color) and the alpha (white on black) independently - they are guaranteed to match when recombined if made with the same settings. I prefer this method myself because usually all the other wealthing alphas need to be made anyway.

The constraint I found is - put extremely simply  - the Windows Clipboard does not preserve Transparency. It will load a previously saved transparent image from the clipboard with a blue background in XP and a whiteish background in later versions of windows.  I tried a number of workarounds from around the WEB but they were unreliable.

What this means is that in order to support transparency the resultant image needs to be explicitly saved in a format that does, and then explicitly loaded. (Hence avoiding clipboard by two save/load dialogs).  I was trying to not go there because then you need extra steps - however its quite possible to make. Also I don't currently support loading an image with transparency because of the above - can be changed - its not difficult. As they say watch this space.

The inner/centre/outer fit perhaps needs explaining. Its intent is to allow positioning of the edge of the curve. Outer will put the right edge corner to the box size, inner the bottom corner to the bottom of the box while respecting the angle asked for. Centre fit is default into the box and will leave most space. There are combinations for which these settings appear useless (256px at 90deg will look the same in all three cases because it actually exactly fits the box all three ways!) - and they probably are. They are most useful for small textures and close bends like the straight to diagonal in two tiles we see in all original networks .

Other problems mentioned are news to me and I'd like someone else to verify those problems independently. Since I know how the code works I cant see how this is (or rather isn't) happening at all. 

rivit

And here is a version that can handle alpha and save to clipboard and file

vortext

#8
Sweet, thanks for adding transparency!!  :bnn:

re: inner/center/outer fit, this is were a small readme would've come in handy.  ;D

My - faulty - understanding was it had to do with the scaling of the texture, e.g. scale the inner curve correctly, similarly to the scaling factor in Markus' radial bend for gimp. But I get it now and it's very, very nice!  :thumbsup:

One new issue: when saving as file, it prompts 'texturname_Bent does not exist. Verify that the correct file name was given'. In other words it only allows to overwrite the original file.

Still leaves the issue I sometimes have to press 'go' more than once before clipboard gives the correct output. However, that has become a moot point as far as I'm concerned as I'll be saving as png anyway. Still would be nice if someone could verify it, and I'm on win8.1 if that matters.

time flies like a bird
fruit flies like a banana

rivit

A 'final' version which fixes my overenthusiasm with the previous version and finesses the antialiasing on the texture edges, as well as some stability fixes.


mgb204

Great stuff, if an Idiot like me can make an S-Curve in seconds using this tool, then it should be very useful. I re-made a GLR one I'd previously experimented with using the Radial Bending script, not only was a lot of time saved, but I got almost pixel perfect results first time, I had to play around with the last one to get it looking worse :thumbsup:.

vortext

Quote from: rivit on April 29, 2015, 05:20:40 PM
A 'final' version which fixes my overenthusiasm with the previous version [...]

:D

But, erm, clipboard output no longer has transparency. Since I'm not sure if that's intentional thought I should mention it. Other than that everything seems in working order.  :thumbsup:

And yes, this tool is gonna save a lot of time.  &apls
time flies like a bird
fruit flies like a banana

rivit

You're right, but with all due respect Clipboard output never had transparency - this is a limitation 8-( of Windows clipboard.

What I've done now is to not even try to store it there - I colour the background to show where it would have been - just like windows used to do in XP days - the modern white just isn't distinctive enough. The transparency IS completely propagated into the saved versions of output. In any case, in Photoshop at least, selecting the blue background and cutting it off works quite cleanly.

vester

Maybe save out the transparency out as seperate alpha file ?
Adding a to the end of the file name good be a way to go.
Or save it out as png.... there you can handle alpha as well.

vershner

Hi there, I tried to use this tools to create a 45 degree rail curve matching the original NAM wide radius curve. However, I couldn't find any setting that would produce that curve. The closest I could get was 768 box with outer fit, but that is still too wide.

I think the settings that would produce the correct curve would be size 384 inner fit, but it needs a box of 768x384. Would it be possible to add non-square boxes as an option?  Or, is that a setting combination that I've missed that would produce the rail curve?

eggman121

Try 700 px  ;)

Than blend that with the diagonal.

-eggman121

vershner

In the end I used the 384, which produced half the curve, then flipped and rotated to get the other half. I'll try 700 with the next one though, cheers! For some reason I hadn't noticed you could type in arbitrary values.