Hi everyone,
I’m exploring a potential improvement for material editing.
While developing my material editor, I had to extract types and variable names from the .j3md file by reading the lines one by one and parsing spaces, colons, brackets (the SDK does the same thing). This approach is not very robust and feels limited.
Could a JSON format for j3md/j3m files offer a simpler and more robust approach? This wouldn’t be a core engine change but could be an external project.
Storing FloatArray
and TextureArray
data in the Material.json file would provide the flexibility to configure these elements directly in the JSON format. This functionality is not currently available in the .j3m format (see AdvancedPBRTerrain.j3md).
This approach could streamline material editing and potentially benefit future development.
What are your thoughts? Does anyone want to take up the challenge?
*** Edit:
For example, here is the PBRLighting.j3md file converted to .json format:
{
"MaterialDef": {
"name": "PBR Lighting", // Assuming this is the material name
"MaterialParameters": [
{
"type": "Int",
"name": "BoundDrawBuffer",
"value": null // Assuming no default value provided in the original definition
},
{
"type": "Float",
"name": "AlphaDiscardThreshold",
"value": 0.0 // Assuming a default value
},
{
"type": "Float",
"name": "Metallic",
"value": 1.0
},
{
"type": "Color",
"name": "Specular",
"value": [1.0, 1.0, 1.0, 1.0]
},
{
"type": "Float",
"name": "Glossiness",
"value": 1.0
},
{
"type": "Texture2D",
"name": "ParallaxMap",
"colorSpace": "Linear"
}
// ... and so on ...
],
"Techniques": [
{
"name": "Default", // Assuming technique name can be extracted
"LightMode": "SinglePassAndImageBased",
"VertexShader": "Common/MatDefs/Light/PBRLighting.vert",
"FragmentShader": "Common/MatDefs/Light/PBRLighting.frag",
"ShaderLanguages": ["GLSL300", "GLSL150", "GLSL110"],
"WorldParameters": [
"WorldViewProjectionMatrix",
"CameraPosition",
"WorldMatrix",
"WorldNormalMatrix",
"ViewProjectionMatrix",
"ViewMatrix"
],
"Defines": [
{
"name": "BOUND_DRAW_BUFFER",
"param": "BoundDrawBuffer"
},
{
"name": "BASECOLORMAP",
"param": "BaseColorMap"
},
{
"name": "VERTEX_COLOR",
"param": "UseVertexColor"
}
// ... other defines mapping parameters to names ...
]
},
{
"name": "PreShadow", // Assuming technique name can be extracted
"VertexShader": "Common/MatDefs/Shadow/PreShadow.vert",
"FragmentShader": "Common/MatDefs/Shadow/PreShadowPBR.frag",
"ShaderLanguages": ["GLSL300", "GLSL150", "GLSL110" ],
"WorldParameters": [
"WorldViewProjectionMatrix",
"WorldViewMatrix",
"ViewProjectionMatrix",
"ViewMatrix"
],
"Defines": [
{
"name": "BOUND_DRAW_BUFFER",
"param": "AlphaDiscardThreshold"
},
{
"name": "DISCARD_ALPHA",
"param": "AlphaDiscardThreshold"
}
// ... other defines mapping parameters to names ...
],
"ForcedRenderState": {
"FaceCull": "Off",
"DepthTest": true,
"DepthWrite": true,
"PolyOffset": [5, 3],
"ColorWrite": false
}
}
// ... other techniques following the same structure ...
]
}
}