" #define occTexture1D texture\n"
" #define occTexture2D texture\n"
" #define occTexture3D texture\n"
+ " #define occTextureCube texture\n"
+ " #define occTextureCubeLod textureLod\n"
"#else\n"
" #define THE_ATTRIBUTE attribute\n"
" #define THE_SHADER_IN varying\n"
" #define occTexture1D texture1D\n"
" #define occTexture2D texture2D\n"
" #define occTexture3D texture3D\n"
+ " #define occTextureCube textureCube\n"
+ " #define occTextureCubeLod textureCubeLod\n"
"#endif\n"
"\n"
"#ifdef GL_ES\n"
- " #define THE_PREC_ENUM lowp // enumerations should fit into lowp range\n"
+ "#if (__VERSION__ >= 300)\n"
+ " #define THE_PREC_ENUM highp // lowp should be enough for enums but triggers driver bugs\n"
+ "#else\n"
+ " #define THE_PREC_ENUM lowp\n"
+ "#endif\n"
"#else\n"
" #define THE_PREC_ENUM\n"
"#endif\n"
" void occSetFragColor (in vec4 theColor);\n"
"#endif\n"
"\n"
+ "// Pi number definitions\n"
+ "#define PI 3.141592654\n"
+ "#define PI_2 6.283185307\n"
+ "#define PI_DIV_2 1.570796327\n"
+ "#define PI_DIV_3 1.047197551\n"
+ "#define PI_DIV_4 0.785398163\n"
+ "#define INV_PI 0.318309886\n"
+ "#define INV_PI_2 0.159154943\n"
+ "\n"
"// Matrix state\n"
"uniform mat4 occWorldViewMatrix; //!< World-view matrix\n"
"uniform mat4 occProjectionMatrix; //!< Projection matrix\n"
"uniform mat4 occProjectionMatrixInverseTranspose; //!< Transpose of the inverse of the projection matrix\n"
"uniform mat4 occModelWorldMatrixInverseTranspose; //!< Transpose of the inverse of the model-world matrix\n"
"\n"
+ "#if defined(THE_IS_PBR)\n"
+ "uniform sampler2D occEnvLUT; //!< Environment Lookup Table\n"
+ "uniform sampler2D occDiffIBLMapSHCoeffs; //!< Packed diffuse (irradiance) IBL map's spherical harmonics coefficients\n"
+ "uniform samplerCube occSpecIBLMap; //!< Specular IBL map\n"
+ "uniform int occNbSpecIBLLevels; //!< Number of mipmap levels used in occSpecIBLMap to store different roughness values maps\n"
+ "\n"
+ "vec3 occDiffIBLMap (in vec3 theNormal); //!< Unpacks spherical harmonics coefficients to diffuse IBL map's values\n"
+ "#endif\n"
+ "\n"
"// light type enumeration (same as Graphic3d_TypeOfLightSource)\n"
"const int OccLightType_Direct = 1; //!< directional light source\n"
"const int OccLightType_Point = 2; //!< isotropic point light source\n"
"#define occLight_Type(theId) occLightSourcesTypes[theId].x\n"
"\n"
"//! Is light a headlight, int?\n"
- "#define occLight_IsHeadlight(theId) occLightSourcesTypes[theId].y\n"
+ "#define occLight_IsHeadlight(theId) (occLightSourcesTypes[theId].y != 0)\n"
"\n"
"//! Specular intensity (equals to diffuse), vec4.\n"
"#define occLight_Specular(theId) occLightSources[theId * 4 + 0]\n"
"//! Attenuation of the spot light intensity (from 0 to 1), float.\n"
"#define occLight_SpotExponent(theId) occLightSources[theId * 4 + 3].w\n"
"\n"
+ "#if defined(THE_IS_PBR)\n"
+ "//! Intensity of light source (>= 0), float.\n"
+ "#define occLight_Intensity(theId) occLightSources[theId * 4 + 0].a\n"
+ "#else\n"
+ "\n"
"//! Diffuse intensity (equals to Specular), vec4.\n"
"#define occLight_Diffuse(theId) occLightSources[theId * 4 + 0]\n"
"\n"
"//! Linear attenuation factor of positional light source, float.\n"
"#define occLight_LinearAttenuation(theId) occLightSources[theId * 4 + 3].y\n"
"#endif\n"
+ "#endif\n"
+ "\n"
+ "// Converts roughness value from range [0, 1] to real value for calculations\n"
+ "float occRoughness (in float theNormalizedRoughness);\n"
"\n"
"// Front material properties accessors\n"
- "vec4 occFrontMaterial_Emission(void); //!< Emission color\n"
- "vec4 occFrontMaterial_Ambient(void); //!< Ambient reflection\n"
- "vec4 occFrontMaterial_Diffuse(void); //!< Diffuse reflection\n"
- "vec4 occFrontMaterial_Specular(void); //!< Specular reflection\n"
- "float occFrontMaterial_Shininess(void); //!< Specular exponent\n"
- "float occFrontMaterial_Transparency(void); //!< Transparency coefficient\n"
+ "#if !defined(THE_IS_PBR)\n"
+ "vec4 occFrontMaterial_Emission(void); //!< Emission color\n"
+ "vec4 occFrontMaterial_Ambient(void); //!< Ambient reflection\n"
+ "vec4 occFrontMaterial_Diffuse(void); //!< Diffuse reflection\n"
+ "vec4 occFrontMaterial_Specular(void); //!< Specular reflection\n"
+ "float occFrontMaterial_Shininess(void); //!< Specular exponent\n"
+ "float occFrontMaterial_Transparency(void); //!< Transparency coefficient\n"
+ "#else\n"
+ "vec4 occPBRFrontMaterial_Color(void); //!< Base color of PBR material\n"
+ "float occPBRFrontMaterial_Metallic(void); //!< Metallic coefficient\n"
+ "float occPBRFrontMaterial_Roughness(void); //!< Roughness coefficient\n"
+ "float occPBRFrontMaterial_NormalizedRoughness(void); //!< Normalized roughness coefficient\n"
+ "vec3 occPBRFrontMaterial_Emission(void); //!< Light intensity emitted by material\n"
+ "float occPBRFrontMaterial_IOR(void); //!< Index of refraction\n"
+ "#endif\n"
"\n"
"// Back material properties accessors\n"
- "vec4 occBackMaterial_Emission(void); //!< Emission color\n"
- "vec4 occBackMaterial_Ambient(void); //!< Ambient reflection\n"
- "vec4 occBackMaterial_Diffuse(void); //!< Diffuse reflection\n"
- "vec4 occBackMaterial_Specular(void); //!< Specular reflection\n"
- "float occBackMaterial_Shininess(void); //!< Specular exponent\n"
- "float occBackMaterial_Transparency(void); //!< Transparency coefficient\n"
+ "#if !defined(THE_IS_PBR)\n"
+ "vec4 occBackMaterial_Emission(void); //!< Emission color\n"
+ "vec4 occBackMaterial_Ambient(void); //!< Ambient reflection\n"
+ "vec4 occBackMaterial_Diffuse(void); //!< Diffuse reflection\n"
+ "vec4 occBackMaterial_Specular(void); //!< Specular reflection\n"
+ "float occBackMaterial_Shininess(void); //!< Specular exponent\n"
+ "float occBackMaterial_Transparency(void); //!< Transparency coefficient\n"
+ "#else\n"
+ "vec4 occPBRBackMaterial_Color(void); //!< Base color of PBR material\n"
+ "float occPBRBackMaterial_Metallic(void); //!< Metallic coefficient\n"
+ "float occPBRBackMaterial_Roughness(void); //!< Roughness coefficient\n"
+ "float occPBRBackMaterial_NormalizedRoughness(void); //!< Normalized roughness coefficient\n"
+ "vec3 occPBRBackMaterial_Emission(void); //!< Light intensity emitted by material\n"
+ "float occPBRBackMaterial_IOR(void); //!< Index of refraction\n"
+ "#endif\n"
"\n"
"#ifdef THE_HAS_DEFAULT_SAMPLER\n"
"#define occActiveSampler occSampler0 //!< alias for backward compatibility\n"