Asset-based texture path

Started by KyL, January 29, 2016, 12:09:12 PM

Previous topic - Next topic

KyL

 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!

Dune

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).

Oshyan

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

Matt

#3
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.

Quote from: KyL on January 29, 2016, 12:09:12 PM
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
Just because milk is white doesn't mean that clouds are made of milk.

KyL

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!

Dune

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  ;)

KyL

Quote from: Dune on February 01, 2016, 12:25:31 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!

Matt

#7
Quote from: KyL on February 01, 2016, 11:01:02 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
Just because milk is white doesn't mean that clouds are made of milk.

Dune

QuoteI 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!

KyL

Quote from: Matt on February 02, 2016, 01:47:31 AM
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.


Quote from: Dune on February 02, 2016, 03:11:27 AM
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.