SceneView / sceneform-android

Sceneform Maintained is an ARCore Android SDK with Google Filament as 3D engine. This is the continuation of the archived Sceneform
https://sceneview.github.io/sceneform-android/
Apache License 2.0
632 stars 147 forks source link

Video pivot issue with VideoNode #108

Closed suryanadiminti99 closed 3 years ago

suryanadiminti99 commented 3 years ago

Hi Team , I recently added VideoNode for playing videos . I think there is a pivot issue with plane . If i scale the node , the position of node is moved to right side .

VideoNode videoNode = new VideoNode(ArActivity.this, mediaPlayer, chromaKeyColor, new VideoNode.Listener() {
    @Override
    public void onCreated(VideoNode videoNode) {
        videoNode.setParent(modelNode);
    }

    @Override
    public void onError(Throwable throwable) {
        Toast.makeText(ArActivity.this, "Unable to load material", Toast.LENGTH_LONG).show();
    }
});

Again i commented VideoNode and i tried with previous code video is loaded at the center . its working but here how can i play chromakey videos. is it possible ?

Created ModelRenderable and loaded glb plane .

MaterialBuilder.init();
MaterialBuilder materialBuilder = new MaterialBuilder()
     // By default, materials are generated only for DESKTOP. Since we're an Android
     // app, we set the platform to MOBILE.
    .platform(MaterialBuilder.Platform.MOBILE)
    .name("Plain Video Material")
    .require(MaterialBuilder.VertexAttribute.UV0)
    // Defaults to UNLIT because it's the only emissive one
    .shading(MaterialBuilder.Shading.UNLIT)
    .doubleSided(true)
    .samplerParameter(
        MaterialBuilder.SamplerType.SAMPLER_EXTERNAL, 
        MaterialBuilder.SamplerFormat.FLOAT, 
        MaterialBuilder.SamplerPrecision.DEFAULT, 
        "videoTexture")
    .optimization(MaterialBuilder.Optimization.NONE);

// When compiling more than one material variant, it is more efficient to pass an Engine
// instance to reuse the Engine's job system
MaterialPackage plainVideoMaterialPackage = materialBuilder
    .blending(MaterialBuilder.BlendingMode.OPAQUE)
    .material("void material(inout MaterialInputs material) {\n" +
                   "    prepareMaterial(material);\n" +
                   "    material.baseColor = texture(materialParams_videoTexture, getUV0()).rgba;\n" +
                   "}\n")
    .build(filamentEngine);

Anyone has a pivot issue with the video please share possibilities. Also how can we play chroma video with previous code .

ThomasGorisse commented 3 years ago

Hi,

That's right in fact.

There is an issue on the the ’VideoNode.makePlane()’. Its center is currently wrongly defined. It has been fixed in a PR.

Waiting for the PR to be merged, you can override the ’makePlane’ or use the VideoNode.Horizontal or Vertical class which have no center issue. (For Vertical, the origin is defined at the bottom y in order to anchor the node on the floor)

suryanadiminti99 commented 3 years ago

Oh .. That's great. Thank you.

ThomasGorisse commented 3 years ago

You're welcome.

In counterpart, can you please click on the Preview tab before sending your issues/comments. We had to edit it for making it readable.

suryanadiminti99 commented 3 years ago

Yeah ... sure. Sorry for the inconvenience. Next time onwards I will update properly.