#CurveTexture creating curve when set to sharp transition

22 messages · Page 1 of 1 (latest)

idle lantern
#

Hello !
I'm trying to create sharp cel shading falloff curve, to do so I'm using a CurveTexture to describe the falloff.
The curve got sharp transition (as you can see in the image) and in my shader I'm reading in it using the filter_nearest parameter.
Even with this, I can detect a smoothing on my shadows.
As you can see on the image, there is more than the 3 shades I'm expecting.

it look like it's still interpolating between the points even thought the points are strictly sharp.

I also noticied that this does not occur if I reduce the resolution of my curve texture,
as you can see on this last image, this is the expected result, and it occur when I set my texture resolution to 32px.

I was wondering why is this happening, is there something I'm missing ?

autumn wagon
# idle lantern Hello ! I'm trying to create sharp cel shading falloff curve, to do so I'm using...

Hi!
I wanted to do something similar, and here's the code I came up with

shader_type spatial;

uniform sampler2D SCREEN_TEXTURE : hint_screen_texture;
uniform sampler2D FALLOFF: repeat_disable;

void vertex() {
    VERTEX = VERTEX;
    NORMAL = NORMAL;
    BINORMAL = BINORMAL;
    TANGENT = TANGENT;
}

void fragment() {
    ALBEDO = texture(SCREEN_TEXTURE, SCREEN_UV).rgb;
}

void light() {
    vec3 light = (INV_VIEW_MATRIX * vec4(LIGHT, 0)).xyz;
    vec3 normal = (INV_VIEW_MATRIX * vec4(NORMAL, 0)).xyz;
    float shad = max(dot(normalize(light), normalize(normal)), 0.0);
    shad = texture(FALLOFF, vec2(shad * 256., 1)).r;
    DIFFUSE_LIGHT = vec3(shad);
}
#

Also you would want to check if you've disabled shading on the 3d model itself

idle lantern
#

If yes, the code you’re showing me look wrong, you are sampling your texture with a value that go beyond 1, also, you should use your shad value as a factor to the light color and not as the color itself, or you will have a problem when you will be using other color than white

autumn wagon
autumn wagon
idle lantern
#

In my case I’m making a 2D cel Shading shader and there is nothing I like already made

autumn wagon
#

also, weirdly enough, for some reason in my case the shad before texturing isn't greater than 1...

idle lantern
autumn wagon
idle lantern
autumn wagon
idle lantern
autumn wagon
idle lantern
#

The artefacts must have to do with the way you're computing your normals, NORMALS, I don't know

#

Just use directle LIGHT and NORMAL in your dot product

autumn wagon
autumn wagon