diff options
Diffstat (limited to 'Studio/Content/Material Library')
100 files changed, 8352 insertions, 0 deletions
diff --git a/Studio/Content/Material Library/aluminium_anodized.shader b/Studio/Content/Material Library/aluminium_anodized.shader new file mode 100644 index 0000000..17da9fb --- /dev/null +++ b/Studio/Content/Material Library/aluminium_anodized.shader @@ -0,0 +1,178 @@ +<Material name="aluminium_anodized" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Roughness" name="roughness" type="Float" min="0.000000" max="1.000000" default="0.300000" description="Roughness of the material.\n0 = fully specular\n1 = fully diffuse" category="Material"/> + <Property formalName="Base color" name="base_color" type="Color" default="0.7 0.7 0.7" description="Color of the material" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#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 0 + +#include "vertexFragmentBase.glsllib" + +// set shader output +out vec4 fragColor; + +// add structure defines +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 "square.glsllib" +#include "calculateRoughness.glsllib" +#include "evalBakedShadowMap.glsllib" +#include "evalEnvironmentMap.glsllib" +#include "luminance.glsllib" +#include "microfacetBSDF.glsllib" +#include "physGlossyBSDF.glsllib" +#include "simpleGlossyBSDF.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 * vec4( 0.0, 0.0, 0.0, 1.0 ); + 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 * vec4( 0.0, 0.0, 0.0, 1.0 ); + 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 * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[0].layer += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, roughness, roughness, scatter_reflect ); + +#else + layers[0].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + 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( normal ); +} + +void computeTemporaries() +{ + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = fresnelLayer( normal, vec3( 22, 22, 22 ), 1.000000, base_color.rgb, layers[0].layer, layers[0].base, 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 ) ); +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="4"/> + <LayerKey count="1"/> + <Pass > + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/aluminium_anodized_emissive.shader b/Studio/Content/Material Library/aluminium_anodized_emissive.shader new file mode 100644 index 0000000..1c3233f --- /dev/null +++ b/Studio/Content/Material Library/aluminium_anodized_emissive.shader @@ -0,0 +1,214 @@ +<Material name="aluminium_anodized_emissive" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Roughness" name="roughness" type="Float" min="0.000000" max="1.000000" default="0.300000" description="Roughness of the material.\n0 = fully specular\n1 = fully diffuse" category="Material"/> + <Property formalName="Base color" name="base_color" type="Color" default="0.7 0.7 0.7" description="Color of the material" category="Material"/> + <Property formalName="Intensity" name="intensity" description="Emission intensity" type="Float" default="1.000000" category="Material"/> + <Property formalName="Emission Color" name="emission_color" description="Color of the emission" type="Color" default="0 0 0" category="Material"/> + <Property formalName="Emissive Map" name="emissive_texture" description="Emissive texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="emissive" default="./maps/materials/emissive.png" category="Material"/> + <Property formalName="Emissive Map Mask" name="emissive_mask_texture" description="Emissive mask texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="emissive_mask" default="./maps/materials/emissive_mask.png" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#define scatter_reflect 0 +#define scatter_transmit 1 +#define scatter_reflect_transmit 2 +#define mono_alpha 0 +#define mono_average 1 +#define mono_luminance 2 +#define mono_maximum 3 +#define wrap_clamp 0 +#define wrap_repeat 1 +#define wrap_mirrored_repeat 2 +#define gamma_default 0 +#define gamma_linear 1 +#define gamma_srgb 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 layer_result +{ + vec4 base; + vec4 layer; + mat3 tanFrame; +}; + + +struct texture_coordinate_info +{ + vec3 position; + vec3 tangent_u; + vec3 tangent_v; +}; + + +struct texture_return +{ + vec3 tint; + float mono; +}; + + +// temporary declarations +texture_coordinate_info tmp3; + vec4 tmpShadowTerm; + +layer_result layers[1]; + +#include "SSAOCustomMaterial.glsllib" +#include "sampleLight.glsllib" +#include "sampleProbe.glsllib" +#include "sampleArea.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 "fresnelLayer.glsllib" +#include "monoChannel.glsllib" +#include "fileTexture.glsllib" +#include "transformCoordinate.glsllib" +#include "rotationTranslationScale.glsllib" +#include "textureCoordinateInfo.glsllib" + +bool evalTwoSided() +{ + return( false ); +} + +vec3 computeFrontMaterialEmissive() +{ + return( vec3(1.0) * vec3( vec3( ( intensity *( emission_color.rgb * ( fileTexture(emissive_texture, vec3(0.0), vec3(1.0), mono_alpha, tmp3, vec2(0.0, 1.0), vec2(0.0, 1.0), wrap_repeat, wrap_repeat, gamma_default ).tint * fileTexture(emissive_mask_texture, vec3(0.0), vec3(1.0), mono_alpha, tmp3, vec2(0.0, 1.0), vec2(0.0, 1.0), wrap_repeat, wrap_repeat, gamma_default ).tint ) ) ) ) ) ); +} + +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 * vec4(0.0, 0.0, 0.0, 1.0); + 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 * vec4( 0.0, 0.0, 0.0, 1.0 ); + 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 * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[0].layer += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, roughness, roughness, scatter_reflect ); + +#else + layers[0].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + 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( normal ); +} + +void computeTemporaries() +{ + tmp3 = transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), vec3( 1.000000, 1.000000, 1.000000 ) ), textureCoordinateInfo( texCoord0, tangent, binormal ) ); + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = fresnelLayer( normal, vec3( 22, 22, 22 ), 1.000000, base_color.rgb, layers[0].layer, layers[0].base, 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 ) ); +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="4"/> + <LayerKey count="1"/> + <Pass > + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/aluminum.shader b/Studio/Content/Material Library/aluminum.shader new file mode 100644 index 0000000..e2a5bea --- /dev/null +++ b/Studio/Content/Material Library/aluminum.shader @@ -0,0 +1,223 @@ +<Material name="aluminum" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Reflectivity Map" name="reflection_texture" description="Reflection texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="specular" default="./maps/materials/grunge_b.png" category="Material"/> + <Property formalName="Reflection Map Offset" name="reflection_map_offset" hidden="True" type="Float" default="0.500000" description="Reflection texture value offset" category="Material"/> + <Property formalName="Reflection Map Scale" name="reflection_map_scale" hidden="True" type="Float" default="0.300000" description="Reflection texture value scale" category="Material"/> + <Property formalName="Tiling" name="tiling" type="Vector" default="1 1 1" description="Texture Tiling size" category="Material"/> + <Property formalName="Roughness Map" name="roughness_texture" description="Roughness texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="roughness" default="./maps/materials/grunge_d.png" category="Material"/> + <Property formalName="Roughness Map Offset" name="roughness_map_offset" hidden="True" type="Float" default="0.160000" description="Roughness texture value offset" category="Material"/> + <Property formalName="Roughness Map Scale" name="roughness_map_scale" hidden="True" type="Float" default="0.400000" description="Roughness texture value scale" category="Material"/> + <Property formalName="Metal Color" name="metal_color" type="Color" default="0.95 0.95 0.95" description="Base color of the material" category="Material"/> + <Property formalName="Bump Map" name="bump_texture" description="Bump texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="bump" default="./maps/materials/grunge_d.png" category="Material"/> + <Property formalName="Bump Amount" name="bump_amount" type="Float" min="0" max="2" default="0.500000" description="Scale value for bump amount" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#define mono_alpha 0 +#define mono_average 1 +#define mono_luminance 2 +#define mono_maximum 3 +#define wrap_clamp 0 +#define wrap_repeat 1 +#define wrap_mirrored_repeat 2 +#define gamma_default 0 +#define gamma_linear 1 +#define gamma_srgb 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; +}; + + +struct texture_return +{ + vec3 tint; + float mono; +}; + + +// temporary declarations +texture_coordinate_info tmp1; +float tmp2; +float ftmp0; + vec4 tmpShadowTerm; + +layer_result layers[1]; + +#include "SSAOCustomMaterial.glsllib" +#include "sampleLight.glsllib" +#include "sampleProbe.glsllib" +#include "sampleArea.glsllib" +#include "luminance.glsllib" +#include "monoChannel.glsllib" +#include "fileBumpTexture.glsllib" +#include "transformCoordinate.glsllib" +#include "rotationTranslationScale.glsllib" +#include "textureCoordinateInfo.glsllib" +#include "weightedLayer.glsllib" +#include "fileTexture.glsllib" +#include "square.glsllib" +#include "calculateRoughness.glsllib" +#include "evalBakedShadowMap.glsllib" +#include "evalEnvironmentMap.glsllib" +#include "microfacetBSDF.glsllib" +#include "physGlossyBSDF.glsllib" +#include "simpleGlossyBSDF.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 * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[0].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, tmp2, tmp2, scatter_reflect ); + +#endif +} + +void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[0].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[0].tanFrame, varWorldPos, lightIdx, viewDir, tmp2, tmp2 ); + +#endif +} + +void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFactor ) +{ +#if !QT3DS_ENABLE_LIGHT_PROBE + layers[0].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[0].layer += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, tmp2, tmp2, scatter_reflect ); + +#else + layers[0].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, tmp2, tmp2 ); + +#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( fileBumpTexture(bump_texture, bump_amount, mono_average, tmp1, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, normal ) ); +} + +void computeTemporaries() +{ + tmp1 = transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), tiling ), textureCoordinateInfo( texCoord0, tangent, binormal ) ); + tmp2 = fileTexture(roughness_texture, vec3( roughness_map_offset ), vec3( roughness_map_scale ), mono_luminance, tmp1, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_default ).mono; + ftmp0 = fileTexture(reflection_texture, vec3( reflection_map_offset ), vec3( reflection_map_scale ), mono_luminance, tmp1, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_default ).mono; + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = weightedLayer( ftmp0, metal_color.rgb, layers[0].layer, layers[0].base, 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 ) ); +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="4"/> + <LayerKey count="1"/> + <Pass > + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/aluminum_anisotropic.shader b/Studio/Content/Material Library/aluminum_anisotropic.shader new file mode 100644 index 0000000..b5fed9f --- /dev/null +++ b/Studio/Content/Material Library/aluminum_anisotropic.shader @@ -0,0 +1,260 @@ +<Material name="aluminum_anisotropic" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Index of Refraction" name="material_ior" description="Refractive index of the material" type="Float" default="8.000000" category="Material"/> + <Property formalName="Diffuse Map" name="reflection_texture" description="Reflection texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="specular" default="./maps/materials/concentric_milled_steel.png" category="Material"/> + <Property formalName="Reflection Map Offset" name="reflection_map_offset" hidden="True" type="Float" default="1.000000" description="Reflection texture value offset" category="Material"/> + <Property formalName="Reflection Map Scale" name="reflection_map_scale" hidden="True" type="Float" default="1.000000" description="Reflection texture value scale" category="Material"/> + <Property formalName="Tiling" name="tiling" type="Float2" default="8 5" description="Texture Tiling size" category="Material"/> + <Property formalName="Roughness Map Offset" name="roughness_map_offset" hidden="True" type="Float" default="0.000000" description="Roughness texture value offset" category="Material"/> + <Property formalName="Roughness Map Scale" name="roughness_map_scale" hidden="True" type="Float" default="1.000000" description="Roughness texture value scale" category="Material"/> + <Property formalName="Anisotropy" name="anisotropy" type="Float" default="0.800000" description="Anisotropy" category="Material"/> + <Property formalName="Anisotropy Map" name="aniso_rot_texture" description="Anisotropy rot texture of the material" type="Texture" filter="linear" minfilter="linear" clamp="repeat" usage="anisotropy" default="./maps/materials/concentric_milled_steel_aniso.png" category="Material"/> + <Property formalName="Roughness Map Offset" name="aniso_tex_color_offset" hidden="True" type="Float" default="0.000000" description="Roughness texture value offset" category="Material"/> + <Property formalName="Roughness Map Scale" name="aniso_tex_color_scale" hidden="True" type="Float" default="1.000000" description="Roughness texture value scale" category="Material"/> + <Property formalName="Base Weight" name="base_weight" description="Base weight" hidden="True" type="Float" default="1.000000" category="Material"/> + <Property formalName="Bump Map" name="bump_texture" description="Bump texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="bump" default="./maps/materials/concentric_milled_steel.png" category="Material"/> + <Property formalName="Bump Amount" name="bump_amount" type="Float" min="0" max="2" default="0.000000" description="Scale value for bump amount" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#define mono_alpha 0 +#define mono_average 1 +#define mono_luminance 2 +#define mono_maximum 3 +#define wrap_clamp 0 +#define wrap_repeat 1 +#define wrap_mirrored_repeat 2 +#define gamma_default 0 +#define gamma_linear 1 +#define gamma_srgb 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; +}; + + +struct texture_return +{ + vec3 tint; + float mono; +}; + + +struct anisotropy_return +{ + float roughness_u; + float roughness_v; + vec3 tangent_u; +}; + + +// temporary declarations +texture_coordinate_info tmp3; +texture_return tmp4; +anisotropy_return tmp5; +vec3 tmp6; +vec3 tmp8; +float ftmp0; +float ftmp1; +vec3 ftmp2; + vec4 tmpShadowTerm; + +layer_result layers[2]; + +#include "SSAOCustomMaterial.glsllib" +#include "sampleLight.glsllib" +#include "sampleProbe.glsllib" +#include "sampleArea.glsllib" +#include "luminance.glsllib" +#include "monoChannel.glsllib" +#include "fileBumpTexture.glsllib" +#include "transformCoordinate.glsllib" +#include "rotationTranslationScale.glsllib" +#include "textureCoordinateInfo.glsllib" +#include "fileTexture.glsllib" +#include "square.glsllib" +#include "calculateRoughness.glsllib" +#include "evalBakedShadowMap.glsllib" +#include "evalEnvironmentMap.glsllib" +#include "microfacetBSDF.glsllib" +#include "physGlossyBSDF.glsllib" +#include "simpleGlossyBSDF.glsllib" +#include "anisotropyConversion.glsllib" +#include "weightedLayer.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].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, ftmp0, ftmp1, scatter_reflect ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( normal, lightDir, viewDir, lightDiffuse, 0.000000 ); + +#endif +} + +void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[0].tanFrame, varWorldPos, lightIdx, viewDir, ftmp0, ftmp1 ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * lightDiffuse * sampleAreaDiffuse( layers[1].tanFrame, varWorldPos, lightIdx ); + +#endif +} + +void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFactor ) +{ +#if !QT3DS_ENABLE_LIGHT_PROBE + layers[0].layer += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, ftmp0, ftmp1, scatter_reflect ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( normal, 0.000000 ) * aoFactor; + +#else + layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, ftmp0, ftmp1 ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * sampleDiffuse( layers[1].tanFrame ) * aoFactor; + +#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( tmp8 ); +} + +void computeTemporaries() +{ + tmp3 = transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), vec3( tiling[0], tiling[1], 1.000000 ) ), textureCoordinateInfo( texCoord0, tangent, binormal ) ); + tmp4 = fileTexture(reflection_texture, vec3( reflection_map_offset ), vec3( reflection_map_scale ), mono_luminance, tmp3, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_linear ); + tmp5 = anisotropyConversion( fileTexture(reflection_texture, vec3( roughness_map_offset ), vec3( roughness_map_scale ), mono_luminance, tmp3, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_linear ).mono, anisotropy, fileTexture(aniso_rot_texture, vec3( aniso_tex_color_offset ), vec3( aniso_tex_color_scale ), mono_luminance, tmp3, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_default ).mono, tangent, false ); + tmp6 = tmp4.tint; + tmp8 = fileBumpTexture(bump_texture, bump_amount, mono_average, tmp3, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, normal ); + ftmp0 = tmp5.roughness_u; + ftmp1 = tmp5.roughness_v; + ftmp2 = tmp5.tangent_u; + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = weightedLayer( base_weight, vec4( tmp6, 1.0).rgb, layers[1].layer, layers[1].base, alpha ); + color = fresnelLayer( tmp8, vec3( material_ior ), tmp4.mono, vec4( tmp6, 1.0).rgb, layers[0].layer, color, color.a ); + 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( ftmp2, cross(tmp8, ftmp2), tmp8 ) ); + layers[1].base = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].layer = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].tanFrame = orthoNormalize( mat3( tangent, cross(normal, tangent), normal ) ); +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="5"/> + <LayerKey count="2"/> + <Pass > + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/aluminum_brushed.shader b/Studio/Content/Material Library/aluminum_brushed.shader new file mode 100644 index 0000000..594b4fa --- /dev/null +++ b/Studio/Content/Material Library/aluminum_brushed.shader @@ -0,0 +1,224 @@ +<Material name="aluminum_brushed" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Brush Map" name="brush_texture" description="Brush texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="brush" default="./maps/materials/brushed_full_contrast.png" category="Material"/> + <Property formalName="Tiling" name="tiling" description="Texture tiling size" type="Vector" default="3 3 3" category="Material"/> + <Property formalName="Roughness Map U" name="roughness_texture_u" description="Horizontal roughness texture" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="roughness" default="./maps/materials/brushed_full_contrast.png" category="Material"/> + <Property formalName="Brush strength" name="brushing_strength" description="Strength of the brush stroke" type="Float" default="0.500000" category="Material"/> + <Property formalName="Roughness Map V" name="roughness_texture_v" description="Vertical roughness texture" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="roughness" default="./maps/materials/brushed_full_contrast.png" category="Material"/> + <Property formalName="Reflection Stretch" name="reflection_stretch" description="Reflection stretch" type="Float" default="0.500000" category="Material"/> + <Property formalName="Metal Color" name="metal_color" description="Base color of the material" type="Color" default="0.95 0.95 0.95" category="Material"/> + <Property formalName="Bump Map" name="bump_texture" description="Bump texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="bump" default="./maps/materials/brushed_a.png" category="Material"/> + <Property formalName="Bump Amount" name="bump_amount" description="Scale value for bump amount" type="Float" default="0.400000" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#define mono_alpha 0 +#define mono_average 1 +#define mono_luminance 2 +#define mono_maximum 3 +#define wrap_clamp 0 +#define wrap_repeat 1 +#define wrap_mirrored_repeat 2 +#define gamma_default 0 +#define gamma_linear 1 +#define gamma_srgb 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; +}; + + +struct texture_return +{ + vec3 tint; + float mono; +}; + + +// temporary declarations +texture_coordinate_info tmp1; +float ftmp0; +float ftmp1; +float ftmp2; + vec4 tmpShadowTerm; + +layer_result layers[1]; + +#include "SSAOCustomMaterial.glsllib" +#include "sampleLight.glsllib" +#include "sampleProbe.glsllib" +#include "sampleArea.glsllib" +#include "luminance.glsllib" +#include "monoChannel.glsllib" +#include "fileBumpTexture.glsllib" +#include "transformCoordinate.glsllib" +#include "rotationTranslationScale.glsllib" +#include "textureCoordinateInfo.glsllib" +#include "weightedLayer.glsllib" +#include "fileTexture.glsllib" +#include "square.glsllib" +#include "calculateRoughness.glsllib" +#include "evalBakedShadowMap.glsllib" +#include "evalEnvironmentMap.glsllib" +#include "microfacetBSDF.glsllib" +#include "physGlossyBSDF.glsllib" +#include "simpleGlossyBSDF.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 * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[0].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, ftmp1, ftmp2, scatter_reflect ); + +#endif +} + +void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[0].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[0].tanFrame, varWorldPos, lightIdx, viewDir, ftmp1, ftmp2 ); + +#endif +} + +void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFactor ) +{ +#if !QT3DS_ENABLE_LIGHT_PROBE + layers[0].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[0].layer += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, ftmp1, ftmp2, scatter_reflect ); + +#else + layers[0].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, ftmp1, ftmp2 ); + +#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( fileBumpTexture(bump_texture, bump_amount, mono_average, tmp1, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, normal ) ); +} + +void computeTemporaries() +{ + tmp1 = transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), tiling ), textureCoordinateInfo( texCoord0, tangent, binormal ) ); + ftmp0 = fileTexture(brush_texture, vec3( 0.5, 0.5, 0.5 ), vec3( 0.5, 0.5, 0.5 ), mono_luminance, tmp1, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_default ).mono; + ftmp1 = fileTexture(roughness_texture_u, vec3( 0.12, 0.12, 0.12 ), vec3( ( 0.800000*brushing_strength ) ), mono_luminance, tmp1, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_default ).mono; + ftmp2 = fileTexture(roughness_texture_v, vec3( ( 0.150000+( 0.400000*reflection_stretch ) ) ), vec3( ( 0.100000+( reflection_stretch*0.300000 ) ) ), mono_luminance, tmp1, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_default ).mono; + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = weightedLayer( ftmp0, metal_color.rgb, layers[0].layer, layers[0].base, 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 ) ); +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="4"/> + <LayerKey count="1"/> + <Pass > + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/aluminum_emissive.shader b/Studio/Content/Material Library/aluminum_emissive.shader new file mode 100644 index 0000000..ed48012 --- /dev/null +++ b/Studio/Content/Material Library/aluminum_emissive.shader @@ -0,0 +1,230 @@ +<Material name="aluminum" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Reflectivity Map" name="reflection_texture" description="Reflection texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="specular" default="./maps/materials/grunge_b.png" category="Material"/> + <Property formalName="Reflection Map Offset" name="reflection_map_offset" hidden="True" type="Float" default="0.500000" description="Reflection texture value offset" category="Material"/> + <Property formalName="Reflection Map Scale" name="reflection_map_scale" hidden="True" type="Float" default="0.300000" description="Reflection texture value scale" category="Material"/> + <Property formalName="Tiling" name="tiling" type="Vector" default="1 1 1" description="Texture Tiling size" category="Material"/> + <Property formalName="Roughness Map" name="roughness_texture" description="Roughness texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="roughness" default="./maps/materials/grunge_d.png" category="Material"/> + <Property formalName="Roughness Map Offset" name="roughness_map_offset" hidden="True" type="Float" default="0.160000" description="Roughness texture value offset" category="Material"/> + <Property formalName="Roughness Map Scale" name="roughness_map_scale" hidden="True" type="Float" default="0.400000" description="Roughness texture value scale" category="Material"/> + <Property formalName="Metal Color" name="metal_color" type="Color" default="0.95 0.95 0.95" description="Base color of the material" category="Material"/> + <Property formalName="Intensity" name="intensity" description="Emission intensity" type="Float" default="1.000000" category="Material"/> + <Property formalName="Emission Color" name="emission_color" description="Color of the emission" type="Color" default="0 0 0" category="Material"/> + <Property formalName="Emissive Map" name="emissive_texture" description="Emissive texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="emissive" default="./maps/materials/emissive.png" category="Material"/> + <Property formalName="Emissive Map Mask" name="emissive_mask_texture" description="Emissive mask texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="emissive_mask" default="./maps/materials/emissive_mask.png" category="Material"/> + <Property formalName="Emissive Mask Offset" name="emissive_mask_offset" description="Offset of the emissive mask texture" type="Vector" default="0 0 0" category="Material"/> + <Property formalName="Bump Map" name="bump_texture" description="Bump texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="bump" default="./maps/materials/grunge_d.png" category="Material"/> + <Property formalName="Bump Amount" name="bump_amount" type="Float" min="0" max="2" default="0.500000" description="Scale value for bump amount" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#define mono_alpha 0 +#define mono_average 1 +#define mono_luminance 2 +#define mono_maximum 3 +#define wrap_clamp 0 +#define wrap_repeat 1 +#define wrap_mirrored_repeat 2 +#define gamma_default 0 +#define gamma_linear 1 +#define gamma_srgb 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; +}; + + +struct texture_return +{ + vec3 tint; + float mono; +}; + + +// temporary declarations +texture_coordinate_info tmp1; +texture_coordinate_info tmp2; +float tmp3; +float ftmp0; + vec4 tmpShadowTerm; + +layer_result layers[1]; + +#include "SSAOCustomMaterial.glsllib" +#include "sampleLight.glsllib" +#include "sampleProbe.glsllib" +#include "sampleArea.glsllib" +#include "luminance.glsllib" +#include "monoChannel.glsllib" +#include "fileBumpTexture.glsllib" +#include "transformCoordinate.glsllib" +#include "rotationTranslationScale.glsllib" +#include "textureCoordinateInfo.glsllib" +#include "weightedLayer.glsllib" +#include "fileTexture.glsllib" +#include "square.glsllib" +#include "calculateRoughness.glsllib" +#include "evalBakedShadowMap.glsllib" +#include "evalEnvironmentMap.glsllib" +#include "microfacetBSDF.glsllib" +#include "physGlossyBSDF.glsllib" +#include "simpleGlossyBSDF.glsllib" + +bool evalTwoSided() +{ + return( false ); +} + +vec3 computeFrontMaterialEmissive() +{ + return( vec3( 1.0, 1.0, 1.0) * vec3( vec3( ( intensity*( emission_color.rgb *( fileTexture(emissive_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_alpha, transformCoordinate( rotationTranslationScale( vec3( 0.0, 0.0, 0.0 ), vec3( 0.0, 0.0, 0.0 ), vec3( 1.0, 1.0, 1.0 ) ), tmp1 ), vec2( 0.0, 1.0 ), vec2( 0.0, 1.0 ), wrap_repeat, wrap_repeat, gamma_default ).tint*fileTexture(emissive_mask_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_alpha, transformCoordinate( rotationTranslationScale( vec3( 0.0, 0.0, 0.0 ), emissive_mask_offset, vec3( 1.0, 1.0, 1.0 ) ), tmp1 ), vec2( 0.0, 1.0 ), vec2( 0.0, 1.0 ), wrap_repeat, wrap_repeat, gamma_default ).tint ) ) ) ) ) ); +} + +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 * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[0].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, tmp3, tmp3, scatter_reflect ); + +#endif +} + +void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[0].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[0].tanFrame, varWorldPos, lightIdx, viewDir, tmp3, tmp3 ); + +#endif +} + +void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFactor ) +{ +#if !QT3DS_ENABLE_LIGHT_PROBE + layers[0].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[0].layer += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, tmp3, tmp3, scatter_reflect ); + +#else + layers[0].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, tmp3, tmp3 ); + +#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.0 ); +} + +vec3 computeNormal() +{ + return( fileBumpTexture(bump_texture, bump_amount, mono_average, tmp2, vec2( 0.0, 1.0 ), vec2( 0.0, 1.0 ), wrap_repeat, wrap_repeat, normal ) ); +} + +void computeTemporaries() +{ + tmp1 = textureCoordinateInfo( texCoord0, tangent, binormal ); + tmp2 = transformCoordinate( rotationTranslationScale( vec3( 0.0, 0.0, 0.0 ), vec3( 0.0, 0.0, 0.0 ), tiling ), tmp1 ); + tmp3 = fileTexture(roughness_texture, vec3( roughness_map_offset ), vec3( roughness_map_scale ), mono_luminance, tmp2, vec2( 0.0, 1.0 ), vec2( 0.0, 1.0 ), wrap_repeat, wrap_repeat, gamma_default ).mono; + ftmp0 = fileTexture(reflection_texture, vec3( reflection_map_offset ), vec3( reflection_map_scale ), mono_luminance, tmp2, vec2( 0.0, 1.0 ), vec2( 0.0, 1.0 ), wrap_repeat, wrap_repeat, gamma_default ).mono; + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = weightedLayer( ftmp0, metal_color.rgb, layers[0].layer, layers[0].base, 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 ) ); +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="4"/> + <LayerKey count="1"/> + <Pass > + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/aluminum_textured_aniso.shader b/Studio/Content/Material Library/aluminum_textured_aniso.shader new file mode 100644 index 0000000..ed9fb88 --- /dev/null +++ b/Studio/Content/Material Library/aluminum_textured_aniso.shader @@ -0,0 +1,263 @@ +<Material name="aluminum_anisotropic" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Index of Refraction" name="material_ior" description="Refractive index of the material" type="Float" default="8.000000" category="Material"/> + <Property formalName="Diffuse Map" name="reflection_texture" description="Reflection texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="specular" default="./maps/materials/concentric_milled_steel.png" category="Material"/> + <Property formalName="Reflection Map Offset" name="reflection_map_offset" hidden="True" type="Float" default="1.000000" description="Reflection texture value offset" category="Material"/> + <Property formalName="Reflection Map Scale" name="reflection_map_scale" hidden="True" type="Float" default="1.000000" description="Reflection texture value scale" category="Material"/> + <Property formalName="Tiling" name="tiling" type="Float2" default="1 1" description="Texture Tiling size" category="Material"/> + <Property formalName="Roughness Map Offset" name="roughness_map_offset" hidden="True" type="Float" default="0.000000" description="Roughness texture value offset" category="Material"/> + <Property formalName="Roughness Map Scale" name="roughness_map_scale" hidden="True" type="Float" default="1.000000" description="Roughness texture value scale" category="Material"/> + <Property formalName="Anisotropy" name="anisotropy" type="Float" default="0.800000" description="Anisotropy" category="Material"/> + <Property formalName="Anisotropy Map" name="aniso_rot_texture" description="Anisotropy rot texture of the material" type="Texture" filter="linear" minfilter="linear" clamp="repeat" usage="anisotropy" default="./maps/materials/concentric_milled_steel_aniso.png" category="Material"/> + <Property formalName="Roughness Map Offset" name="aniso_tex_color_offset" hidden="True" type="Float" default="0.000000" description="Roughness texture value offset" category="Material"/> + <Property formalName="Roughness Map Scale" name="aniso_tex_color_scale" hidden="True" type="Float" default="1.000000" description="Roughness texture value scale" category="Material"/> + <Property formalName="Anisotropy Tiling" name="aniso_tiling" description="Anisotropy Tiling" type="Float2" default="1 1" category="Material"/> + <Property formalName="Base Weight" name="base_weight" description="Base weight" hidden="True" type="Float" default="1.000000" category="Material"/> + <Property formalName="Bump Map" name="bump_texture" description="Bump texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="bump" default="./maps/materials/concentric_milled_steel.png" category="Material"/> + <Property formalName="Bump Amount" name="bump_amount" type="Float" min="0" max="2" default="0.000000" description="Scale value for bump amount" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#define mono_alpha 0 +#define mono_average 1 +#define mono_luminance 2 +#define mono_maximum 3 +#define wrap_clamp 0 +#define wrap_repeat 1 +#define wrap_mirrored_repeat 2 +#define gamma_default 0 +#define gamma_linear 1 +#define gamma_srgb 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; +}; + + +struct texture_return +{ + vec3 tint; + float mono; +}; + + +struct anisotropy_return +{ + float roughness_u; + float roughness_v; + vec3 tangent_u; +}; + + +// temporary declarations +texture_coordinate_info tmp2; +texture_coordinate_info tmp4; +texture_return tmp5; +anisotropy_return tmp7; +vec3 tmp8; +vec3 tmp10; +float ftmp0; +float ftmp1; +vec3 ftmp2; + vec4 tmpShadowTerm; + +layer_result layers[2]; + +#include "SSAOCustomMaterial.glsllib" +#include "sampleLight.glsllib" +#include "sampleProbe.glsllib" +#include "sampleArea.glsllib" +#include "luminance.glsllib" +#include "monoChannel.glsllib" +#include "fileBumpTexture.glsllib" +#include "transformCoordinate.glsllib" +#include "rotationTranslationScale.glsllib" +#include "textureCoordinateInfo.glsllib" +#include "fileTexture.glsllib" +#include "square.glsllib" +#include "calculateRoughness.glsllib" +#include "evalBakedShadowMap.glsllib" +#include "evalEnvironmentMap.glsllib" +#include "microfacetBSDF.glsllib" +#include "physGlossyBSDF.glsllib" +#include "simpleGlossyBSDF.glsllib" +#include "anisotropyConversion.glsllib" +#include "weightedLayer.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].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, ftmp0, ftmp1, scatter_reflect ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( normal, lightDir, viewDir, lightDiffuse, 0.000000 ); + +#endif +} + +void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[0].tanFrame, varWorldPos, lightIdx, viewDir, ftmp0, ftmp1 ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * lightDiffuse * sampleAreaDiffuse( layers[1].tanFrame, varWorldPos, lightIdx ); + +#endif +} + +void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFactor ) +{ +#if !QT3DS_ENABLE_LIGHT_PROBE + layers[0].layer += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, ftmp0, ftmp1, scatter_reflect ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( normal, 0.000000 ) * aoFactor; + +#else + layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, ftmp0, ftmp1 ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * sampleDiffuse( layers[1].tanFrame ) * aoFactor; + +#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( tmp10 ); +} + +void computeTemporaries() +{ + tmp2 = textureCoordinateInfo( texCoord0, tangent, binormal ); + tmp4 = transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), vec3( tiling[0], tiling[1], 1.000000 ) ), tmp2 ); + tmp5 = fileTexture(reflection_texture, vec3( reflection_map_offset ), vec3( reflection_map_scale ), mono_luminance, tmp4, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_linear ); + tmp7 = anisotropyConversion( fileTexture(reflection_texture, vec3( roughness_map_offset ), vec3( roughness_map_scale ), mono_luminance, tmp4, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_linear ).mono, anisotropy, fileTexture(aniso_rot_texture, vec3( aniso_tex_color_offset ), vec3( aniso_tex_color_scale ), mono_luminance, transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), vec3( aniso_tiling[0], aniso_tiling[1], 1.000000 ) ), tmp2 ), vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_default ).mono, tangent, false ); + tmp8 = tmp5.tint; + tmp10 = fileBumpTexture(bump_texture, bump_amount, mono_average, tmp4, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, normal ); + ftmp0 = tmp7.roughness_u; + ftmp1 = tmp7.roughness_v; + ftmp2 = tmp7.tangent_u; + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = weightedLayer( base_weight, vec4( tmp8, 1.0).rgb, layers[1].layer, layers[1].base, alpha ); + color = fresnelLayer( tmp10, vec3( material_ior ), tmp5.mono, vec4( tmp8, 1.0).rgb, layers[0].layer, color, color.a ); + 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( ftmp2, cross(tmp10, ftmp2), tmp10 ) ); + layers[1].base = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].layer = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].tanFrame = orthoNormalize( mat3( tangent, cross(normal, tangent), normal ) ); +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="5"/> + <LayerKey count="2"/> + <Pass > + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/asphalt.shader b/Studio/Content/Material Library/asphalt.shader new file mode 100644 index 0000000..da37ed4 --- /dev/null +++ b/Studio/Content/Material Library/asphalt.shader @@ -0,0 +1,236 @@ +<Material name="asphalt" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Index of Refraction" name="material_ior" type="Float" default="2.000000" description="Index of refraction of the material" category="Material"/> + <Property formalName="Roughness" name="roughness" type="Float" min="0.000000" max="1.000000" default="0.250000" description="Roughness of the material.\n0 = fully specular\n1 = fully diffuse" category="Material"/> + <Property formalName="Reflectivity Map" name="reflect_texture" description="Reflectivity texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="specular" default="./maps/materials/asphalt_bump.png" category="Material"/> + <Property formalName="Tiling" name="texture_tiling" type="Float2" default="4 4" description="Scaling of the textures" category="Material"/> + <Property formalName="Diffuse Map" name="diffuse_texture" description="Diffuse texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="diffuse" default="./maps/materials/asphalt.png" category="Material"/> + <Property formalName="Bump Map" name="bump_texture" description="Bump texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="bump" default="./maps/materials/asphalt_bump.png" category="Material"/> + <Property formalName="Bump Amount" name="bump_amount" type="Float" default="7.000000" description="Value determining the bumpiness" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#define mono_alpha 0 +#define mono_average 1 +#define mono_luminance 2 +#define mono_maximum 3 +#define wrap_clamp 0 +#define wrap_repeat 1 +#define wrap_mirrored_repeat 2 +#define gamma_default 0 +#define gamma_linear 1 +#define gamma_srgb 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 layer_result +{ + vec4 base; + vec4 layer; + mat3 tanFrame; +}; + + +struct texture_coordinate_info +{ + vec3 position; + vec3 tangent_u; + vec3 tangent_v; +}; + + +struct texture_return +{ + vec3 tint; + float mono; +}; + + +// temporary declarations +texture_coordinate_info tmp2; +vec3 tmp5; +vec3 ftmp0; +vec3 ftmp1; + vec4 tmpShadowTerm; + +layer_result layers[2]; + +#include "SSAOCustomMaterial.glsllib" +#include "sampleLight.glsllib" +#include "sampleProbe.glsllib" +#include "sampleArea.glsllib" +#include "luminance.glsllib" +#include "monoChannel.glsllib" +#include "fileBumpTexture.glsllib" +#include "transformCoordinate.glsllib" +#include "rotationTranslationScale.glsllib" +#include "textureCoordinateInfo.glsllib" +#include "square.glsllib" +#include "calculateRoughness.glsllib" +#include "evalBakedShadowMap.glsllib" +#include "evalEnvironmentMap.glsllib" +#include "microfacetBSDF.glsllib" +#include "physGlossyBSDF.glsllib" +#include "simpleGlossyBSDF.glsllib" +#include "fileTexture.glsllib" +#include "weightedLayer.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].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp5, lightDir, viewDir, lightDiffuse, 0.000000 ); + +#endif +} + +void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[0].tanFrame, varWorldPos, lightIdx, viewDir, roughness, roughness ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * lightDiffuse * sampleAreaDiffuse( layers[1].tanFrame, varWorldPos, lightIdx ); + +#endif +} + +void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFactor ) +{ +#if !QT3DS_ENABLE_LIGHT_PROBE + layers[0].layer += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, roughness, roughness, scatter_reflect ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( tmp5, 0.000000 ) * aoFactor; + +#else + layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * sampleDiffuse( layers[1].tanFrame ) * aoFactor; + +#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( normal ); +} + +void computeTemporaries() +{ + tmp2 = transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), vec3( texture_tiling[0], texture_tiling[1], 1.000000 ) ), textureCoordinateInfo( texCoord0, tangent, binormal ) ); + tmp5 = fileBumpTexture(bump_texture, bump_amount, mono_average, tmp2, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, normal ); + ftmp0 = fileTexture(reflect_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_luminance, tmp2, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_linear ).tint; + ftmp1 = fileTexture(diffuse_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_luminance, tmp2, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_srgb ).tint; + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = weightedLayer( 1.000000, vec4( ftmp1, 1.0).rgb, layers[1].layer, layers[1].base, alpha ); + color = fresnelLayer( tmp5, vec3( material_ior ), 1.000000, vec4( ftmp0, 1.0).rgb, layers[0].layer, color, color.a ); + 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(tmp5, tangent), tmp5 ) ); + layers[1].base = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].layer = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].tanFrame = orthoNormalize( mat3( tangent, cross(tmp5, tangent), tmp5 ) ); +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="5"/> + <LayerKey count="2"/> + <Pass > + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/bamboo_natural_matte.shader b/Studio/Content/Material Library/bamboo_natural_matte.shader new file mode 100644 index 0000000..28ab611 --- /dev/null +++ b/Studio/Content/Material Library/bamboo_natural_matte.shader @@ -0,0 +1,236 @@ +<Material name="bamboo_natural_matte" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Index of Refraction" name="material_ior" type="Float" default="1.500000" description="Index of refraction of the material" category="Material"/> + <Property formalName="Roughness" name="roughness" type="Float" min="0.000000" max="1.000000" default="0.300000" description="Roughness of the material.\n0 = fully specular\n1 = fully diffuse" category="Material"/> + <Property formalName="Reflectivity Map" name="reflect_texture" description="Reflectivity texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="specular" default="./maps/materials/bamboo_natural_spec.png" category="Material"/> + <Property formalName="Tiling" name="texture_tiling" type="Float2" default="4 4" description="Scaling of the textures" category="Material"/> + <Property formalName="Diffuse Map" name="diffuse_texture" description="Diffuse texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="diffuse" default="./maps/materials/bamboo_natural.png" category="Material"/> + <Property formalName="Bump Map" name="bump_texture" description="Bump texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="bump" default="./maps/materials/bamboo_natural_bump.png" category="Material"/> + <Property formalName="Bump Amount" name="bump_amount" type="Float" default="0.150000" description="Value determining the bumpiness" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#define mono_alpha 0 +#define mono_average 1 +#define mono_luminance 2 +#define mono_maximum 3 +#define wrap_clamp 0 +#define wrap_repeat 1 +#define wrap_mirrored_repeat 2 +#define gamma_default 0 +#define gamma_linear 1 +#define gamma_srgb 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 layer_result +{ + vec4 base; + vec4 layer; + mat3 tanFrame; +}; + + +struct texture_coordinate_info +{ + vec3 position; + vec3 tangent_u; + vec3 tangent_v; +}; + + +struct texture_return +{ + vec3 tint; + float mono; +}; + + +// temporary declarations +texture_coordinate_info tmp2; +vec3 tmp5; +vec3 ftmp0; +vec3 ftmp1; + vec4 tmpShadowTerm; + +layer_result layers[2]; + +#include "SSAOCustomMaterial.glsllib" +#include "sampleLight.glsllib" +#include "sampleProbe.glsllib" +#include "sampleArea.glsllib" +#include "luminance.glsllib" +#include "monoChannel.glsllib" +#include "fileBumpTexture.glsllib" +#include "transformCoordinate.glsllib" +#include "rotationTranslationScale.glsllib" +#include "textureCoordinateInfo.glsllib" +#include "square.glsllib" +#include "calculateRoughness.glsllib" +#include "evalBakedShadowMap.glsllib" +#include "evalEnvironmentMap.glsllib" +#include "microfacetBSDF.glsllib" +#include "physGlossyBSDF.glsllib" +#include "simpleGlossyBSDF.glsllib" +#include "fileTexture.glsllib" +#include "weightedLayer.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].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp5, lightDir, viewDir, lightDiffuse, 0.000000 ); + +#endif +} + +void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[0].tanFrame, varWorldPos, lightIdx, viewDir, roughness, roughness ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * lightDiffuse * sampleAreaDiffuse( layers[1].tanFrame, varWorldPos, lightIdx ); + +#endif +} + +void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFactor ) +{ +#if !QT3DS_ENABLE_LIGHT_PROBE + layers[0].layer += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, roughness, roughness, scatter_reflect ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( tmp5, 0.000000 ) * aoFactor; + +#else + layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * sampleDiffuse( layers[1].tanFrame ) * aoFactor; + +#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( normal ); +} + +void computeTemporaries() +{ + tmp2 = transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), vec3( texture_tiling[0], texture_tiling[1], 1.000000 ) ), textureCoordinateInfo( texCoord0, tangent, binormal ) ); + tmp5 = fileBumpTexture(bump_texture, bump_amount, mono_average, tmp2, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, normal ); + ftmp0 = fileTexture(reflect_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_luminance, tmp2, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_linear ).tint; + ftmp1 = fileTexture(diffuse_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_luminance, tmp2, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_srgb ).tint; + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = weightedLayer( 1.000000, vec4( ftmp1, 1.0).rgb, layers[1].layer, layers[1].base, alpha ); + color = fresnelLayer( tmp5, vec3( material_ior ), 1.000000, vec4( ftmp0, 1.0).rgb, layers[0].layer, color, color.a ); + 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(tmp5, tangent), tmp5 ) ); + layers[1].base = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].layer = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].tanFrame = orthoNormalize( mat3( tangent, cross(tmp5, tangent), tmp5 ) ); +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="5"/> + <LayerKey count="2"/> + <Pass > + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/bamboo_natural_matte_emissive.shader b/Studio/Content/Material Library/bamboo_natural_matte_emissive.shader new file mode 100644 index 0000000..7096c14 --- /dev/null +++ b/Studio/Content/Material Library/bamboo_natural_matte_emissive.shader @@ -0,0 +1,242 @@ +<Material name="bamboo_natural_matte_emissive" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Index of Refraction" name="material_ior" type="Float" default="1.500000" description="Index of refraction of the material" category="Material"/> + <Property formalName="Roughness" name="roughness" type="Float" min="0.000000" max="1.000000" default="0.300000" description="Roughness of the material.\n0 = fully specular\n1 = fully diffuse" category="Material"/> + <Property formalName="Reflectivity Map" name="reflect_texture" description="Reflectivity texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="specular" default="./maps/materials/bamboo_natural_spec.png" category="Material"/> + <Property formalName="Tiling" name="texture_tiling" type="Float2" default="4 4" description="Scaling of the textures" category="Material"/> + <Property formalName="Diffuse Map" name="diffuse_texture" description="Diffuse texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="diffuse" default="./maps/materials/bamboo_natural.png" category="Material"/> + <Property formalName="Bump Map" name="bump_texture" description="Bump texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="bump" default="./maps/materials/bamboo_natural_bump.png" category="Material"/> + <Property formalName="Bump Amount" name="bump_amount" type="Float" default="0.150000" description="Value determining the bumpiness" category="Material"/> + <Property formalName="Intensity" name="intensity" description="Emission intensity" type="Float" default="1.000000" category="Material"/> + <Property formalName="Emission Color" name="emission_color" description="Color of the emission" type="Color" default="0 0 0" category="Material"/> + <Property formalName="Emissive Map" name="emissive_texture" description="Emissive texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="emissive" default="./maps/materials/emissive.png" category="Material"/> + <Property formalName="Emissive Mask Map" name="emissive_mask_texture" description="Emissive mask texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="emissive_mask" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#define mono_alpha 0 +#define mono_average 1 +#define mono_luminance 2 +#define mono_maximum 3 +#define wrap_clamp 0 +#define wrap_repeat 1 +#define wrap_mirrored_repeat 2 +#define gamma_default 0 +#define gamma_linear 1 +#define gamma_srgb 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 layer_result +{ + vec4 base; + vec4 layer; + mat3 tanFrame; +}; + + +struct texture_coordinate_info +{ + vec3 position; + vec3 tangent_u; + vec3 tangent_v; +}; + + +struct texture_return +{ + vec3 tint; + float mono; +}; + + +// temporary declarations +texture_coordinate_info tmp2; +texture_coordinate_info tmp3; +vec3 tmp6; +vec3 ftmp0; +vec3 ftmp1; + vec4 tmpShadowTerm; + +layer_result layers[2]; + +#include "SSAOCustomMaterial.glsllib" +#include "sampleLight.glsllib" +#include "sampleProbe.glsllib" +#include "sampleArea.glsllib" +#include "luminance.glsllib" +#include "monoChannel.glsllib" +#include "fileBumpTexture.glsllib" +#include "transformCoordinate.glsllib" +#include "rotationTranslationScale.glsllib" +#include "textureCoordinateInfo.glsllib" +#include "square.glsllib" +#include "calculateRoughness.glsllib" +#include "evalBakedShadowMap.glsllib" +#include "evalEnvironmentMap.glsllib" +#include "microfacetBSDF.glsllib" +#include "physGlossyBSDF.glsllib" +#include "simpleGlossyBSDF.glsllib" +#include "fileTexture.glsllib" +#include "weightedLayer.glsllib" +#include "diffuseReflectionBSDF.glsllib" +#include "fresnelLayer.glsllib" + +bool evalTwoSided() +{ + return( false ); +} + +vec3 computeFrontMaterialEmissive() +{ + return( vec3(1.0) * vec3( vec3( ( intensity *( emission_color.rgb * fileTexture(emissive_texture, vec3(0.0), vec3(1.0), mono_alpha, transformCoordinate( rotationTranslationScale( vec3(0.0), vec3(0.0), vec3(1.0) ), tmp2 ), vec2(0.0, 1.0), vec2(0.0, 1.0), wrap_repeat, wrap_repeat, gamma_default ).tint ) ) ) ) ); +} + +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].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp6, lightDir, viewDir, lightDiffuse, 0.000000 ); + +#endif +} + +void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[0].tanFrame, varWorldPos, lightIdx, viewDir, roughness, roughness ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * lightDiffuse * sampleAreaDiffuse( layers[1].tanFrame, varWorldPos, lightIdx ); + +#endif +} + +void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFactor ) +{ +#if !QT3DS_ENABLE_LIGHT_PROBE + layers[0].layer += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, roughness, roughness, scatter_reflect ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( tmp6, 0.000000 ) * aoFactor; + +#else + layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * sampleDiffuse( layers[1].tanFrame ) * aoFactor; + +#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( normal ); +} + +void computeTemporaries() +{ + tmp2 = textureCoordinateInfo( texCoord0, tangent, binormal ); + tmp3 = transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), vec3( texture_tiling[0], texture_tiling[1], 1.000000 ) ), tmp2 ); + tmp6 = fileBumpTexture(bump_texture, bump_amount, mono_average, tmp3, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, normal ); + ftmp0 = fileTexture(reflect_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_luminance, tmp3, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_linear ).tint; + ftmp1 = fileTexture(diffuse_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_luminance, tmp3, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_srgb ).tint; + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = weightedLayer( 1.000000, vec4( ftmp1, 1.0).rgb, layers[1].layer, layers[1].base, alpha ); + color = fresnelLayer( tmp6, vec3( material_ior ), 1.000000, vec4( ftmp0, 1.0).rgb, layers[0].layer, color, color.a ); + 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(tmp6, tangent), tmp6 ) ); + layers[1].base = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].layer = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].tanFrame = orthoNormalize( mat3( tangent, cross(tmp6, tangent), tmp6 ) ); +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="5"/> + <LayerKey count="2"/> + <Pass > + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/carbon_fiber.shader b/Studio/Content/Material Library/carbon_fiber.shader new file mode 100644 index 0000000..fd3eca3 --- /dev/null +++ b/Studio/Content/Material Library/carbon_fiber.shader @@ -0,0 +1,271 @@ +<Material name="carbon_fiber" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Coat ior" name="coat_ior" type="Float" default="1.250000" description="Index of refraction of the coating layer" category="Material"/> + <Property formalName="Coat Glossy weight" name="coat_weight" type="Float" min="0.000000" max="1.000000" default="1.000000" description="Strength of the coating's glossy reflection.\n0 = no reflection\n1 = maximum reflectivity" category="Material"/> + <Property formalName="Coat Roughness" name="coat_roughness" type="Float" min="0.000000" max="1.000000" default="0.000000" description="Roughness of the material.\n0 = fully specular\n1 = fully diffuse" category="Material"/> + <Property formalName="Base ior" name="base_ior" type="Float" default="1.650000" description="Index of refraction of the material" category="Material"/> + <Property formalName="Glossy Weight" name="base_weight" type="Float" min="0.000000" max="1.000000" default="0.500000" description="Strength of glossy reflection at incident angles.\n0 = no reflection\n1 = maximum reflectivity" category="Material"/> + <Property formalName="Roughness" name="base_roughness" type="Float" min="0.000000" max="1.000000" default="0.100000" description="Roughness of the material.\n0 = fully specular\n1 = fully diffuse" category="Material"/> + <Property formalName="Anisotropy" name="anisotropy" type="Float" min="0.000000" max="0.999000" default="0.800000" description="The anisotropy of the roughness" category="Material"/> + <Property formalName="Anisotropy Map" description="Anisotropy transformation texture" name="anisotropy_rotation_texture" type="Texture" filter="linear" minfilter="linear" clamp="repeat" usage="anisotropy" default="./maps/materials/carbon_fiber_aniso.png" category="Material"/> + <Property formalName="Tiling" name="texture_tiling" type="Float2" default="12 12" description="Scaling of the textures" category="Material"/> + <Property formalName="Reflectivity Map" name="reflect_texture" description="Reflectivity texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="specular" default="./maps/materials/carbon_fiber_spec.png" category="Material"/> + <Property formalName="Diffuse Map" name="diffuse_texture" description="Diffuse texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="diffuse" default="./maps/materials/carbon_fiber.png" category="Material"/> + <Property formalName="Bump Map" name="bump_texture" description="Bump texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="bump" default="./maps/materials/carbon_fiber_bump.png" category="Material"/> + <Property formalName="Bump Amount" name="bump_amount" type="Float" default="1.000000" description="Value determining the bumpiness" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#define scatter_reflect 0 +#define scatter_transmit 1 +#define scatter_reflect_transmit 2 +#define mono_alpha 0 +#define mono_average 1 +#define mono_luminance 2 +#define mono_maximum 3 +#define wrap_clamp 0 +#define wrap_repeat 1 +#define wrap_mirrored_repeat 2 +#define gamma_default 0 +#define gamma_linear 1 +#define gamma_srgb 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 layer_result +{ + vec4 base; + vec4 layer; + mat3 tanFrame; +}; + + +struct texture_coordinate_info +{ + vec3 position; + vec3 tangent_u; + vec3 tangent_v; +}; + + +struct anisotropy_return +{ + float roughness_u; + float roughness_v; + vec3 tangent_u; +}; + + +struct texture_return +{ + vec3 tint; + float mono; +}; + + +// temporary declarations +texture_coordinate_info tmp3; +anisotropy_return tmp4; +vec3 tmp6; +float ftmp0; +float ftmp1; +vec3 ftmp2; +vec3 ftmp3; +vec3 ftmp4; + vec4 tmpShadowTerm; + +layer_result layers[3]; + +#include "SSAOCustomMaterial.glsllib" +#include "sampleLight.glsllib" +#include "sampleProbe.glsllib" +#include "sampleArea.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 "monoChannel.glsllib" +#include "fileBumpTexture.glsllib" +#include "transformCoordinate.glsllib" +#include "rotationTranslationScale.glsllib" +#include "textureCoordinateInfo.glsllib" +#include "fileTexture.glsllib" +#include "anisotropyConversion.glsllib" +#include "weightedLayer.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].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, coat_roughness, coat_roughness, scatter_reflect ); + + layers[1].layer += tmpShadowTerm * microfacetBSDF( layers[1].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, ftmp0, ftmp1, scatter_reflect ); + + layers[2].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[2].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp6, lightDir, viewDir, lightDiffuse, 0.000000 ); + +#endif +} + +void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[0].tanFrame, varWorldPos, lightIdx, viewDir, coat_roughness, coat_roughness ); + + layers[1].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[1].tanFrame, varWorldPos, lightIdx, viewDir, ftmp0, ftmp1 ); + + layers[2].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[2].layer += tmpShadowTerm * lightDiffuse * sampleAreaDiffuse( layers[2].tanFrame, varWorldPos, lightIdx ); + +#endif +} + +void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFactor ) +{ +#if !QT3DS_ENABLE_LIGHT_PROBE + layers[0].layer += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, coat_roughness, coat_roughness, scatter_reflect ); + + layers[1].layer += tmpShadowTerm * microfacetSampledBSDF( layers[1].tanFrame, viewDir, ftmp0, ftmp1, scatter_reflect ); + + layers[2].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[2].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( tmp6, 0.000000 ) * aoFactor; + +#else + layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, coat_roughness, coat_roughness ); + + layers[1].layer += tmpShadowTerm * sampleGlossyAniso( layers[1].tanFrame, viewDir, ftmp0, ftmp1 ); + + layers[2].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[2].layer += tmpShadowTerm * sampleDiffuse( layers[2].tanFrame ) * aoFactor; + +#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( normal ); +} + +void computeTemporaries() +{ + tmp3 = transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), vec3( texture_tiling[0], texture_tiling[1], 1.000000 ) ), textureCoordinateInfo( texCoord0, tangent, binormal ) ); + tmp4 = anisotropyConversion( base_roughness, anisotropy, fileTexture(anisotropy_rotation_texture, vec3( 0, 0, 0 ), vec3( 3.14, 3.14, 3.14 ), mono_luminance, tmp3, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_linear ).mono, tangent, false ); + tmp6 = fileBumpTexture(bump_texture, bump_amount, mono_average, tmp3, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, normal ); + ftmp0 = tmp4.roughness_u; + ftmp1 = tmp4.roughness_v; + ftmp2 = fileTexture(reflect_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_luminance, tmp3, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_linear ).tint; + ftmp3 = tmp4.tangent_u; + ftmp4 = fileTexture(diffuse_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_luminance, tmp3, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_srgb ).tint; + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = weightedLayer( 1.000000, vec4( ftmp4, 1.0).rgb, layers[2].layer, layers[2].base, alpha ); + color = fresnelLayer( tmp6, vec3( base_ior ), base_weight, vec4( ftmp2, 1.0).rgb, layers[1].layer, color, color.a ); + color = fresnelLayer( normal, vec3( coat_ior ), coat_weight, vec4( vec3( 1, 1, 1 ), 1.0).rgb, layers[0].layer, color, color.a ); + 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 ) ); + layers[1].base = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].layer = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].tanFrame = orthoNormalize( mat3( ftmp3, cross(tmp6, ftmp3), tmp6 ) ); + layers[2].base = vec4(0.0, 0.0, 0.0, 1.0); + layers[2].layer = vec4(0.0, 0.0, 0.0, 1.0); + layers[2].tanFrame = orthoNormalize( mat3( tangent, cross(tmp6, tangent), tmp6 ) ); +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="5"/> + <LayerKey count="3"/> + <Pass > + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/carbon_fiber_emissive.shader b/Studio/Content/Material Library/carbon_fiber_emissive.shader new file mode 100644 index 0000000..fae9b7b --- /dev/null +++ b/Studio/Content/Material Library/carbon_fiber_emissive.shader @@ -0,0 +1,277 @@ +<Material name="carbon_fiber" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Coat ior" name="coat_ior" type="Float" default="1.250000" description="Index of refraction of the coating layer" category="Material"/> + <Property formalName="Coat Glossy weight" name="coat_weight" type="Float" min="0.000000" max="1.000000" default="1.000000" description="Strength of the coating's glossy reflection.\n0 = no reflection\n1 = maximum reflectivity" category="Material"/> + <Property formalName="Coat Roughness" name="coat_roughness" type="Float" min="0.000000" max="1.000000" default="0.000000" description="Roughness of the material.\n0 = fully specular\n1 = fully diffuse" category="Material"/> + <Property formalName="Base ior" name="base_ior" type="Float" default="1.650000" description="Index of refraction of the material" category="Material"/> + <Property formalName="Glossy Weight" name="base_weight" type="Float" min="0.000000" max="1.000000" default="0.500000" description="Strength of glossy reflection at incident angles.\n0 = no reflection\n1 = maximum reflectivity" category="Material"/> + <Property formalName="Roughness" name="base_roughness" type="Float" min="0.000000" max="1.000000" default="0.100000" description="Roughness of the material.\n0 = fully specular\n1 = fully diffuse" category="Material"/> + <Property formalName="Anisotropy" name="anisotropy" type="Float" min="0.000000" max="0.999000" default="0.800000" description="The anisotropy of the roughness" category="Material"/> + <Property formalName="Anisotropy Map" description="Anisotropy transformation texture" name="anisotropy_rotation_texture" type="Texture" filter="linear" minfilter="linear" clamp="repeat" usage="anisotropy" default="./maps/materials/carbon_fiber_aniso.png" category="Material"/> + <Property formalName="Tiling" name="texture_tiling" type="Float2" default="12 12" description="Scaling of the textures" category="Material"/> + <Property formalName="Reflectivity Map" name="reflect_texture" description="Reflectivity texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="specular" default="./maps/materials/carbon_fiber_spec.png" category="Material"/> + <Property formalName="Diffuse Map" name="diffuse_texture" description="Diffuse texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="diffuse" default="./maps/materials/carbon_fiber.png" category="Material"/> + <Property formalName="Bump Map" name="bump_texture" description="Bump texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="bump" default="./maps/materials/carbon_fiber_bump.png" category="Material"/> + <Property formalName="Bump Amount" name="bump_amount" type="Float" default="1.000000" description="Value determining the bumpiness" category="Material"/> + <Property formalName="Intensity" name="intensity" description="Emission intensity" type="Float" default="1.000000" category="Material"/> + <Property formalName="Emission Color" name="emission_color" description="Color of the emission" type="Color" default="0 0 0" category="Material"/> + <Property formalName="Emissive Map" name="emissive_texture" description="Emissive texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="emissive" default="./maps/materials/emissive.png" category="Material"/> + <Property formalName="Emissive Mask Map" name="emissive_mask_texture" description="Emissive mask texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="emissive_mask" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#define scatter_reflect 0 +#define scatter_transmit 1 +#define scatter_reflect_transmit 2 +#define mono_alpha 0 +#define mono_average 1 +#define mono_luminance 2 +#define mono_maximum 3 +#define wrap_clamp 0 +#define wrap_repeat 1 +#define wrap_mirrored_repeat 2 +#define gamma_default 0 +#define gamma_linear 1 +#define gamma_srgb 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 layer_result +{ + vec4 base; + vec4 layer; + mat3 tanFrame; +}; + + +struct texture_coordinate_info +{ + vec3 position; + vec3 tangent_u; + vec3 tangent_v; +}; + + +struct anisotropy_return +{ + float roughness_u; + float roughness_v; + vec3 tangent_u; +}; + + +struct texture_return +{ + vec3 tint; + float mono; +}; + + +// temporary declarations +texture_coordinate_info tmp3; +texture_coordinate_info tmp4; +anisotropy_return tmp5; +vec3 tmp7; +float ftmp0; +float ftmp1; +vec3 ftmp2; +vec3 ftmp3; +vec3 ftmp4; + vec4 tmpShadowTerm; + +layer_result layers[3]; + +#include "SSAOCustomMaterial.glsllib" +#include "sampleLight.glsllib" +#include "sampleProbe.glsllib" +#include "sampleArea.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 "monoChannel.glsllib" +#include "fileBumpTexture.glsllib" +#include "transformCoordinate.glsllib" +#include "rotationTranslationScale.glsllib" +#include "textureCoordinateInfo.glsllib" +#include "fileTexture.glsllib" +#include "anisotropyConversion.glsllib" +#include "weightedLayer.glsllib" +#include "diffuseReflectionBSDF.glsllib" +#include "fresnelLayer.glsllib" + +bool evalTwoSided() +{ + return( false ); +} + +vec3 computeFrontMaterialEmissive() +{ + return( vec3( 1.0, 1.0, 1.0) * vec3( vec3( ( intensity *( emission_color.rgb * fileTexture(emissive_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_alpha, transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), vec3( 1.000000, 1.000000, 1.000000 ) ), tmp3 ), vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_default ).tint ) ) ) ) ); +} + +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].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, coat_roughness, coat_roughness, scatter_reflect ); + + layers[1].layer += tmpShadowTerm * microfacetBSDF( layers[1].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, ftmp0, ftmp1, scatter_reflect ); + + layers[2].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[2].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp7, lightDir, viewDir, lightDiffuse, 0.000000 ); + +#endif +} + +void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[0].tanFrame, varWorldPos, lightIdx, viewDir, coat_roughness, coat_roughness ); + + layers[1].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[1].tanFrame, varWorldPos, lightIdx, viewDir, ftmp0, ftmp1 ); + + layers[2].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[2].layer += tmpShadowTerm * lightDiffuse * sampleAreaDiffuse( layers[2].tanFrame, varWorldPos, lightIdx ); + +#endif +} + +void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFactor ) +{ +#if !QT3DS_ENABLE_LIGHT_PROBE + layers[0].layer += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, coat_roughness, coat_roughness, scatter_reflect ); + + layers[1].layer += tmpShadowTerm * microfacetSampledBSDF( layers[1].tanFrame, viewDir, ftmp0, ftmp1, scatter_reflect ); + + layers[2].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[2].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( tmp7, 0.000000 ) * aoFactor; + +#else + layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, coat_roughness, coat_roughness ); + + layers[1].layer += tmpShadowTerm * sampleGlossyAniso( layers[1].tanFrame, viewDir, ftmp0, ftmp1 ); + + layers[2].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[2].layer += tmpShadowTerm * sampleDiffuse( layers[2].tanFrame ) * aoFactor; + +#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( normal ); +} + +void computeTemporaries() +{ + tmp3 = textureCoordinateInfo( texCoord0, tangent, binormal ); + tmp4 = transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), vec3( texture_tiling[0], texture_tiling[1], 1.000000 ) ), tmp3 ); + tmp5 = anisotropyConversion( base_roughness, anisotropy, fileTexture(anisotropy_rotation_texture, vec3( 0, 0, 0 ), vec3( 3.14, 3.14, 3.14 ), mono_luminance, tmp4, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_linear ).mono, tangent, false ); + tmp7 = fileBumpTexture(bump_texture, bump_amount, mono_average, tmp4, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, normal ); + ftmp0 = tmp5.roughness_u; + ftmp1 = tmp5.roughness_v; + ftmp2 = fileTexture(reflect_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_luminance, tmp4, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_linear ).tint; + ftmp3 = tmp5.tangent_u; + ftmp4 = fileTexture(diffuse_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_luminance, tmp4, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_srgb ).tint; + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = weightedLayer( 1.000000, vec4( ftmp4, 1.0).rgb, layers[2].layer, layers[2].base, alpha ); + color = fresnelLayer( tmp7, vec3( base_ior ), base_weight, vec4( ftmp2, 1.0).rgb, layers[1].layer, color, color.a ); + color = fresnelLayer( normal, vec3( coat_ior ), coat_weight, vec4( vec3( 1, 1, 1 ), 1.0).rgb, layers[0].layer, color, color.a ); + 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 ) ); + layers[1].base = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].layer = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].tanFrame = orthoNormalize( mat3( ftmp3, cross(tmp7, ftmp3), tmp7 ) ); + layers[2].base = vec4(0.0, 0.0, 0.0, 1.0); + layers[2].layer = vec4(0.0, 0.0, 0.0, 1.0); + layers[2].tanFrame = orthoNormalize( mat3( tangent, cross(tmp7, tangent), tmp7 ) ); +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="5"/> + <LayerKey count="3"/> + <Pass > + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/carpaint_blue_standard.shader b/Studio/Content/Material Library/carpaint_blue_standard.shader new file mode 100644 index 0000000..b28a814 --- /dev/null +++ b/Studio/Content/Material Library/carpaint_blue_standard.shader @@ -0,0 +1,231 @@ +<Material name="carpaint_blue_standard" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Gradient1D Map" description="Gradient texture of the material" hidden="True" name="randomGradient1D" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="gradient" default="./maps/materials/randomGradient1D.png"/> + <Property formalName="Gradient2D Map" description="Gradient texture of the material" hidden="True" name="randomGradient2D" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="gradient" default="./maps/materials/randomGradient2D.png"/> + <Property formalName="Gradient3D Map" description="Gradient texture of the material" hidden="True" name="randomGradient3D" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="gradient" default="./maps/materials/randomGradient3D.png"/> + <Property formalName="Gradient4D Map" description="Gradient texture of the material" hidden="True" name="randomGradient4D" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="gradient" default="./maps/materials/randomGradient4D.png"/> + <Property formalName="Unit Conversion Factor" name="unit_conversion" description="Unit conversion factor" type="Float" default="1.000000" category="Other"/> + <Property formalName="Normal Base Color" name="normal_base_color" description="Base color of the material" type="Color" default="0.0427 0.1538 0.353" category="Material"/> + <Property formalName="Grazing Base Color" name="grazing_base_color" description="Grazing base color of the material" type="Color" default="0.0021 0.0074 0.017" category="Material"/> + <Property formalName="Orange Peel Amount" name="peel_amount" description="Orange peel bumpiness of the material" type="Float" default="0.100000" category="Material"/> + <Property formalName="Orange Peel Size" name="peel_size" description="Orange peel bump size" type="Float" default="0.100000" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// 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 layer_result +{ + vec4 base; + vec4 layer; + mat3 tanFrame; +}; + + +struct texture_coordinate_info +{ + vec3 position; + vec3 tangent_u; + vec3 tangent_v; +}; + + +struct texture_return +{ + vec3 tint; + float mono; +}; + + +// temporary declarations +texture_coordinate_info tmp2; +vec3 ftmp0; +float ftmp1; + vec4 tmpShadowTerm; + +layer_result layers[2]; + +#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 "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 "weightedLayer.glsllib" +#include "miNoise.glsllib" +#include "flakeNoiseTexture.glsllib" +#include "directionalFactor.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].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, 0.000000, 0.000000, scatter_reflect ); + + layers[1].base += tmpShadowTerm * directionalFactor( normal, viewDir, normal_base_color.rgb, grazing_base_color.rgb, 5.000000, diffuseReflectionBSDF( normal, lightDir, viewDir, lightDiffuse, 0.000000 ) ); + layers[1].layer += tmpShadowTerm * microfacetBSDF( layers[1].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, 0.200000, 0.200000, scatter_reflect ); + +#endif +} + +void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[0].tanFrame, varWorldPos, lightIdx, viewDir, 0.000000, 0.000000 ); + + layers[1].base += tmpShadowTerm * directionalFactor( normal, viewDir, normal_base_color.rgb, grazing_base_color.rgb, 5.000000, lightDiffuse * sampleAreaDiffuse( layers[1].tanFrame, varWorldPos, lightIdx ) ); + layers[1].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[1].tanFrame, varWorldPos, lightIdx, viewDir, 0.200000, 0.200000 ); + +#endif +} + +void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFactor ) +{ +#if !QT3DS_ENABLE_LIGHT_PROBE + layers[0].layer += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, 0.000000, 0.000000, scatter_reflect ); + + layers[1].base += tmpShadowTerm * directionalFactor( normal, viewDir, normal_base_color.rgb, grazing_base_color.rgb, 5.000000, diffuseReflectionBSDFEnvironment( normal, 0.000000 ) * aoFactor ); + layers[1].layer += tmpShadowTerm * microfacetSampledBSDF( layers[1].tanFrame, viewDir, 0.200000, 0.200000, scatter_reflect ); + +#else + layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, 0.000000, 0.000000 ); + + layers[1].base += tmpShadowTerm * directionalFactor( normal, viewDir, normal_base_color.rgb, grazing_base_color.rgb, 5.000000, sampleDiffuse( layers[1].tanFrame ) * aoFactor ); + layers[1].layer += tmpShadowTerm * sampleGlossyAniso( layers[1].tanFrame, viewDir, 0.200000, 0.200000 ); + +#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( normal ); +} + +void computeTemporaries() +{ + tmp2 = coordinateSource(texture_coordinate_object, 0 ); + ftmp0 = perlinNoiseBumpTexture( tmp2, ( peel_amount/10.000000 ), ( peel_size*unit_conversion ), false, false, 0.000000, 1, false, vec3( 0.000000, 0.000000, 0.000000 ), 1.000000, 0.000000, 1.000000, normal ); + ftmp1 = flakeNoiseTexture(tmp2, 0.000000, ( unit_conversion*0.002000 ), 0.350000 ).mono; + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = weightedLayer( ftmp1, vec4( vec3( 1, 0.117, 0.087 ), 1.0).rgb, layers[1].layer, layers[1].base * vec4( vec3( 1, 1, 1 ), 1.0), alpha ); + color = fresnelLayer( ftmp0, vec3( 1.5, 1.5, 1.5 ), 1.000000, vec4( vec3( 1, 1, 1 ), 1.0).rgb, layers[0].layer, color, color.a ); + 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(ftmp0, tangent), ftmp0 ) ); + layers[1].base = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].layer = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].tanFrame = orthoNormalize( mat3( tangent, cross(normal, tangent), normal ) ); +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="5"/> + <LayerKey count="2"/> + <Pass > + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/carpaint_color_peel_2_layer.shader b/Studio/Content/Material Library/carpaint_color_peel_2_layer.shader new file mode 100644 index 0000000..c435306 --- /dev/null +++ b/Studio/Content/Material Library/carpaint_color_peel_2_layer.shader @@ -0,0 +1,255 @@ +<Material name="carpaint_color_peel_2_layer" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Gradient1D Map" description="Gradient texture of the material" hidden="True" name="randomGradient1D" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="gradient" default="./maps/materials/randomGradient1D.png"/> + <Property formalName="Gradient2D Map" description="Gradient texture of the material" hidden="True" name="randomGradient2D" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="gradient" default="./maps/materials/randomGradient2D.png"/> + <Property formalName="Gradient3D Map" description="Gradient texture of the material" hidden="True" name="randomGradient3D" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="gradient" default="./maps/materials/randomGradient3D.png"/> + <Property formalName="Gradient4D Map" description="Gradient texture of the material" hidden="True" name="randomGradient4D" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="gradient" default="./maps/materials/randomGradient4D.png"/> + <Property formalName="Coat Index of refraction" name="coating_ior" description="Index of refraction of the coat" type="Float" default="1.500000" category="Top coat"/> + <Property formalName="Coat Weight" name="coat_weight" description="Weight of the coat" type="Float" default="1.000000" category="Top coat"/> + <Property formalName="Coat Micro roughness" name="coat_roughness" description="Micro roughness of the coat" type="Float" default="0.000000" category="Top coat"/> + <Property formalName="Coat Color" name="coat_color" description="Base color of the coat" type="Color" default="1 1 1" category="Top coat"/> + <Property formalName="Flake Weight" name="flake_intensity" description="Intensity of the flakes" type="Float" default="0.500000" category="Flake layer"/> + <Property formalName="Flake size" name="flake_size" description="Size of the flakes" type="Float" default="0.002000" category="Flake layer"/> + <Property formalName="Flake amount" name="flake_amount" description="Amount of flakes" type="Float" default="0.220000" category="Flake layer"/> + <Property formalName="Flake Micro roughness" name="flake_roughness" description="Micro roughness of the flakes" type="Float" default="0.200000" category="Flake layer"/> + <Property formalName="Flake Color" name="flake_color" type="Color" description="Base color of the flakes" default="1 0.7 0.02" category="Flake layer"/> + <Property formalName="Base Color" name="base_color" type="Color" description="Base color of the material" default="0.1 0.001 0.001" category="Base paint"/> + <Property formalName="Flake Macro roughness" name="flake_bumpiness" description="Bumpiness of the flakes" type="Float" default="0.600000" category="Flake layer"/> + <Property formalName="Orange Peel Size" name="peel_size" description="Orange peel bump size" type="Float" default="1.000000" category="Top coat"/> + <Property formalName="Orange Peel Amount" name="peel_amount" description="Orange peel amount" type="Float" default="0.010000" category="Top coat"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// 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 layer_result +{ + vec4 base; + vec4 layer; + mat3 tanFrame; +}; + + +struct texture_coordinate_info +{ + vec3 position; + vec3 tangent_u; + vec3 tangent_v; +}; + + +struct texture_return +{ + vec3 tint; + float mono; +}; + + +// temporary declarations +texture_coordinate_info tmp2; +vec3 ftmp0; +vec3 ftmp1; +float ftmp2; +float ftmp3; + vec4 tmpShadowTerm; + +layer_result layers[3]; + +#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 "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 "weightedLayer.glsllib" +#include "miNoise.glsllib" +#include "flakeNoiseBumpTexture.glsllib" +#include "flakeNoiseTexture.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].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, coat_roughness, coat_roughness, scatter_reflect ); + + layers[1].layer += tmpShadowTerm * microfacetBSDF( layers[1].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, flake_roughness, flake_roughness, scatter_reflect ); + + layers[2].base += tmpShadowTerm * diffuseReflectionBSDF( normal, lightDir, viewDir, lightDiffuse, 0.000000 ); + layers[2].layer += tmpShadowTerm * microfacetBSDF( layers[2].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, 0.300000, 0.300000, scatter_reflect ); + +#endif +} + +void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[0].tanFrame, varWorldPos, lightIdx, viewDir, coat_roughness, coat_roughness ); + + layers[1].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[1].tanFrame, varWorldPos, lightIdx, viewDir, flake_roughness, flake_roughness ); + + layers[2].base += tmpShadowTerm * lightDiffuse * sampleAreaDiffuse( layers[2].tanFrame, varWorldPos, lightIdx ); + layers[2].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[2].tanFrame, varWorldPos, lightIdx, viewDir, 0.300000, 0.300000 ); + +#endif +} + +void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFactor ) +{ +#if !QT3DS_ENABLE_LIGHT_PROBE + layers[0].layer += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, coat_roughness, coat_roughness, scatter_reflect ); + + layers[1].layer += tmpShadowTerm * microfacetSampledBSDF( layers[1].tanFrame, viewDir, flake_roughness, flake_roughness, scatter_reflect ); + + layers[2].base += tmpShadowTerm * diffuseReflectionBSDFEnvironment( normal, 0.000000 ) * aoFactor; + layers[2].layer += tmpShadowTerm * microfacetSampledBSDF( layers[2].tanFrame, viewDir, 0.300000, 0.300000, scatter_reflect ); + +#else + layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, coat_roughness, coat_roughness ); + + layers[1].layer += tmpShadowTerm * sampleGlossyAniso( layers[1].tanFrame, viewDir, flake_roughness, flake_roughness ); + + layers[2].base += tmpShadowTerm * sampleDiffuse( layers[2].tanFrame ) * aoFactor; + layers[2].layer += tmpShadowTerm * sampleGlossyAniso( layers[2].tanFrame, viewDir, 0.300000, 0.300000 ); + +#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.0f : luminance( vec3( 1, 1, 1 ) ) ); +} + +float evalCutout() +{ + return( 1.000000 ); +} + +vec3 computeNormal() +{ + return( normal ); +} + +void computeTemporaries() +{ + tmp2 = coordinateSource(texture_coordinate_object, 0 ); + ftmp0 = perlinNoiseBumpTexture( tmp2, peel_amount, peel_size, false, false, 0.000000, 1, false, vec3( 0.000000, 0.000000, 0.000000 ), 1.000000, 0.000000, 1.000000, normal ); + ftmp1 = flakeNoiseBumpTexture(tmp2, flake_size, flake_bumpiness, normal ); + ftmp2 = flakeNoiseTexture(tmp2, flake_intensity, flake_size, flake_amount ).mono; + ftmp3 = flakeNoiseTexture(tmp2, 0.000000, 0.002200, 1.000000 ).mono; + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = weightedLayer( ftmp3, vec4( vec3( 1, 0.01, 0.01 ), 1.0).rgb, layers[2].layer, layers[2].base * vec4( base_color.rgb, 1.0), alpha ); + color = weightedLayer( ftmp2, flake_color.rgb, layers[1].layer, color, color.a ); + color = fresnelLayer( ftmp0, vec3( coating_ior ), coat_weight, coat_color.rgb, layers[0].layer, color, color.a ); + 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(ftmp0, tangent), ftmp0 ) ); + layers[1].base = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].layer = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].tanFrame = orthoNormalize( mat3( tangent, cross(ftmp1, tangent), ftmp1 ) ); + layers[2].base = vec4(0.0, 0.0, 0.0, 1.0); + layers[2].layer = vec4(0.0, 0.0, 0.0, 1.0); + layers[2].tanFrame = orthoNormalize( mat3( tangent, cross(normal, tangent), normal ) ); +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="5"/> + <LayerKey count="3"/> + <Pass > + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/carpaint_yellow_standard.shader b/Studio/Content/Material Library/carpaint_yellow_standard.shader new file mode 100644 index 0000000..7e79511 --- /dev/null +++ b/Studio/Content/Material Library/carpaint_yellow_standard.shader @@ -0,0 +1,231 @@ +<Material name="carpaint_yellow_standard" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Gradient1D Map" description="Gradient texture of the material" hidden="True" name="randomGradient1D" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="gradient" default="./maps/materials/randomGradient1D.png"/> + <Property formalName="Gradient2D Map" description="Gradient texture of the material" hidden="True" name="randomGradient2D" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="gradient" default="./maps/materials/randomGradient2D.png"/> + <Property formalName="Gradient3D Map" description="Gradient texture of the material" hidden="True" name="randomGradient3D" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="gradient" default="./maps/materials/randomGradient3D.png"/> + <Property formalName="Gradient4D Map" description="Gradient texture of the material" hidden="True" name="randomGradient4D" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="gradient" default="./maps/materials/randomGradient4D.png"/> + <Property formalName="Unit Conversion Factor" name="unit_conversion" description="Unit conversion factor" type="Float" default="1.000000" category="Other"/> + <Property formalName="Normal Base Color" name="normal_base_color" description="Base color of the material" type="Color" default="0.659 0.4261 0.0494" category="Material"/> + <Property formalName="Grazing Base Color" name="grazing_base_color" description="Grazing base color of the material" type="Color" default="0.393 0.2654 0.0549" category="Material"/> + <Property formalName="Orange Peel Amount" name="peel_amount" description="Orange peel bumpiness of the material" type="Float" default="0.100000" category="Material"/> + <Property formalName="Orange Peel Size" name="peel_size" description="Orange peel bump size" type="Float" default="0.100000" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// 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 layer_result +{ + vec4 base; + vec4 layer; + mat3 tanFrame; +}; + + +struct texture_coordinate_info +{ + vec3 position; + vec3 tangent_u; + vec3 tangent_v; +}; + + +struct texture_return +{ + vec3 tint; + float mono; +}; + + +// temporary declarations +texture_coordinate_info tmp2; +vec3 ftmp0; +float ftmp1; + vec4 tmpShadowTerm; + +layer_result layers[2]; + +#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 "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 "weightedLayer.glsllib" +#include "miNoise.glsllib" +#include "flakeNoiseTexture.glsllib" +#include "directionalFactor.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].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, 0.000000, 0.000000, scatter_reflect ); + + layers[1].base += tmpShadowTerm * directionalFactor( normal, viewDir, normal_base_color.rgb, grazing_base_color.rgb, 5.000000, diffuseReflectionBSDF( normal, lightDir, viewDir, lightDiffuse, 0.000000 ) ); + layers[1].layer += tmpShadowTerm * microfacetBSDF( layers[1].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, 0.200000, 0.200000, scatter_reflect ); + +#endif +} + +void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[0].tanFrame, varWorldPos, lightIdx, viewDir, 0.000000, 0.000000 ); + + layers[1].base += tmpShadowTerm * directionalFactor( normal, viewDir, normal_base_color.rgb, grazing_base_color.rgb, 5.000000, lightDiffuse * sampleAreaDiffuse( layers[1].tanFrame, varWorldPos, lightIdx ) ); + layers[1].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[1].tanFrame, varWorldPos, lightIdx, viewDir, 0.200000, 0.200000 ); + +#endif +} + +void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFactor ) +{ +#if !QT3DS_ENABLE_LIGHT_PROBE + layers[0].layer += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, 0.000000, 0.000000, scatter_reflect ); + + layers[1].base += tmpShadowTerm * directionalFactor( normal, viewDir, normal_base_color.rgb, grazing_base_color.rgb, 5.000000, diffuseReflectionBSDFEnvironment( normal, 0.000000 ) * aoFactor ); + layers[1].layer += tmpShadowTerm * microfacetSampledBSDF( layers[1].tanFrame, viewDir, 0.200000, 0.200000, scatter_reflect ); + +#else + layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, 0.000000, 0.000000 ); + + layers[1].base += tmpShadowTerm * directionalFactor( normal, viewDir, normal_base_color.rgb, grazing_base_color.rgb, 5.000000, sampleDiffuse( layers[1].tanFrame ) * aoFactor ); + layers[1].layer += tmpShadowTerm * sampleGlossyAniso( layers[1].tanFrame, viewDir, 0.200000, 0.200000 ); + +#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( normal ); +} + +void computeTemporaries() +{ + tmp2 = coordinateSource(texture_coordinate_object, 0 ); + ftmp0 = perlinNoiseBumpTexture( tmp2, ( peel_amount/10.000000 ), ( peel_size*unit_conversion ), false, false, 0.000000, 1, false, vec3( 0.000000, 0.000000, 0.000000 ), 1.000000, 0.000000, 1.000000, normal ); + ftmp1 = flakeNoiseTexture(tmp2, 0.000000, ( unit_conversion*0.002000 ), 0.350000 ).mono; + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = weightedLayer( ftmp1, vec4( vec3( 1, 0.117, 0.087 ), 1.0).rgb, layers[1].layer, layers[1].base * vec4( vec3( 1, 1, 1 ), 1.0), alpha ); + color = fresnelLayer( ftmp0, vec3( 1.5, 1.5, 1.5 ), 1.000000, vec4( vec3( 1, 1, 1 ), 1.0).rgb, layers[0].layer, color, color.a ); + 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(ftmp0, tangent), ftmp0 ) ); + layers[1].base = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].layer = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].tanFrame = orthoNormalize( mat3( tangent, cross(normal, tangent), normal ) ); +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="5"/> + <LayerKey count="2"/> + <Pass > + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/concrete.shader b/Studio/Content/Material Library/concrete.shader new file mode 100644 index 0000000..1bcdadc --- /dev/null +++ b/Studio/Content/Material Library/concrete.shader @@ -0,0 +1,235 @@ +<Material name="concrete" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Index of Refraction" name="material_ior" type="Float" default="1.500000" description="Index of refraction of the material" category="Material"/> + <Property formalName="Roughness" name="roughness" type="Float" min="0.000000" max="1.000000" default="0.350000" description="Roughness of the material.\n0 = fully specular\n1 = fully diffuse" category="Material"/> + <Property formalName="Bump Map" name="bump_texture" description="Bump texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="bump" default="./maps/materials/concrete_plain_bump.png" category="Material"/> + <Property formalName="Tiling" name="texture_tiling" type="Float2" default="5 2" description="Scaling of the textures" category="Material"/> + <Property formalName="Diffuse Map" name="diffuse_texture" description="Diffuse texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="diffuse" default="./maps/materials/concrete_plain.png" category="Material"/> + <Property formalName="Bump Amount" name="bump_amount" type="Float" default="6.000000" description="Value determining the bumpiness" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#define mono_alpha 0 +#define mono_average 1 +#define mono_luminance 2 +#define mono_maximum 3 +#define wrap_clamp 0 +#define wrap_repeat 1 +#define wrap_mirrored_repeat 2 +#define gamma_default 0 +#define gamma_linear 1 +#define gamma_srgb 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 layer_result +{ + vec4 base; + vec4 layer; + mat3 tanFrame; +}; + + +struct texture_coordinate_info +{ + vec3 position; + vec3 tangent_u; + vec3 tangent_v; +}; + + +struct texture_return +{ + vec3 tint; + float mono; +}; + + +// temporary declarations +texture_coordinate_info tmp3; +vec3 tmp6; +vec3 ftmp0; +vec3 ftmp1; + vec4 tmpShadowTerm; + +layer_result layers[2]; + +#include "SSAOCustomMaterial.glsllib" +#include "sampleLight.glsllib" +#include "sampleProbe.glsllib" +#include "sampleArea.glsllib" +#include "luminance.glsllib" +#include "monoChannel.glsllib" +#include "fileBumpTexture.glsllib" +#include "transformCoordinate.glsllib" +#include "rotationTranslationScale.glsllib" +#include "textureCoordinateInfo.glsllib" +#include "square.glsllib" +#include "calculateRoughness.glsllib" +#include "evalBakedShadowMap.glsllib" +#include "evalEnvironmentMap.glsllib" +#include "microfacetBSDF.glsllib" +#include "physGlossyBSDF.glsllib" +#include "simpleGlossyBSDF.glsllib" +#include "fileTexture.glsllib" +#include "weightedLayer.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].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp6, lightDir, viewDir, lightDiffuse, 0.000000 ); + +#endif +} + +void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[0].tanFrame, varWorldPos, lightIdx, viewDir, roughness, roughness ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * lightDiffuse * sampleAreaDiffuse( layers[1].tanFrame, varWorldPos, lightIdx ); + +#endif +} + +void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFactor ) +{ +#if !QT3DS_ENABLE_LIGHT_PROBE + layers[0].layer += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, roughness, roughness, scatter_reflect ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( tmp6, 0.000000 ) * aoFactor; + +#else + layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * sampleDiffuse( layers[1].tanFrame ) * aoFactor; + +#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( normal ); +} + +void computeTemporaries() +{ + tmp3 = transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), vec3( texture_tiling[0], texture_tiling[1], 1.000000 ) ), textureCoordinateInfo( texCoord0, tangent, binormal ) ); + tmp6 = fileBumpTexture(bump_texture, bump_amount, mono_average, tmp3, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, normal ); + ftmp0 = fileTexture(bump_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_luminance, tmp3, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_linear ).tint; + ftmp1 = fileTexture(diffuse_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_luminance, tmp3, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_srgb ).tint; + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = weightedLayer( 1.000000, vec4( ftmp1, 1.0).rgb, layers[1].layer, layers[1].base, alpha ); + color = fresnelLayer( tmp6, vec3( material_ior ), 1.000000, vec4( ftmp0, 1.0).rgb, layers[0].layer, color, color.a ); + 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(tmp6, tangent), tmp6 ) ); + layers[1].base = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].layer = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].tanFrame = orthoNormalize( mat3( tangent, cross(tmp6, tangent), tmp6 ) ); +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="5"/> + <LayerKey count="2"/> + <Pass > + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/copper.shader b/Studio/Content/Material Library/copper.shader new file mode 100644 index 0000000..cf9e1ad --- /dev/null +++ b/Studio/Content/Material Library/copper.shader @@ -0,0 +1,178 @@ +<Material name="copper" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Roughness" name="roughness" type="Float" min="0.000000" max="1.000000" default="0.000000" description="Roughness of the material.\n0 = fully specular\n1 = fully diffuse" category="Material"/> + <Property formalName="Metal Color" name="metal_color" type="Color" default="0.805 0.395 0.305" description="Color of the material" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#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 0 + +#include "vertexFragmentBase.glsllib" + +// set shader output +out vec4 fragColor; + +// add structure defines +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 "square.glsllib" +#include "calculateRoughness.glsllib" +#include "evalBakedShadowMap.glsllib" +#include "evalEnvironmentMap.glsllib" +#include "luminance.glsllib" +#include "microfacetBSDF.glsllib" +#include "physGlossyBSDF.glsllib" +#include "simpleGlossyBSDF.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 * vec4( 0.0, 0.0, 0.0, 1.0 ); + 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 * vec4( 0.0, 0.0, 0.0, 1.0 ); + 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 * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[0].layer += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, roughness, roughness, scatter_reflect ); + +#else + layers[0].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + 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( normal ); +} + +void computeTemporaries() +{ + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = fresnelLayer( normal, vec3( 25.65, 25.65, 25.65 ), 1.000000, metal_color.rgb, layers[0].layer, layers[0].base, 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 ) ); +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="4"/> + <LayerKey count="1"/> + <Pass > + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/leather_smoothed_black.shader b/Studio/Content/Material Library/leather_smoothed_black.shader new file mode 100644 index 0000000..8d45669 --- /dev/null +++ b/Studio/Content/Material Library/leather_smoothed_black.shader @@ -0,0 +1,236 @@ +<Material name="leather_smoothed_black" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Index of Refraction" name="material_ior" type="Float" default="1.400000" description="Index of refraction of the material" category="Material"/> + <Property formalName="Roughness" name="roughness" type="Float" min="0.000000" max="1.000000" default="0.300000" description="Roughness of the material.\n0 = fully specular\n1 = fully diffuse" category="Material"/> + <Property formalName="Reflectivity Map" name="reflect_texture" description="Reflectivity texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="specular" default="./maps/materials/smooth_black_leather_spec.png" category="Material"/> + <Property formalName="Tiling" name="texture_tiling" type="Float2" default="4 4" description="Scaling of the textures" category="Material"/> + <Property formalName="Diffuse Map" name="diffuse_texture" description="Diffuse texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="diffuse" default="./maps/materials/smooth_black_leather.png" category="Material"/> + <Property formalName="Bump Map" name="bump_texture" description="Bump texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="bump" default="./maps/materials/smooth_black_leather_bump.png" category="Material"/> + <Property formalName="Bump Amount" name="bump_amount" type="Float" default="2.000000" description="Value determining the bumpiness" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#define mono_alpha 0 +#define mono_average 1 +#define mono_luminance 2 +#define mono_maximum 3 +#define wrap_clamp 0 +#define wrap_repeat 1 +#define wrap_mirrored_repeat 2 +#define gamma_default 0 +#define gamma_linear 1 +#define gamma_srgb 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 layer_result +{ + vec4 base; + vec4 layer; + mat3 tanFrame; +}; + + +struct texture_coordinate_info +{ + vec3 position; + vec3 tangent_u; + vec3 tangent_v; +}; + + +struct texture_return +{ + vec3 tint; + float mono; +}; + + +// temporary declarations +texture_coordinate_info tmp2; +vec3 tmp5; +vec3 ftmp0; +vec3 ftmp1; + vec4 tmpShadowTerm; + +layer_result layers[2]; + +#include "SSAOCustomMaterial.glsllib" +#include "sampleLight.glsllib" +#include "sampleProbe.glsllib" +#include "sampleArea.glsllib" +#include "luminance.glsllib" +#include "monoChannel.glsllib" +#include "fileBumpTexture.glsllib" +#include "transformCoordinate.glsllib" +#include "rotationTranslationScale.glsllib" +#include "textureCoordinateInfo.glsllib" +#include "square.glsllib" +#include "calculateRoughness.glsllib" +#include "evalBakedShadowMap.glsllib" +#include "evalEnvironmentMap.glsllib" +#include "microfacetBSDF.glsllib" +#include "physGlossyBSDF.glsllib" +#include "simpleGlossyBSDF.glsllib" +#include "fileTexture.glsllib" +#include "weightedLayer.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].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp5, lightDir, viewDir, lightDiffuse, 0.000000 ); + +#endif +} + +void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[0].tanFrame, varWorldPos, lightIdx, viewDir, roughness, roughness ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * lightDiffuse * sampleAreaDiffuse( layers[1].tanFrame, varWorldPos, lightIdx ); + +#endif +} + +void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFactor ) +{ +#if !QT3DS_ENABLE_LIGHT_PROBE + layers[0].layer += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, roughness, roughness, scatter_reflect ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( tmp5, 0.000000 ) * aoFactor; + +#else + layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * sampleDiffuse( layers[1].tanFrame ) * aoFactor; + +#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( normal ); +} + +void computeTemporaries() +{ + tmp2 = transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), vec3( texture_tiling[0], texture_tiling[1], 1.000000 ) ), textureCoordinateInfo( texCoord0, tangent, binormal ) ); + tmp5 = fileBumpTexture(bump_texture, bump_amount, mono_average, tmp2, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, normal ); + ftmp0 = fileTexture(reflect_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_luminance, tmp2, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_linear ).tint; + ftmp1 = fileTexture(diffuse_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_luminance, tmp2, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_srgb ).tint; + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = weightedLayer( 1.000000, vec4( ftmp1, 1.0).rgb, layers[1].layer, layers[1].base, alpha ); + color = fresnelLayer( tmp5, vec3( material_ior ), 1.000000, vec4( ftmp0, 1.0).rgb, layers[0].layer, color, color.a ); + 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(tmp5, tangent), tmp5 ) ); + layers[1].base = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].layer = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].tanFrame = orthoNormalize( mat3( tangent, cross(tmp5, tangent), tmp5 ) ); +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="5"/> + <LayerKey count="2"/> + <Pass > + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/maps/materials/art_paper_normal.png b/Studio/Content/Material Library/maps/materials/art_paper_normal.png Binary files differnew file mode 100644 index 0000000..7a26860 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/art_paper_normal.png diff --git a/Studio/Content/Material Library/maps/materials/art_paper_trans.png b/Studio/Content/Material Library/maps/materials/art_paper_trans.png Binary files differnew file mode 100644 index 0000000..8465c27 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/art_paper_trans.png diff --git a/Studio/Content/Material Library/maps/materials/asphalt.png b/Studio/Content/Material Library/maps/materials/asphalt.png Binary files differnew file mode 100644 index 0000000..f04e623 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/asphalt.png diff --git a/Studio/Content/Material Library/maps/materials/asphalt_bump.png b/Studio/Content/Material Library/maps/materials/asphalt_bump.png Binary files differnew file mode 100644 index 0000000..002ba88 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/asphalt_bump.png diff --git a/Studio/Content/Material Library/maps/materials/bamboo_natural.png b/Studio/Content/Material Library/maps/materials/bamboo_natural.png Binary files differnew file mode 100644 index 0000000..1e35a39 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/bamboo_natural.png diff --git a/Studio/Content/Material Library/maps/materials/bamboo_natural_bump.png b/Studio/Content/Material Library/maps/materials/bamboo_natural_bump.png Binary files differnew file mode 100644 index 0000000..07e813a --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/bamboo_natural_bump.png diff --git a/Studio/Content/Material Library/maps/materials/bamboo_natural_spec.png b/Studio/Content/Material Library/maps/materials/bamboo_natural_spec.png Binary files differnew file mode 100644 index 0000000..b139113 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/bamboo_natural_spec.png diff --git a/Studio/Content/Material Library/maps/materials/brushed_a.png b/Studio/Content/Material Library/maps/materials/brushed_a.png Binary files differnew file mode 100644 index 0000000..c0602ca --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/brushed_a.png diff --git a/Studio/Content/Material Library/maps/materials/brushed_a_full_contrast_scratched.png b/Studio/Content/Material Library/maps/materials/brushed_a_full_contrast_scratched.png Binary files differnew file mode 100644 index 0000000..93c9ab8 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/brushed_a_full_contrast_scratched.png diff --git a/Studio/Content/Material Library/maps/materials/brushed_a_scratched_50_percent.png b/Studio/Content/Material Library/maps/materials/brushed_a_scratched_50_percent.png Binary files differnew file mode 100644 index 0000000..f132e25 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/brushed_a_scratched_50_percent.png diff --git a/Studio/Content/Material Library/maps/materials/brushed_chrome.png b/Studio/Content/Material Library/maps/materials/brushed_chrome.png Binary files differnew file mode 100644 index 0000000..d262e81 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/brushed_chrome.png diff --git a/Studio/Content/Material Library/maps/materials/brushed_chrome_spec.png b/Studio/Content/Material Library/maps/materials/brushed_chrome_spec.png Binary files differnew file mode 100644 index 0000000..93fca97 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/brushed_chrome_spec.png diff --git a/Studio/Content/Material Library/maps/materials/brushed_full_contrast.png b/Studio/Content/Material Library/maps/materials/brushed_full_contrast.png Binary files differnew file mode 100644 index 0000000..a7864fe --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/brushed_full_contrast.png diff --git a/Studio/Content/Material Library/maps/materials/brushed_full_contrast_inverted.png b/Studio/Content/Material Library/maps/materials/brushed_full_contrast_inverted.png Binary files differnew file mode 100644 index 0000000..928a0d6 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/brushed_full_contrast_inverted.png diff --git a/Studio/Content/Material Library/maps/materials/bubinga.png b/Studio/Content/Material Library/maps/materials/bubinga.png Binary files differnew file mode 100644 index 0000000..59d65d2 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/bubinga.png diff --git a/Studio/Content/Material Library/maps/materials/bubinga_bump.png b/Studio/Content/Material Library/maps/materials/bubinga_bump.png Binary files differnew file mode 100644 index 0000000..cdb722c --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/bubinga_bump.png diff --git a/Studio/Content/Material Library/maps/materials/bubinga_spec.png b/Studio/Content/Material Library/maps/materials/bubinga_spec.png Binary files differnew file mode 100644 index 0000000..ebc7d65 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/bubinga_spec.png diff --git a/Studio/Content/Material Library/maps/materials/carbon_fiber.png b/Studio/Content/Material Library/maps/materials/carbon_fiber.png Binary files differnew file mode 100644 index 0000000..69e2ba5 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/carbon_fiber.png diff --git a/Studio/Content/Material Library/maps/materials/carbon_fiber_aniso.png b/Studio/Content/Material Library/maps/materials/carbon_fiber_aniso.png Binary files differnew file mode 100644 index 0000000..8bd7a30 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/carbon_fiber_aniso.png diff --git a/Studio/Content/Material Library/maps/materials/carbon_fiber_bump.png b/Studio/Content/Material Library/maps/materials/carbon_fiber_bump.png Binary files differnew file mode 100644 index 0000000..e1cca48 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/carbon_fiber_bump.png diff --git a/Studio/Content/Material Library/maps/materials/carbon_fiber_spec.png b/Studio/Content/Material Library/maps/materials/carbon_fiber_spec.png Binary files differnew file mode 100644 index 0000000..5c50a00 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/carbon_fiber_spec.png diff --git a/Studio/Content/Material Library/maps/materials/concentric_milled_steel.png b/Studio/Content/Material Library/maps/materials/concentric_milled_steel.png Binary files differnew file mode 100644 index 0000000..56101f2 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/concentric_milled_steel.png diff --git a/Studio/Content/Material Library/maps/materials/concentric_milled_steel_aniso.png b/Studio/Content/Material Library/maps/materials/concentric_milled_steel_aniso.png Binary files differnew file mode 100644 index 0000000..f6071d9 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/concentric_milled_steel_aniso.png diff --git a/Studio/Content/Material Library/maps/materials/concrete_plain.png b/Studio/Content/Material Library/maps/materials/concrete_plain.png Binary files differnew file mode 100644 index 0000000..fb16072 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/concrete_plain.png diff --git a/Studio/Content/Material Library/maps/materials/concrete_plain_bump.png b/Studio/Content/Material Library/maps/materials/concrete_plain_bump.png Binary files differnew file mode 100644 index 0000000..e20f1cd --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/concrete_plain_bump.png diff --git a/Studio/Content/Material Library/maps/materials/cyclone_mesh_fencing.png b/Studio/Content/Material Library/maps/materials/cyclone_mesh_fencing.png Binary files differnew file mode 100644 index 0000000..ab36204 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/cyclone_mesh_fencing.png diff --git a/Studio/Content/Material Library/maps/materials/cyclone_mesh_fencing_normal.png b/Studio/Content/Material Library/maps/materials/cyclone_mesh_fencing_normal.png Binary files differnew file mode 100644 index 0000000..3b96bbf --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/cyclone_mesh_fencing_normal.png diff --git a/Studio/Content/Material Library/maps/materials/emissive.png b/Studio/Content/Material Library/maps/materials/emissive.png Binary files differnew file mode 100644 index 0000000..599b1cc --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/emissive.png diff --git a/Studio/Content/Material Library/maps/materials/emissive_mask.png b/Studio/Content/Material Library/maps/materials/emissive_mask.png Binary files differnew file mode 100644 index 0000000..599b1cc --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/emissive_mask.png diff --git a/Studio/Content/Material Library/maps/materials/gentle_noise.png b/Studio/Content/Material Library/maps/materials/gentle_noise.png Binary files differnew file mode 100644 index 0000000..a163c82 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/gentle_noise.png diff --git a/Studio/Content/Material Library/maps/materials/granite_black.png b/Studio/Content/Material Library/maps/materials/granite_black.png Binary files differnew file mode 100644 index 0000000..629cc91 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/granite_black.png diff --git a/Studio/Content/Material Library/maps/materials/granite_yellow.png b/Studio/Content/Material Library/maps/materials/granite_yellow.png Binary files differnew file mode 100644 index 0000000..cdf8c19 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/granite_yellow.png diff --git a/Studio/Content/Material Library/maps/materials/grunge_b.png b/Studio/Content/Material Library/maps/materials/grunge_b.png Binary files differnew file mode 100644 index 0000000..fa43782 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/grunge_b.png diff --git a/Studio/Content/Material Library/maps/materials/grunge_b1.png b/Studio/Content/Material Library/maps/materials/grunge_b1.png Binary files differnew file mode 100644 index 0000000..c4e4429 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/grunge_b1.png diff --git a/Studio/Content/Material Library/maps/materials/grunge_d.png b/Studio/Content/Material Library/maps/materials/grunge_d.png Binary files differnew file mode 100644 index 0000000..c62a5a0 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/grunge_d.png diff --git a/Studio/Content/Material Library/maps/materials/grunge_texture_01.png b/Studio/Content/Material Library/maps/materials/grunge_texture_01.png Binary files differnew file mode 100644 index 0000000..d256719 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/grunge_texture_01.png diff --git a/Studio/Content/Material Library/maps/materials/mahogany.png b/Studio/Content/Material Library/maps/materials/mahogany.png Binary files differnew file mode 100644 index 0000000..f438a63 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/mahogany.png diff --git a/Studio/Content/Material Library/maps/materials/mahogany_bump.png b/Studio/Content/Material Library/maps/materials/mahogany_bump.png Binary files differnew file mode 100644 index 0000000..3f4f0d0 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/mahogany_bump.png diff --git a/Studio/Content/Material Library/maps/materials/mahogany_floorboards.png b/Studio/Content/Material Library/maps/materials/mahogany_floorboards.png Binary files differnew file mode 100644 index 0000000..c9fc35a --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/mahogany_floorboards.png diff --git a/Studio/Content/Material Library/maps/materials/mahogany_floorboards_bump.png b/Studio/Content/Material Library/maps/materials/mahogany_floorboards_bump.png Binary files differnew file mode 100644 index 0000000..5a54372 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/mahogany_floorboards_bump.png diff --git a/Studio/Content/Material Library/maps/materials/mahogany_floorboards_spec.png b/Studio/Content/Material Library/maps/materials/mahogany_floorboards_spec.png Binary files differnew file mode 100644 index 0000000..0784bb8 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/mahogany_floorboards_spec.png diff --git a/Studio/Content/Material Library/maps/materials/mahogany_spec.png b/Studio/Content/Material Library/maps/materials/mahogany_spec.png Binary files differnew file mode 100644 index 0000000..c82144d --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/mahogany_spec.png diff --git a/Studio/Content/Material Library/maps/materials/metal_mesh.png b/Studio/Content/Material Library/maps/materials/metal_mesh.png Binary files differnew file mode 100644 index 0000000..f722347 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/metal_mesh.png diff --git a/Studio/Content/Material Library/maps/materials/metal_mesh_bump.png b/Studio/Content/Material Library/maps/materials/metal_mesh_bump.png Binary files differnew file mode 100644 index 0000000..756d9c4 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/metal_mesh_bump.png diff --git a/Studio/Content/Material Library/maps/materials/metal_mesh_spec.png b/Studio/Content/Material Library/maps/materials/metal_mesh_spec.png Binary files differnew file mode 100644 index 0000000..7444604 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/metal_mesh_spec.png diff --git a/Studio/Content/Material Library/maps/materials/paper_diffuse.png b/Studio/Content/Material Library/maps/materials/paper_diffuse.png Binary files differnew file mode 100644 index 0000000..3fbd653 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/paper_diffuse.png diff --git a/Studio/Content/Material Library/maps/materials/paper_trans.png b/Studio/Content/Material Library/maps/materials/paper_trans.png Binary files differnew file mode 100644 index 0000000..6bf7c50 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/paper_trans.png diff --git a/Studio/Content/Material Library/maps/materials/powdercoat_bump_01.png b/Studio/Content/Material Library/maps/materials/powdercoat_bump_01.png Binary files differnew file mode 100644 index 0000000..769f549 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/powdercoat_bump_01.png diff --git a/Studio/Content/Material Library/maps/materials/randomGradient1D.png b/Studio/Content/Material Library/maps/materials/randomGradient1D.png Binary files differnew file mode 100644 index 0000000..0d37132 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/randomGradient1D.png diff --git a/Studio/Content/Material Library/maps/materials/randomGradient2D.png b/Studio/Content/Material Library/maps/materials/randomGradient2D.png Binary files differnew file mode 100644 index 0000000..8b60ca6 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/randomGradient2D.png diff --git a/Studio/Content/Material Library/maps/materials/randomGradient3D.png b/Studio/Content/Material Library/maps/materials/randomGradient3D.png Binary files differnew file mode 100644 index 0000000..c22e1ba --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/randomGradient3D.png diff --git a/Studio/Content/Material Library/maps/materials/randomGradient4D.png b/Studio/Content/Material Library/maps/materials/randomGradient4D.png Binary files differnew file mode 100644 index 0000000..ad282d8 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/randomGradient4D.png diff --git a/Studio/Content/Material Library/maps/materials/shadow.png b/Studio/Content/Material Library/maps/materials/shadow.png Binary files differnew file mode 100644 index 0000000..599b1cc --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/shadow.png diff --git a/Studio/Content/Material Library/maps/materials/smooth_black_leather.png b/Studio/Content/Material Library/maps/materials/smooth_black_leather.png Binary files differnew file mode 100644 index 0000000..ce82635 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/smooth_black_leather.png diff --git a/Studio/Content/Material Library/maps/materials/smooth_black_leather_bump.png b/Studio/Content/Material Library/maps/materials/smooth_black_leather_bump.png Binary files differnew file mode 100644 index 0000000..1c71529 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/smooth_black_leather_bump.png diff --git a/Studio/Content/Material Library/maps/materials/smooth_black_leather_spec.png b/Studio/Content/Material Library/maps/materials/smooth_black_leather_spec.png Binary files differnew file mode 100644 index 0000000..7e289c1 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/smooth_black_leather_spec.png diff --git a/Studio/Content/Material Library/maps/materials/spherical_checker.png b/Studio/Content/Material Library/maps/materials/spherical_checker.png Binary files differnew file mode 100644 index 0000000..e42394d --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/spherical_checker.png diff --git a/Studio/Content/Material Library/maps/materials/studded_rubber_bump.png b/Studio/Content/Material Library/maps/materials/studded_rubber_bump.png Binary files differnew file mode 100644 index 0000000..b751476 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/studded_rubber_bump.png diff --git a/Studio/Content/Material Library/maps/materials/teak.png b/Studio/Content/Material Library/maps/materials/teak.png Binary files differnew file mode 100644 index 0000000..5d1a63b --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/teak.png diff --git a/Studio/Content/Material Library/maps/materials/teak_bump.png b/Studio/Content/Material Library/maps/materials/teak_bump.png Binary files differnew file mode 100644 index 0000000..cd2496a --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/teak_bump.png diff --git a/Studio/Content/Material Library/maps/materials/teak_spec.png b/Studio/Content/Material Library/maps/materials/teak_spec.png Binary files differnew file mode 100644 index 0000000..8751288 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/teak_spec.png diff --git a/Studio/Content/Material Library/maps/materials/walnut.png b/Studio/Content/Material Library/maps/materials/walnut.png Binary files differnew file mode 100644 index 0000000..abe5704 --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/walnut.png diff --git a/Studio/Content/Material Library/maps/materials/walnut_bump.png b/Studio/Content/Material Library/maps/materials/walnut_bump.png Binary files differnew file mode 100644 index 0000000..a6434fd --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/walnut_bump.png diff --git a/Studio/Content/Material Library/maps/materials/walnut_spec.png b/Studio/Content/Material Library/maps/materials/walnut_spec.png Binary files differnew file mode 100644 index 0000000..b03a1dc --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/walnut_spec.png diff --git a/Studio/Content/Material Library/maps/materials/white_marble.png b/Studio/Content/Material Library/maps/materials/white_marble.png Binary files differnew file mode 100644 index 0000000..472b33e --- /dev/null +++ b/Studio/Content/Material Library/maps/materials/white_marble.png diff --git a/Studio/Content/Material Library/mesh_fence.shader b/Studio/Content/Material Library/mesh_fence.shader new file mode 100644 index 0000000..df5d817 --- /dev/null +++ b/Studio/Content/Material Library/mesh_fence.shader @@ -0,0 +1,236 @@ +<Material name="mesh_fence" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Index of Refraction" name="material_ior" type="Float" default="15.000000" description="Index of refraction of the material" category="Material"/> + <Property formalName="Glossiness" name="glossy_weight" type="Float" min="0.000000" max="1.000000" default="0.500000" description="Reflectivity factor at incident angles" category="Material"/> + <Property formalName="Roughness" name="roughness" type="Float" min="0.000000" max="1.000000" default="0.250000" description="Roughness of the material.\n0 = fully specular\n1 = fully diffuse" category="Material"/> + <Property formalName="Diffuse Map" name="diffuse_texture" description="Diffuse texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="diffuse" default="./maps/materials/cyclone_mesh_fencing.png" category="Material"/> + <Property formalName="Tiling" name="texture_tiling" type="Float2" default="3 3" description="Scaling of the textures" category="Material"/> + <Property formalName="Bump Map" name="bump_texture" description="Bump texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="bump" default="./maps/materials/cyclone_mesh_fencing_normal.png" category="Material"/> + <Property formalName="Bump Amount" name="bump_amount" type="Float" default="2.000000" description="Value determining the bumpiness" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#define mono_alpha 0 +#define mono_average 1 +#define mono_luminance 2 +#define mono_maximum 3 +#define wrap_clamp 0 +#define wrap_repeat 1 +#define wrap_mirrored_repeat 2 +#define gamma_default 0 +#define gamma_linear 1 +#define gamma_srgb 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 texture_return +{ + vec3 tint; + float mono; +}; + + +struct layer_result +{ + vec4 base; + vec4 layer; + mat3 tanFrame; +}; + + +// temporary declarations +texture_coordinate_info tmp3; +texture_return tmp4; +vec3 tmp5; +vec3 ftmp0; + vec4 tmpShadowTerm; + +layer_result layers[2]; + +#include "SSAOCustomMaterial.glsllib" +#include "sampleLight.glsllib" +#include "sampleProbe.glsllib" +#include "sampleArea.glsllib" +#include "luminance.glsllib" +#include "monoChannel.glsllib" +#include "fileTexture.glsllib" +#include "transformCoordinate.glsllib" +#include "rotationTranslationScale.glsllib" +#include "textureCoordinateInfo.glsllib" +#include "tangentSpaceNormalTexture.glsllib" +#include "square.glsllib" +#include "calculateRoughness.glsllib" +#include "evalBakedShadowMap.glsllib" +#include "evalEnvironmentMap.glsllib" +#include "microfacetBSDF.glsllib" +#include "physGlossyBSDF.glsllib" +#include "simpleGlossyBSDF.glsllib" +#include "weightedLayer.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].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp5, lightDir, viewDir, lightDiffuse, 0.000000 ); + +#endif +} + +void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[0].tanFrame, varWorldPos, lightIdx, viewDir, roughness, roughness ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * lightDiffuse * sampleAreaDiffuse( layers[1].tanFrame, varWorldPos, lightIdx ); + +#endif +} + +void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFactor ) +{ +#if !QT3DS_ENABLE_LIGHT_PROBE + layers[0].layer += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, roughness, roughness, scatter_reflect ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( tmp5, 0.000000 ) * aoFactor; + +#else + layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * sampleDiffuse( layers[1].tanFrame ) * aoFactor; + +#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( tmp4.mono ); +} + +vec3 computeNormal() +{ + return( normal ); +} + +void computeTemporaries() +{ + tmp3 = transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), vec3( texture_tiling[0], texture_tiling[1], 1.000000 ) ), textureCoordinateInfo( texCoord0, tangent, binormal ) ); + tmp4 = fileTexture(diffuse_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_alpha, tmp3, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_srgb ); + tmp5 = tangentSpaceNormalTexture( bump_texture, bump_amount, false, false, tmp3, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat ); + ftmp0 = tmp4.tint; + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = weightedLayer( 1.000000, vec4( ftmp0, 1.0).rgb, layers[1].layer, layers[1].base, alpha ); + color = fresnelLayer( tmp5, vec3( material_ior ), glossy_weight, vec4( vec3( 1, 1, 1 ), 1.0).rgb, layers[0].layer, color, color.a ); + 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(tmp5, tangent), tmp5 ) ); + layers[1].base = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].layer = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].tanFrame = orthoNormalize( mat3( tangent, cross(tmp5, tangent), tmp5 ) ); +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="13"/> + <LayerKey count="2"/> + <Pass > + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/metal_mesh_fine.shader b/Studio/Content/Material Library/metal_mesh_fine.shader new file mode 100644 index 0000000..f4e2d9f --- /dev/null +++ b/Studio/Content/Material Library/metal_mesh_fine.shader @@ -0,0 +1,234 @@ +<Material name="metal_mesh_fine" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Index of Refraction" name="material_ior" type="Float" default="15.000000" description="Index of refraction of the material" category="Material"/> + <Property formalName="Roughness" name="roughness" type="Float" min="0.000000" max="1.000000" default="0.000000" description="Roughness of the material.\n0 = fully specular\n1 = fully diffuse" category="Material"/> + <Property formalName="Diffuse Map" name="diffuse_texture" description="Diffuse texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="diffuse" default="./maps/materials/metal_mesh.png" category="Material"/> + <Property formalName="Tiling" name="texture_tiling" type="Float2" default="75 75" description="Scaling of the textures" category="Material"/> + <Property formalName="Bump Map" name="bump_texture" description="Bump texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="bump" default="./maps/materials/metal_mesh_bump.png" category="Material"/> + <Property formalName="Bump Amount" name="bump_amount" type="Float" default="13.000000" description="Value determining the bumpiness" category="Material"/> + <Property formalName="Cutout Opacity Map" name="cutout_opacity_texture" description="Cutout opacity texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="cutout" default="./maps/materials/metal_mesh_spec.png" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#define mono_alpha 0 +#define mono_average 1 +#define mono_luminance 2 +#define mono_maximum 3 +#define wrap_clamp 0 +#define wrap_repeat 1 +#define wrap_mirrored_repeat 2 +#define gamma_default 0 +#define gamma_linear 1 +#define gamma_srgb 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 texture_return +{ + vec3 tint; + float mono; +}; + + +struct layer_result +{ + vec4 base; + vec4 layer; + mat3 tanFrame; +}; + + +// temporary declarations +texture_coordinate_info tmp2; +vec3 tmp4; +vec3 tmp6; + vec4 tmpShadowTerm; + +layer_result layers[2]; + +#include "SSAOCustomMaterial.glsllib" +#include "sampleLight.glsllib" +#include "sampleProbe.glsllib" +#include "sampleArea.glsllib" +#include "luminance.glsllib" +#include "monoChannel.glsllib" +#include "fileTexture.glsllib" +#include "transformCoordinate.glsllib" +#include "rotationTranslationScale.glsllib" +#include "textureCoordinateInfo.glsllib" +#include "fileBumpTexture.glsllib" +#include "square.glsllib" +#include "calculateRoughness.glsllib" +#include "evalBakedShadowMap.glsllib" +#include "evalEnvironmentMap.glsllib" +#include "microfacetBSDF.glsllib" +#include "physGlossyBSDF.glsllib" +#include "simpleGlossyBSDF.glsllib" +#include "weightedLayer.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].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp6, lightDir, viewDir, lightDiffuse, 0.000000 ); + +#endif +} + +void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[0].tanFrame, varWorldPos, lightIdx, viewDir, roughness, roughness ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * lightDiffuse * sampleAreaDiffuse( layers[1].tanFrame, varWorldPos, lightIdx ); + +#endif +} + +void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFactor ) +{ +#if !QT3DS_ENABLE_LIGHT_PROBE + layers[0].layer += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, roughness, roughness, scatter_reflect ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( tmp6, 0.000000 ) * aoFactor; + +#else + layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * sampleDiffuse( layers[1].tanFrame ) * aoFactor; + +#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( fileTexture(cutout_opacity_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_luminance, tmp2, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_linear ).mono ); +} + +vec3 computeNormal() +{ + return( normal ); +} + +void computeTemporaries() +{ + tmp2 = transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), vec3( texture_tiling[0], texture_tiling[1], 1.000000 ) ), textureCoordinateInfo( texCoord0, tangent, binormal ) ); + tmp4 = fileTexture(diffuse_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_luminance, tmp2, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_srgb ).tint; + tmp6 = fileBumpTexture(bump_texture, bump_amount, mono_average, tmp2, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, normal ); + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = weightedLayer( 1.000000, vec4( tmp4, 1.0).rgb, layers[1].layer, layers[1].base, alpha ); + color = fresnelLayer( tmp6, vec3( material_ior ), 1.000000, vec4( tmp4, 1.0).rgb, layers[0].layer, color, color.a ); + 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(tmp6, tangent), tmp6 ) ); + layers[1].base = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].layer = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].tanFrame = orthoNormalize( mat3( tangent, cross(tmp6, tangent), tmp6 ) ); +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="13"/> + <LayerKey count="2"/> + <Pass > + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/paper_artistic.shader b/Studio/Content/Material Library/paper_artistic.shader new file mode 100644 index 0000000..6c7b075 --- /dev/null +++ b/Studio/Content/Material Library/paper_artistic.shader @@ -0,0 +1,257 @@ +<Material name="paper_artistic" version="1.0"> + <MetaData > + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Translucency Falloff" name="uTranslucentFalloff" description="Falloff of the translucency of the\nmaterial" type="Float" default="0.0" category="Material"/> + <Property formalName="Diffuse Light Bend" name="uDiffuseLightWrap" description="Diffuse light bend of the material" type="Float" min="0.0" max="1.0" default="0.0" category="Material"/> + <Property formalName="Transparency" name="uOpacity" description="Transparency of the material" type="Float" min="0.0" max="100.0" default="100.0" category="Material"/> + <Property formalName="Transmission Weight" name="transmission_weight" type="Float" default="0.200000" description="Value determining transmission" category="Material"/> + <Property formalName="Transmission Map" name="transmission_texture" description="Transmission texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="transmission" default="./maps/materials/art_paper_trans.png" category="Textures"/> + <Property formalName="Tiling" name="texture_tiling" type="Float2" default="5 5" description="Scaling of the textures" category="Textures"/> + <Property formalName="Diffuse Map" name="diffuse_texture" description="Diffuse texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="diffuse" default="./maps/materials/paper_diffuse.png" category="Textures"/> + <Property formalName="Reflection Weight" name="reflection_weight" type="Float" default="0.800000" description="Value determining reflection" category="Material"/> + <Property formalName="Bump Map" name="bump_texture" description="Bump texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="bump" default="./maps/materials/art_paper_normal.png" category="Textures"/> + <Property formalName="Bump Amount" name="bump_amount" type="Float" default="0.500000" description="Value determining the bumpiness" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#define wrap_clamp 0 +#define wrap_repeat 1 +#define wrap_mirrored_repeat 2 +#define mono_alpha 0 +#define mono_average 1 +#define mono_luminance 2 +#define mono_maximum 3 +#define gamma_default 0 +#define gamma_linear 1 +#define gamma_srgb 2 +#define color_layer_blend 0 +#define color_layer_add 1 +#define color_layer_multiply 2 +#define color_layer_screen 3 +#define color_layer_overlay 4 +#define color_layer_brightness 5 +#define color_layer_color 6 + +#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 bsdf_component +{ + float weight; + vec4 component; +}; + + +struct color_layer +{ + vec3 layer_color; + float weight; + int mode; +}; + + +struct texture_return +{ + vec3 tint; + float mono; +}; + + +struct layer_result +{ + vec4 base; + vec4 layer; + mat3 tanFrame; +}; + + +// temporary declarations +texture_coordinate_info tmp1; +vec3 tmp2; +vec3 ftmp0; + vec4 tmpShadowTerm; + +layer_result layers[1]; + +#include "SSAOCustomMaterial.glsllib" +#include "sampleLight.glsllib" +#include "sampleProbe.glsllib" +#include "sampleArea.glsllib" +#include "tangentSpaceNormalTexture.glsllib" +#include "transformCoordinate.glsllib" +#include "rotationTranslationScale.glsllib" +#include "textureCoordinateInfo.glsllib" +#include "normalizedMix.glsllib" +#include "evalBakedShadowMap.glsllib" +#include "diffuseTransmissionBSDF.glsllib" +#include "luminance.glsllib" +#include "monoChannel.glsllib" +#include "fileTexture.glsllib" +#include "blendColorLayers.glsllib" +#include "diffuseReflectionBSDF.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 * normalizedMix( bsdf_component[2]( bsdf_component(transmission_weight, diffuseTransmissionBSDF( -normal, lightDir, viewDir, lightDiffuse, vec4( ftmp0, 1.0), uTranslucentFalloff, uDiffuseLightWrap )) ,bsdf_component(reflection_weight, diffuseReflectionBSDF( normal, lightDir, viewDir, lightDiffuse, 0.000000 )) ) ); + +#endif +} + +void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].base += tmpShadowTerm * normalizedMix( bsdf_component[2]( bsdf_component(transmission_weight, lightDiffuse * sampleAreaDiffuseTransmissive( layers[0].tanFrame, varWorldPos, lightIdx, vec4( ftmp0, 1.0), uTranslucentFalloff, uDiffuseLightWrap )) ,bsdf_component(reflection_weight, lightDiffuse * sampleAreaDiffuse( layers[0].tanFrame, varWorldPos, lightIdx )) ) ); + +#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; + +#else + layers[0].base += tmpShadowTerm * sampleDiffuse( layers[0].tanFrame ) * aoFactor; + +#endif +} + +void computeFrontLayerRnmColor( in vec3 normal, in vec3 rnmX, in vec3 rnmY, in vec3 rnmZ ) +{ +#if QT3DS_ENABLE_RNM + layers[0].base += tmpShadowTerm * diffuseRNM( normal, rnmX, rnmY, rnmZ ); + +#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 +} + +void computeBackLayerRnmColor( in vec3 normal, in vec3 rnmX, in vec3 rnmY, in vec3 rnmZ ) +{ +#if QT3DS_ENABLE_RNM + 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( tangentSpaceNormalTexture( bump_texture, bump_amount, false, false, tmp1, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat ) ); +} + +void computeTemporaries() +{ + tmp1 = transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), vec3( texture_tiling[0], texture_tiling[1], 1.000000 ) ), textureCoordinateInfo( texCoord0, tangent, binormal ) ); + tmp2 = fileTexture(diffuse_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_luminance, tmp1, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_srgb ).tint; + ftmp0 = blendColorLayers( color_layer[1]( color_layer(blendColorLayers( color_layer[1]( color_layer(fileTexture(transmission_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_luminance, tmp1, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_linear ).tint, 1.000000, color_layer_blend ) ), tmp2, mono_average ).tint, 1.000000, color_layer_multiply ) ), vec3( 1, 1, 1 ), mono_average ).tint; + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = layers[0].base * vec4( tmp2, 1.0); + 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( tangentFrame( normal, varWorldPos ) ); +} + +vec4 computeOpacity(in vec4 color) +{ + vec4 rgba = color; + rgba.a = uOpacity * 0.01; + return rgba; +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="257"/> + <LayerKey count="1"/> + <Pass > + <Blending source="SrcAlpha" dest="OneMinusSrcAlpha"/> + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/paper_office.shader b/Studio/Content/Material Library/paper_office.shader new file mode 100644 index 0000000..6f183a5 --- /dev/null +++ b/Studio/Content/Material Library/paper_office.shader @@ -0,0 +1,255 @@ +<Material name="paper_office" version="1.0"> + <MetaData > + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Translucency Falloff" name="uTranslucentFalloff" description="Falloff of the translucency of the\nmaterial" type="Float" default="0.0" category="Material"/> + <Property formalName="Diffuse Light Bend" name="uDiffuseLightWrap" description="Diffuse light bend of the material" type="Float" min="0.0" max="1.0" default="0.0" category="Material"/> + <Property formalName="Transparency" name="uOpacity" description="Transparency of the material" type="Float" min="0.0" max="100.0" default="100.0" category="Material"/> + <Property formalName="Transmission Weight" name="transmission_weight" type="Float" default="0.200000" description="Value determining transmission" category="Material"/> + <Property formalName="Transmission Map" name="transmission_texture" description="Transmission texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="transmission" default="./maps/materials/paper_trans.png" category="Textures"/> + <Property formalName="Tiling" name="texture_tiling" type="Float2" default="1 1" description="Scaling of the textures" category="Textures"/> + <Property formalName="Paper Color" name="paper_color" type="Color" default="0.531 0.531 0.531" description="Color of the paper" category="Material"/> + <Property formalName="Reflection Weight" name="reflection_weight" type="Float" default="0.800000" description="Value determining reflection" category="Material"/> + <Property formalName="Bump Map" name="bump_texture" description="Bump texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="bump" default="./maps/materials/paper_diffuse.png" category="Textures"/> + <Property formalName="Bump Amount" name="bump_amount" type="Float" default="0.500000" description="Value determining the bumpiness" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#define mono_alpha 0 +#define mono_average 1 +#define mono_luminance 2 +#define mono_maximum 3 +#define wrap_clamp 0 +#define wrap_repeat 1 +#define wrap_mirrored_repeat 2 +#define gamma_default 0 +#define gamma_linear 1 +#define gamma_srgb 2 +#define color_layer_blend 0 +#define color_layer_add 1 +#define color_layer_multiply 2 +#define color_layer_screen 3 +#define color_layer_overlay 4 +#define color_layer_brightness 5 +#define color_layer_color 6 + +#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 bsdf_component +{ + float weight; + vec4 component; +}; + + +struct color_layer +{ + vec3 layer_color; + float weight; + int mode; +}; + + +struct texture_return +{ + vec3 tint; + float mono; +}; + + +struct layer_result +{ + vec4 base; + vec4 layer; + mat3 tanFrame; +}; + + +// temporary declarations +texture_coordinate_info tmp1; +vec3 ftmp0; + vec4 tmpShadowTerm; + +layer_result layers[1]; + +#include "SSAOCustomMaterial.glsllib" +#include "sampleLight.glsllib" +#include "sampleProbe.glsllib" +#include "sampleArea.glsllib" +#include "luminance.glsllib" +#include "monoChannel.glsllib" +#include "fileBumpTexture.glsllib" +#include "transformCoordinate.glsllib" +#include "rotationTranslationScale.glsllib" +#include "textureCoordinateInfo.glsllib" +#include "normalizedMix.glsllib" +#include "evalBakedShadowMap.glsllib" +#include "diffuseTransmissionBSDF.glsllib" +#include "fileTexture.glsllib" +#include "blendColorLayers.glsllib" +#include "diffuseReflectionBSDF.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 * normalizedMix( bsdf_component[2]( bsdf_component(transmission_weight, diffuseTransmissionBSDF( -normal, lightDir, viewDir, lightDiffuse, vec4( ftmp0, 1.0), uTranslucentFalloff, uDiffuseLightWrap )) ,bsdf_component(reflection_weight, diffuseReflectionBSDF( normal, lightDir, viewDir, lightDiffuse, 0.000000 )) ) ); + +#endif +} + +void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].base += tmpShadowTerm * normalizedMix( bsdf_component[2]( bsdf_component(transmission_weight, lightDiffuse * sampleAreaDiffuseTransmissive( layers[0].tanFrame, varWorldPos, lightIdx, vec4( ftmp0, 1.0), uTranslucentFalloff, uDiffuseLightWrap )) ,bsdf_component(reflection_weight, lightDiffuse * sampleAreaDiffuse( layers[0].tanFrame, varWorldPos, lightIdx )) ) ); + +#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; + +#else + layers[0].base += tmpShadowTerm * sampleDiffuse( layers[0].tanFrame ) * aoFactor; + +#endif +} + +void computeFrontLayerRnmColor( in vec3 normal, in vec3 rnmX, in vec3 rnmY, in vec3 rnmZ ) +{ +#if QT3DS_ENABLE_RNM + layers[0].base += tmpShadowTerm * diffuseRNM( normal, rnmX, rnmY, rnmZ ); + +#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 +} + +void computeBackLayerRnmColor( in vec3 normal, in vec3 rnmX, in vec3 rnmY, in vec3 rnmZ ) +{ +#if QT3DS_ENABLE_RNM + 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( fileBumpTexture(bump_texture, bump_amount, mono_average, tmp1, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, normal ) ); +} + +void computeTemporaries() +{ + tmp1 = transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), vec3( texture_tiling[0], texture_tiling[1], 1.000000 ) ), textureCoordinateInfo( texCoord0, tangent, binormal ) ); + ftmp0 = blendColorLayers( color_layer[1]( color_layer(blendColorLayers( color_layer[1]( color_layer(fileTexture(transmission_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_luminance, tmp1, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_default ).tint, 0.700000, color_layer_blend ) ), paper_color.rgb, mono_average ).tint, 1.000000, color_layer_multiply ) ), vec3( 1, 1, 1 ), mono_average ).tint; + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = layers[0].base * vec4( paper_color.rgb, 1.0); + 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( tangentFrame( normal, varWorldPos ) ); +} + +vec4 computeOpacity(in vec4 color) +{ + vec4 rgba = color; + rgba.a = uOpacity * 0.01; + return rgba; +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="257"/> + <LayerKey count="1"/> + <Pass > + <Blending source="SrcAlpha" dest="OneMinusSrcAlpha"/> + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/plastic_structured_red.shader b/Studio/Content/Material Library/plastic_structured_red.shader new file mode 100644 index 0000000..1e6b798 --- /dev/null +++ b/Studio/Content/Material Library/plastic_structured_red.shader @@ -0,0 +1,204 @@ +<Material name="plastic_structured_red" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Gradient1D Map" description="Gradient texture of the material" hidden="True" name="randomGradient1D" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="gradient" default="./maps/materials/randomGradient1D.png"/> + <Property formalName="Gradient2D Map" description="Gradient texture of the material" hidden="True" name="randomGradient2D" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="gradient" default="./maps/materials/randomGradient2D.png"/> + <Property formalName="Gradient3D Map" description="Gradient texture of the material" hidden="True" name="randomGradient3D" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="gradient" default="./maps/materials/randomGradient3D.png"/> + <Property formalName="Gradient4D Map" description="Gradient texture of the material" hidden="True" name="randomGradient4D" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="gradient" default="./maps/materials/randomGradient4D.png"/> + <Property formalName="Index of Refraction" name="material_ior" description="Refractive index of the material" type="Float" default="1.800000" category="Material"/> + <Property formalName="Roughness" name="roughness" description="Roughness of the material.\n0 = fully specular\n1 = fully diffuse" type="Float" default="0.250000" category="Material"/> + <Property formalName="Color" name="diffuse_color" description="Color of the material" type="Color" default="0.451 0.04 0.035" category="Material"/> + <Property formalName="Texture Scale" name="texture_scaling" description="Scaling of the texture" type="Float" default="0.100000" category="Material"/> + <Property formalName="Bump Amount" name="bump_factor" description="Bumpiness of the material" type="Float" default="0.400000" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// 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.rgb, 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 ) ); +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="5"/> + <LayerKey count="1"/> + <Pass > + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/plastic_structured_red_emissive.shader b/Studio/Content/Material Library/plastic_structured_red_emissive.shader new file mode 100644 index 0000000..f85719e --- /dev/null +++ b/Studio/Content/Material Library/plastic_structured_red_emissive.shader @@ -0,0 +1,228 @@ +<Material name="plastic_structured_red_emissive" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Gradient1D Map" description="Gradient texture of the material" hidden="True" name="randomGradient1D" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="gradient" default="./maps/materials/randomGradient1D.png"/> + <Property formalName="Gradient2D Map" description="Gradient texture of the material" hidden="True" name="randomGradient2D" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="gradient" default="./maps/materials/randomGradient2D.png"/> + <Property formalName="Gradient3D Map" description="Gradient texture of the material" hidden="True" name="randomGradient3D" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="gradient" default="./maps/materials/randomGradient3D.png"/> + <Property formalName="Gradient4D Map" description="Gradient texture of the material" hidden="True" name="randomGradient4D" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="gradient" default="./maps/materials/randomGradient4D.png"/> + <Property formalName="Index of Refraction" name="material_ior" description="Refractive index of the material" type="Float" default="1.800000" category="Material"/> + <Property formalName="Roughness" name="roughness" description="Roughness of the material.\n0 = fully specular\n1 = fully diffuse" type="Float" default="0.250000" category="Material"/> + <Property formalName="Color" name="diffuse_color" description="Color of the material" type="Color" default="0.451 0.04 0.035" category="Material"/> + <Property formalName="Intensity" name="intensity" description="Emission intensity" type="Float" default="1.000000" category="Material"/> + <Property formalName="Emission Color" name="emission_color" description="Color of the emission" type="Color" default="0 0 0" category="Material"/> + <Property formalName="Emissive Map" name="emissive_texture" description="Emissive texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="emissive" default="./maps/materials/emissive.png" category="Material"/> + <Property formalName="Texture Scale" name="texture_scaling" description="Scaling of the texture" type="Float" default="0.100000" category="Material"/> + <Property formalName="Bump Amount" name="bump_factor" description="Bumpiness of the material" type="Float" default="0.400000" category="Material"/> + <Property formalName="Emissive Mask Map" name="emissive_mask_texture" description="Emissive mask texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="emissive_mask" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// 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 mono_alpha 0 +#define mono_average 1 +#define mono_luminance 2 +#define mono_maximum 3 +#define wrap_clamp 0 +#define wrap_repeat 1 +#define wrap_mirrored_repeat 2 +#define gamma_default 0 +#define gamma_linear 1 +#define gamma_srgb 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; +}; + + +struct texture_return +{ + vec3 tint; + float mono; +}; + + +// 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" +#include "monoChannel.glsllib" +#include "fileTexture.glsllib" +#include "textureCoordinateInfo.glsllib" + +bool evalTwoSided() +{ + return( false ); +} + +vec3 computeFrontMaterialEmissive() +{ + return( vec3( 1.0, 1.0, 1.0) * vec3( vec3( ( intensity * ( emission_color.rgb * fileTexture(emissive_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_alpha, transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), vec3( 1.000000, 1.000000, 1.000000 ) ), textureCoordinateInfo( texCoord0, tangent, binormal ) ), vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_default ).tint ) ) ) ) ); +} + +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.rgb, 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 ) ); +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="5"/> + <LayerKey count="1"/> + <Pass > + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/porcelain.shader b/Studio/Content/Material Library/porcelain.shader new file mode 100644 index 0000000..8b5978e --- /dev/null +++ b/Studio/Content/Material Library/porcelain.shader @@ -0,0 +1,181 @@ +<Material name="porcelain" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Index of Refraction" name="material_ior" type="Float" default="1.500000" description="Index of refraction of the material" category="Material"/> + <Property formalName="Glossiness" name="glossy_weight" type="Float" min="0.000000" max="1.000000" default="1.000000" description="Strength of glossy reflection" category="Material"/> + <Property formalName="Roughness" name="roughness" type="Float" min="0.000000" max="1.000000" default="0.150000" description="Roughness of the material.\n0 = fully specular\n1 = fully diffuse" category="Material"/> + <Property formalName="Porcelain Color" name="porcelain_color" type="Color" default="0.92 0.92 0.92" description="Color of the material" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#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 0 + +#include "vertexFragmentBase.glsllib" + +// set shader output +out vec4 fragColor; + +// add structure defines +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 "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( normal ); +} + +void computeTemporaries() +{ + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = fresnelLayer( normal, vec3( material_ior ), glossy_weight, vec4( vec3( 1, 1, 1 ), 1.0).rgb, layers[0].layer, layers[0].base * vec4( porcelain_color.rgb, 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 ) ); +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="5"/> + <LayerKey count="1"/> + <Pass > + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/powder_coat.shader b/Studio/Content/Material Library/powder_coat.shader new file mode 100644 index 0000000..c26fa04 --- /dev/null +++ b/Studio/Content/Material Library/powder_coat.shader @@ -0,0 +1,221 @@ +<Material name="powder_coat" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Index of Refraction" name="material_ior" description="Refractive index of the material" type="Float" default="5.000000" category="Material"/> + <Property formalName="Glossiness" name="glossy_weight" description="Reflectivity of the material at the\nincident lighting angles.\n0.0 = no reflection\n1.0 = totally reflective" type="Float" default="0.500000" category="Material"/> + <Property formalName="Roughness" name="roughness" description="Roughness of the material.\n0 = fully specular\n1 = fully diffuse" type="Float" default="0.100000" category="Material"/> + <Property formalName="Reflectivity" name="reflectivity" description="Reflectivity of the material" type="Float" default="0.100000" category="Material"/> + <Property formalName="Diffuse Weight" name="diffuse_weight" description="Diffuse weight of the material" type="Float" default="1.000000" category="Material"/> + <Property formalName="Powdercoat Color" name="powdercoat_diffuse_color" description="Color of the powdercoat" type="Color" default="0.046 0.046 0.054" category="Material"/> + <Property formalName="Bump Map" name="powdercoat_bump_texture" description="Bump texture of the powdercoat" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="bump" default="./maps/materials/powdercoat_bump_01.png" category="Material"/> + <Property formalName="Bump Amount" name="bump_factor" description="Bumpiness of the material" type="Float" default="2.000000" category="Material"/> + <Property formalName="Texture Scale" name="texture_scaling" description="Scaling of the texture" type="Vector" default="3 3 3" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#define mono_alpha 0 +#define mono_average 1 +#define mono_luminance 2 +#define mono_maximum 3 +#define wrap_clamp 0 +#define wrap_repeat 1 +#define wrap_mirrored_repeat 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 +vec3 ftmp0; + vec4 tmpShadowTerm; + +layer_result layers[2]; + +#include "SSAOCustomMaterial.glsllib" +#include "sampleLight.glsllib" +#include "sampleProbe.glsllib" +#include "sampleArea.glsllib" +#include "luminance.glsllib" +#include "monoChannel.glsllib" +#include "fileBumpTexture.glsllib" +#include "transformCoordinate.glsllib" +#include "rotationTranslationScale.glsllib" +#include "textureCoordinateInfo.glsllib" +#include "square.glsllib" +#include "calculateRoughness.glsllib" +#include "evalBakedShadowMap.glsllib" +#include "evalEnvironmentMap.glsllib" +#include "microfacetBSDF.glsllib" +#include "physGlossyBSDF.glsllib" +#include "simpleGlossyBSDF.glsllib" +#include "weightedLayer.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].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( normal, lightDir, viewDir, lightDiffuse, 0.000000 ); + +#endif +} + +void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[0].tanFrame, varWorldPos, lightIdx, viewDir, roughness, roughness ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * lightDiffuse * sampleAreaDiffuse( layers[1].tanFrame, varWorldPos, lightIdx ); + +#endif +} + +void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFactor ) +{ +#if !QT3DS_ENABLE_LIGHT_PROBE + layers[0].layer += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, roughness, roughness, scatter_reflect ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( normal, 0.000000 ) * aoFactor; + +#else + layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * sampleDiffuse( layers[1].tanFrame ) * aoFactor; + +#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( fileBumpTexture(powdercoat_bump_texture, bump_factor, mono_average, transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), texture_scaling ), textureCoordinateInfo( texCoord0, tangent, binormal ) ), vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, normal ) ); +} + +void computeTemporaries() +{ + ftmp0 = vec3( reflectivity ); + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = weightedLayer( diffuse_weight, powdercoat_diffuse_color.rgb, layers[1].layer, layers[1].base, alpha ); + color = fresnelLayer( normal, vec3( material_ior ), glossy_weight, vec4( ftmp0, 1.0).rgb, layers[0].layer, color, color.a ); + 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 ) ); + layers[1].base = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].layer = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].tanFrame = orthoNormalize( mat3( tangent, cross(normal, tangent), normal ) ); +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="5"/> + <LayerKey count="2"/> + <Pass > + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/powder_coat_emissive.shader b/Studio/Content/Material Library/powder_coat_emissive.shader new file mode 100644 index 0000000..4056079 --- /dev/null +++ b/Studio/Content/Material Library/powder_coat_emissive.shader @@ -0,0 +1,256 @@ +<Material name="powder_coat_emisssive" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Index of Refraction" name="material_ior" description="Refractive index of the material" type="Float" default="5.000000" category="Material"/> + <Property formalName="Glossiness" name="glossy_weight" description="Reflectivity of the material at the\nincident lighting angles.\n0.0 = no reflection\n1.0 = totally reflective" type="Float" default="0.500000" category="Material"/> + <Property formalName="Roughness" name="roughness" description="Roughness of the material.\n0 = fully specular\n1 = fully diffuse" type="Float" default="0.100000" category="Material"/> + <Property formalName="Reflectivity" name="reflectivity" description="Reflectivity of the material" type="Float" default="0.100000" category="Material"/> + <Property formalName="Diffuse Weight" name="diffuse_weight" description="Diffuse weight of the material" type="Float" default="1.000000" category="Material"/> + <Property formalName="Powdercoat Color" name="powdercoat_diffuse_color" description="Color of the powdercoat" type="Color" default="0.046 0.046 0.054" category="Material"/> + <Property formalName="Emissive Map" name="emissive_texture" description="Emissive texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="emissive" default="./maps/materials/emissive.png" category="Material"/> + <Property formalName="Emission Color" name="emission_color" description="Color of the emission" type="Color" default="0 0 0" category="Material"/> + <Property formalName="Intensity" name="intensity" description="Emission intensity" type="Float" default="1.000000" category="Material"/> + <Property formalName="Bump Map" name="powdercoat_bump_texture" description="Bump texture of the powdercoat" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="bump" default="./maps/materials/powdercoat_bump_01.png" category="Material"/> + <Property formalName="Bump Amount" name="bump_factor" description="Bumpiness of the material" type="Float" default="2.000000" category="Material"/> + <Property formalName="Texture Scale" name="texture_scaling" description="Scaling of the texture" type="Vector" default="3 3 3" category="Material"/> + <Property formalName="Emissive Mask Map" name="emissive_mask_texture" description="Emissive mask texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="emissive_mask" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#define mono_alpha 0 +#define mono_average 1 +#define mono_luminance 2 +#define mono_maximum 3 +#define wrap_clamp 0 +#define wrap_repeat 1 +#define wrap_mirrored_repeat 2 +#define scatter_reflect 0 +#define scatter_transmit 1 +#define scatter_reflect_transmit 2 +#define gamma_default 0 +#define gamma_linear 1 +#define gamma_srgb 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; +}; + + +struct texture_return +{ + vec3 tint; + float mono; +}; + + +// temporary declarations +texture_coordinate_info tmp3; +vec3 ftmp0; + vec4 tmpShadowTerm; + +layer_result layers[2]; + +#include "SSAOCustomMaterial.glsllib" +#include "sampleLight.glsllib" +#include "sampleProbe.glsllib" +#include "sampleArea.glsllib" +#include "luminance.glsllib" +#include "monoChannel.glsllib" +#include "fileBumpTexture.glsllib" +#include "transformCoordinate.glsllib" +#include "rotationTranslationScale.glsllib" +#include "textureCoordinateInfo.glsllib" +#include "square.glsllib" +#include "calculateRoughness.glsllib" +#include "evalBakedShadowMap.glsllib" +#include "evalEnvironmentMap.glsllib" +#include "microfacetBSDF.glsllib" +#include "physGlossyBSDF.glsllib" +#include "simpleGlossyBSDF.glsllib" +#include "weightedLayer.glsllib" +#include "diffuseReflectionBSDF.glsllib" +#include "fresnelLayer.glsllib" +#include "fileTexture.glsllib" + +bool evalTwoSided() +{ + return( false ); +} + +vec3 computeFrontMaterialEmissive() +{ + return( vec3( 1.0, 1.0, 1.0) * vec3( vec3( ( ( fileTexture(emissive_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_alpha, transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), vec3( 1.000000, 1.000000, 1.000000 ) ), tmp3 ), vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_default ).tint * emission_color.rgb ) * intensity ) ) ) ); +} + +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].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( normal, lightDir, viewDir, lightDiffuse, 0.000000 ); + +#endif +} + +void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[0].tanFrame, varWorldPos, lightIdx, viewDir, roughness, roughness ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * lightDiffuse * sampleAreaDiffuse( layers[1].tanFrame, varWorldPos, lightIdx ); + +#endif +} + +void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFactor ) +{ +#if !QT3DS_ENABLE_LIGHT_PROBE + layers[0].layer += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, roughness, roughness, scatter_reflect ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( normal, 0.000000 ) * aoFactor; + +#else + layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * sampleDiffuse( layers[1].tanFrame ) * aoFactor; + +#endif +} + +void computeFrontLayerRnmColor( in vec3 normal, in vec3 rnmX, in vec3 rnmY, in vec3 rnmZ ) +{ +#if QT3DS_ENABLE_RNM + layers[0].layer += tmpShadowTerm * glossyRNM( normal, rnmX, rnmY, rnmZ ); + + layers[1].layer += tmpShadowTerm * diffuseRNM( normal, rnmX, rnmY, rnmZ ); + +#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 +} + +void computeBackLayerRnmColor( in vec3 normal, in vec3 rnmX, in vec3 rnmY, in vec3 rnmZ ) +{ +#if QT3DS_ENABLE_RNM + 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( fileBumpTexture(powdercoat_bump_texture, bump_factor, mono_average, transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), texture_scaling ), tmp3 ), vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, normal ) ); +} + +void computeTemporaries() +{ + tmp3 = textureCoordinateInfo( texCoord0, tangent, binormal ); + ftmp0 = vec3( reflectivity ); + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = weightedLayer( diffuse_weight, powdercoat_diffuse_color.rgb, layers[1].layer, layers[1].base, alpha ); + color = fresnelLayer( normal, vec3( material_ior ), glossy_weight, vec4( ftmp0, 1.0).rgb, layers[0].layer, color, color.a ); + 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 ) ); + layers[1].base = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].layer = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].tanFrame = orthoNormalize( mat3( tangent, cross(normal, tangent), normal ) ); +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="5"/> + <LayerKey count="2"/> + <Pass > + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/rubber_studded_black.shader b/Studio/Content/Material Library/rubber_studded_black.shader new file mode 100644 index 0000000..a2af7d0 --- /dev/null +++ b/Studio/Content/Material Library/rubber_studded_black.shader @@ -0,0 +1,219 @@ +<Material name="rubber_studded_black" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Index of Refraction" name="material_ior" type="Float" default="1.800000" description="Index of refraction of the material" category="Material"/> + <Property formalName="Glossiness" name="glossy_weight" type="Float" min="0.000000" max="1.000000" default="0.500000" description="Reflectivity of the material at the\nincident lighting angles.\n0.0 = no reflection\n1.0 = totally reflective" category="Material"/> + <Property formalName="Roughness" name="roughness" type="Float" min="0.000000" max="1.000000" default="0.250000" description="Roughness of the material.\n0 = fully specular\n1 = fully diffuse" category="Material"/> + <Property formalName="Base color" name="base_color" type="Color" default="0 0 0" description="Color of the material" category="Material"/> + <Property formalName="Bump Map" name="bump_texture" description="Bump texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="bump" default="./maps/materials/studded_rubber_bump.png" category="Material"/> + <Property formalName="Bump Amount" name="bump_amount" type="Float" default="9.000000" description="Value determining the bumpiness" category="Material"/> + <Property formalName="Tiling" name="texture_tiling" type="Float2" default="10 7" description="Scaling of the textures" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#define mono_alpha 0 +#define mono_average 1 +#define mono_luminance 2 +#define mono_maximum 3 +#define wrap_clamp 0 +#define wrap_repeat 1 +#define wrap_mirrored_repeat 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 layer_result +{ + vec4 base; + vec4 layer; + mat3 tanFrame; +}; + + +struct texture_coordinate_info +{ + vec3 position; + vec3 tangent_u; + vec3 tangent_v; +}; + + +// temporary declarations +vec3 tmp4; + vec4 tmpShadowTerm; + +layer_result layers[2]; + +#include "SSAOCustomMaterial.glsllib" +#include "sampleLight.glsllib" +#include "sampleProbe.glsllib" +#include "sampleArea.glsllib" +#include "luminance.glsllib" +#include "monoChannel.glsllib" +#include "fileBumpTexture.glsllib" +#include "transformCoordinate.glsllib" +#include "rotationTranslationScale.glsllib" +#include "textureCoordinateInfo.glsllib" +#include "square.glsllib" +#include "calculateRoughness.glsllib" +#include "evalBakedShadowMap.glsllib" +#include "evalEnvironmentMap.glsllib" +#include "microfacetBSDF.glsllib" +#include "physGlossyBSDF.glsllib" +#include "simpleGlossyBSDF.glsllib" +#include "weightedLayer.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].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp4, lightDir, viewDir, lightDiffuse, 0.000000 ); + +#endif +} + +void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[0].tanFrame, varWorldPos, lightIdx, viewDir, roughness, roughness ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * lightDiffuse * sampleAreaDiffuse( layers[1].tanFrame, varWorldPos, lightIdx ); + +#endif +} + +void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFactor ) +{ +#if !QT3DS_ENABLE_LIGHT_PROBE + layers[0].layer += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, roughness, roughness, scatter_reflect ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( tmp4, 0.000000 ) * aoFactor; + +#else + layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * sampleDiffuse( layers[1].tanFrame ) * aoFactor; + +#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( normal ); +} + +void computeTemporaries() +{ + tmp4 = fileBumpTexture(bump_texture, bump_amount, mono_average, transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), vec3( texture_tiling[0], texture_tiling[1], 1.000000 ) ), textureCoordinateInfo( texCoord0, tangent, binormal ) ), vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, normal ); + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = weightedLayer( 1.0, base_color.rgb, layers[1].layer, layers[1].base, alpha ); + color = fresnelLayer( tmp4, vec3( material_ior ), glossy_weight, vec3(1.0), layers[0].layer, color, color.a ); + 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(tmp4, tangent), tmp4 ) ); + layers[1].base = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].layer = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].tanFrame = orthoNormalize( mat3( tangent, cross(tmp4, tangent), tmp4 ) ); +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="5"/> + <LayerKey count="2"/> + <Pass > + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/rubber_studded_emissive.shader b/Studio/Content/Material Library/rubber_studded_emissive.shader new file mode 100644 index 0000000..de45c93 --- /dev/null +++ b/Studio/Content/Material Library/rubber_studded_emissive.shader @@ -0,0 +1,238 @@ +<Material name="rubber_studded_emissive" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Index of Refraction" name="material_ior" type="Float" default="1.800000" description="Index of refraction of the material" category="Material"/> + <Property formalName="Glossiness" name="glossy_weight" type="Float" min="0.000000" max="1.000000" default="0.500000" description="Reflectivity of the material at the\nincident lighting angles.\n0.0 = no reflection\n1.0 = totally reflective" category="Material"/> + <Property formalName="Roughness" name="roughness" type="Float" min="0.000000" max="1.000000" default="0.250000" description="Roughness of the material.\n0 = fully specular\n1 = fully diffuse" category="Material"/> + <Property formalName="Base color" name="base_color" type="Color" default="0 0 0" description="Color of the material" category="Material"/> + <Property formalName="Bump Map" name="bump_texture" description="Bump texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="bump" default="./maps/materials/studded_rubber_bump.png" category="Material"/> + <Property formalName="Bump Amount" name="bump_amount" type="Float" default="9.000000" description="Value determining the bumpiness" category="Material"/> + <Property formalName="Tiling" name="texture_tiling" type="Float2" default="10 7" description="Scaling of the textures" category="Material"/> + <Property formalName="Intensity" name="intensity" description="Emission intensity" type="Float" default="1.000000" category="Material"/> + <Property formalName="Emission Color" name="emission_color" description="Color of the emission" type="Color" default="0 0 0" category="Material"/> + <Property formalName="Emissive Map" name="emissive_texture" description="Emissive texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="emissive" default="./maps/materials/emissive.png" category="Material"/> + <Property formalName="Emissive Map Mask" name="emissive_mask_texture" description="Emissive mask texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="emissive_mask" default="./maps/materials/emissive_mask.png" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#define mono_alpha 0 +#define mono_average 1 +#define mono_luminance 2 +#define mono_maximum 3 +#define wrap_clamp 0 +#define wrap_repeat 1 +#define wrap_mirrored_repeat 2 +#define scatter_reflect 0 +#define scatter_transmit 1 +#define scatter_reflect_transmit 2 +#define gamma_default 0 +#define gamma_linear 1 +#define gamma_srgb 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 layer_result +{ + vec4 base; + vec4 layer; + mat3 tanFrame; +}; + + +struct texture_coordinate_info +{ + vec3 position; + vec3 tangent_u; + vec3 tangent_v; +}; + + +struct texture_return +{ + vec3 tint; + float mono; +}; + + +// temporary declarations +texture_coordinate_info tmp3; +vec3 tmp5; +texture_coordinate_info tmp6; + vec4 tmpShadowTerm; + +layer_result layers[2]; + +#include "SSAOCustomMaterial.glsllib" +#include "sampleLight.glsllib" +#include "sampleProbe.glsllib" +#include "sampleArea.glsllib" +#include "luminance.glsllib" +#include "monoChannel.glsllib" +#include "fileBumpTexture.glsllib" +#include "transformCoordinate.glsllib" +#include "rotationTranslationScale.glsllib" +#include "textureCoordinateInfo.glsllib" +#include "square.glsllib" +#include "calculateRoughness.glsllib" +#include "evalBakedShadowMap.glsllib" +#include "evalEnvironmentMap.glsllib" +#include "microfacetBSDF.glsllib" +#include "physGlossyBSDF.glsllib" +#include "simpleGlossyBSDF.glsllib" +#include "weightedLayer.glsllib" +#include "diffuseReflectionBSDF.glsllib" +#include "fresnelLayer.glsllib" +#include "fileTexture.glsllib" + +bool evalTwoSided() +{ + return( false ); +} + +vec3 computeFrontMaterialEmissive() +{ + return( vec3( 1.0, 1.0, 1.0) * vec3( vec3( ( intensity * ( emission_color.rgb * ( fileTexture(emissive_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_alpha, tmp6, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_default ).tint*fileTexture(emissive_mask_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_alpha, tmp6, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_default ).tint ) ) ) ) ) ); +} + +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].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp5, lightDir, viewDir, lightDiffuse, 0.000000 ); + +#endif +} + +void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[0].tanFrame, varWorldPos, lightIdx, viewDir, roughness, roughness ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * lightDiffuse * sampleAreaDiffuse( layers[1].tanFrame, varWorldPos, lightIdx ); + +#endif +} + +void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFactor ) +{ +#if !QT3DS_ENABLE_LIGHT_PROBE + layers[0].layer += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, roughness, roughness, scatter_reflect ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( tmp5, 0.000000 ) * aoFactor; + +#else + layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * sampleDiffuse( layers[1].tanFrame ) * aoFactor; + +#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( normal ); +} + +void computeTemporaries() +{ + tmp3 = textureCoordinateInfo( texCoord0, tangent, binormal ); + tmp5 = fileBumpTexture(bump_texture, bump_amount, mono_average, transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), vec3( texture_tiling[0], texture_tiling[1], 1.000000 ) ), tmp3 ), vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, normal ); + tmp6 = transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), vec3( 1.000000, 1.000000, 1.000000 ) ), tmp3 ); + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = weightedLayer( 1.000000, base_color.rgb, layers[1].layer, layers[1].base, alpha ); + color = fresnelLayer( tmp5, vec3( material_ior ), glossy_weight, vec4( vec3( 1, 1, 1 ), 1.0).rgb, layers[0].layer, color, color.a ); + 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(tmp5, tangent), tmp5 ) ); + layers[1].base = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].layer = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].tanFrame = orthoNormalize( mat3( tangent, cross(tmp5, tangent), tmp5 ) ); +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="5"/> + <LayerKey count="2"/> + <Pass > + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/simple_glass.shader b/Studio/Content/Material Library/simple_glass.shader new file mode 100644 index 0000000..09aa2c9 --- /dev/null +++ b/Studio/Content/Material Library/simple_glass.shader @@ -0,0 +1,197 @@ +<Material name="simple_glass" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Fresnel Power" name="uFresnelPower" description="Fresnel power of the material" type="Float" default="1.0" category="Material"/> + <Property formalName="Minimum Opacity" name="uMinOpacity" description="Minimum opacity of the material" type="Float" default="0.5" category="Material"/> + <Property formalName="Reflectivity" name="reflectivity_amount" type="Float" min="0.000000" max="1.000000" default="1.000000" description="Reflectivity factor" category="Material"/> + <Property formalName="Glass ior" name="glass_ior" hidden="True" type="Float" default="1.100000" description="Index of refraction of the material" category="Material"/> + <Property formalName="Glass Color" name="glass_color" type="Color" default="0.9 0.9 0.9" description="Color of the material" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#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 0 + +#include "vertexFragmentBase.glsllib" + +// set shader output +out vec4 fragColor; + +// add structure defines +struct layer_result +{ + vec4 base; + vec4 layer; + mat3 tanFrame; +}; + + +// temporary declarations +vec3 ftmp0; + vec4 tmpShadowTerm; + +layer_result layers[1]; + +#include "SSAOCustomMaterial.glsllib" +#include "sampleLight.glsllib" +#include "sampleProbe.glsllib" +#include "sampleArea.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 "abbeNumberIOR.glsllib" +#include "fresnelLayer.glsllib" +#include "refraction.glsllib" + +bool evalTwoSided() +{ + return( true ); +} + +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 * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, 0.000000, 0.000000, scatter_reflect_transmit ); + +#endif +} + +void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].base += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[0].tanFrame, varWorldPos, lightIdx, viewDir, 0.000000, 0.000000 ); + +#endif +} + +void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFactor ) +{ +#if !QT3DS_ENABLE_LIGHT_PROBE + layers[0].base += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, 0.000000, 0.000000, scatter_reflect_transmit ); + +#else + layers[0].base += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, 0.000000, 0.000000 ); + +#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( true ? 1.0 : luminance( vec3( abbeNumberIOR(glass_ior, 0.000000 ) ) ) ); +} + +float evalCutout() +{ + return( 1.000000 ); +} + +vec3 computeNormal() +{ + return( normal ); +} + +void computeTemporaries() +{ + ftmp0 = vec3( reflectivity_amount ); + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = layers[0].base * vec4( ftmp0, 1.0); + 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( tangentFrame( normal, varWorldPos ) ); +} + +vec4 computeGlass(in vec3 normal, in float materialIOR, in float alpha, in vec4 color) +{ + vec4 rgba = color; + float ratio = simpleFresnel( normal, materialIOR, uFresnelPower ); + vec3 absorb_color = ( log( glass_color.rgb )/-1.000000 ); + // prevent log(0) -> inf number issue + if ( isinf(absorb_color.r) ) absorb_color.r = 1.0; + if ( isinf(absorb_color.g) ) absorb_color.g = 1.0; + if ( isinf(absorb_color.b) ) absorb_color.b = 1.0; + rgba.rgb = mix(vec3(1.0) - absorb_color, rgba.rgb * (vec3(1.0) - absorb_color), ratio); + rgba.a = mix(uMinOpacity, alpha, ratio); + return rgba; +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="36"/> + <LayerKey count="1"/> + <Pass > + <Blending source="SrcAlpha" dest="OneMinusSrcAlpha"/> + <RenderState name="CullFace"/> + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/steel_milled_concentric.shader b/Studio/Content/Material Library/steel_milled_concentric.shader new file mode 100644 index 0000000..3cf9585 --- /dev/null +++ b/Studio/Content/Material Library/steel_milled_concentric.shader @@ -0,0 +1,237 @@ +<Material name="steel_milled_concentric" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Index of Refraction" name="material_ior" type="Float" default="20.000000" description="Index of refraction of the material" category="Material"/> + <Property formalName="Diffuse Map" name="diffuse_texture" description="Diffuse texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="diffuse" default="./maps/materials/concentric_milled_steel.png" category="Material"/> + <Property formalName="Tiling" name="texture_tiling" type="Float2" default="8 5" description="Scaling of the textures" category="Material"/> + <Property formalName="Anisotropy" name="anisotropy" type="Float" min="0.010000" max="100.000000" default="0.800000" description="The anisotropy of the roughness" category="Material"/> + <Property formalName="Anisotropy Rot Map" name="anisotropy_rot_texture" description="Anisotropy rot texture of the material" type="Texture" filter="linear" minfilter="linear" clamp="repeat" usage="anisotropy" default="./maps/materials/concentric_milled_steel_aniso.png" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#define mono_alpha 0 +#define mono_average 1 +#define mono_luminance 2 +#define mono_maximum 3 +#define wrap_clamp 0 +#define wrap_repeat 1 +#define wrap_mirrored_repeat 2 +#define gamma_default 0 +#define gamma_linear 1 +#define gamma_srgb 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 layer_result +{ + vec4 base; + vec4 layer; + mat3 tanFrame; +}; + + +struct anisotropy_return +{ + float roughness_u; + float roughness_v; + vec3 tangent_u; +}; + + +struct texture_coordinate_info +{ + vec3 position; + vec3 tangent_u; + vec3 tangent_v; +}; + + +struct texture_return +{ + vec3 tint; + float mono; +}; + + +// temporary declarations +texture_coordinate_info tmp3; +texture_return tmp4; +anisotropy_return tmp5; +float ftmp0; +float ftmp1; +vec3 ftmp2; +vec3 ftmp3; +vec3 ftmp4; + vec4 tmpShadowTerm; + +layer_result layers[1]; + +#include "SSAOCustomMaterial.glsllib" +#include "sampleLight.glsllib" +#include "sampleProbe.glsllib" +#include "sampleArea.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 "monoChannel.glsllib" +#include "fileTexture.glsllib" +#include "transformCoordinate.glsllib" +#include "rotationTranslationScale.glsllib" +#include "textureCoordinateInfo.glsllib" +#include "anisotropyConversion.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, ftmp0, ftmp1, 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, ftmp0, ftmp1 ); + +#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, ftmp0, ftmp1, scatter_reflect ); + +#else + layers[0].base += tmpShadowTerm * sampleDiffuse( layers[0].tanFrame ) * aoFactor; + layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, ftmp0, ftmp1 ); + +#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( normal ); +} + +void computeTemporaries() +{ + tmp3 = transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), vec3( texture_tiling[0], texture_tiling[1], 1.000000 ) ), textureCoordinateInfo( texCoord0, tangent, binormal ) ); + tmp4 = fileTexture(diffuse_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_luminance, tmp3, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_linear ); + tmp5 = anisotropyConversion( tmp4.mono, anisotropy, fileTexture(anisotropy_rot_texture, vec3( -1, -1, -1 ), vec3( 1, 1, 1 ), mono_luminance, tmp3, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_linear ).mono, tangent, false ); + ftmp0 = tmp5.roughness_u; + ftmp1 = tmp5.roughness_v; + ftmp2 = fileTexture(diffuse_texture, vec3( 1, 1, 1 ), vec3( -1, -1, -1 ), mono_luminance, tmp3, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_linear ).tint; + ftmp3 = tmp5.tangent_u; + ftmp4 = tmp4.tint; + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = fresnelLayer( normal, vec3( material_ior ), 1.000000, vec4( ftmp2, 1.0).rgb, layers[0].layer, layers[0].base * vec4( ftmp4, 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( ftmp3, cross(normal, ftmp3), normal ) ); +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="5"/> + <LayerKey count="1"/> + <Pass > + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/thin_glass_frosted.shader b/Studio/Content/Material Library/thin_glass_frosted.shader new file mode 100644 index 0000000..b66c4cd --- /dev/null +++ b/Studio/Content/Material Library/thin_glass_frosted.shader @@ -0,0 +1,485 @@ +<Material name="thin_glass_frosted" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Fresnel Power" name="uFresnelPower" description="Fresnel power of the material" type="Float" default="1.0" category="Material"/> + <Property formalName="Roughness" name="roughness" type="Float" min="0.000000" max="1.000000" default="1.000000" description="Roughness of the material.\n0 = fully specular\n1 = fully diffuse" category="Material"/> + <Property formalName="Reflectivity" name="reflectivity_amount" type="Float" min="0.000000" max="1.000000" default="0.100000" description="Reflectivity factor" category="Material"/> + <Property formalName="Glass ior" name="glass_ior" type="Float" default="1.100000" description="Index of refraction of the material" category="Material"/> + <Property formalName="Glass Color" name="glass_color" type="Color" default="0.9 0.9 0.9" description="Color of the material" category="Material"/> + <Property formalName="Glass Bump map" name="glass_bump" description="Additional bump map for surface" type="Texture" clamp="repeat" category="Material"/> + <Property formalName="Glass Bump Factor" name="glass_bfactor" description="Bump map factor" default="0.0" category="Material"/> + <Property formalName="Glass Bump Inside" name="glass_binside" description="Use bump map for internal lighting only" type="Boolean" default="False" category="Material"/> + <Property formalName="Blur Width" name="blur_size" type="Float" default="8" min="1" max="50" description="Amount of blurring behind the glass" category="Material"/> + <Property formalName="Gradient1D Map" description="Gradient texture of the material" hidden="True" name="randomGradient1D" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="gradient" default="./maps/materials/randomGradient1D.png"/> + <Property formalName="Gradient2D Map" description="Gradient texture of the material" hidden="True" name="randomGradient2D" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="gradient" default="./maps/materials/randomGradient2D.png"/> + <Property formalName="Gradient3D Map" description="Gradient texture of the material" hidden="True" name="randomGradient3D" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="gradient" default="./maps/materials/randomGradient3D.png"/> + <Property formalName="Gradient4D Map" description="Gradient texture of the material" hidden="True" name="randomGradient4D" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="gradient" default="./maps/materials/randomGradient4D.png"/> + <Property formalName="Refract Depth" name="refract_depth" type="Float" default="5" min="0" max="20" description="Degree of bend from refraction. Allows\ncontrol of refraction without affecting\nlighting" category="Refraction"/> + <Property formalName="Bump Coordinates" name="bumpCoords" description="Bump coordinates of the refraction" type="Vector" default="1 1 1" category="Refraction"/> + <Property formalName="Bump Scale" name="bumpScale" description="Scale of the bumps" type="Float" min="0.000000" max="5.000000" default="0.500000" category="Refraction"/> + <Property formalName="Bump Bands" name="bumpBands" description="Bump bands of the refraction" type="Long" min="1.000000" max="10.000000" default="1" category="Refraction"/> + <Property formalName="Light Position" name="intLightPos" type="Float2" description="Position in UV space of the band-light" default="0.5 0" category="Translucent Lighting"/> + <Property formalName="Light Color" name="intLightCol" type="Color" description="Color of the band-light" default="0.9 0.9 0.9" category="Translucent Lighting"/> + <Property formalName="Light Brightness" name="intLightBrt" type="Float" description="Brightness of the band-light" default="0" category="Translucent Lighting"/> + <Property formalName="Light Rotation" name="intLightRot" type="Float" description="Angle the lightsource is oriented.\nBand is perpendicular to this" default="0" min="0" max="360" category="Translucent Lighting"/> + <Property formalName="Falloff rate" name="intLightFall" type="Float" description="Rate at which intensity drops off" default="2.0" category="Translucent Lighting"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader name="MAIN"> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#define mono_alpha 0 +#define mono_average 1 +#define mono_luminance 2 +#define mono_maximum 3 +#define wrap_clamp 0 +#define wrap_repeat 1 +#define wrap_mirrored_repeat 2 +#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 0 + +#include "vertexFragmentBase.glsllib" + +// set shader output +out vec4 fragColor; + +// add structure defines +struct layer_result +{ + vec4 base; + vec4 layer; + mat3 tanFrame; +}; + +// add structure defines +struct texture_coordinate_info +{ + vec3 position; + vec3 tangent_u; + vec3 tangent_v; +}; + +struct texture_return +{ + vec3 tint; + float mono; +}; + +// temporary declarations +texture_coordinate_info tmp0; +texture_coordinate_info tmp1; +vec3 ftmp0; +vec3 ftmp1; +vec3 ftmp2; +vec4 tmpShadowTerm; + +layer_result layers[1]; + +#include "SSAOCustomMaterial.glsllib" +#include "sampleLight.glsllib" +#include "sampleProbe.glsllib" +#include "sampleArea.glsllib" +#include "square.glsllib" +#include "cube.glsllib" +#include "random255.glsllib" +#include "perlinNoise.glsllib" +#include "perlinNoiseBumpTexture.glsllib" +#include "luminance.glsllib" +#include "monoChannel.glsllib" +#include "fileBumpTexture.glsllib" +#include "transformCoordinate.glsllib" +#include "rotationTranslationScale.glsllib" +#include "coordinateSource.glsllib" +#include "calculateRoughness.glsllib" +#include "evalBakedShadowMap.glsllib" +#include "evalEnvironmentMap.glsllib" +#include "microfacetBSDF.glsllib" +#include "physGlossyBSDF.glsllib" +#include "simpleGlossyBSDF.glsllib" +#include "abbeNumberIOR.glsllib" +#include "average.glsllib" +#include "perlinNoiseTexture.glsllib" +#include "fresnelLayer.glsllib" +#include "refraction.glsllib" + +uniform sampler2D refractiveTexture; + +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 * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect_transmit ); + +#endif +} + +void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].base += 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 * microfacetSampledBSDF( layers[0].tanFrame, viewDir, roughness, roughness, scatter_reflect_transmit ); + +#else + layers[0].base += 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( abbeNumberIOR(glass_ior, 0.000000 ) ) ) ); +} + +float evalCutout() +{ + return( 1.000000 ); +} + +vec3 computeNormal() +{ + if ( glass_bfactor > 0.0 ) + { + ftmp2 = fileBumpTexture(glass_bump, glass_bfactor, mono_average, tmp0, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, normal ); + if (!glass_binside) { normal = ftmp2; } + } + + return( perlinNoiseBumpTexture( tmp1, bumpScale, 1.000000, false, false, 0.000000, bumpBands, false, vec3( 0.000000, 0.000000, 0.000000 ), 0.5, 0.0, 1.000000, normal ) ); +} + +void computeTemporaries() +{ + //tmp0 = transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), refractCoords ), coordinateSource(texture_coordinate_world, 0 ) ); + //ftmp1 = perlinNoiseBumpTexture( tmp0, refractScale, 1.000000, false, false, 0.000000, 1, false, vec3( 0.000000, 0.000000, 0.000000 ), 1.0, 0.5, 1.000000, viewDir ); + tmp0 = transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), bumpCoords ), textureCoordinateInfo( texCoord0, tangent, binormal ) ); + tmp1 = transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), bumpCoords ), coordinateSource(texture_coordinate_world, 0 ) ); + ftmp1 = viewDir; + ftmp0 = vec3( reflectivity_amount ); + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = layers[0].base * vec4( ftmp0, 1.0); + 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( tangentFrame( normal, varWorldPos ) ); +} + +vec3 getRefractUV( in vec2 baseUV, in vec3 normal, in float materialIOR, in float refractDepth ) +{ + // Real honest-to-goodness refraction! + vec3 refractedDir = refract( -viewDir, normal, 1.0 / materialIOR ); + float thickness = refractDepth / clamp( dot(viewDir, normal), 0.0001, 1.0 ); + + // This will do an "AA" version of that loss due to critical angle and TIR + // fakes the same effect than using the glsl refract. + float weight = smoothstep( 0.0, 1.0, abs(dot(viewDir, normal)) * 100.0 ); + + // Trace out the refracted ray and the straight view ray + refractedDir *= thickness; + vec3 rawDir = -viewDir * thickness; + + vec3 displace = refractedDir - rawDir; + vec3 newUV = vec3(baseUV + displace.xy, weight); + return newUV; +} + +vec4 doFakeInnerLight( in vec3 normal, in vec3 absorb_color ) +{ + vec3 lightColor = intLightCol.rgb * intLightBrt; + + float cosRot = cos(intLightRot * 0.01745329251); + float sinRot = sin(intLightRot * 0.01745329251); + vec2 uvDir = vec2(sinRot, cosRot); + + vec2 dvec = texCoord0.xy - intLightPos; + float dist = dot( dvec, uvDir ); + float fallRate = log2( max( abs(intLightFall), 1.01 ) ); + vec3 fallCol = exp2( -abs(dist) * fallRate / absorb_color ); + + vec3 projDir = (tangent * uvDir.x + binormal * uvDir.y) * dist * intLightFall - surfNormal * refract_depth; + projDir = normalize(projDir); + + vec4 retVal = vec4(lightColor * fallCol, 1.0); + retVal *= abs(dot( projDir, -ftmp2 )); + retVal.a = pow( retVal.a, uFresnelPower ); + retVal.a *= clamp( intLightBrt * exp2(-dist * fallRate), 0.0, 1.0 ); + + return retVal; +} + +vec4 computeGlass(in vec3 normal, in float materialIOR, in float alpha, in vec4 color) +{ + vec4 rgba = color; + float ratio = simpleFresnel( normal, materialIOR, uFresnelPower ); + vec3 absorb_color = ( log( glass_color.rgb ) * -1.000000 ); + // prevent log(0) -> inf number issue + if ( isinf(absorb_color.r) ) absorb_color.r = 1.0; + if ( isinf(absorb_color.g) ) absorb_color.g = 1.0; + if ( isinf(absorb_color.b) ) absorb_color.b = 1.0; + rgba.rgb *= (vec3(1.0) - absorb_color); + + vec2 texSize = vec2( textureSize( refractiveTexture, 0 ) ); + vec3 newUV = vec3((gl_FragCoord.xy * 0.5) / texSize, 0.0); + vec4 value = texture( refractiveTexture, newUV.xy ); + + newUV = getRefractUV( newUV.xy, normal, materialIOR, 0.01 * refract_depth ); + vec4 refractValue = texture( refractiveTexture, newUV.xy ); + + vec3 refractColor = refractValue.a * refractValue.rgb + (1.0 - refractValue.a) * value.rgb; + refractColor = refractColor * (vec3(1.0) - absorb_color); + vec4 internalColor = doFakeInnerLight( normal, glass_color.rgb ); + refractColor += internalColor.rgb * internalColor.a; + + rgba = vec4(mix(refractColor, rgba.rgb, ratio), 1.0); + return rgba; +} + + </FragmentShader> + </Shader> + <Shader name="NOOP"> +<VertexShader> +</VertexShader> +<FragmentShader> +#define QT3DS_ENABLE_UV0 1 +#define QT3DS_ENABLE_WORLD_POSITION 1 +#define QT3DS_ENABLE_TEXTAN 1 + +vec3 texCoord0; + +void main() +{ + + // This is a bit silly, but the thing is that a buffer blit takes place on this + // pass, and if you do a buffer blit on a pass that outputs to lower-resolution, + // it only blits a smaller portion of the backbuffer that occupies that number of + // pixels. So we need a dummy no-op pass that is full-res in order to blit everything. +</FragmentShader> + </Shader> + <Shader name="PREBLUR"> +<VertexShader> +</VertexShader> +<FragmentShader> +#define QT3DS_ENABLE_UV0 1 +#define QT3DS_ENABLE_WORLD_POSITION 1 +#define QT3DS_ENABLE_TEXTAN 1 + +vec3 texCoord0; + +uniform sampler2D OriginBuffer; + +void main() +{ + vec2 texSize = vec2( textureSize( OriginBuffer, 0 ) ); + texSize = vec2(1.0) / texSize; + texCoord0.z = 0.0; + texCoord0.xy = vec2(gl_FragCoord.xy * 2.0 * texSize); + + float wtSum = 0.0; + vec4 totSum = vec4(0.0); + for (int ix = -1; ix <= 1; ++ix) + { + for (int iy = -1; iy <= 1; ++iy) + { + float wt = float(ix*ix + iy*iy) * 4.0; + wt = exp2( -wt ); + vec2 texOfs = vec2(ix, iy) * texSize; + totSum += wt * texture( OriginBuffer, texCoord0.xy + texOfs ); + wtSum += wt; + } + } + + totSum /= wtSum; + gl_FragColor = totSum; + // No close paren because the generator adds it for us. + +</FragmentShader> + </Shader> + <Shader name="BLURX"> +<VertexShader> +</VertexShader> +<FragmentShader> +#define QT3DS_ENABLE_UV0 1 +#define QT3DS_ENABLE_WORLD_POSITION 1 +#define QT3DS_ENABLE_TEXTAN 1 + +vec3 texCoord0; + +uniform sampler2D BlurBuffer; + +void main() +{ + vec2 texSize = vec2( textureSize( BlurBuffer, 0 ) ); + texSize = vec2(1.0) / texSize; + texCoord0.z = 0.0; + texCoord0.xy = vec2(gl_FragCoord.xy * texSize); + + float sigma = clamp(blur_size * 0.5, 0.5, 100.0); + int smpCount = int(ceil( sigma )); + vec4 value = texture(BlurBuffer, texCoord0.xy); + float wtsum = 1.0; + for (int i = 1; i <= smpCount; ++i) + { + // Base 2 Gaussian blur + float wt = float(i) / (sigma * 0.5); + wt = exp2( -wt*wt ); + vec2 texOfs = vec2(i, 0) * texSize; + value += wt * texture(BlurBuffer, texCoord0.xy+texOfs); + value += wt * texture(BlurBuffer, texCoord0.xy-texOfs); + wtsum += wt * 2.0; + } + + gl_FragColor = value / wtsum; + gl_FragColor.a = 1.0; + + // No close paren because the generator adds it for us. +</FragmentShader> + </Shader> + <Shader name="BLURY"> +<VertexShader> +</VertexShader> +<FragmentShader> +#define QT3DS_ENABLE_UV0 1 +#define QT3DS_ENABLE_WORLD_POSITION 1 +#define QT3DS_ENABLE_TEXTAN 1 + +vec3 texCoord0; + +uniform sampler2D BlurBuffer; +uniform sampler2D OriginBuffer; + +void main() +{ + vec2 texSize = vec2( textureSize( BlurBuffer, 0 ) ); + texSize = vec2(1.0) / texSize; + texCoord0.z = 0.0; + texCoord0.xy = vec2(gl_FragCoord.xy * texSize); + + float sigma = clamp(blur_size * 0.5, 0.5, 100.0); + int smpCount = int(ceil( sigma )); + vec4 value = texture(BlurBuffer, texCoord0.xy); + + float wtsum = 1.0; + for (int i = 1; i <= smpCount; ++i) + { + // Base 2 Gaussian blur + float wt = float(i) / (sigma * 0.5); + wt = exp2( -wt*wt ); + vec2 texOfs = vec2(0, i) * texSize; + vec4 posValue = texture(BlurBuffer, texCoord0.xy+texOfs); + vec4 negValue = texture(BlurBuffer, texCoord0.xy-texOfs); + posValue = posValue.a * posValue + (1.0 - posValue.a) * texture(OriginBuffer, texCoord0.xy+texOfs); + negValue = negValue.a * negValue + (1.0 - negValue.a) * texture(OriginBuffer, texCoord0.xy-texOfs); + + value += wt * posValue; + value += wt * negValue; + wtsum += wt * 2.0; + } + + gl_FragColor = (value / wtsum); + gl_FragColor.a = 1.0; + + // No close paren because the generator adds it for us. +</FragmentShader> + </Shader> + + </Shaders> +<Passes > + <ShaderKey value="20"/> + <LayerKey count="1"/> + <Buffer name="frame_buffer" format="source" filter="linear" wrap="clamp" size="1.0" lifetime="frame"/> + <Buffer name="dummy_buffer" type="ubyte" format="rgba" wrap="clamp" size="1.0" lifetime="frame"/> + <Buffer name="temp_buffer" type="fp16" format="rgba" filter="linear" wrap="clamp" size="0.5" lifetime="frame"/> + <Buffer name="temp_blurX" type="fp16" format="rgba" filter="linear" wrap="clamp" size="0.5" lifetime="frame"/> + <Buffer name="temp_blurY" type="fp16" format="rgba" filter="linear" wrap="clamp" size="0.5" lifetime="frame"/> + <Pass shader="NOOP" output="dummy_buffer"> + <BufferBlit dest="frame_buffer"/> + </Pass> + <Pass shader="PREBLUR" output="temp_buffer"> + <BufferInput value="frame_buffer" param="OriginBuffer"/> + </Pass> + <Pass shader="BLURX" output="temp_blurX"> + <BufferInput value="temp_buffer" param="BlurBuffer"/> + </Pass> + <Pass shader="BLURY" output="temp_blurY"> + <BufferInput value="temp_blurX" param="BlurBuffer"/> + <BufferInput value="temp_buffer" param="OriginBuffer"/> + </Pass> + <Pass shader="MAIN"> + <BufferInput value="temp_blurY" param="refractiveTexture"/> + <Blending source="SrcAlpha" dest="OneMinusSrcAlpha"/> + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/thin_glass_frosted_sp.shader b/Studio/Content/Material Library/thin_glass_frosted_sp.shader new file mode 100644 index 0000000..6619ec2 --- /dev/null +++ b/Studio/Content/Material Library/thin_glass_frosted_sp.shader @@ -0,0 +1,246 @@ +<Material name="thin_glass_frosted_sp" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Gradient1D Map" description="Gradient texture of the material" hidden="True" name="randomGradient1D" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="gradient" default="./maps/materials/randomGradient1D.png"/> + <Property formalName="Gradient2D Map" description="Gradient texture of the material" hidden="True" name="randomGradient2D" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="gradient" default="./maps/materials/randomGradient2D.png"/> + <Property formalName="Gradient3D Map" description="Gradient texture of the material" hidden="True" name="randomGradient3D" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="gradient" default="./maps/materials/randomGradient3D.png"/> + <Property formalName="Gradient4D Map" description="Gradient texture of the material" hidden="True" name="randomGradient4D" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="gradient" default="./maps/materials/randomGradient4D.png"/> + <Property formalName="Noise Coordinates" name="noiseCoords" description="Coordinates of the noise" type="Vector" default="1 1 1" category="Material"/> + <Property formalName="Noise Scale" name="noiseScale" description="Scaling of the noise" type="Float" min="0.000000" max="40.000000" default="2.000000" category="Material"/> + <Property formalName="Bump Coordinates" name="bumpCoords" description="Bump coordinates of the refraction" type="Vector" default="1 1 1" category="Material"/> + <Property formalName="Bump Scale" name="bumpScale" description="Scale of the bumps" type="Float" min="0.000000" max="1.000000" default="0.500000" category="Material"/> + <Property formalName="Bump Bands" name="bumpBands" description="Bump bands of the material" type="Long" min="1.000000" max="10.000000" default="1" category="Material"/> + <Property formalName="Fresnel Power" name="uFresnelPower" description="Fresnel power of the material" type="Float" default="1.0" category="Material"/> + <Property formalName="Roughness" name="roughness" type="Float" min="0.000000" max="1.000000" default="0.000000" description="Roughness of the material.\n0 = fully specular\n1 = fully diffuse" category="Material"/> + <Property formalName="Blur Width" name="blur_size" description="Width of the blur" type="Float" default="8" min="0.000000" max="20.00000" category="Material"/> + <Property formalName="Reflectivity" name="reflectivity_amount" type="Float" min="0.000000" max="1.000000" default="1.000000" description="Reflectivity factor" category="Material"/> + <Property formalName="Glass ior" name="glass_ior" type="Float" default="1.100000" description="Index of refraction of the material" category="Material"/> + <Property formalName="Glass Color" name="glass_color" type="Color" default="0.9 0.9 0.9" description="Color of the material" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// 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 0 + +#include "vertexFragmentBase.glsllib" + +// set shader output +out vec4 fragColor; + +// add structure defines +struct layer_result +{ + vec4 base; + vec4 layer; + mat3 tanFrame; +}; + +// add structure defines +struct texture_coordinate_info +{ + vec3 position; + vec3 tangent_u; + vec3 tangent_v; +}; + +struct texture_return +{ + vec3 tint; + float mono; +}; + + +// temporary declarations +texture_coordinate_info tmp0; +texture_coordinate_info tmp1; +vec3 ftmp0; +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 "abbeNumberIOR.glsllib" +#include "average.glsllib" +#include "perlinNoiseTexture.glsllib" +#include "fresnelLayer.glsllib" +#include "refraction.glsllib" + +uniform sampler2D refractiveTexture; + +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 * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect_transmit ); + +#endif +} + +void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].base += 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 * microfacetSampledBSDF( layers[0].tanFrame, viewDir, roughness, roughness, scatter_reflect_transmit ); + +#else + layers[0].base += 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( abbeNumberIOR(glass_ior, 0.000000 ) ) ) ); +} + +float evalCutout() +{ + return( 1.000000 ); +} + +vec3 computeNormal() +{ + //return( normal ); + return( perlinNoiseBumpTexture( tmp1, bumpScale, 1.000000, false, false, 0.000000, bumpBands, false, vec3( 0.000000, 0.000000, 0.000000 ), 0.5, 0.0, 1.000000, normal ) ); +} + +void computeTemporaries() +{ + tmp0 = transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), noiseCoords ), coordinateSource(texture_coordinate_world, 0 ) ); + tmp1 = transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), bumpCoords ), coordinateSource(texture_coordinate_world, 0 ) ); + ftmp0 = vec3( reflectivity_amount ); + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = layers[0].base * vec4( ftmp0, 1.0); + 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( tangentFrame( normal, varWorldPos ) ); +} + +vec4 computeGlass(in vec3 normal, in float materialIOR, in float alpha, in vec4 color) +{ + vec4 rgba = color; + float ratio = simpleFresnel( normal, materialIOR, uFresnelPower ); + vec3 absorb_color = ( log( glass_color.rgb )/-1.000000 ); + // prevent log(0) -> inf number issue + if ( isinf(absorb_color.r) ) absorb_color.r = 1.0; + if ( isinf(absorb_color.g) ) absorb_color.g = 1.0; + if ( isinf(absorb_color.b) ) absorb_color.b = 1.0; + rgba.rgb *= (vec3(1.0) - absorb_color); + + vec3 refractDir = perlinNoiseBumpTexture( tmp0, noiseScale, 1.000000, false, false, 0.000000, 1, false, vec3( 0.000000, 0.000000, 0.000000 ), 1.0, 0.5, 1.000000, normalize(viewDir) ); + + vec3 refractColor = refractBlur( refractiveTexture, normalize(refractDir), materialIOR, blur_size ) * (vec3(1.0) - absorb_color); + rgba = vec4(mix(refractColor, rgba.rgb, ratio), 1.0); + return rgba; +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="20"/> + <LayerKey count="1"/> + <Buffer name="temp_buffer" format="source" filter="linear" wrap="clamp" size="1.0" lifetime="frame"/> + <Pass > + <BufferBlit dest="temp_buffer"/> + <BufferInput value="temp_buffer" param="refractiveTexture"/> + <Blending source="SrcAlpha" dest="OneMinusSrcAlpha"/> + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/thin_glass_refractive.shader b/Studio/Content/Material Library/thin_glass_refractive.shader new file mode 100644 index 0000000..16cf172 --- /dev/null +++ b/Studio/Content/Material Library/thin_glass_refractive.shader @@ -0,0 +1,202 @@ +<Material name="thin_glass_refractive" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Fresnel Power" name="uFresnelPower" description="Fresnel power of the material" type="Float" default="1.0" category="Material"/> + <Property formalName="Roughness" name="roughness" type="Float" min="0.000000" max="1.000000" default="0.000000" description="Roughness of the material.\n0 = fully specular\n1 = fully diffuse" category="Material"/> + <Property formalName="Reflectivity" name="reflectivity_amount" type="Float" min="0.000000" max="1.000000" default="1.000000" description="Reflectivity factor" category="Material"/> + <Property formalName="Glass ior" name="glass_ior" type="Float" default="1.100000" description="Index of refraction of the material" category="Material"/> + <Property formalName="Glass Color" name="glass_color" type="Color" default="0.9 0.9 0.9" description="Color of the material" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#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 0 + +#include "vertexFragmentBase.glsllib" + +// set shader output +out vec4 fragColor; + +// add structure defines +struct layer_result +{ + vec4 base; + vec4 layer; + mat3 tanFrame; +}; + + +// temporary declarations +vec3 ftmp0; + vec4 tmpShadowTerm; + +layer_result layers[1]; + +#include "SSAOCustomMaterial.glsllib" +#include "sampleLight.glsllib" +#include "sampleProbe.glsllib" +#include "sampleArea.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 "abbeNumberIOR.glsllib" +#include "fresnelLayer.glsllib" +#include "refraction.glsllib" + +uniform sampler2D refractiveTexture; + +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 * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect_transmit ); + +#endif +} + +void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].base += 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 * microfacetSampledBSDF( layers[0].tanFrame, viewDir, roughness, roughness, scatter_reflect_transmit ); + +#else + layers[0].base += 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( abbeNumberIOR(glass_ior, 0.000000 ) ) ) ); +} + +float evalCutout() +{ + return( 1.000000 ); +} + +vec3 computeNormal() +{ + return( normal ); +} + +void computeTemporaries() +{ + ftmp0 = vec3( reflectivity_amount ); + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = layers[0].base * vec4( ftmp0, 1.0); + 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( tangentFrame( normal, varWorldPos ) ); +} + +vec4 computeGlass(in vec3 normal, in float materialIOR, in float alpha, in vec4 color) +{ + vec4 rgba = color; + float ratio = simpleFresnel( normal, materialIOR, uFresnelPower ); + vec3 absorb_color = ( log( glass_color.rgb )/-1.000000 ); + // prevent log(0) -> inf number issue + if ( isinf(absorb_color.r) ) absorb_color.r = 1.0; + if ( isinf(absorb_color.g) ) absorb_color.g = 1.0; + if ( isinf(absorb_color.b) ) absorb_color.b = 1.0; + rgba.rgb *= (vec3(1.0) - absorb_color); + vec3 refractColor = refraction( refractiveTexture, materialIOR ) * (vec3(1.0) - absorb_color); + rgba = vec4(mix(refractColor, rgba.rgb, ratio), 1.0); + return rgba; +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="20"/> + <LayerKey count="1"/> + <Buffer name="temp_buffer" format="source" filter="linear" wrap="clamp" size="1.0" lifetime="scene"/> + <Pass > + <BufferBlit dest="temp_buffer"/> + <BufferInput value="temp_buffer" param="refractiveTexture"/> + <Blending source="SrcAlpha" dest="OneMinusSrcAlpha"/> + </Pass> +</Passes> +</Material> diff --git a/Studio/Content/Material Library/walnut_matte.shader b/Studio/Content/Material Library/walnut_matte.shader new file mode 100644 index 0000000..4541241 --- /dev/null +++ b/Studio/Content/Material Library/walnut_matte.shader @@ -0,0 +1,236 @@ +<Material name="walnut_matte" version="1.0"> + <MetaData > + <Property formalName="Environment Map" name="uEnvironmentTexture" description="Environment texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="environment" default="./maps/materials/spherical_checker.png" category="Material"/> + <Property formalName="Enable Environment" name="uEnvironmentMappingEnabled" description="Enable environment mapping" type="Boolean" default="True" category="Material"/> + <Property formalName="Baked Shadow Map" name="uBakedShadowTexture" description="Baked shadow texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="shadow" default="./maps/materials/shadow.png" category="Material"/> + <Property formalName="Shadow Mapping" name="uShadowMappingEnabled" description="Enable shadow mapping" type="Boolean" default="False" category="Material"/> + <Property formalName="Index of Refraction" name="material_ior" type="Float" default="1.500000" description="Index of refraction of the material" category="Material"/> + <Property formalName="Roughness" name="roughness" type="Float" min="0.000000" max="1.000000" default="0.250000" description="Roughness of the material.\n0 = fully specular\n1 = fully diffuse" category="Material"/> + <Property formalName="Reflectivity Map" name="reflect_texture" description="Reflectivity texture for the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="specular" default="./maps/materials/walnut_spec.png" category="Material"/> + <Property formalName="Tiling" name="texture_tiling" type="Float2" default="10 7" description="Scaling of the textures" category="Material"/> + <Property formalName="Diffuse Map" name="diffuse_texture" description="Diffuse texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="diffuse" default="./maps/materials/walnut.png" category="Material"/> + <Property formalName="Bump Map" name="bump_texture" description="Bump texture of the material" type="Texture" filter="linear" minfilter="linearMipmapLinear" clamp="repeat" usage="bump" default="./maps/materials/walnut_bump.png" category="Material"/> + <Property formalName="Bump Amount" name="bump_amount" type="Float" default="0.400000" description="Value determining the bumpiness" category="Material"/> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <Shared> </Shared> +<VertexShader> + </VertexShader> + <FragmentShader> + +// add enum defines +#define mono_alpha 0 +#define mono_average 1 +#define mono_luminance 2 +#define mono_maximum 3 +#define wrap_clamp 0 +#define wrap_repeat 1 +#define wrap_mirrored_repeat 2 +#define gamma_default 0 +#define gamma_linear 1 +#define gamma_srgb 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 layer_result +{ + vec4 base; + vec4 layer; + mat3 tanFrame; +}; + + +struct texture_coordinate_info +{ + vec3 position; + vec3 tangent_u; + vec3 tangent_v; +}; + + +struct texture_return +{ + vec3 tint; + float mono; +}; + + +// temporary declarations +texture_coordinate_info tmp2; +vec3 tmp5; +vec3 ftmp0; +vec3 ftmp1; + vec4 tmpShadowTerm; + +layer_result layers[2]; + +#include "SSAOCustomMaterial.glsllib" +#include "sampleLight.glsllib" +#include "sampleProbe.glsllib" +#include "sampleArea.glsllib" +#include "luminance.glsllib" +#include "monoChannel.glsllib" +#include "fileBumpTexture.glsllib" +#include "transformCoordinate.glsllib" +#include "rotationTranslationScale.glsllib" +#include "textureCoordinateInfo.glsllib" +#include "square.glsllib" +#include "calculateRoughness.glsllib" +#include "evalBakedShadowMap.glsllib" +#include "evalEnvironmentMap.glsllib" +#include "microfacetBSDF.glsllib" +#include "physGlossyBSDF.glsllib" +#include "simpleGlossyBSDF.glsllib" +#include "fileTexture.glsllib" +#include "weightedLayer.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].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp5, lightDir, viewDir, lightDiffuse, 0.000000 ); + +#endif +} + +void computeFrontAreaColor( in int lightIdx, in vec4 lightDiffuse, in vec4 lightSpecular ) +{ +#if QT3DS_ENABLE_CG_LIGHTING + layers[0].layer += tmpShadowTerm * lightSpecular * sampleAreaGlossy( layers[0].tanFrame, varWorldPos, lightIdx, viewDir, roughness, roughness ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * lightDiffuse * sampleAreaDiffuse( layers[1].tanFrame, varWorldPos, lightIdx ); + +#endif +} + +void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFactor ) +{ +#if !QT3DS_ENABLE_LIGHT_PROBE + layers[0].layer += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, roughness, roughness, scatter_reflect ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( tmp5, 0.000000 ) * aoFactor; + +#else + layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness ); + + layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 ); + layers[1].layer += tmpShadowTerm * sampleDiffuse( layers[1].tanFrame ) * aoFactor; + +#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( normal ); +} + +void computeTemporaries() +{ + tmp2 = transformCoordinate( rotationTranslationScale( vec3( 0.000000, 0.000000, 0.000000 ), vec3( 0.000000, 0.000000, 0.000000 ), vec3( texture_tiling[0], texture_tiling[1], 1.000000 ) ), textureCoordinateInfo( texCoord0, tangent, binormal ) ); + tmp5 = fileBumpTexture(bump_texture, bump_amount, mono_average, tmp2, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, normal ); + ftmp0 = fileTexture(reflect_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_luminance, tmp2, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_linear ).tint; + ftmp1 = fileTexture(diffuse_texture, vec3( 0, 0, 0 ), vec3( 1, 1, 1 ), mono_luminance, tmp2, vec2( 0.000000, 1.000000 ), vec2( 0.000000, 1.000000 ), wrap_repeat, wrap_repeat, gamma_srgb ).tint; + tmpShadowTerm = evalBakedShadowMap( texCoord0 ); +} + +vec4 computeLayerWeights( in float alpha ) +{ + vec4 color; + color = weightedLayer( 1.000000, vec4( ftmp1, 1.0).rgb, layers[1].layer, layers[1].base, alpha ); + color = fresnelLayer( tmp5, vec3( material_ior ), 1.000000, vec4( ftmp0, 1.0).rgb, layers[0].layer, color, color.a ); + 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(tmp5, tangent), tmp5 ) ); + layers[1].base = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].layer = vec4(0.0, 0.0, 0.0, 1.0); + layers[1].tanFrame = orthoNormalize( mat3( tangent, cross(tmp5, tangent), tmp5 ) ); +} + + </FragmentShader> + </Shader> + </Shaders> +<Passes > + <ShaderKey value="5"/> + <LayerKey count="2"/> + <Pass > + </Pass> +</Passes> +</Material> |