123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- export default {
-
- attributes: ['uv', 'position'],
- uniforms: ['view', 'projection', 'world',
- 'isYUV', 'focal_width_height', 'texture_video'],
- defines: ["#define SHADOWFULLFLOAT", "#define NUM_BONE_INFLUENCERS 0", "#define NUM_MORPH_INFLUENCERS 0"],
- samplers: ['shadowSampler', 'texture_video'],
- vertex:
- `
- precision highp float;
- varying vec3 ModelPos;
-
- attribute vec2 uv;
- attribute vec3 position;
-
- uniform mat4 view;
- uniform mat4 projection;
-
- uniform mat4 world;
- void main()
- {
- ModelPos = vec3( view * world * vec4(position , 1.0));
- gl_Position = projection * view * world * vec4(position , 1.0);
- }
- `,
- fragment: `
- precision highp float;
- varying vec3 ModelPos;
-
- uniform float isYUV; // false: 0, true: 1.0
- uniform sampler2D texture_video;
-
- uniform vec3 focal_width_height;
-
- vec2 SampleTex(vec3 pt3d)
- {
- return focal_width_height.x / focal_width_height.yz * pt3d.xy / pt3d.z + 0.5;
- }
-
- void main()
- {
- vec3 color = vec3(0,0,0);
- float shadow = 1.0;
-
- vec2 uv = SampleTex( normalize(ModelPos) );
- if( isYUV < 0.5 )
- {
- color = texture2D(texture_video, uv).rgb;
- }else{
- const mat4 YUV2RGB = mat4
- (
- 1.1643828125, 0, 1.59602734375, -.87078515625,
- 1.1643828125, -.39176171875, -.81296875, .52959375,
- 1.1643828125, 2.017234375, 0, -1.081390625,
- 0, 0, 0, 1
- );
-
- vec4 result = vec4(
- texture2D( texture_video, vec2( uv.x, uv.y * 0.666666 + 0.333333 ) ).x,
- texture2D( texture_video, vec2( uv.x * 0.5, uv.y * 0.333333 ) ).x,
- texture2D( texture_video, vec2( 0.5 + uv.x * 0.5, uv.y * 0.333333 ) ).x,
- 1
- ) * YUV2RGB;
- color = clamp(result.rgb, 0.0, 1.0);
- }
- if( uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0 )
- {
- color = vec3(0,0,0);
- }
- gl_FragColor = vec4(shadow * color * 1.0, 1.0);
- }
- `
- }
|