View Full Version : Scripted Render Elements ?
03-12-2009, 03:59 PM
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
03-12-2009, 06:29 PM
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.
03-12-2009, 07:21 PM
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.
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.
03-12-2009, 08:02 PM
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
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
Must Dig a bit more in this direction
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.
03-13-2009, 11:50 AM
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,posy*ratio*cameratransform gives the worldcoordinate from pixel value. It works preaty fast for now. Will send the Fn when is ready
03-15-2009, 04:06 PM
AND FURST SUCESSFULL TESTS
Plane length:500 width:500 transform:(matrix3 [1,0,0] [0,0,1] [0,-1,0] [-20.6565,110.056,89.8366]) material:meditMaterials
Plane length:500 width:500 transform:(matrix3 [1,0,0] [0,1,0] [0,0,1] [-19.6874,-38.7186,0]) material:meditMaterials
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
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
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 result is:
-- RedChannel Distance to light
-- Green Chanel Illumination
--ALL DATA IS EXTRACTED FROM DEPTH AND NORMAL PASS (G-BUFFER)
passscl=1 --Pass SCALE
MaxLightDistance=600 --MAXIMUM DISTANCE
---RENDERING DEPTH AND NORMAL PASS - FLOAT
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 \
VFOV = atan(tan(HFOV)/((renderWidth as float)/renderHeight*renderPixelAspect))
TheLights = for obj in Lights where classof obj != TargetObject collect obj
for indx=1 to TheLights.count do (
ThePass[indx]=bitmap TheRender.width TheRender.height
with undo off
progressStart "Processing Depth"
for px=0 to TheRender.width-1 do
for py=0 to TheRender.height-1 do
pixdepth=(getChannel TheRender [px,py] #zDepth)
pixnormal=(getChannel TheRender [px,py] #normal)
if not(pixdepth <=-1e+030) then --IF NOT BACKGROUND
--GET WORLD POSITION FROM Z PIXEL
--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
d=distance worldpos testpos
--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)
setPixels thePass[indx] [px,py] #((color d n 0.0))
---END CICLE LIGHT
)--END IF NOT BACKGROUND
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
96 lights at resolution 640x480
96 bitmaps 640x480 containing Distance to light and Illumination info
for 850k poly in scene preaty cool i think
03-15-2009, 04:34 PM
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 :o
03-15-2009, 04:48 PM
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
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...
03-15-2009, 10:35 PM
that's the way most people go.. there's a few similar-ish scripts up on scriptspot.com.. I swear there was one on our forums as well but the search terms are entirely too common :)
The 'biggie' is that you have to know for each material type what its opacity/transparency type parameters/maps are and, of course, it does squat for refractive transparency (fog would work there, but comes with its own set of problems)
03-16-2009, 07:31 AM
"Override materials and distance falloff maps... " PLEASE i am not an idiot... I AM SPEAKING FOR SINGLE PASS RENDER :buttrock:
"The 'biggie' is that you have to know for each material type what its opacity/transparency type " I KNOW THIS ALREADY check what G-Buffer outputs. Check the depth (not only the channel but his layers too). There is everything needed and if you combine data from transperancy channel and node ID channel i think transperancy is clear :)
The idea is not Production Final quality, and yes i know there are many ways to acheive the same result. i want to focus more on what is possible to extract from single depth and normal pass THE GOAL IS TO GET AS MUCH DATA AS POSSIBLE from those 2 channels with POST actions. Its slow for now, but when it goes on C++ speed will be incredible. Actualy there are some simple calculations that can be reduced even more and thinks can go to a lot of fps.
I am working on Shadow calculations, this is a big challange for now. If sombody has a clever solution please share it. Shadows of coarse cant be precise in order that i dont have 360 info for the objects but it is a future problem, and it has a solution i belive.
03-16-2009, 11:06 AM
Well, excuse you if you thought we labeled you an idiot when we suggested some possible solutions and pitfalls to those solutions (and we didn't realize you didn't care about production quality, of course) :)
I'll leave you to your shadow problem, then. Good luck! :)
03-16-2009, 11:06 AM
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.