Search the Community

Showing results for tags 'shadow'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • HTML5 Game Coding
    • News
    • Game Showcase
    • Coding and Game Design
  • Frameworks
    • Phaser
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Found 54 results

  1. Best way to handle Character with shadow

    I was wondering what is the best way to handle shadow for a "character". I made a character and i want to put a shadow at the bottom a kind of "circle" with opacity, for convenience let's say it's gonna be a transparent PNG. The way i can think of : - (1) Just add the sprite to the game, this leads to duplicated calculations in the update part cause i have to update both the "character" sprite and his shadow; - (2) Add the shadow as a child sprite of the "character", this leads to having the shadow on top of the sprite instead of back to it; - (3) Add the "character" sprite as a child of the shadow sprite, this seems not logical, but it works somehow; - (4) Create a group and add both the shadow and the sprite, (havn't test it but most likely) this leads to define specific property to the group for the size, the position and the overflow boundaries for collision relative to the "character" sprite and the shadow; - (5) Using a filter (Shader) applied on the hole game, with my character position as uniform to render the shadow directly on the "groundLayer". What do you think please ? Is there a better way that i am missing ? Thanks.
  2. Hello, I've created a standard shadowGenerator with var shadowGenerator = new BABYLON.ShadowGenerator(512, light) - after pushing in it multiple objects I've noticed automatic quality decreasing, like that number 512 becomes lower and lower. For example 1 box: The same with only 100 boxes: You see the difference. Testing shows 512 becomes ~24 -> 20 times less. Is that true that there is a fixed count of "rays" for calculating shadows? Because the more objects I have - the less "rays" gets everyone of them. Of course I could set 4096 instead of 512 - but that dramatically decreases FPS. The main question is how can we get more or less good shadows with big amount of objects? Troubleshooting from doesn't help with that.
  3. Hi, I get weird shadow for my imported mesh: Here is a stl version: Any ideas how to fix it? Thank you very much!
  4. Several shadows issues

    Hello, Playing with shadows - Several issues: 1. Why there are no soft shadows? 2. How do I remove this ugly black square around box/torus on the ground? I've noticed it after switching to the latest babylon.js version. If you comment out the line "shadowGenerator.useBlurExponentialShadowMap = true;" - black square will disappear and shadows will appear, but not soft. 3. If you comment out "shadowGenerator.useBlurExponentialShadowMap = true;" and uncomment "shadowGenerator.usePoissonSampling = true;" - poison shadow appears, but black square still exists;
  5. Baking shadow maps

    Hi, I have static objects and static lights inside my scene sou it would make sense to bake them to save resources,, anyone have done it? is there some workflow to generate them from scene (in 3d max or other tool). Thanks
  6. Hi everyone I have some weird issue using shadows in Babylon. Please take a look at the sample below : It seems that the shadow is not cutted off properly ! it still appears even if the object goes under the ground. Is there anything to do to fix that ? Thanks for your time A
  7. Sprites and Shadows

    Hey! I wanted to know if the library has been updated yet to perform this function, as I found a couple of post from 2014 talking about it being in future updates @Deltakosh, An example post I found and wanted to know if it's here as would be suuuuuper useful to me right now in my current project build, if you know of another way also of it being done please let me know, please find the babylon playground link and youtube video of my build as my textures are not very good at working!
  8. Hi, i have a question about shadows, is it possible to let a mesh cast shadow on it self? Currently I can make a tree looking like the first picture, but in this case the 3d deep looks not that good. I looking for a solution I can get a tree like the second picture. Thanks for your help Mirco
  9. Hey Folks! In our scene we have some images with transparency on quads. The transparency is just used to mask the silhouettes of the image, so we have no larger half- transparent areas. So far we used the default shader for this, which produced nice silhouettes. All these Objekt are registered in a shadow generator from which we extract the shadow map an pass it in a custom shader. After writing our own shader for the images we ran into a problem: The shadow generator now only takes the quad into account, not the transparency of the image. Therefor the shadows of these images are square. When constructing the custom shader we tell baby- lon to use alpha blending and we also tell the shadow- generator to use transparency shadows. The diffuse texture is simply loaded with a texture sampler in- cluding the alpha channel. We even tried to clip frag- ments under a certain value but the shadow genera- tor still ignores it. We looked through the default shader but couldn't find anything that's helping us in this matter. We found the opacity map, which to our understanding is just a separate, black and white masking texture. So our question is: What steps are necessiary to generate shadow silhouettes based on the alpha channel of an objects texture? As we said, clipping with a threshold or cutout for that matter would be enough. Thank you for your time -Mainequin Team
  10. Part 6 of my tutorial series on making is here! Check out the demo: Enjoy!
  11. I am loading a mesh from a babylon file The mesh has a skeleton. The shadow casted by it is not proper. See file "with_skel.jpg" to check the shadow casted. Now if i remove the skeleton by doing mesh.skeleton=null; The shadow is proper. See file "without_skel.jpg" I was able to reproduce the issue in playground but wasn't able to save the code. I got the error message "file too big" when trying to save. The code is a little large as it has an embedded scene file. So I have attached the code here. See file "playground_code,txt" Copy the code to playground to check. comment on/off line 44 to see the issue playground_code.txt
  12. can't see any shaodw on my mobile phone for this pg but this demo works pretty good don't know why, would you guys please give me a hand?
  13. Hy gangs, how's your day been? i saw a post on how to cast shadow of a texture from a plane onto a surface using the pointlight, i've been looking for that post but i couldn't find it, i should have followed the discussion trend
  14. Hi, I'm trying to make a light: has fixed position relative to the viewer (camera); casts shadows. I set camera as the light's parent to achieve (1). But the shadow seems not updated as camera orbits. Playground: Can I tell the shadow map to refresh? Thank you very much!
  15. Hello everyone! This is my first question about my first babylon.js project. It will be a strategy game with complex economics (similar to Caesar 3, Knights and Merchants). The framework is amazing, I like it very much, but I have some problems with shadows. Everything works fine, until I add lots of instances of a mesh across a large ground. The shadow becomes just a blob, almost invisible. I think the problem comes from DirectionalLight.prototype.setShadowProjectionMatrix where all mesh positions are checked to see how big the area is for casting shadows. The bigger the area, the more detail will be lost. Can someone give me some advice on how to handle this problem? I thought of the following: 1. Increase the mapSize from 1024 to a much larger value, but it doesn't make much difference with 2048 and the fps drops very much. 2. Somehow force the shadow casting area to be smaller with the help of customProjectionMatrixBuilder, and make it follow the camera, but how? 3. Make the shadow part of the model, like an old-school circle shadow with transparency. Ugly, but at least I get 60 fps Any other idea may be helpful You can take a look at it if it helps: P.S. I know, that instances can't have different animations, I will handle that with separate clones for every action, I think
  16. Shadows in Custom Shader

    Dear Babylon JS community, we as a company have decided, that we want to use Babylon JS for a larger project. For this we have specific requirements for what the shaders have to be able to do. I will first state the problem I am trying to solve and then give the context, for possible alternative solutions. PROBLEMS: For our more complex shader computations we want to integrate shadows from at least one shadow-generator in a custom shader. For reasons of confidentiality I can not submit our current project code, that is why I created this test playground: We want to get the influence of all shadows on a fragment as a float value in the shader for further computations. For this we encountered the following problems: - Mapping to shadow-map coordinates seems to be wrong - using functions like computeShadow() from #include<shadowsFragmentFunctions> yields not-declared-error - computeShadow() yields always 1.0 as a result COURSE OF EVENTS: We started playing around with the standart material and shadow generators and quickly got them to work. we wrote a small utility function for setting up the shadow generators, which you can find at the top of the linked playground code. After this we played around with uploading textures into our custom shaders and were able to create the desired effects. We looked into uploading the shadow-map and the shadow-generator parameters into the shader, which was sucessful. You can find the uploads at line 113-115 of the linked playground code. Since we do not want to write the mapping to shadow map coordinates ourselves, we looked if there is already existing code, which we found in the shadowsVertex.fx, shadowsFragment.fx and shadowsFragmentFunctions.fx files. While trying to get the mapping right, we encountered the aformentioned problems. We were not able to get correct results regarding the shadow-uv-coordinates, shaderincludes like the above mentioned #include<shadowsFragmentFunctions> yields a "computeShadow() has not been declared" error when used in the code after the statement and what code we currently copied from these files seems to always yield 1.0 as a result for the sha- dow intensity. We are turning to you now, because we are at a point where we cannot find the errors in our approach/code anymore. We are required to use Babylon JS version 2.5 in our project. Although it didn't seem to make a difference for the shader code we looked through I wanted to mention it. CONTEXT: Our scene is basically shadeless, with multiple materials per object, distributed via a mask. Therefor we combine a precomputed light texture (for individual objects) with a diffuse texture and multiple material textures blended via a mask texture. Since we require no lighting computation we just want the shadow values to get some visual depth in the scene. Therefor the standart material seems to be not sufficient for our purposes, hence the reliance on a custom shader. I saw code that created a custom material with the standart shaders and then re- placed parts of the vertex and fragment code via a function. We would be ready to do this kind of code insertion, if it yields correct shadow information. Sadly I cannot find the example project for this anymore, so if you could provide a link to a simmiliar source it would be much appreciated. Thank you sincerely for your time and help With best regards from the green heart of Germany The Mainequin Team
  17. Hi ! I am having an issue with shadow maps, it seems pretty random, but from time to time the shadow map seems to "degenerate" meaning that the shadow map's resolution progressively lowers until the shadow is not visible anymore. I don't know what could cause that, I am not running any scene optimiser and not touching my shadow map during the renderloop so there is no reason its resolution suddently start to lower by itself... I am running the (v2.5.-beta) version. I will try and pose a screenshot of the scene as I can't seem to be able to reproduce it in the playground. Thanks in advance for your time and answer !
  18. [SOLVED] - Problem with Exported Shadow

    I think there may be a problem with the "lifecyle" of a exported shadow generator. If i create the shadow generator with the exporter (good bias and filter settings) the shadows show up IF the Y position is high enough off the ground. But if close to ground ... no shadows. If i create the shadows in the client scene.executeWhenReady the shadows are perfect... If i Console.log both shadows generators (the one created from unity exporter and the one manually created) they are the same. Its weird... Maybe something to do with "Where In The Scene Lifecycle" the shadow generator is being created of exported and the shadow generator info is in the .babyone scene file. I am attaching a test .babylon file exported from unity... The shadow generator part of the .babylon looks fine. but even in sandbox. With none of my babylon enhancements, the .babylon on load... Show the sphere above the ground... Shadows enabled and physics enabled... The balls starts to drop but when it gets close to ground, the shadow disappears. Its gotta be something in the way way is reading the shadow generator information and instantiates the BABYLON.ShadowGenerator... or maybe WHEN is instantiates the BABYLON.ShadowGenerator. Anyways take a look a the MiniGame.babylon file in SANDBOX MiniGame.babylon
  19. So I would like to have my terrain cast shadows on it's self, like the mountains shadow the rest of the terrain, etc. But when I try to do this by adding the groundPlane to the shadowGenerator, the entire mesh turns black. Is there a way to do this, or is this not something that can be done yet? I really hope to be able to pull this off!
  20. Shadow issues..

    OK so I have this endless chunked terrain where I am walking around, I head out a ways, the sun/light objects are moving with the player as I move keeping it's orbit and direction pointed toward the player model, but for some reason the shadows start to go off to the wrong side and distorts (see above image)! Is there a way to tell the shadow generator the light position and target has updated because it looks like it isn't updating since it was instantiated. I'd think it would auto update or something each frame to make sure it was following the light source properly, but that doesn't seem to be the case here. Is there something like shadow generator.update() or something I'm missing? How would I get this to work right, it is bugging me! Here is the bit of code that updates the sun/light position pre-calculated before frame render, less global variables of course.. scene.beforeRender = function (){ skybox.rotate(BABYLON.Axis.Z, -0.00008, BABYLON.Space.PIVOT); if(sunmove && actor){ sunvls.mesh.position = new BABYLON.Vector3(actor.position.x + sunorbdis * Math.sin(sunorbdelta), actor.position.y + sunorbdis * Math.cos(sunorbdelta), actor.position.z); light.position = sunvls.mesh.position; sunorbdelta += sunspeed; } }; How can I work in shadow generator update? Thanks!
  21. Hello, is it the correct behaviour that instances that are being disposed doesn't get removed from ShadowGenerator.getShadowMap().renderList ? I have the refreshrate set to 0 and only render with shadow on demand. if (_renderShadow && this._manuallyShadowRender) { this._shadowGenerator.getShadowMap().refreshRate = 1; this._scene.render(); this._shadowGenerator.getShadowMap().refreshRate = 0; } else { this._scene.render(); } Is this a problem i this case? I just want to know (maybe it's a bug). Shouldn't ShadowGenerator check the Mesh.isDisposed attribute? Have a nice day Kevin
  22. Hello, I am having trouble with the shadow generator, this playground illustrate my problem => I made a room with a window. Then I add two lights with a shadowgenerator for each one, the two sphere show their position into the scene. The one outside the room act properly (you can see light pass through the window), but the one inside the room light nothing. If you comment line 97 -> 104 (remove the roof) the light inside act properly. Thanks
  23. Hello, I am trying to generate shadows for a 3D scene with the ShadowGenerator of Babylon. My problem is the following : a mesh can't create shadows and receiving shadows at the same time. Here is a playground where this is illustrated : Let's focus on lines 47 & 48 : torus.receiveShadows = true; shadowGenerator.getShadowMap().renderList.push(torus); If the first one is commented the torus doesn't receive shadow and when it pass into the cube shadow, it is still highlight. If the second one is commented the torus doesn't create shadow but when it pass into the cube shadow, it act well. Finally if the both are uncommented the torus is constantly shadowed (like it is occluding by itself...) Thanks for any help !
  24. shadow issue

    see the following playground This has a ground , 2 boxes and a DirectionalLight The two boxes cast shadow on ground. If you move the two boxes away from each other the shadows cast by them start fading, becomes less sharp. un-comment 13 and comment out 14 to see this effect Is this expected behavior ? (The above does not happen for useVarianceShadowMap) Also is there any documentation on shadowGenerator's properties useVarianceShadowMap, useBlurVarianceShadowMap, usePoissonSampling, bias
  25. shadow generator serialization issue

    serialization uses mesh id to add mesh to the shadowgenerator renderlist if two or more mesh have same id then during deserialization only one mesh gets added to the renderlist and thus only one of them displays shadow Instead of meshid maybe we should use the mesh's uniqueId ? Today, as a workaround, just before I serialize a scene, I rename all mesh id and give each of them unique id