Upbge: Principled PBR shader works in GE but uses lamps set in preferances

Created on 13 Jul 2018  Â·  15Comments  Â·  Source: UPBGE/upbge

is there any way we can setup the Principled node to use the scene lamps?
right now it uses only 3 lamps 'solid glsl light sources' in preferences.

potentially could we be using BVHTree of scene lamps to discard lamps
(forward+ PBR) ?

later we could work on SSR reflections w/fallback to / probe grid / parralax correction
???
@panzergame

All 15 comments

That wouldn't be a bad idea, since the principlied shader is a ready PBR. However, note that the principlied shader you see in viewport/BGE uses per-vertex lighting. You'd be better off moving the calculations to fragment shader, otherwise you're forced to use high-poly meshes to achieve nice looking results.

https://github.com/bge-community/Ketsji-Game-Engine/issues/19
#define NUM_LIGHTS 3
the cycles shaders are all diffuse, bdsf being the exception, but it only bunchs a lot of features into a single shader, wich is not good for a game. it would be better to put those features like tangent shading, metallic or roughness into simpler shaders. BDSF is not a good shader for realtime, it has too many options. if you look at unreal, it has much fewer, that's because each new inthat you put in the shader decreases performance exponentialy, and you don't need all the things for everything, there are instances in wich an effect will not be noticed or is the same as just using lambert+blinn/phong.

Unreal basically packs the same shader, but split up into several lit modes where certain features get disabled. So you can choose either a shader with great clearcoat support (good for car paints and carbon fiber), a translucent shader (for skin, closeup foliage), basic shader (for things that don't need advanced shading, but that could take up a lot of screenspace) and others.

Similar idea could be taken to BGE. There is a dropdown for the Principlied BSDF shader node that offers to choose between GGX and multiscatter GGX. A similar dropdown could be added for feature set (offering minimal feature set that offers use of base color, metallness, roughness, specular, normal, tangent & IOR (used for fresnel, so don't tell me it's only for transmission), preferrably leaving the rest of options greyed out, then a clearcoat feature set that, in addition to previously mentioned features, enables clearcoat, clearcoat roughness and clearcoat normal, then transmissive material that enables transmission, a translucent feature set enabling all subsurface parameters, advanced feature set that enables clearcoat, but also enables sheen and anisotropy, and, lastly, a combined feature set enabling all of the principlied shader features).

Proof of concept
Alt text
(click image to see a video)

Problems:

  • We can link Principled node with 1, 2, 3, ... or N lights but they are not dinamic as they will be always the same ones. That can works in open space games (Sun light) but in closed games with a lot lights, How can we make it work properly?

In closed games with lots of lights one moves them most likely anyways(as it's the best performer option).
However, the only proper solution I see is #656

Maybe instead of all lights, simply pass the 1 to 10 (configurable by node parameter, default 3) lights data with most influence. This way it should be performance/cost aceptable.

image
It works now for all lights but it is unoptimized yet as it searches for lamps against all objects.
Check ge_principle_PBR_light branch for more info

Test build: https://mega.nz/#!9sMHxKyL!PVLp7T1HfEP9z6KKR3J_DwvIMcAsGmIPVBRhQ8-lwh4

NOT FOR PRODUCTION: as it doesn't include current fixes that are in master. ONLY for test the PBR Principled shader

Would be nice if one could feed in reflection maps into the shader (currently, as far as I know, it uses clear color for reflections which is nowhere near ideal).

Mix the shader with a reflection cubemap material is a valid solution?
image

We need metal value of map to mix it in like a stencil,

For roughness it mixes mipmap levels
Of the reflect map

What we need here is a technique called image based lighting I think.

On Wed, Sep 5, 2018, 1:33 AM lordloki notifications@github.com wrote:

Mix the shader with a reflection cubemap material is a valid solution?
[image: image]
https://user-images.githubusercontent.com/1015605/45081240-10332c80-b0f7-11e8-8cd9-352b9a3acfb5.png

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/UPBGE/blender/issues/740#issuecomment-418646452, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AG25WbE-ExaSXKWcvHbVSEcMyi1FADalks5uX4xcgaJpZM4VOQZl
.

@lordloki It would be, but it requires some manual fresnel calculations for proper effect and there yet has to be an efficient way to blur the reflections (ideally approximated GGX should be stored in mipmaps). It would totally make more soense to have the reflections pluggable into the node (so that the node can do all those maths).

Close this as 0.3 already support this. Thanks for the feedback

Was this page helpful?
0 / 5 - 0 ratings