Search the Community
Showing results for tags 'Dynamic Textures'.
-
Folks, hi, again!!! I trying use BJS.DynamicTexture for draw in and next use in custom shader, but shader ignore geometry with shader material if i try set that texture as samplier2D. And do not generate any Errors (( If we switch off DynamicTexture or use simple Texture - all is ok. Sorry, i can't make this case in PG. Try show situation here: // var dataTexture = new BJS.Texture('/accel/static/i/fx/.../name.jpg',scene,true,false,0,function(){loadedTextures--;}); // its work var dataTexture = new BJS.DynamicTexture("dataTx",{width:2048,height:2048}, scene,false,0); // its dosent work // later, when all textures is ready... var shader = new BABYLON.ShaderMaterial("myShader", scene, "/accel/static/js/...", { attributes: ["position", "normal","uv"], uniforms: ["world", "worldView", "worldViewProjection", "view", "projection"] }); shader.setTexture ("dataTx", dataTexture, scene ); myGeom.material = shader; in GLSL fragment uniform sampler2D dataTx; all is ok, if we change DynamicTexture to Texture. Where i make wrong turn? ))
-
Hi Babylonians, I'm sorry I haven't been here much lately, but I'm burried in math hell - if there is such a place - alright, there is. I have a painting app - will post this soon once I've rebuilt the node server ( I haven't posted yet because multiuser is the main point). But I'm continuing to build on our old server to add features to test. So, here is the question - Does anyone have any math to translate x.y pointer events to UV mapping coodinates to piant locally on an object? I currently have the old standards working (unwrap UVs and paint on a plane to reflect the 3D objects UVs.) However, I'm sure there is a way to unwrap the UVs based upon the object your unwraping to allow real time painting locally from the 2D canvas to a dynamic texture. I can work the math on a specific object, but that's not good enough. Any thoughts from the brainiacs here? DB
- 10 replies
-
- dynamic textures
- uv mapping
-
(and 1 more)
Tagged with:
-
Hello, I'm new in babylonjs and i develop a game viewer with server (with socket.io). But for few days, i have a problem. I use dynamic textures for my textures because i want to modify textures without recreating them. I can't use playground because my code depend of a server and nothing will appear in playground without the server. I will take screen and i have a little idea of the source of problem. When i use texture.clear(), i have the texture that i want but with a black background (i want a transparent background). When i don't use texture.clear, the background is transparent but the image is not perfect. Thank's for your attention Ps: Sorry for language mistakes, i'm french.
-
Hello Babylonians, I hope everyone is having a great weekend, and not working like me. I have a scene where I'm drawing on objects with textures using decal. I was drawing on objects using multiple canvas' onto a dynamic texture - however, since this is a real-time multiple user app, I'm not able to create additional canvas' for each user who is on the session to allow unique colors (textures) to be drawn from remote events (the example below is single user and just a basic drawing function and minimal elements.) The issue is of course an expected problem with this new draw function: as I add texture color to my scene objects, it is using memory and decreasing my framerate to the pont where it becomes not a useful tool. Is there a way for me to use a dynamic texture in this script using the same function (decal), or to instance the textures in a way to avoid memory usage for each pick point (draw)? I would really like to use a dynamic texture so that I could save out each object's texture image. However, I was doing this initially, and I have many, many colors (textures), as well as many users drawing together in real time on any object. This doesn't allow for me to use the canvas to pass color information (textures) to a dynamic texture on each object, as I require multiple canvas' for each remote user. The following is a scene to be copied into the playground. Unfortunately, it is too many lines to save as a playground scene. But just copy and paste, and it will run. var createScene = function () {var scene = new BABYLON.Scene(engine); var camera = new BABYLON.ArcRotateCamera("Camera", -Math.PI/2, 1.1, 10, new BABYLON.Vector3(2, 0, 0), scene);//camera.attachControl(canvas, true); var hemilight = new BABYLON.HemisphericLight("hemi", new BABYLON.Vector3(0, 1, 0), scene);hemilight.groundColor = BABYLON.Color3.Gray();hemilight.specular = BABYLON.Color3.Black(); var face = BABYLON.Mesh.CreateSphere("sphere", 3.0, 3.0, scene);face.scaling = new BABYLON.Vector3(1.0,1.3,1.0);face.rotation = new BABYLON.Vector3(Math.PI / 2, Math.PI / 5, Math.PI / 2);face.material = new BABYLON.StandardMaterial("sMat", scene);face.material.diffuseTexture = new BABYLON.Texture("http://i75.photobucket.com/albums/i309/Athox/Scared_face.jpg", scene);face.material.diffuseTexture.hasAlpha = false;face.position = new BABYLON.Vector3(2, 0, 0);face.material.diffuseTexture.uOffset = 1.0;face.material.diffuseTexture.vOffset = 1.85;face.material.diffuseTexture.uScale = 1.1;face.material.diffuseTexture.vScale = -1.0; var hat = new BABYLON.Mesh.CreateCylinder("cylinder", 4, 3, 3, 5, scene);hat.scaling = new BABYLON.Vector3(0.4, 0.5, 0.4);hat.rotation = new BABYLON.Vector3(Math.PI/4,Math.PI/9,-Math.PI/27);hat.material = new BABYLON.StandardMaterial("Mat", scene);hat.material.diffuseTexture = new BABYLON.Texture("http://st.depositphotos.com/1000635/3769/i/950/depositphotos_37695355-Seamless-yellow-sponge-texture-background..jpg", scene);hat.position = new BABYLON.Vector3(2.7, 1.5, 0.9);hat.setEnabled(true); var draw_mat = new BABYLON.StandardMaterial("draw_mat", scene);draw_mat.diffuseTexture = new BABYLON.Texture("http://i.imgur.com/f1ARb.png", scene);draw_mat.diffuseTexture.hasAlpha = true;draw_mat.zOffset = -.5; var isDown = false; var onPointerDown = function (evt) {if (evt.button !== 0) {return;} isDown = true;var pickInfo = scene.pick(scene.pointerX, scene.pointerY);if (pickInfo.hit) {console.log(pickInfo.pickedMesh.name);var decalSize = new BABYLON.Vector3(.1, .1, .1);var newDecal = BABYLON.Mesh.CreateDecal("decal", pickInfo.pickedMesh, pickInfo.pickedPoint, pickInfo.getNormal(true), decalSize);newDecal.material = dmat;}} var onPointerUp = function() { isDown = false; } var onPointerMove = function (evt) {if (evt.button !== 0) {return;} var pickInfo = scene.pick(scene.pointerX, scene.pointerY);if(isDown) {console.log(pickInfo.pickedMesh.name);var brush = new BABYLON.Vector3(.1, .1, .1);var idraw = BABYLON.Mesh.CreateDecal("decal", pickInfo.pickedMesh, pickInfo.pickedPoint, pickInfo.getNormal(true), brush);idraw.material = draw_mat;}} canvas.addEventListener("pointerdown", onPointerDown, false); canvas.addEventListener("pointerup", onPointerUp, false); canvas.addEventListener("pointermove", onPointerMove, false); scene.onDispose = function () { canvas.removeEventListener("pointerdown", onPointerDown); canvas.removeEventListener("pointerup", onPointerUp); canvas.removeEventListener("pointermove", onPointerMove);} return scene;}; Hey DK - is there any way we might increase the # of characters to save a playground scene? Who might have control over this? Thanks, DB
-
We're trying a couple of things, and it looks promising. I just hope I can sta awake.