bonjorno7 / SourceOps

A more convenient alternative to Blender Source Tools.
GNU General Public License v3.0
147 stars 14 forks source link

Texture scaling #79

Open MistyMarshes opened 2 years ago

MistyMarshes commented 2 years ago

Hi, I'm creating a map for CS:S in Blender and using your add-on to export it into Hammer. Thanks a lot for making this!:)

The issue is that if I want to keep things as brushes, I need to re-scale and shift all textures in Hammer each time I export it from Blender. I'm not sure how texture UVs work in Source yet, but I wonder if there is a way to use Blender UVs to create the brush texture data in a way that makes brushes look the same as in Blender.

I was planning to write a script or to modify your add-on for personal use to solve this for my workflow, but then I thought "hey, maybe this was already solved by bonjorno7 and I didn't realize".

Does this make sense or am I missing something? Should I work on your code to create a PR if I figure this out, or are you not interested in this at all?

Thanks

MistyMarshes commented 2 years ago

Hey @bonjorno7, I decided to give this a try yesterday and found your TODO in _types/mapexport/brush.py

I added scale and offset calculation based on texture size and it's working nicely :) I'll clean it up and create a PR this week in case you want to include it.

Edit: I'm Nieblist.

bonjorno7 commented 2 years ago

Oh awesome, thanks!

FenX08 commented 2 years ago

Hey, @MistyMarshes, great work on the update and @bonjorno7 thank you very much for your super awesome plugin! I have a question for @MistyMarshes, can you please do the same thing for displacements and PR the update?

Currently my friend edits my map (map was imported with io_import_vmf plugin) in Blender and converts many brushes to displacements, and it would be great to not redo all of the UVs after export. This is especially important, because right now we are on strict timing of map release.

Thanks! 🙏

Nieblist commented 2 years ago

Hi @bonjorno7, @FenX08

I'm @MistyMarshes (I edited my last comment as proof, I just prefer to use this account). I created a PR for this: https://github.com/bonjorno7/SourceOps/pull/80

I added an option called "Allow Skewed Textures" because there are some issues with scale and offset whenever the texture gets skewed - I'm not sure yet if this is a Hammer limitation or something wrong with the mapping. I included the option because I still find it useful, but I can remove it from the PR if you prefer. If you don't check that option it will correct your UVs to make sure that your textures only get rotated and shifted, but not skewed (as when using Hammer's UI for face texture editing).

Note that texture shift and scale are based on the size of your Blender texture, so you should use a material with a single Image Texture for this to work properly.

@FenX08 Ok, I can try to adapt it to displacements, but I'll probably need to fix the issue I mentioned first. If you find any issue in my code please let me know. Thanks!

bonjorno7 commented 2 years ago

Your PR looks great, I've only requested a few small changes.

Nieblist commented 2 years ago

Nice, I made those changes, please let me know if you find anything else.

PS: Hey, also, let me know if you need help with something else related to computer graphics, I'd like some more practice on this and I may be able to find some time!