mirror of
https://github.com/overte-org/overte.git
synced 2025-06-23 20:20:14 +02:00
81 lines
2.6 KiB
Text
81 lines
2.6 KiB
Text
<@include gpu/Config.slh@>
|
|
<$VERSION_HEADER$>
|
|
// <$_SCRIBE_FILENAME$>
|
|
// Generated on <$_SCRIBE_DATE$>
|
|
//
|
|
// Created by Sam Gateau on 2/15/2016.
|
|
// Copyright 2014 High Fidelity, Inc.
|
|
//
|
|
// Distributed under the Apache License, Version 2.0.
|
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
//
|
|
|
|
<@include DefaultMaterials.slh@>
|
|
<@include graphics/Material.slh@>
|
|
<@include graphics/MaterialTextures.slh@>
|
|
<@include render-utils/ShaderConstants.h@>
|
|
|
|
<@include ForwardGlobalLight.slh@>
|
|
|
|
<$declareEvalGlobalLightingAlphaBlended()$>
|
|
|
|
<@include gpu/Transform.slh@>
|
|
<$declareStandardCameraTransform()$>
|
|
|
|
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION)$>
|
|
|
|
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
|
|
#define _texCoord0 _texCoord01.xy
|
|
#define _texCoord1 _texCoord01.zw
|
|
layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES;
|
|
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
|
|
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
|
|
|
|
layout(location=0) out vec4 _fragColor0;
|
|
|
|
void main(void) {
|
|
Material mat = getMaterial();
|
|
BITFIELD matKey = getMaterialKey(mat);
|
|
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex)$>
|
|
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
|
|
|
float opacity = getMaterialOpacity(mat) * _color.a;
|
|
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
|
|
<$discardInvisible(opacity)$>;
|
|
|
|
vec3 albedo = getMaterialAlbedo(mat);
|
|
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
|
|
albedo *= _color.rgb;
|
|
|
|
float roughness = getMaterialRoughness(mat);
|
|
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
|
|
|
|
float metallic = getMaterialMetallic(mat);
|
|
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
|
|
|
|
vec3 fresnel = getFresnelF0(metallic, albedo);
|
|
|
|
float occlusion = DEFAULT_OCCLUSION;
|
|
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
|
|
|
|
vec3 emissive = getMaterialEmissive(mat);
|
|
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
|
|
|
|
vec3 fragPosition = _positionES.xyz;
|
|
vec3 fragNormal = normalize(_normalWS);
|
|
|
|
TransformCamera cam = getTransformCamera();
|
|
|
|
_fragColor0 = vec4(evalGlobalLightingAlphaBlendedWithHaze(
|
|
cam._viewInverse,
|
|
1.0,
|
|
occlusion,
|
|
fragPosition,
|
|
fragNormal,
|
|
albedo,
|
|
fresnel,
|
|
metallic,
|
|
emissive,
|
|
roughness, opacity),
|
|
opacity);
|
|
}
|