mirror of
https://github.com/overte-org/overte.git
synced 2025-07-12 19:59:22 +02:00
90 lines
2.2 KiB
Text
90 lines
2.2 KiB
Text
<@include gpu/Config.slh@>
|
|
<$VERSION_HEADER$>
|
|
// Generated on <$_SCRIBE_DATE$>
|
|
//
|
|
// forward_simple.frag
|
|
// fragment shader
|
|
//
|
|
// Created by Andrzej Kapolka on 9/15/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 DefaultMaterials.slh@>
|
|
|
|
<@include ForwardGlobalLight.slh@>
|
|
<$declareEvalSkyboxGlobalColor()$>
|
|
|
|
|
|
// the interpolated normal
|
|
in vec3 _normalWS;
|
|
in vec3 _normalMS;
|
|
in vec4 _color;
|
|
in vec2 _texCoord0;
|
|
in vec4 _positionMS;
|
|
in vec4 _positionES;
|
|
|
|
// For retro-compatibility
|
|
#define _normal _normalWS
|
|
#define _modelNormal _normalMS
|
|
#define _position _positionMS
|
|
#define _eyePosition _positionES
|
|
|
|
layout(location = 0) out vec4 _fragColor0;
|
|
|
|
//PROCEDURAL_COMMON_BLOCK
|
|
|
|
#line 1001
|
|
//PROCEDURAL_BLOCK
|
|
|
|
#line 2030
|
|
void main(void) {
|
|
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
|
|
|
|
TransformCamera cam = getTransformCamera();
|
|
vec3 fragPosition = _positionES.xyz;
|
|
|
|
if (emissiveAmount > 0.0) {
|
|
_fragColor0 = vec4(evalSkyboxGlobalColor(
|
|
cam._viewInverse,
|
|
1.0,
|
|
DEFAULT_OCCLUSION,
|
|
fragPosition,
|
|
normal,
|
|
diffuse,
|
|
specular,
|
|
DEFAULT_METALLIC,
|
|
max(0.0, 1.0 - shininess / 128.0)),
|
|
1.0);
|
|
} else {
|
|
_fragColor0 = vec4(evalSkyboxGlobalColor(
|
|
cam._viewInverse,
|
|
1.0,
|
|
DEFAULT_OCCLUSION,
|
|
fragPosition,
|
|
normal,
|
|
diffuse,
|
|
DEFAULT_FRESNEL,
|
|
length(specular),
|
|
max(0.0, 1.0 - shininess / 128.0)),
|
|
1.0);
|
|
}
|
|
}
|