mirror of
https://github.com/lubosz/overte.git
synced 2025-04-14 08:06:13 +02:00
106 lines
3.2 KiB
Text
106 lines
3.2 KiB
Text
<@include gpu/Config.slh@>
|
|
<$VERSION_HEADER$>
|
|
// <$_SCRIBE_FILENAME$>
|
|
// Generated on <$_SCRIBE_DATE$>
|
|
//
|
|
// Created by Bradley Austin Davis on 2015-02-04
|
|
// Based on fragment shader code from
|
|
// https://github.com/paulhoux/Cinder-Samples/blob/master/TextRendering/include/text/Text.cpp
|
|
// Distributed under the Apache License, Version 2.0.
|
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
|
|
<@if HIFI_USE_TRANSLUCENT or HIFI_USE_FORWARD@>
|
|
<@include DefaultMaterials.slh@>
|
|
|
|
<@include GlobalLight.slh@>
|
|
<@if HIFI_USE_TRANSLUCENT@>
|
|
<$declareEvalGlobalLightingAlphaBlended()$>
|
|
<@else@>
|
|
<$declareEvalSkyboxGlobalColor(_SCRIBE_NULL, HIFI_USE_FORWARD)$>
|
|
<@endif@>
|
|
|
|
<@include gpu/Transform.slh@>
|
|
<$declareStandardCameraTransform()$>
|
|
|
|
layout(location=0) out vec4 _fragColor0;
|
|
<@else@>
|
|
<@include DeferredBufferWrite.slh@>
|
|
<@endif@>
|
|
|
|
<@include render-utils/ShaderConstants.h@>
|
|
|
|
<@include sdf_text3D.slh@>
|
|
<$declareEvalSDFSuperSampled()$>
|
|
|
|
<@if HIFI_USE_TRANSLUCENT or HIFI_USE_FORWARD@>
|
|
layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES;
|
|
<@endif@>
|
|
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
|
|
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
|
|
#define _texCoord0 _texCoord01.xy
|
|
#define _texCoord1 _texCoord01.zw
|
|
layout(location=RENDER_UTILS_ATTR_FADE1) flat in vec4 _glyphBounds; // we're reusing the fade texcoord locations here
|
|
|
|
void main() {
|
|
vec4 color = evalSDFSuperSampled(_texCoord0, _glyphBounds);
|
|
|
|
<@if HIFI_USE_TRANSLUCENT or HIFI_USE_FORWARD@>
|
|
color.a *= params.color.a;
|
|
if (color.a <= 0.0) {
|
|
discard;
|
|
}
|
|
<@endif@>
|
|
|
|
<@if HIFI_USE_UNLIT@>
|
|
<@if HIFI_USE_TRANSLUCENT or HIFI_USE_FORWARD@>
|
|
_fragColor0 = vec4(color.rgb * isUnlitEnabled(), color.a);
|
|
<@else@>
|
|
packDeferredFragmentUnlit(
|
|
normalize(_normalWS),
|
|
color.a,
|
|
color.rgb);
|
|
<@endif@>
|
|
<@else@>
|
|
<@if HIFI_USE_TRANSLUCENT or HIFI_USE_FORWARD@>
|
|
TransformCamera cam = getTransformCamera();
|
|
vec3 fragPosition = _positionES.xyz;
|
|
|
|
<@if HIFI_USE_TRANSLUCENT@>
|
|
_fragColor0 = vec4(evalGlobalLightingAlphaBlended(
|
|
cam._viewInverse,
|
|
1.0,
|
|
DEFAULT_OCCLUSION,
|
|
fragPosition,
|
|
normalize(_normalWS),
|
|
color.rgb,
|
|
DEFAULT_FRESNEL,
|
|
DEFAULT_METALLIC,
|
|
DEFAULT_EMISSIVE,
|
|
DEFAULT_ROUGHNESS, color.a),
|
|
color.a);
|
|
<@else@>
|
|
_fragColor0 = vec4(evalSkyboxGlobalColor(
|
|
cam._viewInverse,
|
|
1.0,
|
|
DEFAULT_OCCLUSION,
|
|
fragPosition,
|
|
normalize(_normalWS),
|
|
color.rgb,
|
|
DEFAULT_FRESNEL,
|
|
DEFAULT_METALLIC,
|
|
DEFAULT_ROUGHNESS),
|
|
color.a);
|
|
<@endif@>
|
|
<@else@>
|
|
packDeferredFragment(
|
|
normalize(_normalWS),
|
|
color.a,
|
|
color.rgb,
|
|
DEFAULT_ROUGHNESS,
|
|
DEFAULT_METALLIC,
|
|
DEFAULT_EMISSIVE,
|
|
DEFAULT_OCCLUSION,
|
|
DEFAULT_SCATTERING);
|
|
<@endif@>
|
|
<@endif@>
|
|
}
|