Any reason two effect shouldn't be in same shader

I added a color desaturation effect that was in its “own shader” to my toon shader… apart from wanting both effects to be distinct…which I don’t… are there any other things to consider.

Right now we achieve the cartoon effect by specifying the ColorRamp parameter to the lighting shader, see the TestCartoonEdge test. If the textures are also created in a cartoonish style it will result in the highest quality cartoon rendering.

unfortunately the ramp effect didn’t work out well for what I was trying to do, designed new ramp variants and tested thoroughly…didn’t get what I was looking for…



.this is my own little effort, based on one from BA which was closer to what I wanted,… inside render monkey still though, I 'll converting it to be jme ready soon

http://i.imgur.com/CTljo.jpg

Wow, even you seem to be able to upload images now xD Seems like my button improvements work…

normen said:
Wow, even you seem to be able to upload images now xD Seems like my button improvements work..

yeah it works, haven't tried to see if it still hates photobucket, the upload service u link to is fine, but to continue couldn't figure out how to get rid of the if/s apart from that do I do too much in one shader

[java]
varying vec3 vLight;
varying vec4 vDiff;
//varying vec4 vView;
varying vec3 vNormal;
varying vec4 vMat;
varying vec2 texCoord0;

uniform vec4 vWidths;
uniform vec4 noiseMod;
uniform vec4 vWidthFactor;
uniform sampler2D colorMap0;
uniform float m_Time;
uniform float m_Strength;
uniform float blend;
uniform vec4 Material;


void main(){
vec3 vNorm = normalize(vNormal);
vec4 vColour = vMat;

vec3 vLightN = normalize(vLight);
//vec3 vViewN = normalize(vView.xyz);
//float ndotv = dot(vNorm, vLightN); //vViewN

// Random, adding values to get rid of edge errors and mods that return 0
float x = (texCoord0.x+4.0) * (texCoord0.y+4.0) * (m_Time*10.0);
vec4 grain = vec4(mod((mod(x, 13.0) + 1.0) * (mod(x, 123.0) + 1.0), 0.01)-0.005) * m_Strength;

float ndotl = dot(vNorm, vLightN);
vec4 base0 = texture2D(colorMap0, texCoord0);
gl_FragColor = base0 * gl_FrontMaterial.diffuse /* gl_LightSource[0].diffuse*/;

if ( ndotl < vWidths.x )
vColour *= vWidthFactor.x+(grain*noiseMod.x);
if ( ndotl < vWidths.y )
vColour *= vWidthFactor.y+(grain*noiseMod.y);
if ( ndotl < vWidths.z )
vColour *= vWidthFactor.z+(grain*noiseMod.z);
if ( ndotl < vWidths.w )
vColour *= vWidthFactor.w+(grain*noiseMod.w);


//vec4 color = texture2D(colorMap0, gl_TexCoord[0].st);
float lum = dot(base0.rgb, vec3(0.299, 0.587, 0.114));
vec4 gray = vec4(lum, lum, lum, base0.a);
gl_FragColor = mix(base0, gray, blend);

gl_FragColor *= ((mix(base0, gray, blend) + vColour) * gl_FrontMaterial.diffuse)* Material;
}
[/java]

You can get rid of them with some combination of step function and mix function

step(x,y) will return 0 if x<y else 1

mix(vec1,vec2, value) interpolate between vec1 and vec2 according to value (that goes from 0 to 1)

so this



if ( ndotl < vWidths.x )

vColour = vWidthFactor.x+(grainnoiseMod.x);



can be replaced by something like that



vColour =mix(vWidthFactor.x+(grainnoiseMod.x), 1.0, step(ndotl,vWidths.x ));



this means if ndotl is below vWidths.x, vColour is multiplied by WidthFactor.x+(grain*noiseMod.x) else it’s multiplied by 1.

Repeat that for the 4 if statements and it should work

thanks for this man…it didn’t work…unfortunately… get compiler warnings, the color effect was inverted and only one level of grain seemed to work and the position of that was inverted too…let me re-organize things a bit more (already tried some stuff -.- no go) and see what happens



edit: nah no go -.- , I guess that the way this one will have to be

mhh yeah wait



vColour =mix(vWidthFactor.x+(grainnoiseMod.x), vec4(1.0), step(ndotl,vWidths.x ));



this should get rid of some warnings

post the remaining ones maybe I can help.

normen said:
Wow, even you seem to be able to upload images now xD Seems like my button improvements work..


Yeah I now finally see the upload button as well
EmpirePhoenix said:
Yeah I now finally see the upload button as well

awwww, mcbeth even found it before :P He just didnt know how to use it or is completely oblivious to how html tags work. It was always there, you just needed to click on "[Insert..]" just as you can clock on "[Show Smilies..]" now.
normen said:
awwww, mcbeth even found it before :P He just didnt know how to use it or is completely oblivious to how html tags work. It was always there, you just needed to click on "[Insert..]" just as you can clock on "[Show Smilies..]" now.


first of I'm well aware of how these things work, the fuckin thing jus seem to be be fuckin up fuckin photobucket links and I remember sayin that over and over wtf
mcbeth said:
first of I'm well aware of how these things work, the fuckin thing jus seem to be be fuckin up fuckin photobucket links and I remember sayin that over and over wtf

Oh my, I should add a replacement image for f***n as well. Read the imageshack manual, if you dont embed the image in a certain way, with a link to all their commercials, it just wont show.

Photobucket

image

http://i922.photobucket.com/albums/ad68/mcbeth316/test.jpg



url of image pasted directly

No I cannot, but a normal link seems to work fine. There is no “url tag”, what do you mean?

quote the post above and tell me what you see as opposed to what you get it wont even let me post the link without using the url tags as I have had to do before, and I use photobucket not imageshack and I’ve posted images on other forums from there with no issue

this topic not enclosed in link tags

http://hub.jmonkeyengine.org/groups/effects/forum/topic/any-reason-two-effect-shouldnt-be-in-same-shader/



photo bucket not enclosed in link tag i see garbage where a link should be

type=”text/javascript”>SyntaxHighlighter.all() and anything else below the link is not displayed, there is an obvious issue with how the forums handle certain things, that my point



http://i922.photobucket.com/albums/ad68/mcbeth316/test.jpg

nehon said:
mhh yeah wait
`
vColour *=mix(vWidthFactor.x+(grain*noiseMod.x), vec4(1.0), step(ndotl,vWidths.x ));
`
this should get rid of some warnings
post the remaining ones maybe I can help.



@nehon ok the warning are gone, the effect was still inverted though but changing [java]step(ndotl,vWidths.x )[/java] to [java] step(vWidths.x,ndotl )[/java] fixed it still need to ensure all the "tweakable" values work as they should though but thanks non the less cheers