[Closed] Scripted Render Elements ?
Hi, i need to do custum render pass (render element) let say depth pass but based on distance to light instead of distance to camera. Any idea is it possible trought script?
Generaly any info about how renderelemnts are defined will be in great help for me. I was not able to find ANY detailed info in papers abot this.
Thanks in advance
Surely distance to light would just be a lighting pass? Or am I missing something?
You can use falloff materials, or a manual spherical UVW gizmo might do the job.
AFAIK, there is no way to script a custom render element like that, but you could easily do it with scene states. Assign a distance falloff to all objects with your light as the picked object.
-Eric
Edit: Option 2 is assign a white material to all objects, set your light to ambient only, and use the far attenuation to define the desired falloff. See the attched example.
Yeah but i need to render all passes 1 by one… 10 lights-10 years… i know how to get the pass of coarse, the problem is how to get those passes in SINGLE render. I can extract data from normal pass and do a simmple subtract with light vector, can do a gradient, falloff and etc, this is not a problem. The problem is to do it WITHOT RERENDERING, thats why i need to know is it scriptable. And
if scriptable do howto.getInfo
hehehe
edit: maybe some workaround… check the RPF format for example, those chanells are stored somwhere… must have a way to acess Gbuffer at least, and most important every rpf channel has layers and they contain some useful data too. So i note the UV chanel it has layers too, so i am thinkig maybe to do a uvmap representing light and trough this chanel to get nneded light info, but the problem is taht it exports only UV#1 maybe there is a way to export all UV chanels at once
maybe those fns are the magic, depth is in world units so if i know depth and camera positon, its a simple math to get distancce to any other object in the scene
getChannel
getChannelAsMask
Must Dig a bit more in this direction
Thanks people
Keep us posted!
I’d personally go for a custum mr pass with a fallof material based on distance to a point(light) It would give the same results. We use that allot for zDepth and custom Z channels.
-Johan
I already got the function that delivers WORLD position from Zbuffer but there is small vary in calculated and real value ( as expected ) My system is a bit strange but this is what i did.
I calculate the Image plane width and height at certain depth. After that i divide ImagePlaneWidth by RenderedImageWidth and height in same way to get Image to render ratio. after that posx,posyratiocameratransform gives the worldcoordinate from pixel value. It works preaty fast for now. Will send the Fn when is ready
AND FURST SUCESSFULL TESTS
the scene:
Plane length:500 width:500 transform:(matrix3 [1,0,0] [0,0,1] [0,-1,0] [-20.6565,110.056,89.8366]) material:meditMaterials[1]
Plane length:500 width:500 transform:(matrix3 [1,0,0] [0,1,0] [0,0,1] [-19.6874,-38.7186,0]) material:meditMaterials[1]
Plane length:500 width:500 transform:(matrix3 [-1.62921e-007,-1,0] [0,0,1] [-1,1.62921e-007,0] [143.399,-41.5139,91.4713]) material:meditMaterials[1]
Sphere radius:35.2937 transform:(matrix3 [-1.62921e-007,-1,0] [0,0,1] [-1,1.62921e-007,0] [24.6056,0.703619,42.9211]) material:meditMaterials[1]
Freecamera name:"Camera01" fov:45 targetDistance:159.029 transform:(matrix3 [0.700909,-0.713251,0] [0.074555,0.0732649,0.994522] [-0.709343,-0.697069,0.104528] [-229.659,-251.946,80.1231])
Omnilight rgb:(color 255 255 255) multiplier:1 transform:(matrix3 [1,0,0] [0,1,0] [0,0,1] [-20.8343,206.698,518.586])
Omnilight rgb:(color 255 255 255) multiplier:1 transform:(matrix3 [1,0,0] [0,1,0] [0,0,1] [-281.989,-21.9769,185.726])
freeSpot rgb:(color 255 255 255) multiplier:1 transform:(matrix3 [0.895675,-0.44471,0] [0.18674,0.376106,0.907564] [-0.403603,-0.812882,0.419914] [-79.6777,-211.186,151.361])
the script:
-- The result is:
-- RedChannel Distance to light
-- Green Chanel Illumination
--ALL DATA IS EXTRACTED FROM DEPTH AND NORMAL PASS (G-BUFFER)
TheCamera=$camera01 --Camera
passscl=1 --Pass SCALE
MaxLightDistance=600 --MAXIMUM DISTANCE
---RENDERING DEPTH AND NORMAL PASS - FLOAT
--undisplay TheRender
TheRender= render camera:TheCamera \
renderType:#normal outputHDRbitmap:true channels:#(#zDepth, #normal) \
outputSize: [renderWidth*passscl,renderHeight*passscl] pixelaspect:renderPixelAspect renderfields: false vfb:false \
renderElements:false progressbar:true renderMultiPassEffects:false \
antiAliasing:false enablePixelSampler:false mapping:false shadows:false \
autoReflect:false forceWireframe:false filterMaps:false objectMotionBlur:false \
imageMotionBlur:false renderatmosphericeffects:false
-----
HFOV=theCamera.fov/2.0
VFOV = atan(tan(HFOV)/((renderWidth as float)/renderHeight*renderPixelAspect))
rw=TheRender.width
rh=TheRender.height
TM=TheCamera.transform
RatioX=(sin(HFOV)/sin(90-HFOV))
RatioY=(sin(VFOV)/sin(90-VFOV))
---SomePreparations
TheLights=#()
TheLights = for obj in Lights where classof obj != TargetObject collect obj
ThePass=#()
for indx=1 to TheLights.count do (
ThePass[indx]=bitmap TheRender.width TheRender.height
)
---END preparations
with undo off
(
progressStart "Processing Depth"
for px=0 to TheRender.width-1 do
(
progressUpdate (100.0*px/TheRender.width)
for py=0 to TheRender.height-1 do
(
pixdepth=(getChannel TheRender [px,py] #zDepth)[1]
pixnormal=(getChannel TheRender [px,py] #normal)[1]
if not(pixdepth <=-1e+030) then --IF NOT BACKGROUND
(
--GET WORLD POSITION FROM Z PIXEL
posPX=-(px*2-rw)*((RatioX*pixdepth)/rw)
posPY=(py*2-rh)*((RatioY*pixdepth)/rh)
posPZ=pixdepth
worldPos=([posPX,posPY,posPZ]*TM)
--END GET WORLD POSITION FROM Z PIXEL
---CICLE ALL LIGHTS AND GET DATA
for indx=1 to TheLights.count do
(
--GET DISTANCE TO LIGHT DATA
testpos=TheLights[indx].Position
d=distance worldpos testpos
d=255.0-(255.0*d/MaxLightDistance)
--GET NORMAL LIGHT DATA
if TheLights[indx].type == #freeDirect or TheLights[indx].type == #targetDirect then \
TheLightDir=TheLights[indx].dir else TheLightDir=testpos-worldpos
TheLightsNorm=(normalize (TheLightDir*(inverse TheCamera.transform.rotationpart)))
LightAngle=(dot TheLightsNorm pixnormal)
n=255*LightAngle
setPixels thePass[indx] [px,py] #((color d n 0.0))
)
---END CICLE LIGHT
)--END IF NOT BACKGROUND
)
)
)
progressEnd()
--display TheRender
for indx in ThePass do display indx
A bit slow for now but with big potential, furst of all the speed is independent from geometry, means that 1 or 1000000 poligons will not make any diference in speed at all. After all maybe the c++ code will be better and realtime i belive. now i must find a way to get Shadows from Depth and Normall, its hard but not impossible.
And some numbers
test:
96 lights at resolution 640×480
result:
96 bitmaps 640×480 containing Distance to light and Illumination info
Time:
3.245 min.
for 850k poly in scene preaty cool i think
That… is more like a post-render effect, no?
In fact… the File Output render effect already has a z-depth output option… if that’s all that was needed 😮
yes its post effect in order that you do only 1 actual render.
The whole idea is a bit diferent, if you have very complex geometry and complicated light set, the advantages of this passes are HUGE, means that you can adjust the lighting, materials, colors and fog in realtime, and after you are happy just paste settings back to your scene and get the same result. Its more reverse engenering approach to lighting a scene. Not sure that i explain it proper. Check the PSD and you will see a lot of things that i am speaking about.
The problem is how to get needed custom passes with 1 render only. imagine 1000k poly scene and 60 rerenders to get what you need…a bit stupid.
[ http://www.ufo-bg.com/temp/COMP EXAMPLE MORE ADVANCED.rar]( http://www.ufo-bg.com/temp/COMP EXAMPLE MORE ADVANCED.rar)
So Groups in the psd are general control (intensity) if you play with the layers inside groups you wil see how many things are controlable only with a few stupid grayscale passes.
And how many more things can be acheived with some more Brain intead of raw render power…
I’d go a different route for this approach, hopefully I have some time the coming days to work it out. Override materials and distance falloff maps…
-Johan