Notifications
Clear all

[Closed] Cast ray and get its color?

Is there a way in MAXscript to cast single ray from camera and get rendered color WITHOUT actually rendering whole scene into bitmap?
I have an object with color-coded data on its surface and I only need to know which colors are present in front of the camera, I don’t need actual bitmap generated and I don’t want to deal with that slow getPixels routine.
So I just need to shoot few rays from camera and get returned colors.
But I can’t find such function.

7 Replies

how is the colour “encoded” on the objects ? vertex shading/material colour/texture colour/procedural or you want the render colour ??

Yes, I want to get color from production renderer, but WITHOUT dealing bitmap values.

1 Reply
(@serejah)
Joined: 11 months ago

Posts: 0

Rendertime color depends on the renderer, lighting, camera, material and texturemap settings so you obviously can’t just get it from a scene. What you perhaps can do is to make a quick region renders and get average values from there. But you can’t get away from the pre render scene compiling, gi calculation etc. so it won’t be a quick process, imo

But I’m not going to do this, my scene is pretty simple and I use scanline without GI and other advanced tech.
All I need is exactly what I say:
cast ray and get its color, without wasting time on slow getPixels()
Maybe it’s possible to deal quickly with bitmaps using c#?
Maybe some 3rd party renderers have feature to render single ray?

so what if you do a dozen of quick 2×2 px region renders (maybe it should be a blowup renders) instead of single whole-frame render?
getPixels shouldn’t be a problem in this case

I will not avoid gerPixels() that way, and this function is SLOW.
Maybe there is a quick way to read colors from bitmap using C#?
I need to get float RGB values.

Look at c++ sdk Bitmap class and its available methods.
.GetStoragePtr isn’t documented, but perhaps it is the pointer to raw pixel data.

You can get IBitmap using this method
public unsafe virtual int QuickRender(int t, IBitmap rendbm, IRendProgressCallback prog)

(dotnetclass "autodesk.max.globalinterface").instance.interface8.QuickRender

also check out this thread