FxCleaner conditioner: Difference between revisions

From COLLADA Public Wiki
Jump to navigation Jump to search
 
(4 intermediate revisions by the same user not shown)
Line 16: Line 16:
This algorithm checks all <material>-elements for <setparam>-values that are already in the default-state of its instanced effect.  
This algorithm checks all <material>-elements for <setparam>-values that are already in the default-state of its instanced effect.  


In the following example, the <setparam ref="Lamp0Color"> would be deleted, because its value (1 1 1) is the same as the default state of the referenced <newparam sid="Lamp0Color"> in <effect id="Effect1">.
In the following example the <setparam ref="Lamp0Color"> would be deleted because its value (1 1 1) is the same as the default state value of the referenced <newparam sid="Lamp0Color"> in <effect id="Effect1">.


[[Image:Fxcl_pBalancing_snippet1.png]][[Image:Fxcl_pBalancing_snippet2.png ]]
[[Image:Fxcl_pBalancing_snippet1.png]][[Image:Fxcl_pBalancing_snippet2.png ]]


The implementation of this algorithm also takes care of multiple profile-definitions per effect. So a <setparam> in <material> gets only deleted, if its value is the same as the default value of its <newparam> across all present profiles.  
The implementation of this algorithm also takes care of multiple profile-definitions per effect. So a <setparam> in <material> gets only deleted, if its value is the same as the default value of its <newparam> across all present profiles.


====Reducing Effect Redundancies====
====Reducing Effect Redundancies====
This feature is the most powerful one of the FxCleaner conditioner. As mentioned in the introduction the current implementation of the COLLADAMAYA FX exporter is not able to use the feature of COLLADAFX having multiple materials instancing one effect.  
This feature is the most powerful one of the FxCleaner conditioner. As already mentioned in the introduction, the current implementation of the COLLADAMAYA FX exporter is not able to use the feature of COLLADAFX having multiple materials instancing one effect.  


Take the following example:  
Take the following example:  
Line 31: Line 31:
[[Image:Fxcl_preview_mm.jpg | thumb | 300px | none | Same shading-effect, different textures ]]
[[Image:Fxcl_preview_mm.jpg | thumb | 300px | none | Same shading-effect, different textures ]]


Now, in COLLADAMAYA we would have to create two COLLADAFX materials which unfortunately creates two <effect>s with the only difference of having distinct surfaces linked to the Color-Sampler:
Now, in COLLADAMAYA we would have to create two COLLADAFX materials which unfortunately creates two <effect>s. In our example case the only difference between those two effect are distinct surfaces linked to the Color-Sampler:


[[Image:Fxcl_redundant_effect1.png]][[Image:Fxcl_redundant_effect2.png ]]
[[Image:Fxcl_redundant_effect1.png]][[Image:Fxcl_redundant_effect2.png ]]


And the two actual <material>s simply instance each of the two effects:
The two actual <material>s simply instance each of the two effects:


[[Image:Fxcl_redundant_materials.png]]
[[Image:Fxcl_redundant_materials.png]]


It is obviously a very redundant way to define our wanted materials. We would rather expect having two <material>s instancing the same effect and only
This is obviously a very redundant way to define our wanted materials. We would rather expect having two <material>s instancing the same effect and only overriding the ColorTexture-parameter by a <setparam>. FxCleaner is able to automatically detect two redundant <effect>s like in the above example. Those two <effect>s will be merged and their instancing <material>s will be changed accordingly.  
overriding the ColorTexture-parameter by a <setparam>. FxCleaner is able to automatically detect two redundant <effect>s like in the above example. Those two <effect>s will be merged and their instancing <material>s will be changed accordingly.  


In our example, <effect id="Effect2" name="Plastic_Two"> will be deleted, and the new <material>s will look like this:  
In our example, <effect id="Effect2" name="Plastic_Two"> will be deleted, and the new <material>s will look like this:  
Line 46: Line 45:
[[Image:Fxcl_reduceEffect_materialResult.png]]
[[Image:Fxcl_reduceEffect_materialResult.png]]


