Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Lighting shader help

Author
Message
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 19th Feb 2020 23:59
I Haven't done much with lighting in shaders and wasn't able to get anything from any of the examples on the forum - I've looked at the older examples and they just don't seem to work any more.
What I need to start me off is a basic 3D shader which has 1 point light+diffuse texture and inherits or can be supplied with the default AppGameKit ambient and sun lighting.

The reason I need this is because I don't want the default point lights unnaturally shining through objects.

Mesher
User Banned
Posted: 20th Feb 2020 00:29
I think Janbo / Santman maybe able to assist better - there knowledge is extreme on Shaders

There is a YouTube man called "The Art Of Code" for shader development inspirations too.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 20th Feb 2020 01:19
Do you have an example where they shine through objects?
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 20th Feb 2020 02:25
@Blink Any object vs any object?

A point light doesn't get diffused by any geometry. It even lights the back face.
It's always been an issue for me. It will light everything in it's radius.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 20th Feb 2020 07:39
If that was the case wouldn't you see some light on the tile in front of the miner dude?

Attachments

Login to view attachments
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 20th Feb 2020 13:14
Here's an example. The point light is just underneath the ceiling of the lift. However, the light affects the top of the lift shaft (and other things I don't want)

Attachments

Login to view attachments
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 20th Feb 2020 15:36
The object or better the shader executed for the "top of the lift shaft" object don't know about the lift object or any other object in the scene so there is no way to block of the light for the shader.
You can give the shader some information about it's surroundings via a Depthmap for directional light or a whole cube of depthmaps for Pointlights to block the light and create a shadow.
I have something like an "early pre alpha" version for point light shadows lying around, but the distance calculation is wrong so that won't satisfy you, for now.
I guess, to get a quick result, you have to get creative here
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 20th Feb 2020 18:59
Hi Janbo,

I don't care about the shadow - rather, I just want to light the specific object with the shader and not unintended items.

I wouldn't have the point light in the scene, just in the shader so I expect to just be able to apply the shader to the lift and meshes of my choice to light according to the shader specific point light.
The "top of the lift shaft" will be lit normally by the scene lights only and not be affected.

Surely if I only apply the shader to the objects I want to light with the in-shader light, then that is all that would be affected?

Green Gandalf's shader example on here (the 144 lights one) would have been ideal, but doesn't work properly for me. I did try to adjust it with your recommendations, but still no luck.
Similarly, the there are a number of shaders on the shader thread for lighting, but these don't work any more.

So, to recap: I think a shader which accepts input for ambient and sun values and texture0, and the ability to set a point light RGB and radius would be enough.
Mesher
User Banned
Posted: 20th Feb 2020 19:09
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 20th Feb 2020 22:08 Edited at: 20th Feb 2020 22:14
Seems I've managed to do it by hacking around some shaders in the "useful shader" thread.
Not managed to get the sun light added, but seeing as it's artificial, it shouldn't matter too much.

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 20th Feb 2020 23:23
If you could post a project i'd really like to have a look at it
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 21st Feb 2020 12:13
It's working now Blink. I may need to break the model up into separate meshes to get it 100% how I want though.
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 24th Feb 2020 16:21
Oh I see, sorry.
So you could have taken the default shader code from the documentation/guides section
and remove the GetPSLighting( norm, posVarying ) part.
The Sun is calculated in there too so you'd loose it.
Guess that's what you did.

Login to post a reply

Server time is: 2024-04-24 13:52:01
Your offset time is: 2024-04-24 13:52:01