mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
107 lines
3.1 KiB
Text
107 lines
3.1 KiB
Text
<@include gpu/Config.slh@>
|
|
<$VERSION_HEADER$>
|
|
// Generated on <$_SCRIBE_DATE$>
|
|
//
|
|
// simple_fade.frag
|
|
// fragment shader
|
|
//
|
|
// 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 Fade.slh@>
|
|
<$declareFadeFragmentInstanced()$>
|
|
|
|
<@include render-utils/ShaderConstants.h@>
|
|
|
|
// the interpolated normal
|
|
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
|
|
layout(location=RENDER_UTILS_ATTR_NORMAL_MS) in vec3 _normalMS;
|
|
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
|
|
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
|
|
#define _texCoord0 _texCoord01.xy
|
|
#define _texCoord1 _texCoord01.zw
|
|
layout(location=RENDER_UTILS_ATTR_POSITION_MS) in vec4 _positionMS;
|
|
layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES;
|
|
layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS;
|
|
|
|
// For retro-compatibility
|
|
#define _normal _normalWS
|
|
#define _modelNormal _normalMS
|
|
#define _position _positionMS
|
|
#define _eyePosition _positionES
|
|
|
|
<@include procedural/ProceduralCommon.slh@>
|
|
|
|
#line 1001
|
|
//PROCEDURAL_BLOCK
|
|
|
|
#line 2030
|
|
void main(void) {
|
|
vec3 fadeEmissive;
|
|
FadeObjectParams fadeParams;
|
|
|
|
<$fetchFadeObjectParamsInstanced(fadeParams)$>
|
|
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
|
|
|
|
vec3 normal = normalize(_normalWS.xyz);
|
|
vec3 diffuse = _color.rgb;
|
|
vec3 specular = DEFAULT_SPECULAR;
|
|
float shininess = DEFAULT_SHININESS;
|
|
float emissiveAmount = 0.0;
|
|
|
|
#ifdef PROCEDURAL
|
|
|
|
#ifdef PROCEDURAL_V1
|
|
specular = getProceduralColor().rgb;
|
|
// Procedural Shaders are expected to be Gamma corrected so let's bring back the RGB in linear space for the rest of the pipeline
|
|
//specular = pow(specular, vec3(2.2));
|
|
emissiveAmount = 1.0;
|
|
#else
|
|
emissiveAmount = getProceduralColors(diffuse, specular, shininess);
|
|
#endif
|
|
|
|
#endif
|
|
|
|
const float ALPHA_THRESHOLD = 0.999;
|
|
if (_color.a < ALPHA_THRESHOLD) {
|
|
if (emissiveAmount > 0.0) {
|
|
packDeferredFragmentTranslucent(
|
|
normal,
|
|
_color.a,
|
|
specular+fadeEmissive,
|
|
DEFAULT_ROUGHNESS);
|
|
} else {
|
|
packDeferredFragmentTranslucent(
|
|
normal,
|
|
_color.a,
|
|
diffuse+fadeEmissive,
|
|
DEFAULT_ROUGHNESS);
|
|
}
|
|
} else {
|
|
if (emissiveAmount > 0.0) {
|
|
packDeferredFragmentLightmap(
|
|
normal,
|
|
1.0,
|
|
diffuse+fadeEmissive,
|
|
max(0.0, 1.0 - shininess / 128.0),
|
|
DEFAULT_METALLIC,
|
|
specular);
|
|
} else {
|
|
packDeferredFragment(
|
|
normal,
|
|
1.0,
|
|
diffuse,
|
|
max(0.0, 1.0 - shininess / 128.0),
|
|
length(specular),
|
|
DEFAULT_EMISSIVE+fadeEmissive,
|
|
DEFAULT_OCCLUSION,
|
|
DEFAULT_SCATTERING);
|
|
}
|
|
}
|
|
}
|