PDA

View Full Version : Bitmap Transform


Ziboo
12-03-2008, 12:03 PM
Hi everybody,

I have 2 little questions about bitmap transform.

Is it possible to desaturate a bitmap by MaxScript ?

Is it possible to blur a bitmap by MaxScript ?

It's because i use a script to make a virtual viewport, and i render my actual viewport as a bitmap to it, and i want to see it in greyscale or blured (for lighting is cool to have this vision).

Thanks

Rob

LoneRobot
12-03-2008, 12:38 PM
are you using max 2008 or up? you can just use a color correction map in the environment map slot. you can perform many image adjustments and this will show up in vpt background.

Ziboo
12-03-2008, 12:40 PM
i'm using max 9....

That isn't for render but for realtime. I'm using directX shader with vertexColor in my scene.

Here is the script i'm using for duplicate my viewport :

rollout t "Virtual viewport" width:200 height:200
(
bitmap w "" width:200 height:200

fn virtualViewport =
(
w.bitMap = gw.getViewportDib()
--colors = getPixels w.bitmap [0,0] 200
--print colors
)

on t open do
(
virtualViewport()
registerRedrawViewsCallback virtualViewport
)

on t close do
(
unRegisterRedrawViewsCallback virtualViewport
)

on t resized size do
(
x = gw.getWinSizeX()
y = gw.getWinSizeY()
w.width = size.x
w.height = size.y
if size.x > x do
(
t.width = x
w.width = x
)
if size.y > y do
(
t.height = y
w.height = y
)
)

)
createDialog t style:#(#style_resizing,#style_minimizebox,#style_titlebar,#style_border,#style_sysmenu)

handiklap
12-05-2008, 03:59 PM
Do you mean something like this?:

(0.3*pixelVal.x + 0.59*pixelVal.y + 0.11*pixelVal.z)

That will return a pixel's luma value. So just assign that value to pixelVal.x, pixelVal.y, and pixelVal.z and you've got a grayscale. Since you're doing this to a bitmap, remember to read entire rows of pixels at a time, as it is more than twice as quick as doing it one pixel at a time.

As for blurring, I'd assume some research on convolution algorithms would get you what you need.

kees
12-05-2008, 06:25 PM
To do it in realtime, you would have to use Viewport shaders (scene shaders).
Max does support them, though they are poorly documented and don't always work.

But blurring and desaturate should be possible.

Ziboo
12-05-2008, 07:38 PM
Thanks for reply
I will try that handiklap

knees: what is scene shaders ?

PiXeL_MoNKeY
12-05-2008, 07:49 PM
Utilities > More... > Scene Effect Loader.

This allows you to load DirectX Scene Effects, that effect the whole viewport. Max ships with a few samples to do various effects (\maps\fx\scene\).

-Eric

CGTalk Moderation
12-05-2008, 07:49 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.