Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
344ff23a
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,发现更多精彩内容 >>
未验证
提交
344ff23a
编写于
10月 12, 2018
作者:
M
Mr.doob
提交者:
GitHub
10月 12, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15026 from WestLangley/dev-exr_example
EXR example: remove custom tone mapping shader
上级
aa044f69
af6d4615
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
44 addition
and
98 deletion
+44
-98
examples/webgl_loader_texture_exr.html
examples/webgl_loader_texture_exr.html
+44
-98
未找到文件。
examples/webgl_loader_texture_exr.html
浏览文件 @
344ff23a
...
...
@@ -31,7 +31,6 @@
</head>
<body>
<div
id=
"container"
></div>
<div
id=
"info"
>
<a
href=
"http://threejs.org"
target=
"_blank"
rel=
"noopener"
>
three.js
</a>
- webgl EXR texture loader example
</div>
...
...
@@ -42,154 +41,101 @@
<script
src=
"js/libs/dat.gui.min.js"
></script>
<script
src=
"js/WebGL.js"
></script>
<script
src=
"js/libs/stats.min.js"
></script>
<!-- HDR fragment shader -->
<script
id=
"fs-hdr"
type=
"x-shader/x-fragment"
>
uniform
sampler2D
tDiffuse
;
uniform
float
exposure
;
uniform
float
brightMax
;
varying
vec2
vUv
;
void
main
()
{
vec4
color
=
texture2D
(
tDiffuse
,
vUv
);
// Perform tone-mapping
float
Y
=
dot
(
vec4
(
0.30
,
0.59
,
0.11
,
0.0
),
color
);
float
YD
=
exposure
*
(
exposure
/
brightMax
+
1.0
)
/
(
exposure
+
1.0
);
color
*=
YD
;
gl_FragColor
=
vec4
(
color
.
xyz
,
1.0
);
}
</script>
<!-- HDR vertex shader -->
<script
id=
"vs-hdr"
type=
"x-shader/x-vertex"
>
varying
vec2
vUv
;
void
main
()
{
vUv
=
uv
;
gl_Position
=
projectionMatrix
*
modelViewMatrix
*
vec4
(
position
,
1.0
);
}
</script>
<script>
var
params
=
{
exposure
:
1.0
,
};
if
(
WEBGL
.
isWebGLAvailable
()
===
false
)
{
document
.
body
.
appendChild
(
WEBGL
.
getWebGLErrorMessage
()
);
}
var
container
,
stats
;
var
params
=
{
exposure
:
1.0
};
var
camera
,
scene
,
renderer
;
var
materialHDR
,
quad
,
gamma
,
exposure
;
var
renderer
,
scene
,
camera
;
init
();
function
init
()
{
container
=
document
.
getElementById
(
'
container
'
);
renderer
=
new
THREE
.
WebGLRenderer
();
renderer
.
setPixelRatio
(
window
.
devicePixelRatio
);
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
document
.
body
.
appendChild
(
renderer
.
domElement
);
renderer
.
toneMapping
=
THREE
.
ReinhardToneMapping
;
renderer
.
toneMappingExposure
=
params
.
exposure
;
camera
=
new
THREE
.
PerspectiveCamera
(
50
,
window
.
innerWidth
/
window
.
innerHeight
,
1
,
10000
);
camera
.
position
.
z
=
900
;
renderer
.
gammaOutput
=
true
;
scene
=
new
THREE
.
Scene
();
var
loader
=
new
THREE
.
EXRLoader
()
;
var
aspect
=
window
.
innerWidth
/
window
.
innerHeight
;
loader
.
load
(
"
textures/piz_compressed.exr
"
,
function
(
texture
,
textureData
)
{
camera
=
new
THREE
.
OrthographicCamera
(
-
aspect
,
aspect
,
1
,
-
1
,
0
,
1
);
console
.
log
(
textureData
.
header
);
// exr header
new
THREE
.
EXRLoader
().
load
(
'
textures/piz_compressed.exr
'
,
function
(
texture
,
textureData
)
{
texture
.
minFilter
=
THREE
.
NearestFilter
;
texture
.
magFilter
=
THREE
.
NearestFilter
;
//console.log( textureData )
;
//console.log( texture )
;
materialHDR
=
new
THREE
.
ShaderMaterial
(
{
texture
.
generateMipmaps
=
true
;
uniforms
:
{
tDiffuse
:
{
value
:
texture
},
exposure
:
{
value
:
1.0
},
brightMax
:
{
value
:
18.0
}
},
vertexShader
:
getText
(
'
vs-hdr
'
),
fragmentShader
:
getText
(
'
fs-hdr
'
)
// these setting are currently set correctly by default
//texture.encoding = THREE.LinearEncoding;
//texture.minFilter = THREE.LinearMipMapLinearFilter;
//texture.magFilter = THREE.LinearFilter;
//texture.flipY = true;
}
);
var
material
=
new
THREE
.
MeshBasicMaterial
(
{
map
:
texture
}
);
quad
=
new
THREE
.
Mesh
(
new
THREE
.
PlaneBufferGeometry
(
textureData
.
width
,
textureData
.
height
),
materialHDR
);
quad
.
position
.
z
=
-
100
;
scene
.
add
(
quad
);
animate
();
var
quad
=
new
THREE
.
PlaneBufferGeometry
(
textureData
.
width
/
textureData
.
height
,
1
);
}
);
var
mesh
=
new
THREE
.
Mesh
(
quad
,
material
);
renderer
=
new
THREE
.
WebGLRenderer
();
renderer
.
setPixelRatio
(
window
.
devicePixelRatio
);
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
renderer
.
gammaOutput
=
true
;
container
.
appendChild
(
renderer
.
domElement
);
scene
.
add
(
mesh
);
stats
=
new
Stats
();
container
.
appendChild
(
stats
.
dom
);
render
();
window
.
addEventListener
(
'
resize
'
,
onWindowResize
,
false
);
}
);
//
var
gui
=
new
dat
.
GUI
();
gui
.
add
(
params
,
'
exposure
'
,
0
.1
,
5
);
gui
.
add
(
params
,
'
exposure
'
,
0
,
2
).
onChange
(
render
);
gui
.
open
();
}
//
function
onWindowResize
()
{
camera
.
aspect
=
window
.
innerWidth
/
window
.
innerHeight
;
camera
.
updateProjectionMatrix
();
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
window
.
addEventListener
(
'
resize
'
,
onWindowResize
,
false
);
}
function
getText
(
id
)
{
function
onWindowResize
(
)
{
return
document
.
getElementById
(
id
).
textConten
t
;
var
aspect
=
window
.
innerWidth
/
window
.
innerHeigh
t
;
}
var
frustumHeight
=
camera
.
top
-
camera
.
bottom
;
//
camera
.
left
=
-
frustumHeight
*
aspect
/
2
;
camera
.
right
=
frustumHeight
*
aspect
/
2
;
function
animate
()
{
camera
.
updateProjectionMatrix
();
re
questAnimationFrame
(
animate
);
re
nderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
render
();
stats
.
update
();
}
//
function
render
()
{
materialHDR
.
uniforms
.
exposure
.
valu
e
=
params
.
exposure
;
renderer
.
toneMappingExposur
e
=
params
.
exposure
;
renderer
.
render
(
scene
,
camera
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录