Solved UVW coordinates in ShaderData.Output()

Hello,

I need to access uvw coordinartes outside of the 0-1 boundary, in a ShaderData.
In UV Edit mode, I scaled plane's uvw to go beyonx 1,1, but the coordinates passed to ShaderData.Output() always normalized to 1,1.

How can I access the actual uvs I need?
Maybe some trick on material tag?
Some external renderers use this workflow for UDIM textures, so it looks possible.

My plugin is in C++ but, but I made a simple test plugin and it has the same issue...
Py-ShaderUvw.pyp

def Output(self, sh, cd):
	c = c4d.Vector( cd.p.x, cd.p.y, 0 )
	return c

Here's how the UVW is setup, the viewport uvws are repeating...
Screen Shot 2021-03-01 at 14.39.07.png

Confirming that the UVW tag contains coordinates up to 2.0...
Screen Shot 2021-03-01 at 14.11.17.png

And the actual render is even stranger, it makes no sense...
Screen Shot 2021-03-01 at 14.38.36.png

hi,

the V axis have been reverse in the UVs editor but not internally. So you have to introduce a 1-V operation.

Float posX = cd->p.x;
Float posY = 1 - cd->p.y;

The same issue talked in this thread as you already pointed out

Cheers,
Manuel

MAXON SDK Specialist

MAXON Registered Developer

@m_magalhaes Thank you, that works.
It would be super useful to have this piece of information on the Output() reference.

What about having the correct uvw on the viewport, is it possible?

@rsodre said in UVW coordinates in ShaderData.Output():

What about having the correct uvw on the viewport, is it possible?

you mean the render ?

MAXON SDK Specialist

MAXON Registered Developer

@m_magalhaes Difference between the viewport uvs and render uvs.

This is the render, it is correct now, with uvs from 0..2:
Screen Shot 2021-03-04 at 16.45.59.png

But the material rendered at viewport does has normalized uvs (0...1):
Screen Shot 2021-03-04 at 16.46.24.png

As far as I remember, Viewport drawing is handled in Draw() method.

hi,

I've opened a bug report for that.
The viewport should reflect as mush as we can the final render.

Cheers,
Manuel

MAXON SDK Specialist

MAXON Registered Developer

hi,

the Shader is limited to 0,1 uvs space in the viewport.
That's exactly what you can see for example with the noise shader. Except this shader have a special mode (HQ noise) so they can be displayed properly.
You can also see that with the brick shader. (HQ Noise doesn't help in that case)

Cheers,
Manuel

MAXON SDK Specialist

MAXON Registered Developer

@m_magalhaes Ok, is it going to be fixed on the bug report or is that a limitation we have to live with?

hi,

the bug report have been defined as a limitation.
It doesn't mean that it will never be fixed, but not now.

Cheers,
Manuel

MAXON SDK Specialist

MAXON Registered Developer

And I'm still convinced that I had the same problem a while ago and managed to draw a custom preview via Draw() method. (There should be a BL entry)
But still, I don't know if I remember right.

hi,

I don't see how we could do it with the Draw Method in a efficient way.

Cheers,
Manuel

MAXON SDK Specialist

MAXON Registered Developer