// add enum defines
#define texture_coordinate_uvw 0
#define texture_coordinate_world 1
#define texture_coordinate_object 2
#define scatter_reflect 0
#define scatter_transmit 1
#define scatter_reflect_transmit 2
#define QT3DS_ENABLE_UV0 1
#define QT3DS_ENABLE_WORLD_POSITION 1
#define QT3DS_ENABLE_TEXTAN 1
#define QT3DS_ENABLE_BINORMAL 1
#include "vertexFragmentBase.glsllib"
// set shader output
out vec4 fragColor;
// add structure defines
struct texture_coordinate_info
{
vec3 position;
vec3 tangent_u;
vec3 tangent_v;
};
struct layer_result
{
vec4 base;
vec4 layer;
mat3 tanFrame;
};
// temporary declarations
vec4 tmpShadowTerm;
layer_result layers[1];
#include "SSAOCustomMaterial.glsllib"
#include "sampleLight.glsllib"
#include "sampleProbe.glsllib"
#include "sampleArea.glsllib"
#include "cube.glsllib"
#include "random255.glsllib"
#include "perlinNoise.glsllib"
#include "perlinNoiseBumpTexture.glsllib"
#include "transformCoordinate.glsllib"
#include "rotationTranslationScale.glsllib"
#include "coordinateSource.glsllib"
#include "square.glsllib"
#include "calculateRoughness.glsllib"
#include "evalBakedShadowMap.glsllib"
#include "evalEnvironmentMap.glsllib"
#include "luminance.glsllib"
#include "microfacetBSDF.glsllib"
#include "physGlossyBSDF.glsllib"
#include "simpleGlossyBSDF.glsllib"
#include "diffuseReflectionBSDF.glsllib"
#include "fresnelLayer.glsllib"
bool evalTwoSided()
{
return( false );
}
vec3 computeFrontMaterialEmissive()
{
return( vec3( 0, 0, 0 ) );
}
void computeFrontLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir, in vec3 lightDiffuse, in vec3 lightSpecular, in float materialIOR, float aoFactor )
{
#if QT3DS_ENABLE_CG_LIGHTING
layers[0].base += tmpShadowTerm * diffuseReflectionBSDF( normal, lightDir, viewDir, lightDiffuse, 0.000000 );
layers[0].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect );
#endif
}
void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular )
{
#if QT3DS_ENABLE_CG_LIGHTING
layers[0].base += tmpShadowTerm * lightDiffuse * sampleAreaDiffuse( layers[0].tanFrame, varWorldPos, lightIdx );
layers[0].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[0].tanFrame, varWorldPos, lightIdx, viewDir, roughness, roughness );
#endif
}
void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFactor )
{
#if !QT3DS_ENABLE_LIGHT_PROBE
layers[0].base += tmpShadowTerm * diffuseReflectionBSDFEnvironment( normal, 0.000000 ) * aoFactor;
layers[0].layer += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, roughness, roughness, scatter_reflect );
#else
layers[0].base += tmpShadowTerm * sampleDiffuse( layers[0].tanFrame ) * aoFactor;
layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness );
#endif
}
vec3 computeBackMaterialEmissive()
{
return( vec3(0, 0, 0) );
}
void computeBackLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir, in vec3 lightDiffuse, in vec3 lightSpecular, in float materialIOR, float aoFactor )
{
#if QT3DS_ENABLE_CG_LIGHTING
layers[0].base += vec4( 0.0, 0.0, 0.0, 1.0 );
layers[0].layer += vec4( 0.0, 0.0, 0.0, 1.0 );
#endif
}
void computeBackAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular )
{
#if QT3DS_ENABLE_CG_LIGHTING
layers[0].base += vec4( 0.0, 0.0, 0.0, 1.0 );
layers[0].layer += vec4( 0.0, 0.0, 0.0, 1.0 );
#endif
}
void computeBackLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFactor )
{
#if !QT3DS_ENABLE_LIGHT_PROBE
layers[0].base += vec4( 0.0, 0.0, 0.0, 1.0 );
layers[0].layer += vec4( 0.0, 0.0, 0.0, 1.0 );
#else
layers[0].base += vec4( 0.0, 0.0, 0.0, 1.0 );
layers[0].layer += vec4( 0.0, 0.0, 0.0, 1.0 );
#endif
}
float computeIOR()
{
return( false ? 1.0 : luminance( vec3( 1, 1, 1 ) ) );
}
float evalCutout()
{
return( 1.000000 );
}
vec3 computeNormal()
{
return( perlinNoiseBumpTexture( transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), vec3( ( texture_scaling*10.000000 ) ) ), coordinateSource(texture_coordinate_object, 0 ) ), bump_factor, 1.000000, false, false, 0.000000, 6, true, vec3( 0.000000, 0.000000, 0.000000 ), 0.070000, 0.300000, 1.000000, normal ) );
}
void computeTemporaries()
{
tmpShadowTerm = evalBakedShadowMap( texCoord0 );
}
vec4 computeLayerWeights( in float alpha )
{
vec4 color;
color = fresnelLayer( normal, vec3( material_ior ), 0.350000, vec4( vec3( 1, 1, 1 ), 1.0).rgb, layers[0].layer, layers[0].base * vec4( diffuse_color, 1.0), alpha );
return color;
}
void initializeLayerVariables(void)
{
// clear layers
layers[0].base = vec4(0.0, 0.0, 0.0, 1.0);
layers[0].layer = vec4(0.0, 0.0, 0.0, 1.0);
layers[0].tanFrame = orthoNormalize( mat3( tangent, cross(normal, tangent), normal ) );
}