| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- export default {
-
- attributes: ['uv', 'position'],
- uniforms: ['view', 'projection', 'worldViewProjection', '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;
- uniform mat4 worldViewProjection;
- void main()
- {
- #include<instancesVertex>
-
- ModelPos = vec3( view * finalWorld * vec4(position , 1.0));
- gl_Position = projection * view * finalWorld * 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);
- }
- `
- }
|