WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Npr (https://forum.worldviz.com/showthread.php?t=1281)

nige777 11-26-2007 08:28 AM

Npr
 
2 Attachment(s)
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

farshizzo 11-26-2007 09:49 AM

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.

nige777 11-28-2007 08:00 AM

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 :o, 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 :o.

farshizzo 11-28-2007 11:00 AM

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]))


nige777 11-29-2007 01:50 PM

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

farshizzo 11-29-2007 03:03 PM

The OpenGL website has some links to GLSL tutorials. Here is a link to the page: http://www.opengl.org/code/category/C20


All times are GMT -7. The time now is 05:04 PM.

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