#1
|
|||
|
|||
Custom Effect Shading
Hey!
I'm trying to change they way models get shaded, so I was looking into the custom effects. The documentation only gives very simple examples. When things get more complicated I need helper functions, but I suspect these are not supported to work with vizard's effects framework? Let's do a really simple dummy example. Assume inside the shader code I want to use this helper function: Code:
float halve(float k) { return k*0.5; } But whereever I put this function, it throws some error. Inside Shader, but outside Units: Code:
# Setup model logo = vizfx.addChild('logo.osgb') code = """ Effect CustomShadingModel { Shader { float halve(float k) { return k*0.5; } BEGIN FinalColor float half_r = halve(gl_FragColor.r); gl_FragColor.rgb = vec3(half_r, 1.0, 1.0); END } } """ customEffect = viz.addEffect(code) # Apply effect specifically to a model logo.apply(customEffect) Quote:
So is this really not possible with the effects framework? If not, I would have to use a custom GLSL fragment shader? But the documentation on this is very sparse (just a make-a-uniform-color-example). How do I get the ViewDirection, the surface normal, the light direction, etc. to be used inside the shader code? And how can I apply the shader to all osgb models loaded and reference their texures inside the code? Because I don't want to set all textures for a hundred objects via script. |
Tags |
glsl, rendering, shader, shading |
Thread Tools | |
Display Modes | Rate This Thread |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Updating a Postprocessing effect | MissingAFew | Vizard | 2 | 05-07-2015 09:58 AM |
Adding custom faces | mjabon | Vizard | 2 | 04-01-2009 08:34 PM |
How do I add custom functions to a custom plugin? | reedev | Plug-in development | 7 | 02-01-2009 03:39 AM |
animating custom faces: in search of "open_mouth" morphs | vr_boyko | Vizard | 1 | 09-16-2004 10:30 AM |
Creating Custom Avatar Heads | farshizzo | Vizard | 22 | 09-12-2004 09:23 PM |