12381341 |
1 | |
d95f5ce1 |
2 | //! @file DeclarationsImpl.glsl includes implementation of common functions and properties accessors |
b17e5bae |
3 | #if defined(FRAGMENT_SHADER) |
c40eb6b9 |
4 | //! Output color (and coverage for accumulation by OIT algorithm). |
b17e5bae |
5 | void occSetFragColor (in vec4 theColor) |
6 | { |
c40eb6b9 |
7 | #if defined(OCC_ALPHA_TEST) |
8 | if (theColor.a < occAlphaCutoff) discard; |
9 | #endif |
10 | #if defined(OCC_WRITE_WEIGHT_OIT_COVERAGE) |
b17e5bae |
11 | float aWeight = theColor.a * clamp (1e+2 * pow (1.0 - gl_FragCoord.z * occOitDepthFactor, 3.0), 1e-2, 1e+2); |
12 | occFragCoverage.r = theColor.a * aWeight; |
13 | occFragColor = vec4 (theColor.rgb * theColor.a * aWeight, theColor.a); |
b17e5bae |
14 | #else |
c40eb6b9 |
15 | occFragColor = theColor; |
b17e5bae |
16 | #endif |
c40eb6b9 |
17 | } |
b17e5bae |
18 | #endif |
19 | |
daf73ab7 |
20 | #if defined(THE_MAX_LIGHTS) && (THE_MAX_LIGHTS > 0) |
12381341 |
21 | // arrays of light sources |
8a53d1c4 |
22 | uniform THE_PREC_ENUM ivec2 occLightSourcesTypes[THE_MAX_LIGHTS]; //!< packed light sources types |
23 | uniform vec4 occLightSources[THE_MAX_LIGHTS * 4]; //!< packed light sources parameters |
12381341 |
24 | |
25 | // light source properties accessors |
26 | int occLight_Type (in int theId) { return occLightSourcesTypes[theId].x; } |
27 | int occLight_IsHeadlight (in int theId) { return occLightSourcesTypes[theId].y; } |
28 | vec4 occLight_Diffuse (in int theId) { return occLightSources[theId * 4 + 0]; } |
29 | vec4 occLight_Specular (in int theId) { return occLightSources[theId * 4 + 0]; } |
30 | vec4 occLight_Position (in int theId) { return occLightSources[theId * 4 + 1]; } |
31 | vec4 occLight_SpotDirection (in int theId) { return occLightSources[theId * 4 + 2]; } |
32 | float occLight_ConstAttenuation (in int theId) { return occLightSources[theId * 4 + 3].x; } |
33 | float occLight_LinearAttenuation (in int theId) { return occLightSources[theId * 4 + 3].y; } |
34 | float occLight_SpotCutOff (in int theId) { return occLightSources[theId * 4 + 3].z; } |
35 | float occLight_SpotExponent (in int theId) { return occLightSources[theId * 4 + 3].w; } |
daf73ab7 |
36 | #endif |
12381341 |
37 | |
38 | // material state |
39 | uniform vec4 occFrontMaterial[5]; |
40 | uniform vec4 occBackMaterial[5]; |
41 | |
42 | // front material properties accessors |
0adbd30f |
43 | vec4 occFrontMaterial_Ambient(void) { return occFrontMaterial[0]; } |
44 | vec4 occFrontMaterial_Diffuse(void) { return occFrontMaterial[1]; } |
45 | vec4 occFrontMaterial_Specular(void) { return occFrontMaterial[2]; } |
46 | vec4 occFrontMaterial_Emission(void) { return occFrontMaterial[3]; } |
12381341 |
47 | float occFrontMaterial_Shininess(void) { return occFrontMaterial[4].x; } |
48 | float occFrontMaterial_Transparency(void) { return occFrontMaterial[4].y; } |
49 | |
50 | // back material properties accessors |
0adbd30f |
51 | vec4 occBackMaterial_Ambient(void) { return occBackMaterial[0]; } |
52 | vec4 occBackMaterial_Diffuse(void) { return occBackMaterial[1]; } |
53 | vec4 occBackMaterial_Specular(void) { return occBackMaterial[2]; } |
54 | vec4 occBackMaterial_Emission(void) { return occBackMaterial[3]; } |
12381341 |
55 | float occBackMaterial_Shininess(void) { return occBackMaterial[4].x; } |
56 | float occBackMaterial_Transparency(void) { return occBackMaterial[4].y; } |
79f4f036 |
57 | |
58 | // 2D texture coordinates transformation |
59 | vec2 occTextureTrsf_Translation(void) { return occTexTrsf2d[0].xy; } |
60 | vec2 occTextureTrsf_Scale(void) { return occTexTrsf2d[0].zw; } |
61 | float occTextureTrsf_RotationSin(void) { return occTexTrsf2d[1].x; } |
62 | float occTextureTrsf_RotationCos(void) { return occTexTrsf2d[1].y; } |
d95f5ce1 |
63 | //! @endfile DeclarationsImpl.glsl |