WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 05-09-2018, 11:26 PM
saket saket is offline
Member
 
Join Date: Mar 2015
Posts: 20
post-processing effect to single object

Hi,

I need to access the currently displayed pixels on screen within a fragment shader.
For which i found the access through vizard's post-processing at http://docs.worldviz.com/vizard/postprocess_basics.htm using vizpp_InputTex. However it only refers to shader which are applied on whole screen.

How can I apply the the shader using postprocess to only specific objects?
Something like this :
effect = RedEffect()
object.apply(effect)

In which case only the object should have redeffect applied to it and rest of objects should have no effect.
Reply With Quote
  #2  
Old 05-14-2018, 10:39 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
All postprocess effects are applied to the entire window. You can apply shaders to individual objects using Vizard's effects framework. The custom and example effects pages have some example code.
Reply With Quote
  #3  
Old 05-15-2018, 10:45 PM
saket saket is offline
Member
 
Join Date: Mar 2015
Posts: 20
Thanks Jeff. The Effects might solve what I am looking for.
Reply With Quote
  #4  
Old 05-17-2018, 11:09 PM
saket saket is offline
Member
 
Join Date: Mar 2015
Posts: 20
Hi Jeff,

The custom effect work on pre-existing models like 'logo.osgb'

But effects do not work on on-the fly object. Do i need to set some flag for on-the fly object for enabling effects on them as well?
Reply With Quote
  #5  
Old 05-18-2018, 04:38 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Yes, you will need to use the generateEffects command on that model. Here's an example:

Code:
import viz
import vizfx
import vizcam
import vizshape

viz.setMultiSample(4)
viz.go()

viz.clearcolor(viz.SLATE)
# Disable head light
viz.MainView.getHeadLight().disable()
# Add a directional light pointing down 
light = vizfx.addDirectionalLight(euler=(0,90,0), color=[0.2,0.2,0.2])

shape = vizshape.addPyramid(base=(0.4,0.4),height=0.4)
composer = vizfx.getComposer()
shape.generateEffects(composer=composer)

cam = vizcam.PivotNavigate(distance=3.5)
cam.centerNode(shape)

code = '''
Effect { 
    Type Highlight
    Shader { 
        BEGIN FinalColor 
        gl_FragColor.rgb += vec3(0.7, 0.0, 0.0);
        END 
    } 
} 
'''
effect = viz.addEffect(code)
shape.apply(effect)
Reply With Quote
  #6  
Old 05-20-2018, 10:34 PM
saket saket is offline
Member
 
Join Date: Mar 2015
Posts: 20
Thanks Jeff.

It worked with on-the-fly object.

With models creating using external application like :http://www.openscenegraph.org/index....planet-builder . Do I need to run any other command to enable effects on such models?
Reply With Quote
  #7  
Old 05-24-2018, 12:03 AM
saket saket is offline
Member
 
Join Date: Mar 2015
Posts: 20
Additional Info :

If I create a separate copy of root node and apply effects only on it then the effects work.
However if I apply the effects on the entire directory structure where root node load the child nodes itself then the effects do not work.
I tried using different argument values for flags and op in generateEffects but still no success
Reply With Quote
  #8  
Old 05-25-2018, 03:35 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Can you provide a sample file and code that reproduces the issue?
Reply With Quote
  #9  
Old 05-27-2018, 10:21 PM
saket saket is offline
Member
 
Join Date: Mar 2015
Posts: 20
Jeff,

I am using the following code to test the effect on my model.

A subset of model with the code file is in attachment. Execute the shader_test.py to see that no effect is applied on the model.

However if I remove "Earth/main_root_L0_X0_Y0" folder then the effect start working.

Code:
import viz,vizfx

viz.go()
model=vizfx.addChild('./Earth/main.osgb')
viz.MainView.setPosition(2270347.75*2, 3137376.25*2, 7425973.0*2)
viz.MainView.lookAt([0,0,0])

composer=vizfx.getComposer()
model.generateEffects(composer=composer)

code="""
Effect {
    Float rmin{value 0}
    Float rmax{value 255}
    Float gmin{value 0}
    Float gmax{value 255}
    Float bmin{value 0}
    Float bmax{value 255}
    Shader{
        BEGIN FinalColor
        float r=(vizfx_VertexColor.r-rmin)*255/(rmax-rmin);
        float g=(vizfx_VertexColor.g-gmin)*255/(gmax-gmin);
        float b=(vizfx_VertexColor.b-bmin)*255/(bmax-bmin);
        gl_FragColor.rgb=vec3(r,g,b);
        END
    }
}
"""

effect=viz.addEffect(code)
model.apply(effect)
model.setUniformFloat('bmin',50)
Attached Files
File Type: zip effect_test.zip (580.9 KB, 904 views)
Reply With Quote
  #10  
Old 05-31-2018, 11:10 PM
saket saket is offline
Member
 
Join Date: Mar 2015
Posts: 20
Quote:
Originally Posted by Jeff View Post
All postprocess effects are applied to the entire window. You can apply shaders to individual objects using Vizard's effects framework. The custom and example effects pages have some example code.
Can the Effect framework access neighboring pixels to apply effects like blur?

Because all the examples work specifically with pixel in question and not include any effect using neighboring pixel value which would be needed for implementing functions like blur.
Reply With Quote
Reply

Tags
effects, object, post process, shader

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Crosshatch Post-Processing Effect give away Vaquero Vizard 0 08-03-2016 09:48 PM
anaglyph effect at front view of cave g.vannan Vizard 1 02-03-2015 05:29 AM
retrieve Object names Geoffrey Vizard 11 12-11-2009 04:26 AM
importing a single WRL with many objects. giancamati Vizard 3 12-18-2006 01:13 PM
rotate to object jargon Vizard 1 08-08-2005 12:20 PM


All times are GMT -7. The time now is 03:44 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC