WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 11-26-2007, 08:28 AM
nige777 nige777 is offline
Member
 
Join Date: Nov 2007
Location: UK
Posts: 78
Npr

Hi all, as part of a final yr project for my degree i want to produce a walk-through using non-photorealistic rendering techniques. I'm experimenting with a GLSL sketch-like shader produced using Mental Mill (i am not a programmer) using:
- toon2 = viz.addShader(vert='MySketch1_v.gl', frag = 'MySketch_f.gl') -
- box2.apply(toon2) -


but i get this error message:

glLinkProgram "" FAILED
Program "" infolog:
Vertex info
-----------
(20) : warning C7011: implicit cast from "vec4" to "vec3"
(20) : warning C7011: implicit cast from "vec4" to "vec3"
Fragment info
-------------
(581) : warning C7011: implicit cast from "vec4" to "float"
(581) : warning C7011: implicit cast from "float" to "vec4"
(581) : error C3002: call to undefined function "saturate"

I would be VERY grateful of ANY help at all with this as I feel like i've come to a grinding halt.

(I have attached the vert and frag files converted to txt so that i could upload them)

Regards

Nige
Attached Files
File Type: txt MySketch1_v.gl.txt (1.1 KB, 1272 views)
File Type: txt MySketch_f.gl.txt (24.2 KB, 1352 views)

Last edited by nige777; 11-26-2007 at 08:32 AM. Reason: Attach shader files.
Reply With Quote
  #2  
Old 11-26-2007, 09:49 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
It seems like Mental Mill did not produce valid GLSL code. The warnings should not be a big deal. However, there is an error in the fragment shader. GLSL has no saturate function. Even without this error, you will still need to do a lot more to get the shader working. The vertex and fragment shaders depend on runtime uniforms, which you have not declared in your script. Your vertex shader requires the following uniforms:
Code:
uniform float flip_normal;
And your fragment shader requires these:
Code:
//
// The following are free parameters of the shader
// that should be set by the application at runtime.
//
uniform vec4 msl_light0_color;
uniform float msl_light0_intensity;
uniform float msl_light0_distance_falloff_exponent;
uniform float msl_light0_distance_falloff_start;
uniform float msl_light0_distance_falloff_limit;
uniform float msl_light0_distance_scale;
uniform vec3 msl_light0_position;
uniform sampler2D msl_Texture_lookup_2d_4_texture;
uniform sampler2D msl_Texture_lookup_2d_3_texture;
uniform sampler2D msl_Texture_lookup_2d_2_texture;
uniform sampler2D msl_Texture_lookup_2d_1_texture;
uniform float msl_Component_phong_1_specular_shininess;
uniform vec4 msl_Generator_blend_ramp_1_colors[4];
uniform float msl_Layer_posterize_1_steps;
uniform vec4 msl_Math_color_add_1_right;
uniform float msl_Generator_outline_1_threshold;
uniform vec4 msl_Generator_outline_1_line_color;
uniform vec4 msl_Generator_outline_1_fill_color;
The shader examples that come with Vizard show to create and apply shader uniforms.
Reply With Quote
  #3  
Old 11-28-2007, 08:00 AM
nige777 nige777 is offline
Member
 
Join Date: Nov 2007
Location: UK
Posts: 78
Npr

Thank you very much for your prompt reply, the Vizard forum is a wonderful resource for me. I think I may have bitten off more than I can chew with this and am having to re-consider the content of my project , I added the uniforms to my sample script but feel I must have done it incorrectly because although there was no errors displayed there was also no noticable effect on the model!!! But as you say the shader needs more work and my knowledge in this area is lacking . . . . . .

Another (simpler, yet slightly less effective) option for me may be to use the supplied toon shader -couple of questions - is there a way of removing the modifier from an object once it has been added and is there a way of controlling the colour of an object with toon applied?

Thanks for your patience .
Reply With Quote
  #4  
Old 11-28-2007, 11:00 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
I've attached a script that shows how to dynamically add/remove the toon shader from a model and how to dynamically change its color. Let me know if anything is not clear:
Code:
import viz
viz.go()

#Set background color
viz.clearcolor(viz.SKYBLUE)

#Add toon modifier
toon = viz.add('toon.dlm')

#Create group node that has toon shader applied
ToonGroup = viz.addGroup()
ToonGroup.modify(toon)

#Create a model and spin it right round baby right round
model = viz.add('logo.wrl',pos=(0,1,5))
model.addAction(vizact.spin(0,1,0,90))

#Toggle models parent between ToonGroup and World when spacebar is pressed
vizact.onkeydown(' ',model.parent,vizact.choice([ToonGroup,viz.WORLD]))

#Toggle models color when 'c' key is pressed
vizact.onkeydown('c',model.color,vizact.choice([viz.RED,viz.GREEN,viz.YELLOW,viz.BLUE,viz.GRAY]))
Reply With Quote
  #5  
Old 11-29-2007, 01:50 PM
nige777 nige777 is offline
Member
 
Join Date: Nov 2007
Location: UK
Posts: 78
NPR _ Thanks

Thank you farshizzo, that code was great - i'm enjoying expanding my python vocabulary. I think this will be a good compromise until (if !) I get my shader working. Are there any good sources of info about this subject that you no of?

Thanks again
Reply With Quote
  #6  
Old 11-29-2007, 03:03 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
The OpenGL website has some links to GLSL tutorials. Here is a link to the page: http://www.opengl.org/code/category/C20
Reply With Quote
Reply

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


All times are GMT -7. The time now is 12:42 AM.


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