mirror of
https://github.com/overte-org/overte.git
synced 2025-06-17 16:00:20 +02:00
69 lines
2.4 KiB
Text
69 lines
2.4 KiB
Text
<@include gpu/Config.slh@>
|
|
<$VERSION_HEADER$>
|
|
// <$_SCRIBE_FILENAME$>
|
|
// Generated on <$_SCRIBE_DATE$>
|
|
//
|
|
// Created by Andrzej Kapolka on 5/6/14.
|
|
// 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 DeferredBufferWrite.slh@>
|
|
<@include graphics/Material.slh@>
|
|
<@include graphics/MaterialTextures.slh@>
|
|
<@include render-utils/ShaderConstants.h@>
|
|
|
|
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION, SCATTERING)$>
|
|
|
|
layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES;
|
|
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_TANGENT_WS) in vec3 _tangentWS;
|
|
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
|
|
|
|
void main(void) {
|
|
Material mat = getMaterial();
|
|
BITFIELD matKey = getMaterialKey(mat);
|
|
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex, scatteringTex)$>
|
|
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
|
|
|
float opacity = 1.0;
|
|
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)&>;
|
|
<$discardTransparent(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 emissive = getMaterialEmissive(mat);
|
|
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
|
|
|
|
float occlusion = DEFAULT_OCCLUSION;
|
|
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
|
|
|
|
float scattering = getMaterialScattering(mat);
|
|
<$evalMaterialScattering(scatteringTex, scattering, matKey, scattering)$>;
|
|
|
|
vec3 fragNormalWS;
|
|
<$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormalWS)$>
|
|
|
|
packDeferredFragment(
|
|
normalize(fragNormalWS),
|
|
opacity,
|
|
albedo,
|
|
roughness,
|
|
metallic,
|
|
emissive,
|
|
occlusion,
|
|
scattering);
|
|
}
|