mainequin

Members
  • Content Count

    7
  • Joined

  • Last visited

  1. Dear Wingnut, thank you for your answer! It took some time but we peeled the relevant code from our project and used the code from your example playground to illustrate our problem. Basiaclly we want to repro- duce what you did using the default shader with our custom shader. http://www.babylonjs-playground.com/#VZKI0U #12 As you can see in this example, Felix correctly re- ceives shadows, but does not cast them accord- ing to his silhouette. Changing the "hasAlpha" set- tings of the texture does not change this behavi- our. Our guess is, that the depth texture of the shadow generator does not account for the trans- parent parts of the texture. As stated in our last post we could not find rele- vant code in the standard shader that differs from our approach, therefor we think it coult be a setting in the shadow generator. Thank you very much for your time - Mainequin Team
  2. 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
  3. Dear Deltakosh, I cannot offer the original code, since it is relevant to the company I work in. So as an alternative, here is a prepared playground with the respective code. I am trying to follow this tutorial. Thank you for your time -Mainequin
  4. Hey Folks! For my custom Shader I want to use the object's normals in view space. Therefor I need the gl_NormalMatrix. I know how to construct it (inverted and transposed MVMatrix) but I don't want to construct it manually for each object. I found this thread [SOLVED] - Shader Programs Attributes And Uniforms, but there was no hint on how the gl_NormalMatrix is called in babylon. I also searched the babylon git-repository, but could not find where the shader attributes and such are declared. Can anyone please point me in the right direction? Thank you for your time -Mainequin
  5. Dear Deltakosh, thank you for your quick answer! Today we integrated your corrections into our shader code. We received shadow-acne, which we fixed by adding bias again. The computeShadowWithPCF-function looks at neighboring coordinates in a distance defined by a Poisson- disk and fades the shadow strength based on visibility, as far as we understand. If all four samples are in the dark, we receive full shadow. So since this is done in the shader, the filter mode in the shadow generator should be irrelevant for this. We fixed the upload of the shadow-parameters as Vector3, so now darkness, bias etc. are correctly uploaded. We copied the computeShadowWithPCF-function and in- creased the samples of the Poisson-disk, so that it fits our needs. Here is the final project: http://www.babylonjs-playground.com/#VZKI0U#7 Thank you again for your help and time!
  6. 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: http://www.babylonjs-playground.com/#VZKI0U 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