WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 12-07-2006, 04:16 PM
jrodman jrodman is offline
Member
 
Join Date: Jun 2003
Posts: 21
Quote:
Originally Posted by jrodman View Post
Finally, when I increase the "blurScale" to 3 or more, it starts to look pixelated. I presume this is because there's no diagonal blurring. I think I can modify the script myself to blur over a box or circle. I will attempt to do so now.
Having looked a little closer, I now realize that the separate vertical and horizontal passes do generate diagonal blurring. I now think that the pixelation is generated by the fact that there is a fixed number of samples taken to generate the blurring. And this means that when the scale gets too big, it starts skipping pixels.

I tried increasing the number of samples, but the current code adds one line of c++ for each sample. There appears to be a limit to the amount of c++ code that can be passed to the render node's apply function.

Next I tried rewriting the c++ to include a for loop so there wouldn't have to be a separate line for each sample. This code, however, seems to be crashing. I have no way to debug it since it's getting run inside Vizard where I can't attach a debugger or print debug statements.

Here's my code:

Code:
		blur_source = """
		uniform sampler2D srcImage;
		uniform float blurScale;
		void main(void)
		{
			vec4 color = vec4(0,0,0,0);
			float numSamples = blurScale * 4.0;
			for(float index = -numSamples; index <= numSamples; index += 1.0)
			{
				float offset = index / %size%;
				float temp = index / numSamples;
				`float weight = 0.05 + ((1.0 - temp * temp) / 4.0);
				color += ( texture2D( srcImage, gl_TexCoord[0].xy + vec2( %modifier% ) ) * weight );
			}
			color.a = 1.0;
			gl_FragColor = color / 1.7;
		}"""

		#Create horizontal blur shader
		temp_source = blur_source.replace('%size%', str(float(size[0])) )
		blur_code = temp_source.replace('%modifier%', 'offset * blurScale, 0.0' )
		horzBlurShader = viz.addShader(frag=blur_code)

		#Create vertical blur shader
		temp_source = blur_source.replace('%size%', str(float(size[1])) )
		blur_code = temp_source.replace('%modifier%', '0.0, offset * blurScale' )
		vertBlurShader = viz.addShader(frag=blur_code)
I think I left the rest of your script the same. When I run this, I get a notification that a program crashed, but winviz is left running, taking up all of the CPU. I'm guessing this means that winviz spawns a process to run the c++, that process crashes, and winviz is left waiting for it.

Any ideas what would cause this? Is it worth pursuing if we're going to get a video card that will run your other script?
Reply With Quote
  #2  
Old 12-07-2006, 04:42 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
If you want a really blurry look, then just decrease the size of the blur texture. The default is 512x512. Try 128x128 or 64x64.
Code:
import vizblur
vizblur.enable(128,128) #Lower texture size creates more blur
Reply With Quote
  #3  
Old 12-08-2006, 09:50 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
I've attached a better version of the blur example that allows you to specify the blur kernel size. Previously it was 9. In the test script I have set it to 40. Surprisingly this didn't affect performance on my machine. A larger blur kernel will create more blur. Once you specify the blur kernel, you cannot change it. I recommend setting the blur kernel to the point where it matches your maximum desired blur. This way you can keep the blur scale under 1.0, which will prevent pixelization.
Attached Files
File Type: zip VizardBlur.zip (2.0 KB, 1587 views)
Reply With Quote
Reply


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


All times are GMT -7. The time now is 03:59 PM.


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