4
$\begingroup$

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? shader

Update: Try to reproduce answer

$\endgroup$
6
  • $\begingroup$ I'm not sure to understand the bake you want to obtain. But why not simply : i.sstatic.net/gUxeD.jpg $\endgroup$
    – lemon
    Commented Apr 4, 2023 at 14:54
  • $\begingroup$ @lemon could you upload the blender file? $\endgroup$
    – denisbaic
    Commented Apr 4, 2023 at 15:13
  • $\begingroup$ Here you are, Denis, <img src="https://blend-exchange.com/embedImage.png?bid=e93xBBZ8" /> $\endgroup$
    – lemon
    Commented 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$
    – denisbaic
    Commented 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 1

4
$\begingroup$

Here's one way to bake an ortho projection from the camera

enter image description here

.. with the backfacing shading-points mixed to another colour:

enter image description here

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.

$\endgroup$
5
  • $\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$
    – denisbaic
    Commented Apr 6, 2023 at 12:31
  • 1
    $\begingroup$ @denisbaic, try to adjust your bake settings... "diffuse" and only "color" $\endgroup$
    – lemon
    Commented Apr 6, 2023 at 12:37
  • 2
    $\begingroup$ @lemon it worked! Thanks to both of you! $\endgroup$
    – denisbaic
    Commented Apr 6, 2023 at 12:40
  • $\begingroup$ @denisbaic, please accept Robin's answer. $\endgroup$
    – lemon
    Commented 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .