1-- glslfx version 0.1
2
3//
4// Copyright 2016 Pixar
5//
6// Licensed under the Apache License, Version 2.0 (the "Apache License")
7// with the following modification; you may not use this file except in
8// compliance with the Apache License and the following modification to it:
9// Section 6. Trademarks. is deleted and replaced with:
10//
11// 6. Trademarks. This License does not grant permission to use the trade
12//    names, trademarks, service marks, or product names of the Licensor
13//    and its affiliates, except as required to comply with Section 4(c) of
14//    the License and to reproduce the content of the NOTICE file.
15//
16// You may obtain a copy of the Apache License at
17//
18//     http://www.apache.org/licenses/LICENSE-2.0
19//
20// Unless required by applicable law or agreed to in writing, software
21// distributed under the Apache License with the above modification is
22// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
23// KIND, either express or implied. See the Apache License for the specific
24// language governing permissions and limitations under the Apache License.
25//
26
27--- This is what an import might look like.
28--- #import $TOOLS/hdSt/shaders/fallbackLighting.glslfx
29
30--- --------------------------------------------------------------------------
31-- glsl Fallback.LightIntegrator
32#ifndef HD_HAS_integrateLights
33#define HD_HAS_integrateLights
34#endif
35
36struct LightingContribution {
37    vec3 diffuse;
38};
39
40struct LightingInterfaceProperties {
41    float unused;
42};
43
44LightingContribution
45integrateLightsDefault(vec4 Peye, vec3 Neye, LightingInterfaceProperties props)
46{
47    vec3 n = normalize(Neye);
48
49    LightingContribution result;
50    result.diffuse = vec3(dot(n, vec3(0,0,1)));
51
52    return result;
53}
54
55LightingContribution
56integrateLightsConstant(vec4 Peye, vec3 Neye, LightingInterfaceProperties props)
57{
58    LightingContribution result;
59    //pefectly diffuse white hemisphere contribution
60    result.diffuse = vec3(1);
61
62    return result;
63}
64
65-- glsl Fallback.Lighting
66
67LightingContribution
68integrateLights(vec4 Peye, vec3 Neye, LightingInterfaceProperties props);
69
70vec3 FallbackLighting(in vec3 Peye, in vec3 Neye, in vec3 color)
71{
72    LightingInterfaceProperties props;
73    LightingContribution light = integrateLights(vec4(Peye, 1), Neye, props);
74    return color * light.diffuse;
75}
76