PDA

View Full Version : Barycentric point

 CastorBlast02-10-2009, 02:29 AMHello, Let's suppose I have a mesh composed of a single face (triangle). Using barycentric coordinates, how can I change the colour of a point inside the triangle? Right now I know how to change the colour of each of the vertexes that form the triangle, but I need to be able access and change more information. Thank you.
groutcho
02-10-2009, 09:57 AM
What do you mean by "point inside the triangle" ?

If there is no vertex inside this triangle (which is then not a triangle, but three triangles) you cannot change its color (Pure logic). Only vertices, faces and edges can store color information.

CastorBlast
02-10-2009, 10:54 AM

By "point" I mean anything inside the triangle that can be accesed by barycentric coordinates using the three vertexes that define the triangle.

For example, I can assign one colour to each vertex. But how can I assign a different colour to the middle (the barycentric centre) of the triangle?

For example, how can I make the triangle have two different colours? Like half white half black divided by an imaginary line defined by barycentric coordinates.

For example, I want to apply a procedural texture written by me, without using the material editor. Using only the information provided by the vertexes, this doesn't look good.

ZeBoxx2
02-10-2009, 11:32 AM
nope - you would have to refine your mesh (or, in theory, the CPV data - but I'm not sure that actually works)

groutcho
02-10-2009, 12:47 PM
As far as I know, you cannot modify the way two colors interpolate from one vertex to another along a given edge. It is always a linear interpolation so that at the middle of the edge, the color is 50% mix between vertex A and vertex B.

drdubosc
02-10-2009, 12:48 PM
Or, to put it another way, the "point" doesn't exist until render time / viewport render time. It's an artefact of the render pipeline.

groutcho
02-10-2009, 02:04 PM
Maybe with Nurbs you can access precisely a given point on a NURBS surface, voxel like.

CastorBlast
02-10-2009, 03:40 PM
So let me get this straight...

If I have a huge mesh plane consisting of only two faces (the two triangles), I cannot WRITE a procedural texture to make it have a chess board texture, or to make it have all the colours of the rainbow, or whatever procedural texture I want. Right? I have to go to the Material Editor and work in a non-script related manner?

Thanks again

ZeBoxx2
02-10-2009, 04:24 PM
That is correct. The only way to do what you want would be to refine your mesh (e.g. via the Tesselate modifier) and then affect vertices from there. But you're going to end up with a looooooooooot of vertices.

If you want a programmable shader, wait for 2010 which has the mental mill thing going on, or find somebody to recompile MaxShade (it's in SourceForge).. it had a renderman-like shading language support for textures.. anything, including the scanline renderer, would render those. Tad slow, tho'.

In the end, you may have to learn C++ and get down and dirty with the 3ds Max SDK :)

groutcho
02-10-2009, 04:28 PM
Of course you can create, modify and apply materials using MAXscript only, without accessing the Material editor, but what we are telling you is that you cannot act directly on the geometry, you must use maps to apply on your object.

theMaterial = standard "myMaterial"
theMaterial.diffusemap = checker

myPlane.material = theMaterial

CastorBlast
02-18-2009, 02:05 PM
Ok, one last question.

Can I do this at render time? Maybe at render time I'll be able to run a loop by screen pixel? No?

ZeBoxx2
02-18-2009, 02:51 PM
You could write a render effect that writes colored pixels to the rendered image based on the object, its UV coordinates, etc. That's gonna be slow, though, and you're really only messing with the pixels - so it's not exactly a proper procedural.

I'd almost say you'd be better off rendering your procedural straight to a bitmap and using that bitmap as the map for the object.

Your best bet is still going to be either writing a full texture plugin, or playing with the plugins that let you render e.g. Direct3D shaders directly in-render.. and author Direct3D shaders (or wait for later max versions with mental mill, etc.)

CastorBlast
02-20-2009, 11:15 AM
I'd almost say you'd be better off rendering your procedural straight to a bitmap and using that bitmap as the map for the object.

Can I do this using MAXScript? Any example available?

Your best bet is still going to be either writing a full texture plugin.

This means I must use the SDK, right?

Ok. I know C++, so this won't be a problem. The thing is: I have no idea how to actually install this SDK and work with it. I've been looking for examples, tutorials, etc., but it is as if the 3DStudio SDK developers work in a Top Secret way or something like that. =/

Any thoughts?

ZeBoxx2
02-20-2009, 12:53 PM
the bitmap thing - check the help file for getPixels and setPixels

The other bit - yep, would require the max SDK. This forum section covers the 3dsMax SDK as well, I'm sure there's others here who have gone through the SDK setup. The SDK help file seems to have a small 'quick start'-ish section using the app wizard, but I wouldn't know the finer details of what goes where and how to link things :)

dutch_delight
02-20-2009, 01:02 PM
you dont need sdk for that. this is a bit of code i stripped so may not work.
pposx and pposy are bitmap pixel coordinates. so top left would be 1,1 etc

screen_width = 256
screen_height = 256

theCanvasBitmap = bitmap screen_width screen_height color:black
setPixels theCanvasBitmap [pposx,pposy] pixel_color

display theCanvasBitmap
theCanvasBitmap.filename = "c:\\test.tga"
save theCanvasBitmap

ZeBoxx2
02-20-2009, 04:58 PM
you do need the SDK for the latter bit; "Your best bet is still going to be [...] writing a full texture plugin."

CGTalk Moderation
02-20-2009, 04:58 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.