mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 19:24:32 +02:00
71 lines
2 KiB
Text
71 lines
2 KiB
Text
<@include gpu/Config.slh@>
|
|
<$VERSION_HEADER$>
|
|
// Generated on <$_SCRIBE_DATE$>
|
|
//
|
|
// overlay3D_translucent.slf
|
|
// fragment shader
|
|
//
|
|
// Created by Sam Gateau on 6/16/15.
|
|
// Copyright 2015 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 DeferredLighting.slh@>
|
|
<@include model/Light.slh@>
|
|
|
|
<@include gpu/Transform.slh@>
|
|
<$declareStandardCameraTransform()$>
|
|
|
|
vec4 evalGlobalColor(float shadowAttenuation, vec3 position, vec3 normal, vec3 diffuse, vec3 specular, float gloss, float opacity) {
|
|
|
|
// Need the light now
|
|
Light light = getLight();
|
|
TransformCamera cam = getTransformCamera();
|
|
vec3 fragNormal;
|
|
<$transformEyeToWorldDir(cam, normal, fragNormal)$>
|
|
vec3 fragEyeVectorView = normalize(-position);
|
|
vec3 fragEyeDir;
|
|
<$transformEyeToWorldDir(cam, fragEyeVectorView, fragEyeDir)$>
|
|
|
|
vec3 color = opacity * diffuse.rgb * getLightColor(light) * getLightAmbientIntensity(light);
|
|
|
|
vec4 shading = evalFragShading(fragNormal, -getLightDirection(light), fragEyeDir, specular, gloss);
|
|
|
|
color += vec3(diffuse * shading.w * opacity + shading.rgb) * shadowAttenuation * getLightColor(light) * getLightIntensity(light);
|
|
|
|
return vec4(color, opacity);
|
|
}
|
|
|
|
uniform sampler2D originalTexture;
|
|
|
|
in vec2 _texCoord0;
|
|
in vec4 _position;
|
|
in vec3 _normal;
|
|
in vec3 _color;
|
|
in float _alpha;
|
|
|
|
out vec4 _fragColor;
|
|
|
|
void main(void) {
|
|
vec4 diffuse = texture(originalTexture, _texCoord0);
|
|
|
|
vec3 fragPosition = _position.xyz;
|
|
vec3 fragNormal = normalize(_normal);
|
|
vec3 fragDiffuse = diffuse.rgb * _color;
|
|
vec3 fragSpecular = vec3(0.1);
|
|
float fragGloss = 10.0 / 128.0;
|
|
float fragOpacity = diffuse.a * _alpha;
|
|
|
|
vec4 color = evalGlobalColor(1.0,
|
|
fragPosition,
|
|
fragNormal,
|
|
fragDiffuse,
|
|
fragSpecular,
|
|
fragGloss,
|
|
fragOpacity);
|
|
|
|
// Apply standard tone mapping
|
|
_fragColor = vec4(pow(color.xyz, vec3(1.0 / 2.2)), color.w);
|
|
}
|