[T3D 1.1 Alpha bug]Custom materials don't work at all
by Ivan Mandzhukov · in Torque 3D Professional · 11/30/2009 (3:26 pm) · 10 replies
I can not get any Custom material working in T3D 1.1
I tested a few shaders in some of the betas - they worked like a charm.
customMaterialDefinition.cpp
This code:
will always set mTexFilename[0] as $backbuff,no matter what i pass to texture[0]
I tested a few shaders in some of the betas - they worked like a charm.
customMaterialDefinition.cpp
This code:
const char* samplerDecl = "sampler";
S32 i = 0;
for (SimFieldDictionaryIterator itr(getFieldDictionary()); *itr; ++itr)
{
SimFieldDictionary::Entry* entry = *itr;
if (dStrStartsWith(entry->slotName, samplerDecl))
{
if (i >= MAX_TEX_PER_PASS)
{
logError("Too many sampler declarations, you may only have %i", MAX_TEX_PER_PASS);
return false;
}
if (dStrlen(entry->slotName) == dStrlen(samplerDecl))
{
logError("sampler declarations must have a sampler name, e.g. sampler["diffuseMap"]");
return false;
}
mSamplerNames[i] = entry->slotName + dStrlen(samplerDecl);
mSamplerNames[i].insert(0, '$');
mTexFilename[i] = entry->value;
++i;
}
}will always set mTexFilename[0] as $backbuff,no matter what i pass to texture[0]
#2
Yes... CustomMaterials should now look like this...
... which was a change we made to better support OSX as well as future steps to DX11.
As far as it setting $backbuff to texture[0]... that sounds like a bug we need to look into.
THREED-818
12/01/2009 (1:59 pm)
Interesting.Yes... CustomMaterials should now look like this...
new CustomMaterial( MyMaterial )
{
shader = MyShader;
stateBlock = MyStateblock;
sampler["tex1"] = "tex1.dds";
sampler["tex2"] = "tex2.dds";
pixVersion = 3.0;
};... which was a change we made to better support OSX as well as future steps to DX11.
As far as it setting $backbuff to texture[0]... that sounds like a bug we need to look into.
THREED-818
#4
i got some problems again.
1D and 2D samplers do work fine,but CUBE samplers don't sample anything.
I am getting strange errors in console (reference to _initShader()),but i am sure the shader works fine in 1.0
This is what i use:
12/02/2009 (1:49 pm)
hi Tom,i got some problems again.
1D and 2D samplers do work fine,but CUBE samplers don't sample anything.
I am getting strange errors in console (reference to _initShader()),but i am sure the shader works fine in 1.0
This is what i use:
singleton CustomMaterial(Brass)
{
mapTo = "testshapetex";
cubemap = MyCubemap;
sampler["cube01"] = "$cubemap";
shader = BrassShaderData;
version = 2.0;
};
#5
Cube sampler handlers do work fine in c++
The only problem is in Torquescript,i believe there is something very simple to be solved.
My be i am doing it the wrong way...
12/04/2009 (8:34 am)
up againCube sampler handlers do work fine in c++
GFX->setCubeTexture( 0, p->cubemap );
The only problem is in Torquescript,i believe there is something very simple to be solved.
My be i am doing it the wrong way...
#6
somehow the cube sampler worked for me.
I can not understand what i did,but right now it works.
I also have a question.
1D,2D and CUBE samplers are fine.
What happens with the volume samplers ?
I found that 3D samplers are fine,but it seems that GFX is not ready for volume textures.
tex3D() samples the same as tex2D().
I did various texture setups (64 x 64*64),(64*64 x 64) but they did not work.
I believe we should use something like a dml setup,but there is no way how to set up the shader this way.
12/12/2009 (1:21 pm)
Hi Tom,somehow the cube sampler worked for me.
I can not understand what i did,but right now it works.
I also have a question.
1D,2D and CUBE samplers are fine.
What happens with the volume samplers ?
I found that 3D samplers are fine,but it seems that GFX is not ready for volume textures.
tex3D() samples the same as tex2D().
I did various texture setups (64 x 64*64),(64*64 x 64) but they did not work.
I believe we should use something like a dml setup,but there is no way how to set up the shader this way.
#7
Tom posted above that the new format is:
What else is necessary to get these textures all the way into my shader?
08/04/2010 (3:16 pm)
I'm having the same problem where my custom shaders aren't getting the textures I'm setting in the CustomMaterial.Tom posted above that the new format is:
new CustomMaterial( MyMaterial )
{
shader = MyShader;
stateBlock = MyStateblock;
sampler["tex1"] = "tex1.dds";
sampler["tex2"] = "tex2.dds";
pixVersion = 3.0;
};What else is necessary to get these textures all the way into my shader?
Fragout main( ConnectData IN,
uniform sampler2D diffuseMap : register(S0),
uniform sampler2D lightInfoBuffer : register(S1)
)
#8
It has been a while since I've played with a CustomMaterial but I am pretty sure you need to make sure that your shader sampler names match your CustomMaterial's sampler names (with GLSL and DX11 samplers are supposed to be referenced by name and not by register).
Give this a try:
or change your CustomMaterial to:
I apologize in advanced if my information here is inaccurate...it has been nearly a year since I looked at that code and I don't have time right this minute to verify.
09/10/2010 (8:28 am)
Tim,It has been a while since I've played with a CustomMaterial but I am pretty sure you need to make sure that your shader sampler names match your CustomMaterial's sampler names (with GLSL and DX11 samplers are supposed to be referenced by name and not by register).
Give this a try:
Fragout main( ConnectData IN,
uniform sampler2D tex1 : register(S0),
uniform sampler2D tex2 : register(S1)
)or change your CustomMaterial to:
new CustomMaterial( MyMaterial )
{
shader = MyShader;
stateBlock = MyStateblock;
sampler["diffuseMap"] = "tex1.dds";
sampler["lightInfoBuffer"] = "tex2.dds";
pixVersion = 3.0;
};I apologize in advanced if my information here is inaccurate...it has been nearly a year since I looked at that code and I don't have time right this minute to verify.
#9
I wasn't able to reproduce the original bug of getting $backbuff when you didn't set it. Unless you still have this issue or can tell me how to reproduce it i'm assuming this bug is closed.
01/31/2011 (2:24 pm)
@IvanI wasn't able to reproduce the original bug of getting $backbuff when you didn't set it. Unless you still have this issue or can tell me how to reproduce it i'm assuming this bug is closed.
#10
I think this is not a bug.
02/01/2011 (12:14 am)
I think the problem was when you forget to specify a sampler name,but have a cubemap,the CustomMaterial picks a random name and sometimes it is the backbuff.I think this is not a bug.
Torque Owner Ivan Mandzhukov
Liman3D
I found user samplers do work in T3D 1.0
There are some non documented changes in T3D 1.1 about the sampler's handlers,it seems texture[n] is entirely removed and the code handles the texture names as sampler names,but when sampler names are not used,T3D set $backbuff as texture[0]