Custom MatDef parameters are not shown

Hi! I just copied Lighting MatDef to my custom MatDef and parameters are not shown.





Uploaded with ImageShack.us

Hmmmm… strange, any error messages? (warning sign in the bottom right) Also, update again, the layout in your screen is from the version before :D.

The same thing happens after update. There is no any log.

The ony one thing I noticed is that MatDef does not want to be saved. I should close MatDef to save it…





Have a try by yourself. Just create a new MatDef and copy Lighting MatDef code.



I mean:



MaterialDef Phong Lighting {



MaterialParameters {



// Compute vertex lighting in the shader

// For better performance

Boolean VertexLighting



// Use more efficent algorithms to improve performance

Boolean LowQuality



// Improve quality at the cost of performance

Boolean HighQuality



// Output alpha from the diffuse map

Boolean UseAlpha



// Apha threshold for fragment discarding

Float AlphaDiscardThreshold



// Normal map is in BC5/ATI2n/LATC/3Dc compression format

Boolean LATC



// Use the provided ambient, diffuse, and specular colors

Boolean UseMaterialColors



// Activate shading along the tangent, instead of the normal

// Requires tangent data to be available on the model.

Boolean VTangent



// Use minnaert diffuse instead of lambert

Boolean Minnaert



// Use ward specular instead of phong

Boolean WardIso



// Use vertex color as an additional diffuse color.

Boolean UseVertexColor



// Ambient color

Color Ambient



// Diffuse color

Color Diffuse : Color



// Specular color

Color Specular



// Specular power/shininess

Float Shininess



// Diffuse map

Texture2D DiffuseMap



// Normal map

Texture2D NormalMap



// Specular/gloss map

Texture2D SpecularMap



// Parallax/height map

Texture2D ParallaxMap



// Texture that specifies alpha values

Texture2D AlphaMap



// Color ramp, will map diffuse and specular values through it.

Texture2D ColorRamp



// Texture of the glowing parts of the material

Texture2D GlowMap



// The glow color of the object

Color GlowColor

}



Technique {



LightMode MultiPass



VertexShader GLSL100: Common/MatDefs/Light/Lighting.vert

FragmentShader GLSL100: Common/MatDefs/Light/Lighting.frag



WorldParameters {

WorldViewProjectionMatrix

NormalMatrix

WorldViewMatrix

ViewMatrix

}



Defines {

LATC : LATC

VERTEX_COLOR : UseVertexColor

VERTEX_LIGHTING : VertexLighting

ATTENUATION : Attenuation

MATERIAL_COLORS : UseMaterialColors

V_TANGENT : VTangent

MINNAERT : Minnaert

WARDISO : WardIso

LOW_QUALITY : LowQuality

HQ_ATTENUATION : HighQuality



DIFFUSEMAP : DiffuseMap

NORMALMAP : NormalMap

SPECULARMAP : SpecularMap

PARALLAXMAP : ParallaxMap

ALPHAMAP : AlphaMap

COLORRAMP : ColorRamp

}

}



Technique PreShadow {



VertexShader GLSL100 : Common/MatDefs/Shadow/PreShadow.vert

FragmentShader GLSL100 : Common/MatDefs/Shadow/PreShadow.frag



WorldParameters {

WorldViewProjectionMatrix

WorldViewMatrix

}



Defines {

DIFFUSEMAP_ALPHA : DiffuseMap

}



RenderState {

FaceCull Off

DepthTest On

DepthWrite On

PolyOffset 5 0

ColorWrite Off

}



}



Technique PreNormalPass {



VertexShader GLSL100 : Common/MatDefs/SSAO/normal.vert

FragmentShader GLSL100 : Common/MatDefs/SSAO/normal.frag



WorldParameters {

WorldViewProjectionMatrix

WorldViewMatrix

NormalMatrix

}



Defines {

DIFFUSEMAP_ALPHA : DiffuseMap

}



RenderState {



}



}



Technique GBuf {



VertexShader GLSL100: Common/MatDefs/Light/GBuf.vert

FragmentShader GLSL100: Common/MatDefs/Light/GBuf.frag



WorldParameters {

WorldViewProjectionMatrix

NormalMatrix

WorldViewMatrix

WorldMatrix

}



Defines {

VERTEX_COLOR : UseVertexColor

MATERIAL_COLORS : UseMaterialColors

V_TANGENT : VTangent

MINNAERT : Minnaert

WARDISO : WardIso



DIFFUSEMAP : DiffuseMap

NORMALMAP : NormalMap

SPECULARMAP : SpecularMap

PARALLAXMAP : ParallaxMap

}

}



Technique FixedFunc {

LightMode FixedPipeline

}



Technique Glow {



VertexShader GLSL100: Common/MatDefs/Misc/SimpleTextured.vert

FragmentShader GLSL100: Common/MatDefs/Light/Glow.frag



WorldParameters {

WorldViewProjectionMatrix

}



Defines {

HAS_GLOWMAP : GlowMap

HAS_GLOWCOLOR : GlowColor

}

}



}

