mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-25 19:30:22 +02:00
59 lines
2 KiB
Text
59 lines
2 KiB
Text
<@include gpu/Config.slh@>
|
|
<$VERSION_HEADER$>
|
|
// <$_SCRIBE_FILENAME$>
|
|
// Generated on <$_SCRIBE_DATE$>
|
|
//
|
|
// Created by Olivier Prat on 06/05/17.
|
|
// Copyright 2017 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 DeferredBufferWrite.slh@>
|
|
<@include graphics/Material.slh@>
|
|
<@include graphics/MaterialTextures.slh@>
|
|
<@include render-utils/ShaderConstants.h@>
|
|
|
|
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC)$>
|
|
<$declareMaterialLightmap()$>
|
|
|
|
<@include Fade.slh@>
|
|
<$declareFadeFragment()$>
|
|
|
|
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
|
|
#define _texCoord0 _texCoord01.xy
|
|
#define _texCoord1 _texCoord01.zw
|
|
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
|
|
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
|
|
layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS;
|
|
|
|
void main(void) {
|
|
vec3 fadeEmissive;
|
|
FadeObjectParams fadeParams;
|
|
<$fetchFadeObjectParams(fadeParams)$>
|
|
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
|
|
|
|
Material mat = getMaterial();
|
|
BITFIELD matKey = getMaterialKey(mat);
|
|
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex)$>
|
|
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmap)$>
|
|
|
|
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)$>;
|
|
|
|
packDeferredFragmentLightmap(
|
|
normalize(_normalWS),
|
|
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedoTex.a),
|
|
albedo,
|
|
roughness,
|
|
metallic,
|
|
lightmap + fadeEmissive);
|
|
}
|