HLSL texture indexing in Irrlicht
HLSL texture indexing in Irrlicht
In DX9 it is necessary, so says an introduction, to set the textures used by the shader.
I.e.
m_pEffect->SetTexture("tVolumeNoise", m_pVolumeNoiseTexture);
I can´t find any reference to setting texture refs in Irrlicht, and wonder if someone could clarify, especially when many textures are used.
I.e.
m_pEffect->SetTexture("tVolumeNoise", m_pVolumeNoiseTexture);
I can´t find any reference to setting texture refs in Irrlicht, and wonder if someone could clarify, especially when many textures are used.
Re: HLSL texture indexing in Irrlicht
As I know for HLSL You don't need any special binding call to enable texture in a shader, just use semantic.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Re: HLSL texture indexing in Irrlicht
semantic, you mean first declared texture is from material 0...?
this must be handled soemwhere in the irrlicht code then?
this must be handled soemwhere in the irrlicht code then?
Re: HLSL texture indexing in Irrlicht
Yes, this is handle in CD3D9Driver::setActiveTexture at line 750.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Re: HLSL texture indexing in Irrlicht
thanks, I´ll take a look!
Re: HLSL texture indexing in Irrlicht
More exactly, each texture in the material is placed on the corresponding sampler stage, which means that material texture 0 will be on sampler stage 0, material texture 1 will go to the sampler stage 1, and so on.
You don't have to do anything at all, But, what you have to keep in mind also is that when you set material textures 0 and 3, the samplers 1 and 2 won't be set and if you have 4 samplers declared in your shader, the only samplers used will be 0 and 1, unless you specify the register you want each sampler2D to read from. (sampler2D texture:register(0) for register 0, and so on);
You don't have to do anything at all, But, what you have to keep in mind also is that when you set material textures 0 and 3, the samplers 1 and 2 won't be set and if you have 4 samplers declared in your shader, the only samplers used will be 0 and 1, unless you specify the register you want each sampler2D to read from. (sampler2D texture:register(0) for register 0, and so on);
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Re: HLSL texture indexing in Irrlicht
Okay, so any scene node textures not set will cause a displacement in indexing in the shader. Good to know.
On a side issue, I have a strange shader thing going on, which I have yet to explain. Maybe you might know what it might be...
Basically, I have a reflective plane surface node, when used with the GLSL shader it works fine all the time, but with the HLSL shader, which looks pretty standard, the texture image gets tiled twice across the plane (4 images).
However, if I drop any new node into the scene (where it will be visible) using the standard example Gooch shader, then the plane node image stops being tiled and works perfectly!
Why should the presence of the Gooch HLSL shader affect the node using the reflective shader? They don´t share the same texture, or any varaibles... its weird!
On a side issue, I have a strange shader thing going on, which I have yet to explain. Maybe you might know what it might be...
Basically, I have a reflective plane surface node, when used with the GLSL shader it works fine all the time, but with the HLSL shader, which looks pretty standard, the texture image gets tiled twice across the plane (4 images).
However, if I drop any new node into the scene (where it will be visible) using the standard example Gooch shader, then the plane node image stops being tiled and works perfectly!
Why should the presence of the Gooch HLSL shader affect the node using the reflective shader? They don´t share the same texture, or any varaibles... its weird!
Re: HLSL texture indexing in Irrlicht
@Nadro: I sorta meant the code which sets up the textures for the HLSL shaders through DX9.
I´d like to see how Irrlicht does it so that I can try to "extrapolate" the best method for handling the processing of multiple textures (like 32 or even 256 of them) in the HLSL shader code.
The aim is to develop a fader that works with nodes up to 256 textures... if only there was a hardware feature in GPUs to set the alpha for a whole mesh... without having to set thousands of vertex alphas using the CPU
I´d like to see how Irrlicht does it so that I can try to "extrapolate" the best method for handling the processing of multiple textures (like 32 or even 256 of them) in the HLSL shader code.
The aim is to develop a fader that works with nodes up to 256 textures... if only there was a hardware feature in GPUs to set the alpha for a whole mesh... without having to set thousands of vertex alphas using the CPU
Re: HLSL texture indexing in Irrlicht
to have 256 texture in dx9 you would need to make your irrlicht capable of handeling 16 texture ( some transformation matrix are missing) then 16 is the absolute maximum possible with dx9 so you would need to make each texture you bind an atlass that contai 16 texture
Re: HLSL texture indexing in Irrlicht
can´t use atlas textures because user can select any texture from a library... guess I could post process the images into mosaics... sort of messy though.
so it must be possible to fade a 3D object rapidly, and I mean in hardware!! not by processing thousands of vertex alphas...
all that GPU technology ... there must be a way...
so it must be possible to fade a 3D object rapidly, and I mean in hardware!! not by processing thousands of vertex alphas...
all that GPU technology ... there must be a way...
Re: HLSL texture indexing in Irrlicht
So please forget about 256 textures on DX9 hardware (even 3D textures will not help, because filtering for them works differently than for 2D textures). For 256 textures You need texture arrays. If You need the same alpha value for a whole mesh just use shader uniform.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Re: HLSL texture indexing in Irrlicht
I have an externally varying alpha level 0 - 255 to be applied to all meshes of an object, hence all materials.
I just need a shader to process all the materials, that does the alpha multiply, using the external variable.
Can I access the texture from the material... bfff, think I´m getting confused!!
Why can´t the shader just access the texture for the current material being rendered?
I just need a shader to process all the materials, that does the alpha multiply, using the external variable.
Can I access the texture from the material... bfff, think I´m getting confused!!
Why can´t the shader just access the texture for the current material being rendered?
Re: HLSL texture indexing in Irrlicht
It exactly works in this way.robmar wrote:Why can´t the shader just access the texture for the current material being rendered?
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Re: HLSL texture indexing in Irrlicht
I think we have a language issue, and I don´t mean c++!
A shader will render using the texture passed. If that is one texture, that will be the texture of material 1. Right?
If the object has many materials, many sub meshes, and I set the shader to each material, will the shader reference the texture from the 1st material, or will it be the texture of each material... which sort of seems to break the texture indexing mentioned above...
A shader will render using the texture passed. If that is one texture, that will be the texture of material 1. Right?
If the object has many materials, many sub meshes, and I set the shader to each material, will the shader reference the texture from the 1st material, or will it be the texture of each material... which sort of seems to break the texture indexing mentioned above...
Re: HLSL texture indexing in Irrlicht
the textures and shaders are bound to the materials. so, the shaders will reference the textures from the material they are asigned to.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt