How to make emissive catch shadows?

Godot Version

4.2.1

Question

I have this issue where i want to have back facing on grass to be emissive (because it just looks better when a cluster of grass hasn’t really got dark sides)

So to combat that i’ve done this:

vec2 base_uv = UV;
vec4 albedo_tex_ = texture(albedo_tex,base_uv);

	if (FRONT_FACING)
	{
		ALBEDO = albedo.rgb * albedo_tex_.rgb;
	}
	else
	{
		EMISSION = albedo.rgb * 0.75 * (1.0 - UV.y);
	}

It looks pretty good…
image

But not when there is shadow on the grass from other objects →
image
(see here! only the front faces recieve the shadows, but not the backfaces. :face_with_peeking_eye:)

So I’m wondering if i can know if there is shadow being cast on the backfaces, or if there is any other great way of doing this!?

is it possible to get the colour from the front faces, and use that? I wouldn’t know because i haven’t done this stuff yet

1 Like

I think it isn’t possible in the color stage because color and light is two different render stages. So trickery is needed for sure. Hope someone knows. :thinking:

I’m wondering if anyone knows if anything can be done in the void light stage?
Trying things out but so far no good results.

I guess this is impossible…

OK!!! I tried stuff out and got this to actually kind of do the thing!!!

	if (FRONT_FACING)
	{
		ALBEDO = albedo.rgb * albedo_tex_.rgb;
	}
	else
	{
		//EMISSION = albedo.rgb * 0.75 * (1.0 - UV.y) * lightMultiplier;
		//This looks great - But cant use emission(DUHH)!
		//This however does the job!
		BACKLIGHT = albedo.rgb * 10.0;//YAY
		ALBEDO = albedo.rgb * (1.0 - UV.y);
	}

grassShader1

2 Likes

Will you be posting the completed shader online anywhere, like godotshaders.com?

I could. Yeah​:star_struck::star_struck:. I’m just a bit affraid of people calling me out as a bad programmer… Which is absolutely true. :disappointed::disappointed:
There would be 1000s of ways to make it ALOT better!

1 Like

Well, I like it!

2 Likes