Topic: ..shaders documentation..

..hi guys..i went trough forum, and i couldnt find details about shader creation/specifics, regarding Maratis..i know Maratis uses GLSL, but appart from that, there is no specific details related to shader creation for engine. Is there any tutorial/documentation for it ?

Re: ..shaders documentation..

Hi,

you can find details on how to link shader in Blender here : http://www.maratis3d.org/?p=277
And there is some examples of shaders here : http://www.maratis3d.org/?p=548

In the example, the shaders are in the "shaders/" project folder.
It uses classic glsl shaders (vertex + fragment)
using custom uniforms and attributes sent by the engine.

For example this attributes for the geometry :

attribute vec3 Vertex;
attribute vec3 Normal;

Or this uniforms for the matrices :

uniform mat4 ModelViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 NormalMatrix;
uniform mat4 ProjModelViewMatrix;

Re: ..shaders documentation..

..since im not using blender, but 3dsmax, how to link shader with material trough code??

Re: ..shaders documentation..

What format are you exporting from 3dsmax ?

- if you are exporting a Collada or OBJ file, you can use Maratis converter :

Open your project in Maratis
Clic on File > Import 3d model and select your 3d file
It will convert the file and save it as a XML .mesh in your-project/meshs/
Open the .mesh file with a text editor and search for your material nodes : "<Material"
Add this inside the material (check the local path) :

<vertexShader file="../shaders/myShader.vert"/>
<fragmentShader file="../shaders/myShader.frag"/>

Here is an example of a material in Maratis XML format (from a mesh found in the second link I gave you) :

<Materials num="1">
    <Material id="0" type="3">
        <blend type="1"/>
        <opacity value="1.000000"/>
        <shininess value="20.000000"/>
        <customValue value="0.000000"/>
        <diffuseColor r="1.000000" g="1.000000" b="1.000000"/>
        <specularColor r="0.500000" g="0.200000" b="0.300000"/>
        <emitColor r="0.000000" g="0.000000" b="0.000000"/>
        <customColor r="0.000000" g="0.000000" b="0.000000"/>
        <vertexShader file="../shaders/standardDSEN.vert"/>
        <fragmentShader file="../shaders/standardDSEN.frag"/>
        <ZVertexShader file="../shaders/Z_standard.vert"/>
        <ZFragmentShader file="../shaders/Z_standard.frag"/>
        <TexturesPass num="4" >
            <texturePass id="0" texture="0" mode="modulate" mapChannel="0" />
            <texturePass id="1" texture="1" mode="modulate" mapChannel="0" />
            <texturePass id="2" texture="2" mode="dot" mapChannel="0" />
            <texturePass id="3" texture="-1" />
        </TexturesPass>
    </Material>
</Materials>

Re: ..shaders documentation..

note that when you modify an asset, like a texture or a mesh file, it automatically refresh it in Maratis editor.

Re: ..shaders documentation..

Hmm, so will there be the ability to edit a .mesh file from the LUA side in  future release where I could adjust the diffuse color of a material from withn the code? I am guessing this could happen with a plugin to the editor I guess? I am really thinking of digging into the C++ side of Maratis, but I just want to see if I can get something done on the LUA side, since that is the side most new users might prefert to use, and then the might go to the C++ side for more control, or to add their own custom features.

Re: ..shaders documentation..

In c++, everything is possible as there is a direct access to the engine,
you can even generate a mesh from code, like this : http://wiki.maratis3d.org/index.php?tit … coded_Cube