mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-23 02:00:16 +02:00
59 lines
1.7 KiB
Text
59 lines
1.7 KiB
Text
<@include gpu/Config.slh@>
|
|
<$VERSION_HEADER$>
|
|
// Generated on <$_SCRIBE_DATE$>
|
|
// model.frag
|
|
// fragment shader
|
|
//
|
|
// Created by Andrzej Kapolka on 10/14/13.
|
|
// Copyright 2013 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 model/Material.slh@>
|
|
|
|
<@include MaterialTextures.slh@>
|
|
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, _SCRIBE_NULL, EMISSIVE, OCCLUSION)$>
|
|
|
|
in vec4 _position;
|
|
in vec3 _normal;
|
|
in vec3 _color;
|
|
in vec2 _texCoord0;
|
|
in vec2 _texCoord1;
|
|
|
|
|
|
void main(void) {
|
|
Material mat = getMaterial();
|
|
int matKey = getMaterialKey(mat);
|
|
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex)$>
|
|
<$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;
|
|
|
|
float roughness = getMaterialRoughness(mat);
|
|
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
|
|
|
|
vec3 emissive = getMaterialEmissive(mat);
|
|
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
|
|
|
|
float scattering = getMaterialScattering(mat);
|
|
|
|
packDeferredFragment(
|
|
normalize(_normal.xyz),
|
|
opacity,
|
|
albedo,
|
|
roughness,
|
|
getMaterialMetallic(mat),
|
|
emissive,
|
|
occlusionTex,
|
|
scattering);
|
|
}
|