Jump to content

scene complete cellShading


Recommended Posts

I try, but it does not work, What am I doing wrong or what did I forget?


in the console I:


- Unable to compile effect: [object Object]

- Defines:

- Error: Varyings with the same name but different type, or statically used varyings in fragment shader are not declared in vertex shader: vPositionW
PostProcess :

var postProcess0 = new BABYLON.PassPostProcess("Scene copy", 1.0, this.camera);this.postProcess = new BABYLON.PostProcess("cellShading", "./Data/Shaders/cellShading", ["world", "worldViewProjection"], ["textureSampler"], 0.25, null, BABYLON.Texture.BILINEAR_SAMPLINGMODE, this.engine, true);this.postProcess.onApply = function (effect) {    effect.setTextureFromPostProcess("textureSampler", postProcess0);    effect.setVector3("vLightPosition", this.LightDirectional[0].position);    effect.setFloats("ToonThresholds", [0.95, 0.5, 0.2, 0.03]);    effect.setFloats("ToonBrightnessLevels", [1.0, 0.8, 0.6, 0.35, 0.01]);    effect.setColor3("vLightColor", this.LightDirectional[0].diffuse);};

Shader:  ./Data/Shaders/cellShading.fragment.fx

#ifdef GL_ESprecision mediump float;#endif// Lightsvarying vec3 vPositionW;varying vec3 vNormalW;varying vec2 vUV;// Refsuniform float ToonThresholds[4];uniform float ToonBrightnessLevels[5];uniform vec3 vLightPosition;uniform vec3 vLightColor;uniform sampler2D textureSampler;void main(void) {	// Light	vec3 lightVectorW = normalize(vLightPosition - vPositionW);	// diffuse	float ndl = max(0., dot(vNormalW, lightVectorW));	vec3 color = texture2D(textureSampler, vUV).rgb * vLightColor;	if (ndl > ToonThresholds[0]) {		color *= ToonBrightnessLevels[0];	}  else if (ndl > ToonThresholds[1]) {		color *= ToonBrightnessLevels[1];	} else if (ndl > ToonThresholds[2]) {		color *= ToonBrightnessLevels[2];	} else if (ndl > ToonThresholds[3]) {		color *= ToonBrightnessLevels[3];	} else {		color *= ToonBrightnessLevels[4];	}		gl_FragColor = vec4(color, 1.);} 

Thank you

Link to comment
Share on other sites

I'll drop it, it's too complex for me and I do not want to spend three months. I will rather play with textures and lighting effects for a result more drawing.


[edit] I try to make an impact on the images directly and color adjustment on the lights and the result is satisfactory and it is easier than doing postprocessing.  :D

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...