Comments (11)
@mistrydarshan99 Hi, try this code:
// Build texture sampler
Texture.Sampler sampler = Texture.Sampler.builder()
.setMinFilter(Texture.Sampler.MinFilter.LINEAR)
.setMagFilter(Texture.Sampler.MagFilter.LINEAR)
.setWrapMode(Texture.Sampler.WrapMode.REPEAT).build();
// Build texture with sampler
CompletableFuture<Texture> trigrid = Texture.builder()
.setSource(this, R.drawable.trigrid_0)
.setSampler(sampler).build();
// Set plane texture
this.sceneformFragment.getArSceneView()
.getPlaneRenderer()
.getMaterial()
.thenAcceptBoth(trigrid, (material, texture) -> {
material.setTexture(PlaneRenderer.MATERIAL_TEXTURE, texture);
});
from sceneform-android-sdk.
You can change the color of the plane by setting the color parameter of the plane's material like this:
arSceneView.getPlaneRenderer().getMaterial().thenAccept(material -> material.setFloat3(PlaneRenderer.MATERIAL_COLOR, new Color(0.0f, 0.0f, 1.0f, 1.0f)) );
For information about all of the material parameters available for the plane, see the PlaneRenderer documentation here.
from sceneform-android-sdk.
@dsternfeld7 plane color changes successfully. But now I have to try to render texture image instead of color while plane detected but it will not work as expected. Here is my texture image.
CompletableFuture<Texture> build = Texture.builder().setSource(this, R.drawable.images).build();
arFragment.getArSceneView()
.getPlaneRenderer()
.getMaterial()
.thenAcceptBoth(build, (material, texture) -> {
material.setTexture(PlaneRenderer.MATERIAL_TEXTURE, texture);
//material.setFloat3(PlaneRenderer.MATERIAL_COLOR, new Color(0.0f, 0.0f, 1.0f, 1.0f));
});
Another issue is that horizontal and vertical surface detected successfully when I detect a ceiling plane is not visible on ceiling detection, but I put android anchor on it see screenshot:
from sceneform-android-sdk.
I believe you can get the behavior you expect by changing the MATERIAL_UV_SCALE parameter. This parameter is used to control the size at which the texture is tiled in world-space, the default values are setup for the default texture. Try this and see what happens:
CompletableFuture<Texture> build = Texture.builder().setSource(this, R.drawable.images).build();
arFragment.getArSceneView()
.getPlaneRenderer()
.getMaterial()
.thenAcceptBoth(build, (material, texture) -> {
material.setTexture(PlaneRenderer.MATERIAL_TEXTURE, texture);
material.setFloat2(PlaneRenderer.MATERIAL_UV_SCALE, 50.0f, 50.0f);
});
The plane not rendering on ceiling planes sounds like a bug. Can you open a new issue specifically to track that bug?
from sceneform-android-sdk.
Hi,
I have used your code still issue is not fixed. Below is a screenshot.
from sceneform-android-sdk.
@KamikX Thanks, bro. it works very well.
from sceneform-android-sdk.
Hi. I think that this issue is not fixed properly. Custom texture have wrong proportions.
from sceneform-android-sdk.
We also need to set uvScale for Image like this:
material.setFloat2("uvScale", 1f, 1.19245f);
from sceneform-android-sdk.
FYI, this doesn't work w/ vector drawables...you can stick the PNG into the drawables-nodpi folder though.
from sceneform-android-sdk.
How can i apply texture on an object
from sceneform-android-sdk.
Hi, try this code:
// Build texture sampler Texture.Sampler sampler = Texture.Sampler.builder() .setMinFilter(Texture.Sampler.MinFilter.LINEAR) .setMagFilter(Texture.Sampler.MagFilter.LINEAR) .setWrapMode(Texture.Sampler.WrapMode.REPEAT).build(); // Build texture with sampler CompletableFuture<Texture> trigrid = Texture.builder() .setSource(this, R.drawable.trigrid_0) .setSampler(sampler).build(); // Set plane texture this.sceneformFragment.getArSceneView() .getPlaneRenderer() .getMaterial() .thenAcceptBoth(trigrid, (material, texture) -> { material.setTexture(PlaneRenderer.MATERIAL_TEXTURE, texture); });
Hey @KamikX. Thanks for the code. I want to replicate the same for the model. I'm trying to apply a picture to the model. I tried the above code for the plane and it worked. I was applying the texture using modelrenderable.setMaterial(), but I didn't find success the texture is extended. Kindly help me with this.
Thanks in Advance
Chandu.
from sceneform-android-sdk.
Related Issues (20)
- Null object
- How to find angle of model from localRotation?
- two modelRenderable overlapping will flicker HOT 1
- [SceneForm v1.16.0 breakage] Not AndroidX ready
- [SceneForm v1.16.0 breakage] no maven dep
- [SceneForm v1.16.0 breakage] ViewRenderables not working HOT 1
- available configuration for avoiding too much heat on device
- GLTF's UV scale functionality not implemented in 1.16.0?
- Object is moving along when i move the phone ?! HOT 5
- ArSceneView have some black dot
- Sceneform plugin:1.15.0 with Android Studio 3.6 not working at all HOT 5
- [SceneForm v1.16.0 breakage] chromakey video
- Cannot load GLB file at Runtime using canonical face
- Is there a way to generate .sfb files from .fbx in runtime HOT 2
- Work with Canonical Face Mesh in Blender
- SceneForm Uses 100% RAM HOT 3
- Update Filament to v1.6.0 (filament-android:1.6.0 & gltfio-android:1.6.0) HOT 1
- How To Show Normal Texture in UV1?
- How can I import model asset the obj file?
- ArFragment leaking after parent activity finished
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sceneform-android-sdk.