meshphong_frag.glsl.js 2.0 KB
Newer Older
D
Damien Seguin 已提交
1
export default /* glsl */`
2 3 4 5 6 7 8 9 10
#define PHONG

uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
uniform float shininess;
uniform float opacity;

#include <common>
11
#include <packing>
12
#include <dithering_pars_fragment>
13 14 15 16 17 18 19 20
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
21
#include <envmap_common_pars_fragment>
22 23 24
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
S
sunag 已提交
25
#include <lights_pars_begin>
26 27 28 29 30 31
#include <lights_phong_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
T
tschw 已提交
32
#include <clipping_planes_pars_fragment>
33 34 35

void main() {

T
tschw 已提交
36 37
	#include <clipping_planes_fragment>

M
Mr.doob 已提交
38 39
	vec4 diffuseColor = vec4( diffuse, opacity );
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
40
	vec3 totalEmissiveRadiance = emissive;
41

M
Mr.doob 已提交
42 43 44 45 46 47
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <specularmap_fragment>
48 49
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
M
Mr.doob 已提交
50
	#include <emissivemap_fragment>
51

M
Mr.doob 已提交
52 53
	// accumulation
	#include <lights_phong_fragment>
S
sunag 已提交
54 55 56
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
57

M
Mr.doob 已提交
58 59
	// modulation
	#include <aomap_fragment>
60

61
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
62

M
Mr.doob 已提交
63
	#include <envmap_fragment>
64

B
Ben Houston 已提交
65
	gl_FragColor = vec4( outgoingLight, diffuseColor.a );
66

B
Ben Houston 已提交
67 68
	#include <tonemapping_fragment>
	#include <encodings_fragment>
69
	#include <fog_fragment>
70 71
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
72

73
}
M
Mr.doob 已提交
74
`;