Author Topic: Asset-based texture path  (Read 2210 times)

Offline KyL

  • Member
  • *
  • Posts: 123
Asset-based texture path
« on: January 29, 2016, 04:09:12 PM »
 Hi there,

I was looking for something like this on the wiki and I couldn't find any information.

Basically I need to create a city with lots of differents buildings and props.
At the moment I need to have each building having its own set of shader to load its own textures.

What I am looking for is a way to define the texture path depending on the asset name.
So for example the texture filename would be something like ["drive:/directory/directory/textures/%ASSETNAME"_COL.jpg]. This would allow to use the same shaders on every asset, each one loading the texture depending on its name.

Is it something already implemented? If not, this could be a good suggestion for the future versions.

Also, I assume that having a limited set of shaders shared between lots of assets would be more efficient to render that a lot of different shaders. Matt, you could probably shed some light on this for me!

Thanks!

Offline Dune

  • Member
  • *
  • Posts: 15202
    • www.ulco-art.nl
Re: Asset-based texture path
« Reply #1 on: January 30, 2016, 06:28:21 AM »
The only way to do this now is manually reassign the textures to the particular part from (within) each loaded object from a single previously loaded texture file (say in a default shader).

Online Oshyan

  • Planetside Staff
  • *
  • Posts: 13198
  • Holy snagging ducks!
Re: Asset-based texture path
« Reply #2 on: February 01, 2016, 06:23:01 AM »
Or, if you have some scripting/programming talent you could easily figure out the OBJ load syntax in the (XML, human-readable) XML files and generate a TGD with all your objects loaded in and referencing the same shared textures.

- Oshyan

Offline Matt

  • Planetside Staff
  • *
  • Posts: 3583
  • I'm the crazy one
Re: Asset-based texture path
« Reply #3 on: February 01, 2016, 06:50:14 AM »
I don't know if this helps in your case, but if you can put each asset in a separate folder and put its textures in the same folder as the asset (or a subfolder), then Terragen would be able to use relative paths, so all of the "col" textures could be called "col.jpg". But it sounds like you're working in a pipeline where that wouldn't be ideal, either because you need the textures to be located somewhere else or because you need the filename to contain the asset name.

However, even if you can use the relative path idea, you'd still need a different shader for each asset.

Also, I assume that having a limited set of shaders shared between lots of assets would be more efficient to render that a lot of different shaders. Matt, you could probably shed some light on this for me!

It wouldn't really matter to the renderer. Even if TG had a text-replacement mechanism for filenames that allowed you to use fewer shaders, it would still need to use memory to load each texture that you ask it to. The number of separate shaders wouldn't really matter to render time or memory usage, although it could maybe speed up the UI and reduce clutter in your project.

Matt
« Last Edit: February 01, 2016, 06:54:12 AM by Matt »
Just because milk is white doesn't mean that clouds are made of milk.

Offline KyL

  • Member
  • *
  • Posts: 123
Re: Asset-based texture path
« Reply #4 on: February 01, 2016, 03:01:02 PM »
Thanks for your replies guys!

I thought about the editing thing or more simply edit the .mtl file of the OBJ. But this adds another per-asset step that I want to avoid. And I don't really like scripting :)

Actually the reason I want to do that is mainly because I'm lazy: ideally I would have created a set of shaders for every type of material used, regardless of the assets. All the buildings for examples would have all the same shaders, and by just automatically picking up their correct texture, they would have their correct materials. (as I am creating different IDs texture for each buildings to define where each material should be applied).
This is of course the typicall "in a perfect world" situation, and the differences in the textures and colors of each assets already tells me that I will need to do little adjustments to each one of them.

I tried having the textures in the asset folder and it works like a charm! From what I understand it is still looking up the filename of the OBJ defined by the .mtl file, but Terragen is able to look up for this relative texture path, which is very handy. Unfortunatly I won't use it as I have some shared texture between assets like trees, and this would mean unnecessary texture duplicates.

