I want to view the entire screen as a quadrilateral image, and view the quadrilateral imag as a original texture.
So far I have completed the code of shader to compute the mapping of the screen image.
Now I’m wondering how to use shader in Babylon for the final screen image output.
I tried to PostProcess,but I don’t know how to pass variables such as position、worldViewProjection.
I’m looking forward to receiving your reply and thank you for your help.
For a post-process, you don’t provide the vertex shader because the system uses a default one. Also, this is a 2D post-process, you can’t use 3D coordinates. You can use the vUV
varying, though:
2 Likes
But I want to calculate UV based on the coordinates after the mvp transformation.Is it possible to achieve with post-processing? Or is there another way to do it?
In unity, I can do this by binding the shader to the camera.
A post-process uses a single quad (2 tris) for the geometry, so you will only have 4 transformed vertices. If you want your shader to apply to a real mesh and not simply a quad, you must use a regular shader and not a post-process.
I don’t know Unity, but I’m not sure that a post-process in Unity would be any different than a post-process in Babylon.js, that is a full screen quad rendering. I don’t really know what mean to bind a shader to the camera: is it that all meshes are rendered with the shader you bind to the camera? Something like a shader override: the shader for each mesh is replaced by the “camera shader” at rendering time? In that case, can’t you assign this shader to all meshes in Babylon?
I have found other ways to achieve my goal, and thank you very much for your help.
1 Like