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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
ee4ce2fd
Commit
ee4ce2fd
authored
4 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
simplify copy shader
parent
db0aa12e
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mol-canvas3d/passes/draw.ts
+18
-24
18 additions, 24 deletions
src/mol-canvas3d/passes/draw.ts
src/mol-gl/shader/copy.frag.ts
+1
-9
1 addition, 9 deletions
src/mol-gl/shader/copy.frag.ts
with
19 additions
and
33 deletions
src/mol-canvas3d/passes/draw.ts
+
18
−
24
View file @
ee4ce2fd
...
...
@@ -22,7 +22,7 @@ import { Helper } from '../helper/helper';
import
quad_vert
from
'
../../mol-gl/shader/quad.vert
'
;
import
depthMerge_frag
from
'
../../mol-gl/shader/depth-merge.frag
'
;
import
copy
Fbo
_frag
from
'
../../mol-gl/shader/copy
-fbo
.frag
'
;
import
{
copy_frag
}
from
'
../../mol-gl/shader/copy.frag
'
;
import
{
StereoCamera
}
from
'
../camera/stereo
'
;
import
{
WboitPass
}
from
'
./wboit
'
;
import
{
AntialiasingPass
,
PostprocessingPass
,
PostprocessingProps
}
from
'
./postprocessing
'
;
...
...
@@ -52,25 +52,23 @@ function getDepthMergeRenderable(ctx: WebGLContext, depthTexturePrimitives: Text
return
createComputeRenderable
(
renderItem
,
values
);
}
const
Copy
Fbo
Schema
=
{
const
CopySchema
=
{
...
QuadSchema
,
tColor
:
TextureSpec
(
'
texture
'
,
'
rgba
'
,
'
ubyte
'
,
'
nearest
'
),
tDepth
:
TextureSpec
(
'
texture
'
,
'
depth
'
,
'
ushort
'
,
'
nearest
'
),
uTexSize
:
UniformSpec
(
'
v2
'
),
};
const
Copy
Fbo
ShaderCode
=
ShaderCode
(
'
copy
-fbo
'
,
quad_vert
,
copy
Fbo
_frag
,
{
fragDepth
:
'
required
'
}
);
type
Copy
Fbo
Renderable
=
ComputeRenderable
<
Values
<
typeof
Copy
Fbo
Schema
>>
const
CopyShaderCode
=
ShaderCode
(
'
copy
'
,
quad_vert
,
copy_frag
);
type
CopyRenderable
=
ComputeRenderable
<
Values
<
typeof
CopySchema
>>
function
getCopy
Fbo
Renderable
(
ctx
:
WebGLContext
,
colorTexture
:
Texture
,
depthTexture
:
Texture
):
Copy
Fbo
Renderable
{
const
values
:
Values
<
typeof
Copy
Fbo
Schema
>
=
{
function
getCopyRenderable
(
ctx
:
WebGLContext
,
colorTexture
:
Texture
):
CopyRenderable
{
const
values
:
Values
<
typeof
CopySchema
>
=
{
...
QuadValues
,
tColor
:
ValueCell
.
create
(
colorTexture
),
tDepth
:
ValueCell
.
create
(
depthTexture
),
uTexSize
:
ValueCell
.
create
(
Vec2
.
create
(
colorTexture
.
getWidth
(),
colorTexture
.
getHeight
())),
};
const
schema
=
{
...
Copy
Fbo
Schema
};
const
renderItem
=
createComputeRenderItem
(
ctx
,
'
triangles
'
,
Copy
Fbo
ShaderCode
,
schema
,
values
);
const
schema
=
{
...
CopySchema
};
const
renderItem
=
createComputeRenderItem
(
ctx
,
'
triangles
'
,
CopyShaderCode
,
schema
,
values
);
return
createComputeRenderable
(
renderItem
,
values
);
}
...
...
@@ -90,8 +88,8 @@ export class DrawPass {
private
depthTextureVolumes
:
Texture
private
depthMerge
:
DepthMergeRenderable
private
copyFboTarget
:
Copy
Fbo
Renderable
private
copyFboPostprocessing
:
Copy
Fbo
Renderable
private
copyFboTarget
:
CopyRenderable
private
copyFboPostprocessing
:
CopyRenderable
private
wboit
:
WboitPass
|
undefined
readonly
postprocessing
:
PostprocessingPass
...
...
@@ -127,8 +125,8 @@ export class DrawPass {
this
.
postprocessing
=
new
PostprocessingPass
(
webgl
,
this
);
this
.
antialiasing
=
new
AntialiasingPass
(
webgl
,
this
);
this
.
copyFboTarget
=
getCopy
Fbo
Renderable
(
webgl
,
this
.
colorTarget
.
texture
,
this
.
depthTarget
.
texture
);
this
.
copyFboPostprocessing
=
getCopy
Fbo
Renderable
(
webgl
,
this
.
postprocessing
.
target
.
texture
,
this
.
depthTarget
.
texture
);
this
.
copyFboTarget
=
getCopyRenderable
(
webgl
,
this
.
colorTarget
.
texture
);
this
.
copyFboPostprocessing
=
getCopyRenderable
(
webgl
,
this
.
postprocessing
.
target
.
texture
);
}
setSize
(
width
:
number
,
height
:
number
)
{
...
...
@@ -239,6 +237,7 @@ export class DrawPass {
if
(
this
.
depthTargetPrimitives
)
{
this
.
depthTargetPrimitives
.
bind
();
renderer
.
clear
(
false
);
// TODO: this should only render opaque
renderer
.
renderDepth
(
scene
.
primitives
,
camera
,
null
);
this
.
colorTarget
.
bind
();
}
...
...
@@ -267,17 +266,12 @@ export class DrawPass {
}
renderer
.
renderBlendedVolumeTransparent
(
scene
.
volumes
,
camera
,
this
.
depthTexturePrimitives
);
if
(
PostprocessingPass
.
isEnabled
(
postprocessingProps
))
{
const
target
=
PostprocessingPass
.
isEnabled
(
postprocessingProps
)
?
this
.
postprocessing
.
target
:
this
.
colorTarget
;
if
(
!
this
.
packedDepth
)
{
this
.
depthTexturePrimitives
.
attachFramebuffer
(
this
.
postprocessing
.
target
.
framebuffer
,
'
depth
'
);
}
this
.
postprocessing
.
target
.
bind
();
}
else
{
if
(
!
this
.
packedDepth
)
{
this
.
depthTexturePrimitives
.
attachFramebuffer
(
this
.
colorTarget
.
framebuffer
,
'
depth
'
);
}
this
.
colorTarget
.
bind
();
this
.
depthTexturePrimitives
.
attachFramebuffer
(
target
.
framebuffer
,
'
depth
'
);
}
target
.
bind
();
}
renderer
.
renderBlendedTransparent
(
scene
.
primitives
,
camera
,
null
);
...
...
This diff is collapsed.
Click to expand it.
src/mol-gl/shader/copy
-fbo
.frag.ts
→
src/mol-gl/shader/copy.frag.ts
+
1
−
9
View file @
ee4ce2fd
export
default
`
export
const
copy_frag
=
`
precision highp float;
precision highp sampler2D;
uniform sampler2D tColor;
uniform sampler2D tDepth;
uniform vec2 uTexSize;
#include common
float getDepth(const in vec2 coords) {
return unpackRGBAToDepth(texture2D(tDepth, coords));
}
void main() {
vec2 coords = gl_FragCoord.xy / uTexSize;
gl_FragColor = texture2D(tColor, coords);
gl_FragDepthEXT = getDepth(coords);
}
`
;
\ No newline at end of file
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