Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Molstar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
d0c0d8e7
Commit
d0c0d8e7
authored
3 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
require standardDerivatives glsl extension
parent
ebf64404
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/mol-gl/shader-code.ts
+5
-11
5 additions, 11 deletions
src/mol-gl/shader-code.ts
src/mol-gl/shader/mesh.frag.ts
+5
-9
5 additions, 9 deletions
src/mol-gl/shader/mesh.frag.ts
src/mol-gl/webgl/extensions.ts
+3
-5
3 additions, 5 deletions
src/mol-gl/webgl/extensions.ts
with
13 additions
and
25 deletions
src/mol-gl/shader-code.ts
+
5
−
11
View file @
d0c0d8e7
...
@@ -17,7 +17,6 @@ const shaderCodeId = idFactory();
...
@@ -17,7 +17,6 @@ const shaderCodeId = idFactory();
type
ShaderExtensionsValue
=
'
required
'
|
'
optional
'
type
ShaderExtensionsValue
=
'
required
'
|
'
optional
'
export
interface
ShaderExtensions
{
export
interface
ShaderExtensions
{
readonly
standardDerivatives
?:
ShaderExtensionsValue
readonly
fragDepth
?:
ShaderExtensionsValue
readonly
fragDepth
?:
ShaderExtensionsValue
readonly
drawBuffers
?:
ShaderExtensionsValue
readonly
drawBuffers
?:
ShaderExtensionsValue
readonly
shaderTextureLod
?:
ShaderExtensionsValue
readonly
shaderTextureLod
?:
ShaderExtensionsValue
...
@@ -163,7 +162,7 @@ export const CylindersShaderCode = ShaderCode('cylinders', cylinders_vert, cylin
...
@@ -163,7 +162,7 @@ export const CylindersShaderCode = ShaderCode('cylinders', cylinders_vert, cylin
import
{
text_vert
}
from
'
./shader/text.vert
'
;
import
{
text_vert
}
from
'
./shader/text.vert
'
;
import
{
text_frag
}
from
'
./shader/text.frag
'
;
import
{
text_frag
}
from
'
./shader/text.frag
'
;
export
const
TextShaderCode
=
ShaderCode
(
'
text
'
,
text_vert
,
text_frag
,
{
standardDerivatives
:
'
required
'
,
drawBuffers
:
'
optional
'
});
export
const
TextShaderCode
=
ShaderCode
(
'
text
'
,
text_vert
,
text_frag
,
{
drawBuffers
:
'
optional
'
});
import
{
lines_vert
}
from
'
./shader/lines.vert
'
;
import
{
lines_vert
}
from
'
./shader/lines.vert
'
;
import
{
lines_frag
}
from
'
./shader/lines.frag
'
;
import
{
lines_frag
}
from
'
./shader/lines.frag
'
;
...
@@ -171,7 +170,7 @@ export const LinesShaderCode = ShaderCode('lines', lines_vert, lines_frag, { dra
...
@@ -171,7 +170,7 @@ export const LinesShaderCode = ShaderCode('lines', lines_vert, lines_frag, { dra
import
{
mesh_vert
}
from
'
./shader/mesh.vert
'
;
import
{
mesh_vert
}
from
'
./shader/mesh.vert
'
;
import
{
mesh_frag
}
from
'
./shader/mesh.frag
'
;
import
{
mesh_frag
}
from
'
./shader/mesh.frag
'
;
export
const
MeshShaderCode
=
ShaderCode
(
'
mesh
'
,
mesh_vert
,
mesh_frag
,
{
standardDerivatives
:
'
optional
'
,
drawBuffers
:
'
optional
'
});
export
const
MeshShaderCode
=
ShaderCode
(
'
mesh
'
,
mesh_vert
,
mesh_frag
,
{
drawBuffers
:
'
optional
'
});
import
{
directVolume_vert
}
from
'
./shader/direct-volume.vert
'
;
import
{
directVolume_vert
}
from
'
./shader/direct-volume.vert
'
;
import
{
directVolume_frag
}
from
'
./shader/direct-volume.frag
'
;
import
{
directVolume_frag
}
from
'
./shader/direct-volume.frag
'
;
...
@@ -209,11 +208,9 @@ function getDefinesCode(defines: ShaderDefines) {
...
@@ -209,11 +208,9 @@ function getDefinesCode(defines: ShaderDefines) {
}
}
function
getGlsl100FragPrefix
(
extensions
:
WebGLExtensions
,
shaderExtensions
:
ShaderExtensions
)
{
function
getGlsl100FragPrefix
(
extensions
:
WebGLExtensions
,
shaderExtensions
:
ShaderExtensions
)
{
const
prefix
:
string
[]
=
[];
const
prefix
:
string
[]
=
[
if
(
shaderExtensions
.
standardDerivatives
)
{
'
#extension GL_OES_standard_derivatives : enable
'
prefix
.
push
(
'
#extension GL_OES_standard_derivatives : enable
'
);
];
prefix
.
push
(
'
#define enabledStandardDerivatives
'
);
}
if
(
shaderExtensions
.
fragDepth
)
{
if
(
shaderExtensions
.
fragDepth
)
{
if
(
extensions
.
fragDepth
)
{
if
(
extensions
.
fragDepth
)
{
prefix
.
push
(
'
#extension GL_EXT_frag_depth : enable
'
);
prefix
.
push
(
'
#extension GL_EXT_frag_depth : enable
'
);
...
@@ -268,9 +265,6 @@ function getGlsl300FragPrefix(gl: WebGL2RenderingContext, extensions: WebGLExten
...
@@ -268,9 +265,6 @@ function getGlsl300FragPrefix(gl: WebGL2RenderingContext, extensions: WebGLExten
`layout(location = 0) out highp
${
outTypes
[
0
]
||
'
vec4
'
}
out_FragData0;`
`layout(location = 0) out highp
${
outTypes
[
0
]
||
'
vec4
'
}
out_FragData0;`
];
];
if
(
shaderExtensions
.
standardDerivatives
)
{
prefix
.
push
(
'
#define enabledStandardDerivatives
'
);
}
if
(
shaderExtensions
.
fragDepth
)
{
if
(
shaderExtensions
.
fragDepth
)
{
prefix
.
push
(
'
#define enabledFragDepth
'
);
prefix
.
push
(
'
#define enabledFragDepth
'
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/mol-gl/shader/mesh.frag.ts
+
5
−
9
View file @
d0c0d8e7
...
@@ -19,14 +19,10 @@ void main() {
...
@@ -19,14 +19,10 @@ void main() {
#include clip_pixel
#include clip_pixel
// Workaround for buggy gl_FrontFacing (e.g. on some integrated Intel GPUs)
// Workaround for buggy gl_FrontFacing (e.g. on some integrated Intel GPUs)
#if defined(enabledStandardDerivatives)
vec3 fdx = dFdx(vViewPosition);
vec3 fdx = dFdx(vViewPosition);
vec3 fdy = dFdy(vViewPosition);
vec3 fdy = dFdy(vViewPosition);
vec3 faceNormal = normalize(cross(fdx,fdy));
vec3 faceNormal = normalize(cross(fdx,fdy));
bool frontFacing = dot(vNormal, faceNormal) > 0.0;
bool frontFacing = dot(vNormal, faceNormal) > 0.0;
#else
bool frontFacing = dot(vNormal, vViewPosition) < 0.0;
#endif
#if defined(dFlipSided)
#if defined(dFlipSided)
interior = frontFacing;
interior = frontFacing;
...
@@ -48,7 +44,7 @@ void main() {
...
@@ -48,7 +44,7 @@ void main() {
#ifdef dIgnoreLight
#ifdef dIgnoreLight
gl_FragColor = material;
gl_FragColor = material;
#else
#else
#if defined(dFlatShaded)
&& defined(enabledStandardDerivatives)
#if defined(dFlatShaded)
vec3 normal = -faceNormal;
vec3 normal = -faceNormal;
#else
#else
vec3 normal = -normalize(vNormal);
vec3 normal = -normalize(vNormal);
...
...
This diff is collapsed.
Click to expand it.
src/mol-gl/webgl/extensions.ts
+
3
−
5
View file @
d0c0d8e7
...
@@ -36,13 +36,11 @@ export function createExtensions(gl: GLRenderingContext): WebGLExtensions {
...
@@ -36,13 +36,11 @@ export function createExtensions(gl: GLRenderingContext): WebGLExtensions {
if
(
elementIndexUint
===
null
)
{
if
(
elementIndexUint
===
null
)
{
throw
new
Error
(
'
Could not find support for "element_index_uint"
'
);
throw
new
Error
(
'
Could not find support for "element_index_uint"
'
);
}
}
const
standardDerivatives
=
getStandardDerivatives
(
gl
);
const
standardDerivatives
=
getStandardDerivatives
(
gl
);
if
(
isDebugMode
&&
standardDerivatives
===
null
)
{
if
(
standardDerivatives
===
null
)
{
// - non-support handled downstream (flat shading option is ignored)
throw
new
Error
(
'
Could not find support for "standard_derivatives"
'
);
// - can't be a required extension because it is not supported by `headless-gl`
console
.
log
(
'
Could not find support for "standard_derivatives"
'
);
}
}
const
textureFloat
=
getTextureFloat
(
gl
);
const
textureFloat
=
getTextureFloat
(
gl
);
if
(
isDebugMode
&&
textureFloat
===
null
)
{
if
(
isDebugMode
&&
textureFloat
===
null
)
{
console
.
log
(
'
Could not find support for "texture_float"
'
);
console
.
log
(
'
Could not find support for "texture_float"
'
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment