Page 1 of 1

point inputs and projection options for OSL texture

Posted: Tue May 29, 2018 8:46 am
by pxlntwrk
Hi,
I take a question already ask elsewhere on the forum, but has not yet had an answer.
milanm wrote:
Question:

What's going on with point inputs and projection options for OSL texture in the plugin? In OctaneRender ( aka. Standalone), when we add a point input, a projection pin is created, but that doesn't happen in the plugin. Is that a plugin SDK thing? Is that going to change soon? I noticed a related question in the Blender plugin forum too. It's a serious limitation if we have to hardcode the projections ourselves.
example:

Code: Select all

shader Circles(
		float rad=0.5 [[float min=0, float max=1]],
		float sharp=1 [[float min=0, float max=1]],
		int rep=1[[int min=1, int max=10]],
		point proj = point(u, v, 0)
        [[string label = "Projection"]],
        matrix xform = 1
        [[string label = "UV transform"]],
        output color c = 0)
    
{
    point p = transform(1/xform, proj);
    point pt = point(rep*u, rep*v,0);
    float ctx = floor(pt[0])+0.5;
    float cty = floor(pt[1])+0.5;
    point ct = point(ctx, cty, 0);
    float d = fmod(distance(ct, pt), rep)/rad;
    c = 1-smoothstep(0.5*sharp, 1-0.5*sharp, d);

}
and here the different result in Standalone and c4d plugin

Image

in the plugin , no input for transform or projection ?

I think I can easily modify the transform by adding a UVW transform node after the texure , but for the projection I have no idea except to write a few lines in the osl directly.
I have of course read the infos on this page https://docs.otoy.com/osl/input%20types/
but impossible for me so far to put things in the right order...

If someone could kindly show which code to handle a projection (cubic, cynlidrical or any other), directly in the code,waiting for the pins to appear in the nodegraph, it would be nice. :D

thanks

Re: point inputs and projection options for OSL texture

Posted: Tue May 29, 2018 12:25 pm
by aoktar
I don't have time to look for this right now, but it's not yet supported. It will require extra effort and work time! I'll try when it's possible.

Re: point inputs and projection options for OSL texture

Posted: Tue May 29, 2018 12:59 pm
by pxlntwrk
aoktar wrote:I don't have time to look for this right now, but it's not yet supported. It will require extra effort and work time! I'll try when it's possible.
Ok, thanks for answer.

Re: point inputs and projection options for OSL texture

Posted: Tue May 29, 2018 6:38 pm
by milanm
@aoktar

Oh well...

Thanks Ahmet. But seriously, please let us know about the known issues in the release section so we don't have to play detectives here and ask silly questions that have been asked many times before. It's fine if a feature needs more time to be implemented, as long as we know that it's a known issue. Let's not waste each others time here.

This keeps happening over and over again, for years now. Remember all the 'render perfect' questions in the forum? :)

It takes a few minutes to write a list of known issues. It took 2 months to get this answer from you.

Regards
Milan

Re: point inputs and projection options for OSL texture

Posted: Sat Jun 16, 2018 9:11 am
by milanm
Hey pxlntwrk

About hardcoding projections. I think I found a workaround to change default projection but I'm still having a hard time figuring out how to translate, scale and rotate properly. :?

Using this code will force default projection to box projection. There is a list of available options here.

Code: Select all

   point proj = P
        [[ string inputType = "projection:box"]],
Translation is basically adding, like: proj+transform
Scale is multiplication: proj*scale

And for rotation there is a rotate function in OSL. For example this will (in theory) rotate by 90 degrees around Y axis.

Code: Select all

rotate(proj, radians(90), point(0,0,0), point(0,1,0))
You can find more info about it here: osl-languagespec.pdf

I hope this helps somehow. Also, while playing with OSL in 3.08 make sure Material and Opengl Previews are disabled in LV, there was an issue that caused CUDA 700 errors in some rare cases. It's fixed in 4.00-XB3-R1.

Hopefully, when Ahmet is back from holiday we'll see this fixed.

Cheers
Milan

Re: point inputs and projection options for OSL texture

Posted: Sat Jun 16, 2018 9:43 am
by milanm
Here's the Circles texture with a box projection. I had to remove the matrix input to get it to work.

Code: Select all

shader Circles(
      float rad=0.5 [[float min=0, float max=1]],
      float sharp=1 [[float min=0, float max=1]],
      int rep=1[[int min=1, int max=10]],
	    point proj = P
        [[ string inputType = "projection:box"]],
      output color c = 0)
   
{
    point p = proj;
    // Here u and v were referencing mesh uv directly
    // so I replaced them with our p projection
    point pt = point(rep*p[0], rep*p[1],0);
    float ctx = floor(pt[0])+0.5;
    float cty = floor(pt[1])+0.5;
    point ct = point(ctx, cty, 0);
    float d = fmod(distance(ct, pt), rep)/rad;
    c = 1-smoothstep(0.5*sharp, 1-0.5*sharp, d);

}
Cheers
Milan

Re: point inputs and projection options for OSL texture

Posted: Sat Jun 16, 2018 10:04 am
by pxlntwrk
Hey,

awesome, many thnks Milanm,

, i'll test that asap....