mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-21 10:13:43 +03:00
0026665: Visualization, TKOpenGl - specify precision for integer uniforms explicitly within OpenGL ES
Use lowp for enumerations / Boolean uniforms. Define default integer precision to highp in Fragment Shader when available.
This commit is contained in:
parent
f2f478782f
commit
a4eb991a8e
@ -228,7 +228,9 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
|
|||||||
#if defined(GL_ES_VERSION_2_0)
|
#if defined(GL_ES_VERSION_2_0)
|
||||||
TCollection_AsciiString aPrefix (theCtx->hasHighp
|
TCollection_AsciiString aPrefix (theCtx->hasHighp
|
||||||
? "precision highp float;\n"
|
? "precision highp float;\n"
|
||||||
: "precision mediump float;\n");
|
"precision highp int;\n"
|
||||||
|
: "precision mediump float;\n"
|
||||||
|
"precision mediump int;\n");
|
||||||
aSource = aHeader + aPrefix + aSource;
|
aSource = aHeader + aPrefix + aSource;
|
||||||
#else
|
#else
|
||||||
aSource = aHeader + aSource;
|
aSource = aHeader + aSource;
|
||||||
|
@ -33,6 +33,12 @@
|
|||||||
#define occTexture2D texture2D
|
#define occTexture2D texture2D
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef GL_ES
|
||||||
|
#define THE_PREC_ENUM lowp // enumerations should fit into lowp range
|
||||||
|
#else
|
||||||
|
#define THE_PREC_ENUM
|
||||||
|
#endif
|
||||||
|
|
||||||
// Vertex attributes
|
// Vertex attributes
|
||||||
#ifdef VERTEX_SHADER
|
#ifdef VERTEX_SHADER
|
||||||
THE_ATTRIBUTE vec4 occVertex;
|
THE_ATTRIBUTE vec4 occVertex;
|
||||||
@ -69,7 +75,7 @@ const int OccLightType_Spot = 3; //!< spot light source
|
|||||||
|
|
||||||
// Light sources
|
// Light sources
|
||||||
uniform vec4 occLightAmbient; //!< Cumulative ambient color
|
uniform vec4 occLightAmbient; //!< Cumulative ambient color
|
||||||
uniform int occLightSourcesCount; //!< Total number of light sources
|
uniform THE_PREC_ENUM int occLightSourcesCount; //!< Total number of light sources
|
||||||
int occLight_Type (in int theId); //!< Type of light source
|
int occLight_Type (in int theId); //!< Type of light source
|
||||||
int occLight_IsHeadlight (in int theId); //!< Is light a headlight?
|
int occLight_IsHeadlight (in int theId); //!< Is light a headlight?
|
||||||
vec4 occLight_Diffuse (in int theId); //!< Diffuse intensity for specified light source
|
vec4 occLight_Diffuse (in int theId); //!< Diffuse intensity for specified light source
|
||||||
@ -98,8 +104,8 @@ float occBackMaterial_Shininess(void); //!< Specular exponent
|
|||||||
float occBackMaterial_Transparency(void); //!< Transparency coefficient
|
float occBackMaterial_Transparency(void); //!< Transparency coefficient
|
||||||
|
|
||||||
uniform vec4 occColor; //!< color value (in case of disabled lighting)
|
uniform vec4 occColor; //!< color value (in case of disabled lighting)
|
||||||
uniform int occDistinguishingMode; //!< Are front and back faces distinguished?
|
uniform THE_PREC_ENUM int occDistinguishingMode; //!< Are front and back faces distinguished?
|
||||||
uniform int occTextureEnable; //!< Is texture enabled?
|
uniform THE_PREC_ENUM int occTextureEnable; //!< Is texture enabled?
|
||||||
uniform sampler2D occActiveSampler; //!< Current active sampler
|
uniform sampler2D occActiveSampler; //!< Current active sampler
|
||||||
uniform float occPointSize; //!< point size
|
uniform float occPointSize; //!< point size
|
||||||
|
|
||||||
@ -109,5 +115,5 @@ const int OccEquationCoords_World = 1; //!< world-space clipping plane
|
|||||||
|
|
||||||
//! Parameters of clipping planes
|
//! Parameters of clipping planes
|
||||||
uniform vec4 occClipPlaneEquations[THE_MAX_CLIP_PLANES];
|
uniform vec4 occClipPlaneEquations[THE_MAX_CLIP_PLANES];
|
||||||
uniform int occClipPlaneSpaces [THE_MAX_CLIP_PLANES];
|
uniform THE_PREC_ENUM int occClipPlaneSpaces [THE_MAX_CLIP_PLANES];
|
||||||
uniform int occClipPlaneCount; //!< Total number of clip planes
|
uniform THE_PREC_ENUM int occClipPlaneCount; //!< Total number of clip planes
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
// This file includes implementation of common functions and properties accessors
|
// This file includes implementation of common functions and properties accessors
|
||||||
|
|
||||||
// arrays of light sources
|
// arrays of light sources
|
||||||
uniform ivec2 occLightSourcesTypes[THE_MAX_LIGHTS]; //!< packed light sources types
|
uniform THE_PREC_ENUM ivec2 occLightSourcesTypes[THE_MAX_LIGHTS]; //!< packed light sources types
|
||||||
uniform vec4 occLightSources[THE_MAX_LIGHTS * 4]; //!< packed light sources parameters
|
uniform vec4 occLightSources[THE_MAX_LIGHTS * 4]; //!< packed light sources parameters
|
||||||
|
|
||||||
// light source properties accessors
|
// light source properties accessors
|
||||||
|
Loading…
x
Reference in New Issue
Block a user