How to light objects with shader programs?

Problems building or running the engine, queries about how to use features etc.
slapin
Bronze Sponsor
Bronze Sponsor
Posts: 148
Joined: Fri May 23, 2025 5:04 pm
x 5

How to light objects with shader programs?

Post by slapin »

Hi, all!
While doing my water I implement waves, and generate normal/tangent/binormal for them. But unlike Godot I can't find a way to use them for lighting
the water surface. How can I do the lighting in Ogre? Should I do it manually in every shader or is there something which can help me?

User avatar
sercero
Bronze Sponsor
Bronze Sponsor
Posts: 519
Joined: Sun Jan 18, 2015 4:20 pm
Location: Buenos Aires, Argentina
x 188

Re: How to light objects with shader programs?

Post by sercero »

What do you mean?

How is the process in Godot?

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 148
Joined: Fri May 23, 2025 5:04 pm
x 5

Re: How to light objects with shader programs?

Post by slapin »

In Godot you output PBR stuff into variables and engine does lighting stuff itself by generating shader for that.
In Ogre I guess I need to do everything myself for every shader or maybe is there some way I missed?

paroj
OGRE Team Member
OGRE Team Member
Posts: 2204
Joined: Sun Mar 30, 2014 2:51 pm
x 1188

Re: How to light objects with shader programs?

Post by paroj »

things are similar in Ogre, but you have to query the variables via a C++ module, like:

Code: Select all

ParameterPtr positionIn = vsEntry->resolveInputParameter(Parameter::SPC_POSITION_OBJECT_SPACE);

https://ogrecave.github.io/ogre/api/lat ... extensions

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 148
Joined: Fri May 23, 2025 5:04 pm
x 5

Re: How to light objects with shader programs?

Post by slapin »

By that I mean the following:
In Godot I just put ALBEDO = vec4(1.0, 1.0, 0.0, 1.0); NORMAL = vec3(0.0, 1.0, 0.0); in shader program, and Godot appends lighting code itself.
In Ogre I tried enabling per pixel lighting and had no effect, so I had to implement gl_FragColor = vec4(color.xyz * dot(normal, dirLightDir), 1.0); myself.
Which kind of seems wrong thing to do but works. And I found no other working solution. Would be nice to have some intelligent macro system for basic things.

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 148
Joined: Fri May 23, 2025 5:04 pm
x 5

Re: How to light objects with shader programs?

Post by slapin »

paroj wrote: Mon Jul 07, 2025 2:29 pm

things are similar in Ogre, but you have to query the variables via a C++ module, like:

Code: Select all

ParameterPtr positionIn = vsEntry->resolveInputParameter(Parameter::SPC_POSITION_OBJECT_SPACE);

https://ogrecave.github.io/ogre/api/lat ... extensions

That one is too hard for my poor little brain without example :(