Game Development Community

Material creation question

by Ronald J Nelson · in Torque Game Engine Advanced · 01/06/2008 (6:01 pm) · 8 replies

I wanted to know if all materials must be created before the game is started, or can you have a function create a material then allow the object to be added?

#1
01/06/2008 (9:01 pm)
Maybe I needed to be a bit clearer. I want to allow people to really customize their paints. By having the option to set up material combinations that might not be available on all of the clients. I want to be able to command each client to create the material, then allow the other player to join.

Is this possible, or must all materials be declared at the start of the engine?
#2
01/06/2008 (11:22 pm)
Will not work.
materials -> shadergen -> creates a new shader -> must be compiled before it can be used
-> done at start.

you might thought be able to modify the code to allow that.

But I don't see how the user should be able to create materials that you couldn't define upfront.
you can have as many materials as you want. as long as they are not used, they are not loaded as well (unless they have preload = true; set)
#3
01/07/2008 (10:02 am)
Actually I don't think the Shader must be compiled when the application is started, I just that's how it is done right now. Someone can correct me if I'm wrong but I think you could do this by creating a script that generates the Torque Script Material entry then exec the new Material. I'm pretty sure the process of "compiling" the script with the Material definition in it is what generates and compiles the procedural shader.
#4
01/07/2008 (10:22 am)
Totally doable. Just checked by shifting the loadMaterials(); from init.cs initClient() over to missiondownload.cs onMissionDownloadPhase1 and while it played up a bit with the out-of-mission guiobjectviewer implementation this end, the rest of the functionality (ie: colorizing greyscale textures via shaders ect wich would be highly noticeable if not present) worked just fine in the in-game phase.

edit: y'know, opon reflection... considering the engines set up to download dts objects and textures from servers if it's not found on the client already... strikes me as somewhat oddball that the material initialisation's set up where it is in the first place... hrm... [goes off to tinker]
#5
01/07/2008 (11:22 am)
Forget the send over ... it is broken anyway. if a crc incompatible version of the file is present it will just stop connecting and kick you out instead of deleting the original file and load the new for example.
#6
01/07/2008 (3:33 pm)
No only is it possible like Kirk stated, but it can be done quite easily with a string and eval.

Thanks Kirk, I saw how you and Brian did it.
#7
01/08/2008 (9:24 am)
In dx9 shader is passed with D3DXAssembleShader (part of d3dx9.lib) and gets back a binary representation of the compiled shader which in turn is passed to Microsoft Direct3D via IDirect3DDevice9::CreatePixelShader or IDirect3DDevice9::CreateVertexShader.
The runtime does not know anything about HLSL, only the binary assembly shader models.

This is usefull too:
garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=8205

These days i'll try to study how the whole process is coded via the SDK.
#8
01/08/2008 (2:40 pm)
Picasso - That is interesting and all, even though all of the graphics are gone, but I was only looking to create the scripted material. I have a working version of this now and am quite satisfied with the results I am getting from it.