// Generated on <$_SCRIBE_DATE$>//// Created by Sam Gateau on 7/5/16.// Copyright 2016 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 ShadingModel.slh@> <@func declareLightingPoint(supportScattering)@> void evalLightingPoint(out vec3 diffuse, out vec3 specular, Light light, vec4 fragLightDirLen, SurfaceData surface, float metallic, vec3 fresnel, vec3 albedo, float shadow<@if supportScattering@> , float scattering, vec4 midNormalCurvature, vec4 lowNormalCurvature<@endif@> ) { // Allright we re valid in the volume float fragLightDistance = fragLightDirLen.w; vec3 fragLightDir = fragLightDirLen.xyz; updateSurfaceDataWithLight(surface, fragLightDir); // Eval attenuation float radialAttenuation = lightIrradiance_evalLightAttenuation(light.irradiance, fragLightDistance); vec3 lightEnergy = radialAttenuation * shadow * getLightIrradiance(light); // Eval shading evalFragShading(diffuse, specular, metallic, fresnel, surface, albedo<@if supportScattering@> ,scattering, midNormalCurvature, lowNormalCurvature<@endif@> ); lightEnergy *= isPointEnabled(); diffuse *= lightEnergy * isDiffuseEnabled(); specular *= lightEnergy * isSpecularEnabled(); if (isShowLightContour() > 0.0) { // Show edges float edge = abs(2.0 * ((lightVolume_getRadius(light.volume) - fragLightDistance) / (0.1)) - 1.0); float edgeCoord = exp2(-8.0 * edge * edge); diffuse = mix(diffuse, vec3(edgeCoord * edgeCoord * getLightColor(light)), float(edge < 1.0)); }} <@endfunc@> <@func declareDrawPointOutline()@> bool evalLightPointEdge(out vec3 color, Light light, vec4 fragLightDirLen, vec3 fragEyeDir) { // Allright we re valid in the volume float fragLightDistance = fragLightDirLen.w; vec3 fragLightDir = fragLightDirLen.xyz; // Show edges float edge = abs(2.0 * ((lightVolume_getRadius(light.volume) - fragLightDistance) / (0.1)) - 1.0); float edgeCoord = exp2(-8.0 * edge * edge); color = mix(color, vec3(edgeCoord * edgeCoord * getLightColor(light)), float(edge < 1.0)); return (edge < 1.0);} <@endfunc@>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Sam Gateau on 7/5/16.
// Copyright 2016 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 ShadingModel.slh@>
<@func declareLightingPoint(supportScattering)@>
void evalLightingPoint(out vec3 diffuse, out vec3 specular, Light light,
vec4 fragLightDirLen, SurfaceData surface,
float metallic, vec3 fresnel, vec3 albedo, float shadow
<@if supportScattering@>
, float scattering, vec4 midNormalCurvature, vec4 lowNormalCurvature
<@endif@>
) {
// Allright we re valid in the volume
float fragLightDistance = fragLightDirLen.w;
vec3 fragLightDir = fragLightDirLen.xyz;
updateSurfaceDataWithLight(surface, fragLightDir);
// Eval attenuation
float radialAttenuation = lightIrradiance_evalLightAttenuation(light.irradiance, fragLightDistance);
vec3 lightEnergy = radialAttenuation * shadow * getLightIrradiance(light);
// Eval shading
evalFragShading(diffuse, specular, metallic, fresnel, surface, albedo
<@if supportScattering@>
,scattering, midNormalCurvature, lowNormalCurvature
<@endif@>
);
lightEnergy *= isPointEnabled();
diffuse *= lightEnergy * isDiffuseEnabled();
specular *= lightEnergy * isSpecularEnabled();
if (isShowLightContour() > 0.0) {
// Show edges
float edge = abs(2.0 * ((lightVolume_getRadius(light.volume) - fragLightDistance) / (0.1)) - 1.0);
float edgeCoord = exp2(-8.0 * edge * edge);
diffuse = mix(diffuse, vec3(edgeCoord * edgeCoord * getLightColor(light)), float(edge < 1.0));
}
}
<@endfunc@>
<@func declareDrawPointOutline()@>
bool evalLightPointEdge(out vec3 color, Light light, vec4 fragLightDirLen, vec3 fragEyeDir) {
// Allright we re valid in the volume
float fragLightDistance = fragLightDirLen.w;
vec3 fragLightDir = fragLightDirLen.xyz;
// Show edges
float edge = abs(2.0 * ((lightVolume_getRadius(light.volume) - fragLightDistance) / (0.1)) - 1.0);
float edgeCoord = exp2(-8.0 * edge * edge);
color = mix(color, vec3(edgeCoord * edgeCoord * getLightColor(light)), float(edge < 1.0));
return (edge < 1.0);
}
<@endfunc@>