PDA

View Full Version : Use environment mapping from .xmsl file?



koyi
July 11th, 2010, 16:41
Hi,

I am trying to use phenomenon created with Mental mill in RealityServer's mi scene.

I did get almost everything to work now by specifying phenomenon's name in shader declaration like this:


shader "shader_name" "phenomenon_name" (
"diffuse_color" 0.312 0.256 0.184 1,
"diffuse_weight" 3,
"glossiness" 0.193878,
"reflectivity" 0.52551,
"ior" 3.16327
)

material "material_name"
= "shader_name"
end material

instance "inst_name" "obj_name"
light "exclusive" []
material ["material_name"]
caustic on
caustic 3
globillum on
globillum 3
end instance

However, I do not know how to get the environment shader specified in the .xmsl file to work. I have tried using environment definition in the camera instance but that did not work.

Is there a way to do that?


Also, if I want to use an instance of the phenomenon class (which is defined as a node in the xmsl file), which already contains the correct settings, what can I do? Currently I am copying over each parameter's value manually, which is quite troublesome.


<node name="phenomenon_name_1" class="phenomenon_name">


Thank you.

ak
July 12th, 2010, 13:59
Is there a way to do that?


Yes. This feature is currently not supported by Mental Mill, but you can define such a phenomenon manually. The following shows an example, that works with the shipped RealityServer tutorial scenes meyem and meyem II:

environment_phen.xmsl:

<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:/Development/mental/mill_file_io/mill_file_io.xsd">
<metasl_code file_name="environment_map_spherical.msl"/>

<phenomenon name="Environment_phen">
<input name="env_tex" type="Texture2d" value="default.dds"/>
<input name="intensity" value="1" type="float" />
<output name="result" type="Color" />

<node name="env_test" class="Environment_map_spherical">
<input name="env_tex" type="Texture2d">
<attachment target_name="env_tex"/>
</input>
<input name="intensity" value="1" type="float">
<attachment target_name="intensity"/>
</input>
<output name="result" type="Color">
<attachment target_name="result"/>
</output>
</node>
</phenomenon>

</root>


To see it running, just exchange the environment shader assignment in <RS>/applications/util/scene/main.mi as shown as follows:



# shader "environment" "Environment_map_spherical" (
$include "environment_phen.xmsl"
shader "environment" "Environment_phen" (
"env_tex" "environmentTexture",
"intensity" 0.1
)
...


While the environment shader is assigned to the camera like that:


camera "camera"
environment = "environment"
...




Also, if I want to use an instance of the phenomenon class (which is defined as a node in the xmsl file), which already contains the correct settings, what can I do? Currently I am copying over each parameter's value manually, which is quite troublesome.


I am not quite sure if I understand you correctly here. What do you mean with copying over each parameter's value manually? Are you talking about the input parameters in the xmsl file?

Best regards.