The above example illustrates a very simple case. But the conditioner is also able to merge two <effect>s that might have different values in their <newparam>-defitions. After merging, the difference of the <newparam>-values between two <effect>s, is expressed by stepping through all <material>s
The above example illustrates a very simple case. But the conditioner is also able to merge two <effect>s that might have different values in their <newparam>-defitions. After merging, the difference of the <newparam>-values between two <effect>s, is expressed by stepping through all <material>s that instanced those two <effect>s and creating <setparam>s with the correct values.
that instanced those two <effect>s and creating <setparam>s with the correct values.


It is also possible two merge <effect>s with multiple profiles. For example you might run the [http://www.collada.org/mediawiki/index.php/CgToGLSL_conditioner CgToGLSL conditioner] prior to the FxCleaner and achieve the same result, but with multiple profiles (GLSL and Cg).  
It is also possible to merge <effect>s with multiple profiles. For example you might run the [http://www.collada.org/mediawiki/index.php/CgToGLSL_conditioner CgToGLSL conditioner] prior to the FxCleaner and achieve the same result, but with multiple profiles (GLSL and Cg).  


You can download the above example case from [http://sourceforge.net/project/showfiles.php?group_id=184185&package_id=254573&release_id=559159 here] (FxCleaner_example.zip).
You can download the above example case from [http://sourceforge.net/project/showfiles.php?group_id=184185&package_id=254573&release_id=559159 here] (FxCleaner_example.zip).
Line 57: Line 55:


==Availability==
==Availability==
The FxCleaner conditioner is available for Windows and Mac OS X as a Refinery plugin and a standalone CLI tool. Please see <code>install_notes.txt</code> instructions
The FxCleaner conditioner is available for Windows and Mac OS X as a Refinery plugin and a standalone CLI tool. Please read <code>install_notes.txt</code> in the binary packages (available [http://sourceforge.net/project/showfiles.php?group_id=184185&package_id=254573&release_id=559159 here]) for further installation instructions. See <code>BUILD.txt</code> for build instruction on both platforms of the source-package.
of the download packages on [http://sourceforge.net/project/showfiles.php?group_id=184185&package_id=254573&release_id=559159 FxCleaner sourceforge] for instructions on installing the binaries. See <code>BUILD.txt</code> for build instruction on both platforms of the source-package, also
available at [http://sourceforge.net/project/showfiles.php?group_id=184185&package_id=254573&release_id=559159 FxCleaner sourceforge]


==Usage==
==Usage==
Line 72: Line 68:


'''Perform Parameter Balancing'''
'''Perform Parameter Balancing'''
:If enabled, Compares <setparam> arrays of <material>-elements with default values of its effect, and deletes unnecessary <setparam>-elements (also see [http://www.collada.org/mediawiki/index.php/FxCleaner_conditioner#Parameter_Balancing here])
:If enabled, FxCleaner compares <setparam> arrays of <material>-elements with default values of its effect, and deletes unnecessary <setparam>-elements (also see [http://www.collada.org/mediawiki/index.php/FxCleaner_conditioner#Parameter_Balancing here])


'''Reduce Effect Redundancies'''
'''Reduce Effect Redundancies'''
Line 84: Line 80:


'''Write Logfile'''
'''Write Logfile'''
:Enable to write a detailed logfile of the optimization process. By default the logfile is placed in the current working directory (in the Refinery into the directory of the INPUT Collada file).
:Enable to write a detailed logfile of the optimization process. By default the logfile is placed in the current working directory for the CLI-version, the Refinery-plugin places its logfiles into the directory of the INPUT Collada file.


==Revision History==
==Revision History==
Line 92: Line 88:


==Special notes and limitations==
==Special notes and limitations==
* This conditioner depends on the SVN version of the COLLADA DOM as it uses methods for comparison of two elements which are not available in the current official release.
* This conditioner depends on the SVN version of the COLLADA DOM as it uses methods of daeElement which are not available in the current official release for comparing COLLADA elements.

Latest revision as of 20:52, 5 December 2007

Conditioner information
  • Name: FxCleaner
  • Purpose: Optimizes COLLADAFX data
  • Last updated: 3.12.2007
  • Current version: 1.0
  • Status: released
  • Created by: Heinrich Fink
  • Contact for technical issues: [email protected]

Download

This article is part of the COLLADA conditioners directory
Adding to the conditioners directory

Description

The FxCleaner optimizes COLLADA effects by checking for various redundant definitions. The original motivation for this conditioner was to compensate COLLADAMAYA's lack of having multiple <material>-elements instancing one effect. In the next chapter you will find a description of the available algorithms.

Features

Parameter Balancing

This algorithm checks all <material>-elements for <setparam>-values that are already in the default-state of its instanced effect.

In the following example the <setparam ref="Lamp0Color"> would be deleted because its value (1 1 1) is the same as the default state value of the referenced <newparam sid="Lamp0Color"> in <effect id="Effect1">.

Fxcl pBalancing snippet1.pngFxcl pBalancing snippet2.png

The implementation of this algorithm also takes care of multiple profile-definitions per effect. So a <setparam> in <material> gets only deleted, if its value is the same as the default value of its <newparam> across all present profiles.

Reducing Effect Redundancies

This feature is the most powerful one of the FxCleaner conditioner. As already mentioned in the introduction, the current implementation of the COLLADAMAYA FX exporter is not able to use the feature of COLLADAFX having multiple materials instancing one effect.

Take the following example:

Our goal is to create two materials with the same shading-effect (simple phong) but using different textures for the surface color, like on the following screenshot.

Same shading-effect, different textures

Now, in COLLADAMAYA we would have to create two COLLADAFX materials which unfortunately creates two <effect>s. In our example case the only difference between those two effect are distinct surfaces linked to the Color-Sampler:

Fxcl redundant effect1.pngFxcl redundant effect2.png

The two actual <material>s simply instance each of the two effects:

Fxcl redundant materials.png

This is obviously a very redundant way to define our wanted materials. We would rather expect having two <material>s instancing the same effect and only overriding the ColorTexture-parameter by a <setparam>. FxCleaner is able to automatically detect two redundant <effect>s like in the above example. Those two <effect>s will be merged and their instancing <material>s will be changed accordingly.

In our example, <effect id="Effect2" name="Plastic_Two"> will be deleted, and the new <material>s will look like this:

Fxcl reduceEffect materialResult.png

The above example illustrates a very simple case. But the conditioner is also able to merge two <effect>s that might have different values in their <newparam>-defitions. After merging, the difference of the <newparam>-values between two <effect>s, is expressed by stepping through all <material>s that instanced those two <effect>s and creating <setparam>s with the correct values.

It is also possible to merge <effect>s with multiple profiles. For example you might run the CgToGLSL conditioner prior to the FxCleaner and achieve the same result, but with multiple profiles (GLSL and Cg).

You can download the above example case from here (FxCleaner_example.zip).

Removal of unreferenced <effect>s

If an <effect> is not instanced by any <material> in the current COLLADA document it will be removed.

Availability

The FxCleaner conditioner is available for Windows and Mac OS X as a Refinery plugin and a standalone CLI tool. Please read install_notes.txt in the binary packages (available here) for further installation instructions. See BUILD.txt for build instruction on both platforms of the source-package.

Usage

Conditioner options

You can set the following options of the conditioner either via the Refinery GUI, or as a commandline option.

Type

./FxCleaner --help

for command line parameters.

Perform Parameter Balancing

If enabled, FxCleaner compares <setparam> arrays of <material>-elements with default values of its effect, and deletes unnecessary <setparam>-elements (also see here)

Reduce Effect Redundancies

Enable to let the conditioner perform this algorithm.

Delete Material Extras

Enable to delete <extra>-elements in <material>s that referenced a merged effect.

Delete Unreferenced Effects

Enable to remove any <effect>s that are not instanced by any <material>.

Write Logfile

Enable to write a detailed logfile of the optimization process. By default the logfile is placed in the current working directory for the CLI-version, the Refinery-plugin places its logfiles into the directory of the INPUT Collada file.

Revision History

Ver. 1.0 released 2007-12-03

initial release

Special notes and limitations

  • This conditioner depends on the SVN version of the COLLADA DOM as it uses methods of daeElement which are not available in the current official release for comparing COLLADA elements.