MinZe Posted July 28, 2018 Share Posted July 28, 2018 Hi, I want to do an internal reflection shader, and I need to check two things: 1. Check if with a given point, vector and maximum distance there is a face of my geometry in which the vector intersects with. 2. the face's normal. Is there a way to do this? Thanks. Quote Link to comment Share on other sites More sharing options...
brianzinn Posted July 29, 2018 Share Posted July 29, 2018 #1. https://doc.babylonjs.com/babylon101/raycasts var ray = new BABYLON.Ray(origin, direction, length); var hit = scene.pickWithRay(ray); You may need to do a multipick, if you want to go past meshes occluding. #2. I think you need to use the hit.faceId to get the normal of the face. The normal of the hit is, I think, for the ray. var normal = pickInfo.getNormal(...); edit: Welcome to the forum! Quote Link to comment Share on other sites More sharing options...
MinZe Posted July 29, 2018 Author Share Posted July 29, 2018 Thanks, but I wanted to say in the shader, I already know how to to a raycast using babylon's code. Quote Link to comment Share on other sites More sharing options...
brianzinn Posted July 29, 2018 Share Posted July 29, 2018 I've only used the reflection probe: https://doc.babylonjs.com/how_to/how_to_use_reflection_probes That's generating a reflection cube map texture. With just a point, vector, and normal (reflection angle) - you still need to account for other light sources and shadows as well. There are some shader gurus in the forum, but it would be helpful if you had a playground. Quote Link to comment Share on other sites More sharing options...
Nabroski Posted July 29, 2018 Share Posted July 29, 2018 so i'm also not sure what is going on with this engine, take this as a template to go further https://www.babylonjs-playground.com/#6LGN7K#1 i think @NasimiAsl is the expert here. brianzinn 1 Quote Link to comment Share on other sites More sharing options...
MinZe Posted July 29, 2018 Author Share Posted July 29, 2018 Thanks! generating a cubemap in realtime it's something that I needed too! For the intersection with geometry, I think that If I pass the array of the geometry to the shader I can calculate the intersection between a point with a vector and a plane. But If someone knows any method to do it, feel free to post it, as It's gonna help for sure. Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted July 29, 2018 Share Posted July 29, 2018 hi just for start challenge you wanna make something like diamond? or infinity self mirror? Quote Link to comment Share on other sites More sharing options...
MinZe Posted July 29, 2018 Author Share Posted July 29, 2018 1 hour ago, NasimiAsl said: hi just for start challenge you wanna make something like diamond? or infinity self mirror? More like a diamond Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted July 29, 2018 Share Posted July 29, 2018 for step 1 : i just can make fake inner reflect ( i don't calculate inner position for yet ) so i use this pic ** if we can make some real image from inside and make dark and white face ( calculate by normal direction ) we can close to real for step 2 : make refract from this pic http://www.babylonjs-playground.com/#7AIII8#45 step 3 : make reflect from last refract ( like 2 reflect notice in real diamond we have infinity reflact but we do just some level) https://www.babylonjs-playground.com/#7AIII8#46 step 4 : broke refract with last result and use main environment map https://www.babylonjs-playground.com/#7AIII8#47 it is starter solution for make diamond add specular reflect https://www.babylonjs-playground.com/#7AIII8#48 jerome 1 Quote Link to comment Share on other sites More sharing options...
MinZe Posted July 30, 2018 Author Share Posted July 30, 2018 Thanks! it's good enough to have until I've done the shader. thanks for the help NasimiAsl 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.