I recently started looking for a shader for orthographic projection of a texture onto a model from the camera. I needed to bake a projected texture. Found an example with perspective projection and OSL rays. However, I don't understand how to rewrite this for the orthographic case. I see in the code finding the camera normals, but next for me is shader magic. Could someone help to do this with the orthographic case?
-
$\begingroup$ I'm not sure to understand the bake you want to obtain. But why not simply : i.sstatic.net/gUxeD.jpg $\endgroup$– lemonCommented Apr 4, 2023 at 14:54
-
$\begingroup$ @lemon could you upload the blender file? $\endgroup$– denisbaicCommented Apr 4, 2023 at 15:13
-
$\begingroup$ Here you are, Denis, <img src="https://blend-exchange.com/embedImage.png?bid=e93xBBZ8" /> $\endgroup$– lemonCommented Apr 4, 2023 at 15:16
-
1$\begingroup$ @lemon ibb.co/d580wP1 - your case , ibb.co/XSCx9dy - goal. In your implementation, the texture is also drawn on those parts that are not visible from the camera. Is there a way to avoid this? $\endgroup$– denisbaicCommented Apr 4, 2023 at 15:30
-
$\begingroup$ @lemon ... hope I haven't stepped on your toes.. will back out if you put in your own answer. $\endgroup$– Robin Betts ♦Commented Apr 6, 2023 at 10:37
1 Answer
Here's one way to bake an ortho projection from the camera
.. with the backfacing shading-points mixed to another colour:
Here, the mix is plugged straight into the Material Output, and 'Emission' is baked.
It's all a bit confusing while you're setting it up, because 'Camera Space' in your node tree includes the camera space of the viewports. That means you're working blind; you can't see round the back of your object until the bake is made and assigned.
-
$\begingroup$ I just tried to reproduce your solution. However, for some reason I got a darkened result. Could you please attach the file or look at the file that I will attach now when I change the question? $\endgroup$ Commented Apr 6, 2023 at 12:31
-
1$\begingroup$ @denisbaic, try to adjust your bake settings... "diffuse" and only "color" $\endgroup$– lemonCommented Apr 6, 2023 at 12:37
-
2$\begingroup$ @lemon it worked! Thanks to both of you! $\endgroup$ Commented Apr 6, 2023 at 12:40
-
$\begingroup$ @denisbaic, please accept Robin's answer. $\endgroup$– lemonCommented Apr 6, 2023 at 12:41
-
1$\begingroup$ Hi, @denisbaic thanks! My mix was stuck straight into the material output without an explicit shader, because I didn't know how you wanted to use your texture, and I baked 'Emisson'. Same difference.. I should have included that in the illustration. $\endgroup$– Robin Betts ♦Commented Apr 6, 2023 at 12:55