PDA

View Full Version : Syntax error in phenomenon declaration. Anybody help me?



NbongoNbongo
May 5th, 2011, 10:52
Hi all.

I'm trying to declare phenomenon which takes one material parameter and put it directly to the root


declare phenomenon material "proxy_phen" (material "mtl")
root material interface "mtl"
end declare

The result is "syntax error".
Is it possible this to be done that way at all, or maybe should be something like:


declare phenomenon material "proxy_phen" (material "mtl")
material "output"
interface "mtl.surface"
photon interface "mtl.photon"
displace interface "mtl.displace"
...
end material

root material interface "output"
end declare

Anybody?

steve
May 9th, 2011, 18:27
You can create a fresh material inside a phenomenon, and return it as the phenomenon result, turning this phenomenon into a material description.

Is that what you are trying to achieve ?

Removed a previous statement that was incorrect:
you can not pass materials into phenomena, there is no such parameter type called "material".

NbongoNbongo
May 11th, 2011, 14:46
Hi steve. Thanx for reaction.

I am new with mental ray, but in many sources (for example here (http://docs.autodesk.com/MENTALRAY/2012/ENU/mental%20ray%203.9%20Help/files/manual/node112.html)) and in many examples I see that material is valid parameter type.
I need my phenomenon to return material which is the same as (or at least equivalent to) the one passed as parameter.
I am wondering is it possible at all this to be done on mi scene file level.

steve
May 12th, 2011, 15:49
You are absolutely right about the material type, my fault, sorry. I think I need to correct the other post.

What I was driving at was the way you wanted to pass the input material directly back as a return type. That is not supported I fear. You may use the input material to assign it to other internal nodes, though. Like give it as a parameter to a shader that supports such an input.

bart
May 12th, 2011, 16:02
In your second listing, it appears there may be a little confusion between a material and a material shader. Often people call the material shader a surface shader.

A material entity is actually a container for the whole set of shaders which can be used to define appearance. This includes the material (surface) shader, photon shader, shadow shader, displacement shader, etc. A material cannot be used like a multi-output shader as an "output" to a Phenomenon. Its not like a shader which can be used in the shader graph. It is the ending container of all shader graphs for a given look description. This is what is connected to an object when an instance of the object is defined.

However, a material Phenomenon can be instantiated and used by an object or an instance in the instance's material list. An example, from the book Writing mental ray Shaders is here:
http://writingshaders.com/scene_catalog_files/scene_catalog_mifiles/material_phenomena.mi

The first few chapters of the book are a good place to start for learning mi scene description. I assume you have the book, since this is in the sub-forum for the book?

Or please look in the documentation that ships with mental ray for scene description language to see how to declare shaders and Phenomenon. Aside from not being able to use the individual shader graphs from materials for inputs, the example above is missing = signs if you are trying to connect to Phenomenon inputs. Note that the interface to the input parameter uses this syntax:


declare phenomenon material "my_phen" (
color "surface",
color "photon")
material "output"
= interface "surface"
photon = interface "photon"
end material
root material "output"
end declare
That said, it would help us to help you if you could provide more information regarding what you are trying to do more in an overview description and not in the lower level details.

NbongoNbongo
May 16th, 2011, 13:16
Hi Bart. Sorry for the delay.
I have started this thread in search for alternative solution of a problem which I have exposed in another thread in another forum (here (http://forum.mentalimages.com/showthread.php?8030-Translating-3ds-max-material-to-mental-ray-material)). I realize this produced a mess, sorry for that, but I think the original forum is not appropriate place for discussing this matter.
In my second listing I'm trying to decompose the input material to set of shaders and put them together into a new material, but I'm afraid this is not possible on mi scene file level.
Now I'm trying to do the same by writing shaders for material(surface), environment, displace etc which takes material as parameter and executes his corresponding shaders.


declare shader color "proxy_phen_surface" (material "mtl")
version apply bla bla bla
end shader

declare shader scalar "proxy_phen_displace" (material "mtl")
version apply bla bla bla
end shader
...
declare phenomenon material "proxy_phen" (material "mtl")
material "output"
"proxy_phen_surface" ("mtl" = interface "mtl")
photon "proxy_phen_photon" ("mtl" = interface "mtl")
displace "proxy_phen_displace" ("mtl" = interface "mtl")
...
end material

root material "output"
end declareThis works with partial success for now. I think I can bring it to life, but I'm not sure this solution will cover all cases.
Another approach I'm considering is somehow to find all instances with my material assigned and replace this assignment with the "mtl". Maybe in some state shader or something.
I'm afraid I don't know mental ray in deep enough to figure out the right approach.
I'm not happy with neither of above. I have the filling I'm trying to rape mental ray.

bart
May 16th, 2011, 20:30
Maybe I don't understand correctly, but any material definition can be decomposed easily from an original mi file. Lets try to simplify what you are trying to accomplish.

I don't know enough about the 3ds max api function particulars, though others listening in may, but I'd first take a look at the mi export of a standard max material, and see if we can do what you need at a completely different level.

bart
May 16th, 2011, 20:58
Some extra background ...

In 3ds max, the mental ray material represents the material, the whole set of shaders, surface, photon, etc. without any shaders plugged into the slots yet.

The Arch&Design material represnts a material Phenomenon, which is an instantiable material definition, including shader graphs attached to surface, photon, etc. material slots.

Now, a Standard material represents a material as well, but the terminology presented in the UI and in the shader declarations between material and material shader in max is somewhat fuzzy.

For example, one can find a shader named max_Standard_Material. If assigned to an object and then written out to an mi file, you will see the instance of that shader in a shader ... end shader block. That shader is not the instance of a material Phenomenon. Then you will also see an instance of a material in a material ... end material block, referring to that shader. For example, I exported a simple example:


material "Material #19|Mtl"
= "Material #19|MtlProxy(material)|Texmap"
shadow = "Material #19|MtlProxy(material)|Texmap"
photon = "Material #19|MtlProxy(material)|Texmap"
end materialNote that the shader serves in several different functions, as the shader for the material, photon, and shadow shader. That was a choice made by the writers of that shader. They could have written 3 separate shaders for each functionality. One reason for combining them is to assure they all get the same input parameters. Anyway, for those trying to distinguish the functionality, this could also create confusion regarding the material. But the shader in this case is not a material. That material block is the actual material definition.