point inputs and projection options for OSL texture

Maxon Cinema 4D (Export script developed by abstrax, Integrated Plugin developed by aoktar)

Moderators: ChrisHekman, aoktar

Post Reply
User avatar
pxlntwrk
Licensed Customer
Posts: 445
Joined: Sat Mar 23, 2013 2:21 pm
Location: France
Contact:

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
:::::::::::::::::
pxlntwrk.net
User avatar
aoktar
Octane Plugin Developer
Posts: 16066
Joined: Tue Mar 23, 2010 8:28 pm
Location: Türkiye
Contact:

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.
Octane For Cinema 4D developer / 3d generalist

3930k / 16gb / 780ti + 1070/1080 / psu 1600w / numerous hw
User avatar
pxlntwrk
Licensed Customer
Posts: 445
Joined: Sat Mar 23, 2013 2:21 pm
Location: France
Contact:

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.
:::::::::::::::::
pxlntwrk.net
milanm
Licensed Customer
Posts: 261
Joined: Tue Apr 30, 2013 7:23 pm

@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
Colorist / VFX artist / Motion Designer
macOS - Windows 7 - Cinema 4D R19.068 - GTX1070TI - GTX780
milanm
Licensed Customer
Posts: 261
Joined: Tue Apr 30, 2013 7:23 pm

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
Last edited by milanm on Sun Jun 17, 2018 6:39 am, edited 1 time in total.
Colorist / VFX artist / Motion Designer
macOS - Windows 7 - Cinema 4D R19.068 - GTX1070TI - GTX780
milanm
Licensed Customer
Posts: 261
Joined: Tue Apr 30, 2013 7:23 pm

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
Colorist / VFX artist / Motion Designer
macOS - Windows 7 - Cinema 4D R19.068 - GTX1070TI - GTX780
User avatar
pxlntwrk
Licensed Customer
Posts: 445
Joined: Sat Mar 23, 2013 2:21 pm
Location: France
Contact:

Hey,

awesome, many thnks Milanm,

, i'll test that asap....
:::::::::::::::::
pxlntwrk.net
Post Reply

Return to “Maxon Cinema 4D”