Page 1 of 1

[Shader] Querying textures in Hierarchy

Posted: 05 Nov 2015, 04:42
by TVM Cracklings
Hi there.

1.

How do I actually get textures themselves in a certain order in the Hierarchy window? There's some Sas bindings about texture infos in the documentation (e.g. Ventuz.Textures[*].Mapping), but I didn't find anything related to the textures themselves.

So my question is:

In the HLSL node, is there a way to load textures in an order specified in the Hierarchy without having artists to manually bind them every time?

2.

Is there a way to uniformly transform textures without losing the translation?

Currently I'm doing

Code: Select all

Output.vUV = mul(Input.vUV,UVTranslate[0]);
in vertex shader, and then

Code: Select all

tex2D(sampIn, Input.vUV+(float2)(UVTranslate[0][2]));
in fragment shader, which is kind of ugly.


Thx

-C

Re: [Shader] Querying textures in Hierarchy

Posted: 05 Nov 2015, 09:08
by lerou
Ventuz.Textures[*].Mapping

Using this will give you an array of the texture mappings. The elements are associated with the texture stages. The first element belongs to texture stage 1. The second to texture stage 2 and so on. There are 8 stages.

You define your texture samplers like this:

sampler sa[8] : register (s[0]);

An array of 8 texture samplers starting at the first stage (s[0] is the first stage. As usual you start with 0 while texture stages in parameters will start at 1).

You could also do:

sampler s0 : register (s[0]);
sampler s1 : register (s[1]);

without an array.

Textures in your hierarchy will be assigned automatically. Check the texture node. It has a texture stage parameter. It's set to next by default. So the first texture in the hierarchy will be stage 1 or index 0. The second is stage 2 or index 1 and so on. You can also manually assign those stages. You don't have to bind your textures to the shader manually.

Careful: if you set the first texture in your hierarchy to stage 2 and the second one to next, it will be bound to stage 3. Stage 1 would in this case be empty.

Best,
rou

Re: [Shader] Querying textures in Hierarchy

Posted: 05 Nov 2015, 11:43
by TVM Cracklings
Thx rou, you're awesome!

Although, if I multiply my vertex UV with the mapping matrix, the 3rd row of the matrix simply gets lost, since the UV coord is only a float2. Is there a similar way to take the translation part into account in UV coord processing, just like you do when you multiply the 4x4 translation matrix onto a float4(float3, 1.0f) (or the other way round)?

Re: [Shader] Querying textures in Hierarchy

Posted: 05 Nov 2015, 13:15
by lerou
same thing. Add a third value (1) to the uvs.

Re: [Shader] Querying textures in Hierarchy

Posted: 05 Nov 2015, 15:37
by TVM Cracklings
Alright. Thought there might be a cleaner way to do it. Thanks!