2
$\begingroup$

I want to create a Shader inside of the Blender Shader editor that distorts the image cylinderically which would look something like this:

enter image description here

I tried to do this in blender but I failed...what did I do wrong?

enter image description here

These are the nodes I used:

enter image description here

I tried to use this .hlsl code as a reference.

enter image description here

$\endgroup$
3
  • 1
    $\begingroup$ I think it would be more practical just to render the image literally UV mapped onto a cylinder, and then reuse that render here. $\endgroup$
    – TheLabCat
    Oct 11 at 1:45
  • 1
    $\begingroup$ I'm wondering why you're using a shader at all? Cycles will do different panoramic renders in the camera. $\endgroup$
    – Ron Jensen
    Oct 11 at 1:45
  • 1
    $\begingroup$ Hello and welcome. Please use a title that reflects the content of the question. It should be succinct, unique and identifying, and summarize what the issue is so that users can at a glance broadly understand what your post is about before opening it. Use the edit link below your post and avoid any emojis salutations or extraneous text not essential to the question. Remember, your title is the first thing potential visitors will see, and will weight heavily on their decision to open your question, which will directly affect the number of answers you might get. $\endgroup$ Oct 11 at 9:12
7
$\begingroup$

Your HLSL yields the transformation: y -> y*(1+(intensity*abs(x))), where x and y are measured from the center of the image. This can make quite a sharp transition across x = 0. You can relieve that with some kind of mapping of x.

Here, the transform is elaborated to y -> y*(stretch+(intensity*(abs(x)^shape))). shape can smooth out the transition, adding an adjustable power of x to y.

enter image description here

If you want the HLSL function as posted, set shape and stretch to 1.

enter image description here

(Image not packed in the .blend).

You may want to investigate the compositor's Lens Distortion node, depending on where you need this effect in your workflow.

$\endgroup$
7
  • $\begingroup$ +1, reminds me on a question about Blenders polynomial lens distortion model I had light years ago... still a mystery to me. If you're interessted and have the time, I'd appreciate an answer: computergraphics.stackexchange.com/questions/8260/…. Can re-ask the question here and add a bounty, just let me know. $\endgroup$
    – brockmann
    Oct 11 at 12:34
  • $\begingroup$ @brockmann I'll have a look! Are you looking for an HLSL answer? Because I'm no great shakes at that.. $\endgroup$ Oct 11 at 12:43
  • 1
    $\begingroup$ It's a bit cumbersome to set up: blender.stackexchange.com/a/181071/31447 Just added a blend file for convenience. Does this help? If you need anything else, please just let me know. $\endgroup$
    – brockmann
    Oct 11 at 17:12
  • 1
    $\begingroup$ @brockmann Cheers! I'll have a go when I can. It may not be today.. but your Q has been around for a while :) $\endgroup$ Oct 11 at 17:14
  • 1
    $\begingroup$ Yeah, it is supposed to be fun... no hassle. If you have the time I'd appraciate an answer. $\endgroup$
    – brockmann
    Oct 11 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.