10

OSL has the texture command that we can use to load image files and map in an object. Dfelinto made a nice video about it some years ago. https://www.youtube.com/watch?v=V5N2rnFtSlw

We also have many samples of it in the source of blender: https://github.com/dfelinto/blender/blob/master/intern/cycles/kernel/shaders/node_image_texture.osl

But how we can load using OSL an blender's internal image? Some created inside it or already loaded using the uv/image editor?

VitorBalbio
  • 173
  • 1
  • 1
  • 5

2 Answers2

0

Open shading language try this youtuber code

surface environment_node(
    //    filepath input
    string filepath = "find internal blender image path and putin",
    //    surface color output
    output closure color out_color = 0,
)

{ // Image vector value vector mvdir = I; // environment function return color color print = environment(filepath,mvdir); // surface color output = image color * emission strength out_color = print * emission(); }

My similar code:

surface environment_node(
    //    image color input
    color image = 0,
    //    surface color output
    output closure color out_color = 0,
)

{ // surface color output = image color * emission strength out_color = image * emission(); }

[![enter image description here][1]][1][1]: https://i.stack.imgur.com/lfxEo.png

or emission node similer

surface environment_node(
    //    image color input
    color image = 0,
    //    strength
    float strength = 2,
    //    surface color output
    output closure color out_color = 0,
)

{

// surface color output = image color * emission strength out_color = image * strength * emission(); }

enter image description here

To use it add Environment node and plug in the Color output to Image input.

-2

If I understand the question right. The internal images are values that are generated from coardinates and do not realy exist. You should be able to call the existing method eather direct or indirect.

If that don't worke for you all of the math to generate them isn't that hard to find on the internet.

Alfons Marklén
  • 587
  • 1
  • 5
  • 22