initial work to split into dart_filament and flutter_filament
This commit is contained in:
3
materials/Makefile
Normal file
3
materials/Makefile
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:14a484a441dacbc49ce6b8b189a8900a7bb2ab2072731a3a493676aa046b5888
|
||||
size 1009
|
||||
3
materials/gizmo.filamat
Normal file
3
materials/gizmo.filamat
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:f51fc0e67176e28fdf75f351834fa1d36b0993be066d5685eef10aa30ae68b1b
|
||||
size 26876
|
||||
@@ -1,40 +1,3 @@
|
||||
material {
|
||||
name : Gizmo,
|
||||
parameters : [
|
||||
{
|
||||
type : mat4,
|
||||
name : transform,
|
||||
precision : high
|
||||
},
|
||||
{
|
||||
type : float3,
|
||||
name : color,
|
||||
precision : low
|
||||
}
|
||||
],
|
||||
depthWrite : true,
|
||||
depthCulling : false,
|
||||
shadingModel : unlit,
|
||||
variantFilter : [ skinning, shadowReceiver, vsm ],
|
||||
culling: none,
|
||||
instanced: false,
|
||||
vertexDomain: object
|
||||
}
|
||||
|
||||
vertex {
|
||||
void materialVertex(inout MaterialVertexInputs material) {
|
||||
vec4 modelSpace = getPosition();
|
||||
vec4 worldSpace = getWorldFromModelMatrix() * modelSpace;
|
||||
vec4 clipSpace = getClipFromWorldMatrix() * worldSpace;
|
||||
clipSpace.z = 0.99f;
|
||||
material.worldPosition = getWorldFromClipMatrix() * clipSpace;
|
||||
}
|
||||
}
|
||||
|
||||
fragment {
|
||||
void material(inout MaterialInputs material) {
|
||||
prepareMaterial(material);
|
||||
material.baseColor = float4(materialParams.color, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:3158461d081f058dcb9582ce19cc2daedc73abbe758ba5094c94df89028d8c4d
|
||||
size 981
|
||||
|
||||
Binary file not shown.
@@ -1,52 +1,3 @@
|
||||
material {
|
||||
name : Image,
|
||||
parameters : [
|
||||
{
|
||||
type : sampler2d,
|
||||
name : image
|
||||
},
|
||||
{
|
||||
type : mat4,
|
||||
name : transform,
|
||||
precision : high
|
||||
},
|
||||
{
|
||||
type : float4,
|
||||
name : backgroundColor
|
||||
},
|
||||
{
|
||||
type : int,
|
||||
name : showImage
|
||||
}
|
||||
],
|
||||
variables : [
|
||||
imageUV
|
||||
],
|
||||
vertexDomain : device,
|
||||
depthWrite : false,
|
||||
shadingModel : unlit,
|
||||
variantFilter : [ skinning, shadowReceiver, vsm ],
|
||||
culling: none
|
||||
}
|
||||
|
||||
vertex {
|
||||
void materialVertex(inout MaterialVertexInputs material) {
|
||||
material.imageUV.st = getPosition().st * 0.5 + 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
fragment {
|
||||
void material(inout MaterialInputs material) {
|
||||
prepareMaterial(material);
|
||||
highp vec2 uv = (materialParams.transform * vec4(saturate(variable_imageUV.st), 1.0, 1.0)).st;
|
||||
if (materialParams.showImage == 0 || uv.s > 1.0 || uv.s < 0.0 || uv.t < 0.0 || uv.t > 1.0) {
|
||||
material.baseColor = materialParams.backgroundColor;
|
||||
} else {
|
||||
uv.t = 1.0 - uv.t;
|
||||
vec4 color = max(texture(materialParams_image, uv.st), 0.0);
|
||||
color.rgb *= color.a;
|
||||
// Manual, pre-multiplied srcOver with opaque destination optimization
|
||||
material.baseColor.rgb = color.rgb + materialParams.backgroundColor.rgb * (1.0 - color.a);
|
||||
}
|
||||
}
|
||||
}
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:273059c97f96c6848807914d937583864445b51d8e0f1cd98c3e4e0e4bd9f411
|
||||
size 1451
|
||||
|
||||
@@ -1,178 +1,3 @@
|
||||
material {
|
||||
name : unlit_fade,
|
||||
requires : [ uv0, uv1, color ],
|
||||
shadingModel : ${SHADINGMODEL},
|
||||
blending : ${BLENDING},
|
||||
doubleSided : ${DOUBLESIDED},
|
||||
transparency : ${TRANSPARENCY},
|
||||
flipUV : false,
|
||||
specularAmbientOcclusion : simple,
|
||||
specularAntiAliasing : true,
|
||||
clearCoatIorChange : false,
|
||||
reflections : screenspace,
|
||||
parameters : [
|
||||
|
||||
{ type : float3, name : specularFactor },
|
||||
{ type : float, name : glossinessFactor },
|
||||
|
||||
// Base Color
|
||||
{ type : int, name : baseColorIndex },
|
||||
{ type : float4, name : baseColorFactor },
|
||||
{ type : sampler2d, name : baseColorMap },
|
||||
{ type : mat3, name : baseColorUvMatrix, precision: high },
|
||||
|
||||
// Metallic-Roughness Map
|
||||
{ type : int, name : metallicRoughnessIndex },
|
||||
{ type : float, name : metallicFactor },
|
||||
{ type : float, name : roughnessFactor },
|
||||
{ type : sampler2d, name : metallicRoughnessMap },
|
||||
{ type : mat3, name : metallicRoughnessUvMatrix, precision: high },
|
||||
|
||||
// Normal Map
|
||||
{ type : int, name : normalIndex },
|
||||
{ type : float, name : normalScale },
|
||||
{ type : sampler2d, name : normalMap },
|
||||
{ type : mat3, name : normalUvMatrix, precision: high },
|
||||
|
||||
// Ambient Occlusion
|
||||
{ type : int, name : aoIndex },
|
||||
{ type : float, name : aoStrength },
|
||||
{ type : sampler2d, name : occlusionMap },
|
||||
{ type : mat3, name : occlusionUvMatrix, precision: high },
|
||||
|
||||
// Emissive Map
|
||||
{ type : int, name : emissiveIndex },
|
||||
{ type : float3, name : emissiveFactor },
|
||||
{ type : float, name : emissiveStrength },
|
||||
{ type : sampler2d, name : emissiveMap },
|
||||
{ type : mat3, name : emissiveUvMatrix, precision: high },
|
||||
|
||||
// Clear coat
|
||||
{ type : float, name : clearCoatFactor },
|
||||
{ type : float, name : clearCoatRoughnessFactor },
|
||||
{ type : int, name : clearCoatIndex },
|
||||
{ type : sampler2d, name : clearCoatMap },
|
||||
{ type : mat3, name : clearCoatUvMatrix, precision: high },
|
||||
{ type : int, name : clearCoatRoughnessIndex },
|
||||
{ type : sampler2d, name : clearCoatRoughnessMap },
|
||||
{ type : mat3, name : clearCoatRoughnessUvMatrix, precision: high },
|
||||
{ type : int, name : clearCoatNormalIndex },
|
||||
{ type : sampler2d, name : clearCoatNormalMap },
|
||||
{ type : mat3, name : clearCoatNormalUvMatrix, precision: high },
|
||||
{ type : float, name : clearCoatNormalScale },
|
||||
|
||||
// Reflectance
|
||||
{ type : float, name : reflectance }
|
||||
|
||||
${CUSTOM_PARAMS}
|
||||
],
|
||||
}
|
||||
|
||||
vertex {
|
||||
void materialVertex(inout MaterialVertexInputs material) {
|
||||
${CUSTOM_VERTEX}
|
||||
}
|
||||
}
|
||||
|
||||
fragment {
|
||||
void material(inout MaterialInputs material) {
|
||||
highp float2 uvs[2];
|
||||
uvs[0] = getUV0();
|
||||
uvs[1] = getUV1();
|
||||
|
||||
#if !defined(SHADING_MODEL_UNLIT)
|
||||
if (materialParams.normalIndex > -1) {
|
||||
highp float2 uv = uvs[materialParams.normalIndex];
|
||||
uv = (vec3(uv, 1.0) * materialParams.normalUvMatrix).xy;
|
||||
material.normal = texture(materialParams_normalMap, uv).xyz * 2.0 - 1.0;
|
||||
material.normal.xy *= materialParams.normalScale;
|
||||
}
|
||||
#if defined(SHADING_MODEL_LIT)
|
||||
if (materialParams.clearCoatNormalIndex > -1) {
|
||||
highp float2 uv = uvs[materialParams.clearCoatNormalIndex];
|
||||
uv = (vec3(uv, 1.0) * materialParams.clearCoatNormalUvMatrix).xy;
|
||||
material.clearCoatNormal = texture(materialParams_clearCoatNormalMap, uv).xyz * 2.0 - 1.0;
|
||||
material.clearCoatNormal.xy *= materialParams.clearCoatNormalScale;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
prepareMaterial(material);
|
||||
material.baseColor = materialParams.baseColorFactor;
|
||||
|
||||
if (materialParams.baseColorIndex > -1) {
|
||||
highp float2 uv = uvs[materialParams.baseColorIndex];
|
||||
uv = (vec3(uv, 1.0) * materialParams.baseColorUvMatrix).xy;
|
||||
material.baseColor *= texture(materialParams_baseColorMap, uv);
|
||||
}
|
||||
|
||||
#if defined(BLEND_MODE_TRANSPARENT)
|
||||
material.baseColor.rgb *= material.baseColor.a;
|
||||
#endif
|
||||
|
||||
material.baseColor *= getColor();
|
||||
|
||||
#if !defined(SHADING_MODEL_UNLIT)
|
||||
|
||||
#if defined(SHADING_MODEL_LIT)
|
||||
material.roughness = materialParams.roughnessFactor;
|
||||
material.metallic = materialParams.metallicFactor;
|
||||
|
||||
// KHR_materials_clearcoat forbids clear coat from
|
||||
// being applied in the specular/glossiness model
|
||||
material.clearCoat = materialParams.clearCoatFactor;
|
||||
material.clearCoatRoughness = materialParams.clearCoatRoughnessFactor;
|
||||
|
||||
if (materialParams.clearCoatIndex > -1) {
|
||||
highp float2 uv = uvs[materialParams.clearCoatIndex];
|
||||
uv = (vec3(uv, 1.0) * materialParams.clearCoatUvMatrix).xy;
|
||||
material.clearCoat *= texture(materialParams_clearCoatMap, uv).r;
|
||||
}
|
||||
if (materialParams.clearCoatRoughnessIndex > -1) {
|
||||
highp float2 uv = uvs[materialParams.clearCoatRoughnessIndex];
|
||||
uv = (vec3(uv, 1.0) * materialParams.clearCoatRoughnessUvMatrix).xy;
|
||||
material.clearCoatRoughness *= texture(materialParams_clearCoatRoughnessMap, uv).g;
|
||||
}
|
||||
#endif
|
||||
|
||||
material.emissive = vec4(materialParams.emissiveStrength *
|
||||
materialParams.emissiveFactor.rgb, 0.0);
|
||||
|
||||
#if defined(SHADING_MODEL_SPECULAR_GLOSSINESS)
|
||||
material.glossiness = materialParams.glossinessFactor;
|
||||
material.specularColor = materialParams.specularFactor;
|
||||
#else
|
||||
material.reflectance = materialParams.reflectance;
|
||||
#endif
|
||||
|
||||
if (materialParams.metallicRoughnessIndex > -1) {
|
||||
highp float2 uv = uvs[materialParams.metallicRoughnessIndex];
|
||||
uv = (vec3(uv, 1.0) * materialParams.metallicRoughnessUvMatrix).xy;
|
||||
|
||||
#if defined(SHADING_MODEL_SPECULAR_GLOSSINESS)
|
||||
vec4 sg = texture(materialParams_metallicRoughnessMap, uv);
|
||||
material.specularColor *= sg.rgb;
|
||||
material.glossiness *= sg.a;
|
||||
#else
|
||||
vec4 mr = texture(materialParams_metallicRoughnessMap, uv);
|
||||
material.roughness *= mr.g;
|
||||
material.metallic *= mr.b;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (materialParams.aoIndex > -1) {
|
||||
highp float2 uv = uvs[materialParams.aoIndex];
|
||||
uv = (vec3(uv, 1.0) * materialParams.occlusionUvMatrix).xy;
|
||||
float occlusion = texture(materialParams_occlusionMap, uv).r;
|
||||
material.ambientOcclusion = 1.0 + materialParams.aoStrength * (occlusion - 1.0);
|
||||
}
|
||||
if (materialParams.emissiveIndex > -1) {
|
||||
highp float2 uv = uvs[materialParams.emissiveIndex];
|
||||
uv = (vec3(uv, 1.0) * materialParams.emissiveUvMatrix).xy;
|
||||
material.emissive.rgb *= texture(materialParams_emissiveMap, uv).rgb;
|
||||
}
|
||||
#endif
|
||||
|
||||
${CUSTOM_FRAGMENT}
|
||||
}
|
||||
}
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:bca5e20d7fa68fbc2bb7fa3cd65b07e0ac35c8cf961686cfaa267a941ab96d8f
|
||||
size 7393
|
||||
|
||||
@@ -1,178 +1,3 @@
|
||||
material {
|
||||
name : unlit_opaque,
|
||||
requires : [ uv0, uv1, color ],
|
||||
shadingModel : unlit,
|
||||
blending : ${BLENDING},
|
||||
doubleSided : ${DOUBLESIDED},
|
||||
transparency : ${TRANSPARENCY},
|
||||
flipUV : false,
|
||||
specularAmbientOcclusion : simple,
|
||||
specularAntiAliasing : true,
|
||||
clearCoatIorChange : false,
|
||||
reflections : screenspace,
|
||||
parameters : [
|
||||
|
||||
{ type : float3, name : specularFactor },
|
||||
{ type : float, name : glossinessFactor },
|
||||
|
||||
// Base Color
|
||||
{ type : int, name : baseColorIndex },
|
||||
{ type : float4, name : baseColorFactor },
|
||||
{ type : sampler2d, name : baseColorMap },
|
||||
{ type : mat3, name : baseColorUvMatrix, precision: high },
|
||||
|
||||
// Metallic-Roughness Map
|
||||
{ type : int, name : metallicRoughnessIndex },
|
||||
{ type : float, name : metallicFactor },
|
||||
{ type : float, name : roughnessFactor },
|
||||
{ type : sampler2d, name : metallicRoughnessMap },
|
||||
{ type : mat3, name : metallicRoughnessUvMatrix, precision: high },
|
||||
|
||||
// Normal Map
|
||||
{ type : int, name : normalIndex },
|
||||
{ type : float, name : normalScale },
|
||||
{ type : sampler2d, name : normalMap },
|
||||
{ type : mat3, name : normalUvMatrix, precision: high },
|
||||
|
||||
// Ambient Occlusion
|
||||
{ type : int, name : aoIndex },
|
||||
{ type : float, name : aoStrength },
|
||||
{ type : sampler2d, name : occlusionMap },
|
||||
{ type : mat3, name : occlusionUvMatrix, precision: high },
|
||||
|
||||
// Emissive Map
|
||||
{ type : int, name : emissiveIndex },
|
||||
{ type : float3, name : emissiveFactor },
|
||||
{ type : float, name : emissiveStrength },
|
||||
{ type : sampler2d, name : emissiveMap },
|
||||
{ type : mat3, name : emissiveUvMatrix, precision: high },
|
||||
|
||||
// Clear coat
|
||||
{ type : float, name : clearCoatFactor },
|
||||
{ type : float, name : clearCoatRoughnessFactor },
|
||||
{ type : int, name : clearCoatIndex },
|
||||
{ type : sampler2d, name : clearCoatMap },
|
||||
{ type : mat3, name : clearCoatUvMatrix, precision: high },
|
||||
{ type : int, name : clearCoatRoughnessIndex },
|
||||
{ type : sampler2d, name : clearCoatRoughnessMap },
|
||||
{ type : mat3, name : clearCoatRoughnessUvMatrix, precision: high },
|
||||
{ type : int, name : clearCoatNormalIndex },
|
||||
{ type : sampler2d, name : clearCoatNormalMap },
|
||||
{ type : mat3, name : clearCoatNormalUvMatrix, precision: high },
|
||||
{ type : float, name : clearCoatNormalScale },
|
||||
|
||||
// Reflectance
|
||||
{ type : float, name : reflectance }
|
||||
|
||||
${CUSTOM_PARAMS}
|
||||
],
|
||||
}
|
||||
|
||||
vertex {
|
||||
void materialVertex(inout MaterialVertexInputs material) {
|
||||
${CUSTOM_VERTEX}
|
||||
}
|
||||
}
|
||||
|
||||
fragment {
|
||||
void material(inout MaterialInputs material) {
|
||||
highp float2 uvs[2];
|
||||
uvs[0] = getUV0();
|
||||
uvs[1] = getUV1();
|
||||
|
||||
#if !defined(SHADING_MODEL_UNLIT)
|
||||
if (materialParams.normalIndex > -1) {
|
||||
highp float2 uv = uvs[materialParams.normalIndex];
|
||||
uv = (vec3(uv, 1.0) * materialParams.normalUvMatrix).xy;
|
||||
material.normal = texture(materialParams_normalMap, uv).xyz * 2.0 - 1.0;
|
||||
material.normal.xy *= materialParams.normalScale;
|
||||
}
|
||||
#if defined(SHADING_MODEL_LIT)
|
||||
if (materialParams.clearCoatNormalIndex > -1) {
|
||||
highp float2 uv = uvs[materialParams.clearCoatNormalIndex];
|
||||
uv = (vec3(uv, 1.0) * materialParams.clearCoatNormalUvMatrix).xy;
|
||||
material.clearCoatNormal = texture(materialParams_clearCoatNormalMap, uv).xyz * 2.0 - 1.0;
|
||||
material.clearCoatNormal.xy *= materialParams.clearCoatNormalScale;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
prepareMaterial(material);
|
||||
material.baseColor = materialParams.baseColorFactor;
|
||||
|
||||
if (materialParams.baseColorIndex > -1) {
|
||||
highp float2 uv = uvs[materialParams.baseColorIndex];
|
||||
uv = (vec3(uv, 1.0) * materialParams.baseColorUvMatrix).xy;
|
||||
material.baseColor *= texture(materialParams_baseColorMap, uv);
|
||||
}
|
||||
|
||||
#if defined(BLEND_MODE_TRANSPARENT)
|
||||
material.baseColor.rgb *= material.baseColor.a;
|
||||
#endif
|
||||
|
||||
material.baseColor *= getColor();
|
||||
|
||||
#if !defined(SHADING_MODEL_UNLIT)
|
||||
|
||||
#if defined(SHADING_MODEL_LIT)
|
||||
material.roughness = materialParams.roughnessFactor;
|
||||
material.metallic = materialParams.metallicFactor;
|
||||
|
||||
// KHR_materials_clearcoat forbids clear coat from
|
||||
// being applied in the specular/glossiness model
|
||||
material.clearCoat = materialParams.clearCoatFactor;
|
||||
material.clearCoatRoughness = materialParams.clearCoatRoughnessFactor;
|
||||
|
||||
if (materialParams.clearCoatIndex > -1) {
|
||||
highp float2 uv = uvs[materialParams.clearCoatIndex];
|
||||
uv = (vec3(uv, 1.0) * materialParams.clearCoatUvMatrix).xy;
|
||||
material.clearCoat *= texture(materialParams_clearCoatMap, uv).r;
|
||||
}
|
||||
if (materialParams.clearCoatRoughnessIndex > -1) {
|
||||
highp float2 uv = uvs[materialParams.clearCoatRoughnessIndex];
|
||||
uv = (vec3(uv, 1.0) * materialParams.clearCoatRoughnessUvMatrix).xy;
|
||||
material.clearCoatRoughness *= texture(materialParams_clearCoatRoughnessMap, uv).g;
|
||||
}
|
||||
#endif
|
||||
|
||||
material.emissive = vec4(materialParams.emissiveStrength *
|
||||
materialParams.emissiveFactor.rgb, 0.0);
|
||||
|
||||
#if defined(SHADING_MODEL_SPECULAR_GLOSSINESS)
|
||||
material.glossiness = materialParams.glossinessFactor;
|
||||
material.specularColor = materialParams.specularFactor;
|
||||
#else
|
||||
material.reflectance = materialParams.reflectance;
|
||||
#endif
|
||||
|
||||
if (materialParams.metallicRoughnessIndex > -1) {
|
||||
highp float2 uv = uvs[materialParams.metallicRoughnessIndex];
|
||||
uv = (vec3(uv, 1.0) * materialParams.metallicRoughnessUvMatrix).xy;
|
||||
|
||||
#if defined(SHADING_MODEL_SPECULAR_GLOSSINESS)
|
||||
vec4 sg = texture(materialParams_metallicRoughnessMap, uv);
|
||||
material.specularColor *= sg.rgb;
|
||||
material.glossiness *= sg.a;
|
||||
#else
|
||||
vec4 mr = texture(materialParams_metallicRoughnessMap, uv);
|
||||
material.roughness *= mr.g;
|
||||
material.metallic *= mr.b;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (materialParams.aoIndex > -1) {
|
||||
highp float2 uv = uvs[materialParams.aoIndex];
|
||||
uv = (vec3(uv, 1.0) * materialParams.occlusionUvMatrix).xy;
|
||||
float occlusion = texture(materialParams_occlusionMap, uv).r;
|
||||
material.ambientOcclusion = 1.0 + materialParams.aoStrength * (occlusion - 1.0);
|
||||
}
|
||||
if (materialParams.emissiveIndex > -1) {
|
||||
highp float2 uv = uvs[materialParams.emissiveIndex];
|
||||
uv = (vec3(uv, 1.0) * materialParams.emissiveUvMatrix).xy;
|
||||
material.emissive.rgb *= texture(materialParams_emissiveMap, uv).rgb;
|
||||
}
|
||||
#endif
|
||||
|
||||
${CUSTOM_FRAGMENT}
|
||||
}
|
||||
}
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:4abb9e737d20956cced366af6a54dd31ab17cc8d0d1773f02c57a5712760fe10
|
||||
size 7385
|
||||
|
||||
Reference in New Issue
Block a user