Shader editor
by Daniel O'Malley · in Torque Game Engine Advanced · 09/06/2005 (8:27 pm) · 21 replies
I would like to know if i can use any can of shader editor to get the code to put in my script or if they have a specific shader tool you can tell me wich i can use
thanks
thanks
About the author
#2
09/07/2005 (1:10 pm)
Thanks alot i will check this
#3
I am noob to shaders so go easy on me...
09/09/2005 (9:18 pm)
After I port over the shader.. how do I apply it to a dts?I am noob to shaders so go easy on me...
#5
09/10/2005 (5:46 pm)
Hey thanks...
#6
I checked out the book Claudio Martinez said, but it was released in 2004. Is there another good book for newbies?
11/07/2006 (4:46 pm)
RenderMonkey would work on a Nvidia graphic card?I checked out the book Claudio Martinez said, but it was released in 2004. Is there another good book for newbies?
#7
11/07/2006 (4:55 pm)
Yes, RenderMonkey works fine on Nvidia cards. I honestly wouldn't recommend using tools like RenderMonkey. I'm a big fan of hand writing shaders though. If you'd like to learn more about shaders give the ShaderX books a try. Each has a series of articles focusing on GPU related topics. Very useful information.
#8
11/08/2006 (7:14 am)
Thanks Matt. i'll check.
#9
11/08/2006 (8:23 am)
Rendermonkey does allow you to hand code your shaders though in HLSL, it just gives you an easy testing environment for them.
#10
And since you asked how to apply your shaders to material, I have to assume you're new to all this, so keep in mind some things: in TSE a shader and a material are two different things.
Materials are mapped to textures in DTS and DIF objects. There are two types of materials: the "Material" and "CustomMaterial". The first one has many fields you use to define the material appearance (bump texture, specular intensity, etc). Torque then generates a dynamic HLSL shader for that material, based on those parameters, so you don't need to deal with shaders directly. This is the recommended route for newbies.
CustomMaterials are meant to use custom HLSL shaders directly. They have a shader field, in which you specify a ShaderData object which points to your HLSL files. This is far more advanced, since you need to know how Torque pass constants to the shaders, and stuff like vertex struct format. You should study the dynamically generated shaders AND the part of the source code which prepares the shader constants to see what is avaliable for your shaders.
CustomMaterials also become very limited in usage: as example, you could create a single Material to be used in both interiors and shapes, because internally Torque would generate a shader file for each type of object taking in account their features (ie.: interior shaders need to deal with lightmaps, while shapes' don't). A custom shader must be written either for shapes or interiors, so if you wanted the same material on both you'd need more than one material.
I'm sure TDN has one tutorial on how to map materials to textures, give it a search.
11/08/2006 (10:13 am)
If you're MS4, they added a reload method for shaders, allowing you to re-compile your shaders during run-time and seeing the changes right away. That way you don't need to worry about using RenderMonkey features which aren't exposed in Torque.And since you asked how to apply your shaders to material, I have to assume you're new to all this, so keep in mind some things: in TSE a shader and a material are two different things.
Materials are mapped to textures in DTS and DIF objects. There are two types of materials: the "Material" and "CustomMaterial". The first one has many fields you use to define the material appearance (bump texture, specular intensity, etc). Torque then generates a dynamic HLSL shader for that material, based on those parameters, so you don't need to deal with shaders directly. This is the recommended route for newbies.
CustomMaterials are meant to use custom HLSL shaders directly. They have a shader field, in which you specify a ShaderData object which points to your HLSL files. This is far more advanced, since you need to know how Torque pass constants to the shaders, and stuff like vertex struct format. You should study the dynamically generated shaders AND the part of the source code which prepares the shader constants to see what is avaliable for your shaders.
CustomMaterials also become very limited in usage: as example, you could create a single Material to be used in both interiors and shapes, because internally Torque would generate a shader file for each type of object taking in account their features (ie.: interior shaders need to deal with lightmaps, while shapes' don't). A custom shader must be written either for shapes or interiors, so if you wanted the same material on both you'd need more than one material.
I'm sure TDN has one tutorial on how to map materials to textures, give it a search.
#11
I have an interior dif with a material. Do I make another datablock using customMaterial and just specify the shader and version (and other fields..)?
11/09/2006 (10:08 am)
Just to clarify: to get the (custom) shaders to work, you need both the material & custom material datablocks?I have an interior dif with a material. Do I make another datablock using customMaterial and just specify the shader and version (and other fields..)?
#12
Both the customMaterial and the ShaderData need you to specify their shader version required to run it (in the ShaderData case, the version specifies which shader model profile will the shaders). If the videocard version is lower than the required, it'll switch to the callback material, and repeat the process until it finds a compatible shader.
11/09/2006 (10:40 am)
You only need one: either a material or a customMaterial. But a customMaterial needs a shaderData datablock, and optionally, a fallback customMaterial.Both the customMaterial and the ShaderData need you to specify their shader version required to run it (in the ShaderData case, the version specifies which shader model profile will the shaders). If the videocard version is lower than the required, it'll switch to the callback material, and repeat the process until it finds a compatible shader.
#13
I made a material datablock and assigned the material trough addMaterialMapping but it doesn't work.
I got the orange "No Material" in my interior map.
Here what I did:
In data/materialMap.cs
In server/scripts/material.cs
I don't know what I'm doing wrong, maybe a newby mistake, but I spent to much time trying to get it work and I'm still trying.
Thank for any help in advance.
02/12/2007 (10:33 am)
I can't figure out how it works.I made a material datablock and assigned the material trough addMaterialMapping but it doesn't work.
I got the orange "No Material" in my interior map.
Here what I did:
In data/materialMap.cs
addMaterialMapping("glass", "material: GlassMat");In server/scripts/material.cs
datablock CustomMaterial(GlassMat)
{
texture[0] = "~/data/textures/glass";
texture[1] = "$backbuff";
shader = Reflect;
version = 1.4;
};I don't know what I'm doing wrong, maybe a newby mistake, but I spent to much time trying to get it work and I'm still trying.
Thank for any help in advance.
#14
TDN is your friend.
02/12/2007 (11:10 am)
tdn.garagegames.com/wiki/TSE/Materials/Mapping_Materials_to_TexturesTDN is your friend.
#15
If I write just a "new Material", works fine, but if I write a datablock "CustomMaterial", simply doesn't work.
02/12/2007 (12:41 pm)
Thanks @Brian. I already read this TDN article, but still dont work.If I write just a "new Material", works fine, but if I write a datablock "CustomMaterial", simply doesn't work.
#16
If that doesn't work, then you are trying to map a material to a texture name that doesn't exist in your .dts object. If this is the case, are you using Maya? If so, then the texture name is exported with the full filename, so you'll need:
mapTo = "glass.png";
02/12/2007 (6:17 pm)
OK, so you don't need the "addMaterialMapping" call, you can just use the "mapTo" parameter, like the article says.If that doesn't work, then you are trying to map a material to a texture name that doesn't exist in your .dts object. If this is the case, are you using Maya? If so, then the texture name is exported with the full filename, so you'll need:
mapTo = "glass.png";
#17
I put the mapTo parameter, but, dont solve the problem. I'm working with 3DS Max.
I have a glass.png file in the directory "~/data/textures/".
My datablock is inside server/scripts/material.cs.
If I put a "new Material" in the material.cs of DTS folder, works great, but CustomMaterial dont.
My problem is that I can't assing custom shaders with "new Material" and datablocks of CustomMaterial dont works...
I'm using that starter.fps porting.
Thanks.
02/13/2007 (6:58 am)
Still didn't work :(I put the mapTo parameter, but, dont solve the problem. I'm working with 3DS Max.
I have a glass.png file in the directory "~/data/textures/".
My datablock is inside server/scripts/material.cs.
If I put a "new Material" in the material.cs of DTS folder, works great, but CustomMaterial dont.
My problem is that I can't assing custom shaders with "new Material" and datablocks of CustomMaterial dont works...
I'm using that starter.fps porting.
Thanks.
#18
02/13/2007 (7:10 am)
Please post the the contents of your materials.cs file, so we can look at the CustomMaterial you're creating. I fear you're using the same parameters as the Material for the CustomMaterial, and that will not work, as the CustomMaterial uses different fields.
#19
Thanks,
02/13/2007 (8:18 am)
My datablock in server/scripts/material.csdatablock CustomMaterial(GlassMat){
mapTo = "glass";
texture[0] = "~/data/textures/glass";
texture[1] = "$backbuff";
shader = Reflect;
version = 1.4;
};Thanks,
#20
02/13/2007 (11:56 am)
Yeah, the datablock declaration will not work, that should be "new CustomMaterial".
Torque Owner Claudio Martinez
Here's a good book to help with RenderMonkey (although they use an earlier version)
http://www.amazon.com/exec/obidos/tg/detail/-/1592000924/qid=1126103299/sr=2-1/ref=pd_bbs_b_2_1/104-9380397-6279113?v=glance&s=books
Then read this to port to TSE
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=7595
I hope that helps!