Raycasting as a Torch + Light shading
2:00 PM
Today, I improved upon yesterday's work. Yesterday, I created an object which raycasted uniformly in all directions, and only those rays were shown which hit something.
Today, I added a bit of movement and rotating functionality, as well as restricted the rays so that they form a cone. This is similar to having a torch and moving around. Also I drew the complete rays, even if they don't hit the wall, which created a kind of wall shadow illusion.
Below is the embedded project, you can move using arrow keys and rotate using mouse's X coordinate.
Having completed this, I am now moving on and will try to display a sphere that is shaded by a directional light!
2:17 PM
I need to back down a bit 😆. To create 3D graphics, I first need to learn OpenGL. I can ofcourse use the primitives defined by the P5 library itself, but it completely destroys the purpose of learning from scratch. So OpenGL it is!
10:45 PM
So today was just a skim what is OpenGL day. Finally, I decided that since OpenGL is too cumbersome to setup, I would start instead with WebGL. It is same as openGL but is browser based so it does not require some additional setup.
That said, WebGL was nowhere close to simple. We need to write long lines of code just to display the triangle. But actually, that lines are just for the initial setup. After setting up, we need to just modify the Vertex Shader and the Fragment Shader to achieve our desired effect.
These shaders are what tells the browser what to render, where to render and what colour to render the pixel as. So enough for theory today. Tomorrow, I will start to practically implement the WebGL.
This one is super.....!!!
ReplyDeleteThe torch movement 👌🏻
Delete