And this matdef worked before?

Oh… I erased current JMP and downloaded alpha3 without updates. The matdef does not work too. I tested 3 different my shaders and the same problem happens.



It means that we cannot use custom matdefs in your cool material editor. Nehon, save us!!! Is it possible to fix? I mean, will it be possible to use custom matdefs in the material editor?

It should be possible already, the file gets looked for and parsed, thats why it shows up in the menu. I guess the parsing fails somehow. Can you try modifying the j3md so that the parameters section is at the beginning without any comments?

Ok, lets make an experiment. I modified ColoredTextured shader and put all files to MatDefs folder. Shader works when i write parameters into source. But visually parameters are not seen. For instance, i changed color to blue:



[java]Material My Material : MatDefs/Custom.j3md {

MaterialParameters {

m_Color : 0.2 1.0 1.0 1.0

}

}

[/java]



preview material shows a blue sphere…



http://files.mail.ru/93X7RV - zipped shader, matdef and material. MatDefs.zip

Ok, I will check that when I am home.

Btw, m_ prefix will not work anyway. But the proper parameter widgets and names should appear.

ohhh… that MatDef (http://files.mail.ru/93X7RV) does not work with the new material editor. I’m confused.

Just another test with copy of Lighting…



I found such a log:

Failed to load resource: Materials/newMaterial.j3m

Error occured while loading resource Materials/newMaterial.j3m using J3MLoader

Probably when you were editing the j3m file by hand, its saved with each character you enter and tried to load, so you get an error when you have only half a comment or something

Ok, was a stupid mistake, I was searching inside the project folder and not the assets folder, since I was using our normal j3md files the parser would find the originals instead and I didnt notice that because it doesnt reflect in the selection menu. Its all fixed now, saving of matdef files is also fixed.

Thanks for the constructive input!

Cheers,

Normen

No no no… there are no any comments at all in vert, frag, j3m and j3md files. J3m is by default when you create a material. And shader works when I set parameters by hand:



[java] Spatial char_boy = assetManager.loadModel ("Models/jmonkey_test_model/jmonkey_test_model_01.mesh.j3o");





Material mat = new Material(assetManager, "MatDefs/ColoredTextured/ColoredTextured.j3md");

mat.setColor("m_Color", new ColorRGBA(0.5f, 0.5f, 0.3f, 1.0f));

mat.setTexture("m_ColorMap", assetManager.loadTexture("Models/jmonkey_test_model/ao.png"));



char_boy.setMaterial(mat);



rootNode.attachChild(char_boy);[/java]



Did you try to make your own custom shader?

Oh, you were faster than me. :slight_smile:



THANK YOU FOR SUCH A COOL EDITOR!!!

You’re welcome, this is iteration two, according to common coding lore its the third iteration of every software thats really good, I feel that here too :wink: Want to add creating of j3m files from materials saved in e.g. models and live editing and updating of materials in scenes in the next “material editor improvement session”… Work, work ^^