Here the light calculation happens inside DiffuseLight function. The function itself is defined in UnityCG.cginc file (inside application: Unity.app/Contents/CGIncludes/UnityCG.cginc).
However, by default lights in Unity are additive - i.e. each light adds illumination. There’s no easy way to make lights subtract illumination, but you could try to make lights multiply existing illumination to reduce it. Try adding something likeBlend Zero OneMinusSrcColor to the pixel-lit pass for a start. This will turn on inverse-multiplicative blending (instead of default additive one).
There’s one more thing that I saw in the Reflective/Bumped Unlit Shader:
that shader doesn’t take diffuse lighting into account - it only adds the bump effect onto the reflective material.
and THAT’S what I need for my shader - if you would be so kind and help me one more time?
How can I eliminate the diffuse light from the light source in the fragment program and calculate the bump effect only?
I’ve made a workaround for my shader to get what I want but it’s far away from being elegant:
I use “Blend DstColor SrcColor” to add the Pixel Lit Pass and a 50% directional light (under 90° angle).
That way I maintain the brightness of the diffuse texture and add just the bumps.
The reflective bumped unlit shader and your case are a bit different. In reflective case, it does not do “bumpmapping” in lighting sense, it does a “bumpmapped cubemap reflection” (and that does not need any lights at all).
What you want is some sort of “lighting” without the actual lighting, and I’m not sure how to do that You want to bumpmap the base texture, without changing it’s illumination - but for the bump effect to be visible, it has to lighten or darken some parts of the texture at least… so I’m not sure how to do that. Maybe try not real bump-mapping, but emboss mapping?
It just needs a light source to go into the PPL program:
blend mode is 2x multiplicative (Ambient * PPL *2)
I replace the Lambertion diffuse light function from the UNITYCG file by my own calculation IN the shader itself
I take the bump map, subtract 0.5 to make it a 50% grey texture (128/128/128) with bumps
I replaced the second component in the dot product by “1” to eliminate / replace the light source’s influence. As I said: I don’t care about light strenght or angle…
However, I do get a difference of 1% brightness when combinig ambient and PPL pass.
I made a test with a 50% grey Base Texture:
The ambient pass by itself keeps the 128/128/128 RGB values of course.
The PPL pass (with a wildcard bumpmap that’s actually a white RGB texture turned into a bump map) gives me 128/128/128 as well.
When combining Ambient and PPL by “Blend DstColor SrcColor” I get 129/129/129 as a result…
Do you have any clue where that comes from? Is that a round-off error in the Blend DstColor SrcColor Command?
Cause basically it is: (0.5 * 0.5) * 2 - but the result is 0.51 !
I’d guess it’s a rounding error in the blending. Framebuffer is 8 bits per component, and the hardware might round in one or other way… I think I also remember someone on mac-opengl mailing list saying that some graphics cards do blending with “one bit off” - you might be experiencing the same issue.