I am trying to make the toon shader example work in my world. The inking portion works fine but the light ramp appears to not respond to directional light!
Example code applied to my system:
# Check video card capabilities.
if not self.win.getGsg().getSupportsBasicShaders():
print("Toon Shader: Video driver reports that Cg shaders are not supported.")
return
tempnode = NodePath(PandaNode("temp node"))
tempnode.setAttrib(LightRampAttrib.makeSingleThreshold(0.5, 0.4))
tempnode.setShaderAuto()
self.cam.node().setInitialState(tempnode.getState())
# Use class 'CommonFilters' to enable a cartoon inking filter.
# This can fail if the video card is not powerful enough, if so,
# display an error and exit.
self.separation = 1.5 # Pixels
base.filters = CommonFilters(self.win, self.cam)
filterok = base.filters.setCartoonInk(separation=self.separation)
if (filterok == False):
print(
"Toon Shader: Video card not powerful enough to do image postprocessing")
return
Just to check: Are you sure that you didn’t set the level0 value to 0? That would have the effect that you describe, I daresay.
Looking at your code, I think that I may see the problem:
I note that you have an ambient light with an overall value of 0.8–which means, I think, that no point on the object will ever have a luminance less than 0.8.
Since your ramp threshold is 0.5, all points should thus be above the threshold, and thus all points will be shaded at the ramped value of 0.4.
and if this theory were true and all points were being lit, then the effect of the level value (to which i also changed) should adjust the brightness of the model, it doesnt. (am i wrong in this thinking?)
Ha, yeah, i had the same thoughts but i double checked my values and the docs. Doc states parameter 1 is threshold and parameter 2 is level.
Its interesting, another thread was having issues with the auto shader and directional lights when be exported as gltf. I use blend2bam so, its possible I have a related issues?
Its worth noting that the changing of ambient light does indeed shift the brightness of the colors, so it seems as if the dlight just isnt effecting it.
Correction, panda is responding to directional light as well. It just was not apparent to me. So this takes me back to perhaps its a data pipeline issue?
Wait, looking at the code that you just posted–why are you applying the light-ramp to the camera?
Indeed, trying out your code in a simple program, I seem to be able to get a working ramp by instead applying it to render. (And reducing the threshold-value–I think that it’s too high for the lights to pass at their values given there.)
Here follows a short test-program that works on my system, and with a simple test-model of mine, at least:
I did that because the example did that. I have switched the light lamp to render and the panda still responds but my own model does not. I made my intensity values match yours.
Im pretty confident at this point that its related to gltf export. I tried obj(wavefront) and while the material fro principle bsdf had its only color issue, it was absolute responding to directional ligt. I think this is the key. Unfortunately, I dont know where to go with this.
Yes! With this information, i was able to do some testing with the yabee egg exporter and realized its failing because of the blender material!! So perhaps i can skip this and go to egg by figuringout out my materials!!