Thanks for this and the precisions about the renderer Matt. I will keep each assets with its own set of shaders. It makes more sens anyway, and I will be able to export a tgo file for each asset that will be ready to render for any other scenes.

I am not worried about the UI thing, as all the shaders are inside the actual object nodes so I never have more that 20-30 nodes on the screen at the same time.

One last thing:
In the default shader, let's say you put the same file in two slots. For example a .PNG file with alpha.
You put the filepath in the Color section and the same path in the Opacity section with "use alpha as opacity".
Would the shader be smart enough to load the texture one time or would it load the file two times?

Also, it seems that it is automatically applying a linear gamma to the color file, which is correct. What about the displacement and specular slots? Is it leaving the gamma as is (no gamma correction)?
I am used to change that manually in the Image Map shader, but I am curious about what's happening under the hood of the default shader.

Thanks again!

Offline Dune

  • Member
  • *
  • Posts: 15202
    • www.ulco-art.nl
Re: Asset-based texture path
« Reply #5 on: February 01, 2016, 04:25:31 PM »
The only thing I can tell you is that the default shader loads 2 textures 2 times (I have asked before, so I know). That's why I lately don't use an alpha channel in a texture, but an extra greyscale opacity map.  Just to keep memory load down, although for most scenes it isn't that bad  ;)

Offline KyL

  • Member
  • *
  • Posts: 123
Re: Asset-based texture path
« Reply #6 on: February 01, 2016, 06:10:12 PM »
The only thing I can tell you is that the default shader loads 2 textures 2 times

That was my feeling as well. I am almost sure I found this question asked a long time ago, it was probably you Dune  :)

I use Image Map shaders plugged to the various "functions" inputs of the default shader most of the time anyway. This was pure curiosity. Thanks!

Offline Matt

  • Planetside Staff
  • *
  • Posts: 3583
  • I'm the crazy one
Re: Asset-based texture path
« Reply #7 on: February 02, 2016, 05:47:31 AM »
Also, it seems that it is automatically applying a linear gamma to the color file, which is correct. What about the displacement and specular slots? Is it leaving the gamma as is (no gamma correction)?
I am used to change that manually in the Image Map shader, but I am curious about what's happening under the hood of the default shader.

No conversion is done on displacement maps. This matches the defaults on the Displacement tab of the Image Map Shader.

Gamma conversion (2.2) is done on specular in the same way as diffuse, because IMO they are both just different kinds of reflectivity that should be viewed and authored in similar ways. For example, if you had an object whose diffuse colour is black, the specular might completely define the appearance of the object. It should be gamma converted so that renders look like what you authored in Photoshop etc., just like the diffuse should be gamma converted.

Matt
« Last Edit: February 02, 2016, 05:50:56 AM by Matt »
Just because milk is white doesn't mean that clouds are made of milk.

Offline Dune

  • Member
  • *
  • Posts: 15202
    • www.ulco-art.nl
Re: Asset-based texture path
« Reply #8 on: February 02, 2016, 07:11:27 AM »
Quote
I use Image Map shaders plugged to the various "functions" inputs of the default shader most of the time anyway.

That's a way indeed, but I never do that, because I want those inputs for procedural color variation... but you made me think; I can combine that of course, just multiply the image map shader by a world space PF. Ha!

Offline KyL

  • Member
  • *
  • Posts: 123
Re: Asset-based texture path
« Reply #9 on: February 02, 2016, 01:52:18 PM »
Gamma conversion (2.2) is done on specular in the same way as diffuse, because IMO they are both just different kinds of reflectivity that should be viewed and authored in similar ways. For example, if you had an object whose diffuse colour is black, the specular might completely define the appearance of the object. It should be gamma converted so that renders look like what you authored in Photoshop etc., just like the diffuse should be gamma converted.

Makes total sense. Thanks again for those precisions.


I can combine that of course, just multiply the image map shader by a world space PF. Ha!

That's pretty much what I am doing  ;) That's also the only way I am aware of to vary saturation on Trees.

 

anything