From a3f9b75d0b3fb74c4ebb37eb937cfd078f0f7253 Mon Sep 17 00:00:00 2001 From: Nehon Date: Tue, 30 Dec 2014 07:52:18 +0100 Subject: [PATCH] Added proper naming of const in Optics.glsllib and some define tests to avoid name collision when importing several glsllib --- .../src/main/resources/Common/ShaderLib/Optics.glsllib | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/jme3-core/src/main/resources/Common/ShaderLib/Optics.glsllib b/jme3-core/src/main/resources/Common/ShaderLib/Optics.glsllib index 546d7a1af..642e3fb90 100644 --- a/jme3-core/src/main/resources/Common/ShaderLib/Optics.glsllib +++ b/jme3-core/src/main/resources/Common/ShaderLib/Optics.glsllib @@ -23,13 +23,15 @@ vec2 Optics_SphereCoord(in vec3 dir){ return (dir.xy * vec2(inv_two_p)) + vec2(0.5); } -#define PI 3.141592653589793 -//const vec2 rads = vec2(1.0 / (PI * 2.0), 1.0 / PI); -const vec2 rads = vec2(0.159154943091895, 0.318309886183790); +#ifndef PI + #define PI 3.14159265358979323846264 +#endif +//should be vec2(1.0 / (PI * 2.0), 1.0 / PI) but it's precomputed. +const vec2 Optics_Glsllib_Rads = vec2(0.159154943091895, 0.318309886183790); vec2 Optics_LonLatCoords(in ENVMAP envMap, in vec3 dir){ float lon = atan(dir.z, dir.x)+ PI; float lat = acos(dir.y); - return vec2(lon, lat) * rads; + return vec2(lon, lat) * Optics_Glsllib_Rads; } vec4 Optics_GetEnvColor(in ENVMAP envMap, in vec3 dir){