rob Posted June 18, 2008 Author Share Posted June 18, 2008 (edited) Hi Mario, you used vector n = normalize(N); in the occlusion shader and then in the hemisphere color shader you altered vector n to equal vector n = normalize(ntransform( "space:world",N)); . why does this have to change from the original vector n = normalize(N);. Now want to combine the occlusion with grnd /sky colors of course now n has a different value. Edited June 18, 2008 by rob Quote Link to comment Share on other sites More sharing options...
Mario Marengo Posted June 18, 2008 Share Posted June 18, 2008 you used vector n = normalize(N); in the occlusion shader and then in the hemisphere color shader you altered vector n to equal vector n = normalize(ntransform( "space:world",N)); . why does this have to change from the original vector n = normalize(N); It doesn't have to change. As I mentioned earlier, I just hijacked 'n' for my own evil purposes when computing the horizon stuff, without thinking, really. It was there, looking lonely; I was in a rush, so I used it. My bad. Apologies. I'm tempted to just give you the two-line fix for that, but I get the feeling that doing so will just cause more confusion, so here's the whole horizon thing again, minus that goof. #include <math.h> #pragma label htype "Horizon Type" #pragma choice htype "lramp" "Linear Ramp" #pragma choice htype "sramp" "Smooth Ramp" #pragma choice htype "hard" "Hard" #pragma choice htype "soft" "Soft" #pragma label hsoft "Horizon Softness" #pragma range hsoft 1e-4! 1! #pragma disable hsoft htype "lramp" #pragma disable hsoft htype "sramp" #pragma disable hsoft htype "hard" light rs_ambient_v02 ( vector skycolor = {1,0,0}; vector grndcolor = {0,0,1}; string htype = "soft"; float hsoft = 0.2; float intensity = 1; string env_map = "Mandril.rat"; string env_space = "space:world"; ) { vector n = normalize(N); vector nw = ntransform("space:world",n); // <--- NEW WORLD-SPACE VERSION OF n float weight = 1.0 - acos(nw.y)/M_PI; // <--- WORLD-SPACE VERSION USED HERE float hw = weight; if(htype == "sramp") { // Smooth ramp hw = smooth(0,1,weight); } else if(htype == "hard") { // Hard edge hw = filterstep(0.5,weight); } else if(htype == "soft") { // Soft edge float halfinterval= clamp(hsoft*0.5,1e-4,0.5); hw = smooth(0.5-halfinterval,0.5+halfinterval,weight); } vector lightcolor = lerp(grndcolor,skycolor,hw); vector Cenv = 1; if(env_map!="") { string space = env_space=="" ? "space:world" : env_space; Cenv = environment(env_map,n,"envobject",space); } Cl = lightcolor*intensity*Cenv; L = n; // <--- AS BEFORE } Now it leaves 'n' as it used to be, and uses a new variable 'nw' wherever a world-space version of 'n' is needed. Untested... but it should work... I hope. HTH. Quote Link to comment Share on other sites More sharing options...
rob Posted June 19, 2008 Author Share Posted June 19, 2008 (edited) Hi Mario, I have taken everything covered by you and expanded on the interface using the " pragma " operation and included custom icons and help. I guess the final thing to top off this shader would be to somehow implement a way of being able to export various parameters for use in compositing As ever thanks so much for taking the time to expand everyones skills .. Rob rs_void_occlusion_hemis.otl Edited June 19, 2008 by rob Quote Link to comment Share on other sites More sharing options...
zasid Posted July 6, 2008 Share Posted July 6, 2008 It worked just great but now I m getting this error when I try to render it through mantra Couldn't add library C:/Documents and Settings/ZOHAIB/ROBAO.otl to Current HIP File. Check that C:/Documents and Settings/ZOHAIB/ROBAO.otl is a valid operator type library. Unable to get VEX code from: opdef:/Shop/rs_void_occlusion_hemis mantra: VEX error: Unable to load opdef:/Shop/rs_void_occlusion_hemis Path not found Unable to get VEX code from: opdef:/Shop/rs_void_occlusion_hemis mantra: VEX error: Unable to load opdef:/Shop/rs_void_occlusion_hemis Path not found Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.