void GetMaterials(out float smoothness,out float metalness,out float f0,out float metalData,
    inout float emissive,out float ao,out vec3 normalMap,
vec2 newCoord,vec2 dcdx,vec2 dcdy){
    vec4 specularMap=texture2DGradARB(specular,newCoord,dcdx,dcdy);
    
    #if MATERIAL_FORMAT==0
    smoothness=specularMap.r;
    
    f0=specularMap.g;
    metalness=f0>=.9?1.:0.;
    metalData=f0;
    
    emissive=mix(specularMap.a<1.?specularMap.a:0.,1.,emissive);
    ao=texture2DGradARB(normals,newCoord,dcdx,dcdy).z;
    
    normalMap=vec3(texture2DGradARB(normals,newCoord,dcdx,dcdy).xy,0.)*2.-1.;
    float normalCheck=normalMap.x+normalMap.y;
    if(normalCheck>-1.999){
        if(length(normalMap.xy)>1.)normalMap.xy=normalize(normalMap.xy);
        normalMap.z=sqrt(1.-dot(normalMap.xy,normalMap.xy));
        normalMap=normalize(clamp(normalMap,vec3(-1.),vec3(1.)));
    }else{
        normalMap=vec3(0.,0.,1.);
        ao=1.;
    }
    #endif
    
    #if MATERIAL_FORMAT==1
    smoothness=specularMap.r;
    
    metalness=specularMap.g;
    if(metalness>.5)smoothness=1.;
    f0=.78*metalness+.02;
    metalData=metalness;
    
    emissive=mix(specularMap.b,1.,emissive);
    ao=1.;
    
    normalMap=texture2DGradARB(normals,newCoord,dcdx,dcdy).xyz*2.-1.;
    float normalCheck=normalMap.x+normalMap.y;
    if(normalCheck<-1.999)normalMap=vec3(0.,0.,1.);
    #endif
}