Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
ee2eed92
T
three.js
项目概览
Ablesons
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
three.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
ee2eed92
编写于
1月 09, 2021
作者:
G
Garrett Johnson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update LUTPas
上级
fbeb3de7
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
43 addition
and
25 deletion
+43
-25
examples/jsm/loaders/LUT3dlLoader.js
examples/jsm/loaders/LUT3dlLoader.js
+2
-0
examples/jsm/loaders/LUTCubeLoader.js
examples/jsm/loaders/LUTCubeLoader.js
+2
-0
examples/jsm/postprocessing/LUTPass.js
examples/jsm/postprocessing/LUTPass.js
+38
-24
examples/webgl_postprocessing_3dlut.html
examples/webgl_postprocessing_3dlut.html
+1
-1
未找到文件。
examples/jsm/loaders/LUT3dlLoader.js
浏览文件 @
ee2eed92
...
...
@@ -114,6 +114,7 @@ export class LUT3dlLoader extends Loader {
texture
.
format
=
RGBFormat
;
texture
.
type
=
UnsignedByteType
;
texture
.
magFilter
=
LinearFilter
;
texture
.
minFilter
=
LinearFilter
;
texture
.
wrapS
=
ClampToEdgeWrapping
;
texture
.
wrapT
=
ClampToEdgeWrapping
;
texture
.
generateMipmaps
=
false
;
...
...
@@ -126,6 +127,7 @@ export class LUT3dlLoader extends Loader {
texture3D
.
format
=
RGBFormat
;
texture3D
.
type
=
UnsignedByteType
;
texture3D
.
magFilter
=
LinearFilter
;
texture3D
.
minFilter
=
LinearFilter
;
texture3D
.
wrapS
=
ClampToEdgeWrapping
;
texture3D
.
wrapT
=
ClampToEdgeWrapping
;
texture3D
.
wrapR
=
ClampToEdgeWrapping
;
...
...
examples/jsm/loaders/LUTCubeLoader.js
浏览文件 @
ee2eed92
...
...
@@ -120,6 +120,7 @@ export class LUTCubeLoader extends Loader {
texture
.
format
=
RGBFormat
;
texture
.
type
=
UnsignedByteType
;
texture
.
magFilter
=
LinearFilter
;
texture
.
minFilter
=
LinearFilter
;
texture
.
wrapS
=
ClampToEdgeWrapping
;
texture
.
wrapT
=
ClampToEdgeWrapping
;
texture
.
generateMipmaps
=
false
;
...
...
@@ -132,6 +133,7 @@ export class LUTCubeLoader extends Loader {
texture3D
.
format
=
RGBFormat
;
texture3D
.
type
=
UnsignedByteType
;
texture3D
.
magFilter
=
LinearFilter
;
texture3D
.
minFilter
=
LinearFilter
;
texture3D
.
wrapS
=
ClampToEdgeWrapping
;
texture3D
.
wrapT
=
ClampToEdgeWrapping
;
texture3D
.
wrapR
=
ClampToEdgeWrapping
;
...
...
examples/jsm/postprocessing/LUTPass.js
浏览文件 @
ee2eed92
...
...
@@ -33,40 +33,42 @@ const LUTShader = {
fragmentShader
:
/* glsl */
`
precision highp sampler3D;
uniform float lutSize;
#if USE_3DTEXTURE
uniform sampler3D lut3d;
#else
uniform sampler2D lut;
uniform float lutSize;
vec3 lutLookup( sampler2D tex, float size, vec3 rgb ) {
// clamp the sample in by half a pixel to avoid interpolation
// artifacts between slices laid out next to each other.
float halfPixelWidth = 0.5 / size;
rgb.rg = clamp( rgb.rg, halfPixelWidth, 1.0 - halfPixelWidth );
float sliceHeight = 1.0 / size;
float yPixelHeight = 1.0 / ( size * size );
// green offset into a LUT layer
float gOffset = rgb.g / size;
vec2 uv1 = vec2( rgb.r, gOffset );
vec2 uv2 = vec2( rgb.r, gOffset );
// Get the slices on either side of the sample
float slice = rgb.b * size;
float interp = fract( slice );
float slice0 = slice - interp;
float centeredInterp = interp - 0.5;
// adjust b slice offset
float bNormalized = size * rgb.b;
float bSlice = min( floor( size * rgb.b ), size - 1.0 );
float bMix = ( bNormalized - bSlice ) / size;
float slice1 = slice0 + sign( centeredInterp );
//
get the first lut slice and then the one to interpolate to
float b1 = bSlice / size;
float
b2 = ( bSlice + 1.0 ) / size
;
//
Pull y sample in by half a pixel in each direction to avoid color
// bleeding from adjacent slices.
float
greenOffset = clamp( rgb.g * sliceHeight, yPixelHeight * 0.5, sliceHeight - yPixelHeight * 0.5 )
;
uv1.y += b1;
uv2.y += b2;
vec2 uv0 = vec2(
rgb.r,
slice0 * sliceHeight + greenOffset
);
vec2 uv1 = vec2(
rgb.r,
slice1 * sliceHeight + greenOffset
);
vec3 sample0 = texture2D( tex, uv0 ).rgb;
vec3 sample1 = texture2D( tex, uv1 ).rgb;
vec3 sample2 = texture2D( tex, uv2 ).rgb;
return mix( sample
1, sample2, bMix
);
return mix( sample
0, sample1, abs( centeredInterp )
);
}
#endif
...
...
@@ -78,12 +80,24 @@ const LUTShader = {
vec4 val = texture2D( tDiffuse, vUv );
vec4 lutVal;
// pull the sample in by half a pixel so the sample begins
// at the center of the edge pixels.
float pixelWidth = 1.0 / lutSize;
float halfPixelWidth = 0.5 / lutSize;
vec3 uvw = vec3( halfPixelWidth ) + val.rgb * ( 1.0 - pixelWidth );
#if USE_3DTEXTURE
lutVal = vec4( texture( lut3d, val.rgb ).rgb, val.a );
lutVal = vec4( texture( lut3d, uvw ).rgb, val.a );
#else
lutVal = vec4( lutLookup( lut, lutSize, val.rgb ), val.a );
lutVal = vec4( lutLookup( lut, lutSize, uvw ), val.a );
#endif
gl_FragColor = mix( val, lutVal, intensity );
gl_FragColor = vec4( mix( val, lutVal, intensity ) );
}
...
...
@@ -111,6 +125,7 @@ class LUTPass extends ShaderPass {
}
material
.
uniforms
.
lutSize
.
value
=
v
.
image
.
width
;
if
(
v
.
isDataTexture3D
)
{
material
.
uniforms
.
lut3d
.
value
=
v
;
...
...
@@ -118,7 +133,6 @@ class LUTPass extends ShaderPass {
}
else
{
material
.
uniforms
.
lut
.
value
=
v
;
material
.
uniforms
.
lutSize
.
value
=
v
.
image
.
width
;
}
...
...
examples/webgl_postprocessing_3dlut.html
浏览文件 @
ee2eed92
...
...
@@ -103,7 +103,7 @@
renderer
.
toneMapping
=
THREE
.
ACESFilmicToneMapping
;
renderer
.
toneMappingExposure
=
1
;
container
.
appendChild
(
renderer
.
domElement
);
const
target
=
new
THREE
.
WebGLRenderTarget
(
{
minFilter
:
THREE
.
LinearFilter
,
magFilter
:
THREE
.
LinearFilter
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录