OpenTechEngine / OpenTechBFG

Engine based on (RB) Doom 3 BFG aiming to allow the creation of standalone games
Other
85 stars 11 forks source link

Ambient light removes specular and bump from surface #54

Closed ghost closed 9 years ago

ghost commented 9 years ago

Using the ambient light seems to remove bump and spec from surfaces it touches, giving a diffuse look. Not sure if there is a way to force the renderer to draw those two maps when ambient light is used.

I used it for sunlight, but resorted to a pointlight.

kortemik commented 9 years ago

would you be able to screenshot and share material.mtr for the ambient?

ghost commented 9 years ago

pointlight ambientlight pointplussrgb

kortemik commented 9 years ago

AmbientLIGHT seems to be the one used also in Quake4 and it works just like there, looks f-ugly and removes the bumps and spec. There has been some discussion going on how to add it. The DarkMod uses their own system but I recall something that there was also discussion about it on BFG. I think @BielBdeLuna might know better.

ghost commented 9 years ago

@kortemik the r_sRGB command seems to be a nice hack to gain extra brightness, but I'm not sure if it is intended for that purpose. I'm looking into the Ambientlight material scripts and experimenting. I found a problem with bl_portalsky.mtr, it contains a key value called "screen", Dark radiant is giving a warning for it and in the engine there seems to be some weird artifact being rendered by the portal sky around some lights, especially projected lights. glitch

BielBdeLuna commented 9 years ago

bl means Biel it's a material from mine.

"screen" iirc was meant for special materials like portalsky textures where there shouldn't be any interaction with lights ( the sky texture shouldn't make nor receive shadows)

portalskies should work the same with direct light (in fact the portalsky test map has a direct light and it works (or should) without any hassle )

about ambient light, in the real world there isn't a separation on ambient and direct light, there isn't a separation on light terms either (there is no specular nor diffuse)

in real world there are photons that transport energy from balck bodies to our eyes cells, those photons reverberate all around the space (yes reverberate, like sound, check out the wave–particle duality), and those lights reverberations are what we see

since those reverberations are still costly to calculate in real time (GI is one of it's effects amongst other) we use a variation of the Phong light terms model to represent the effects of light in a 3D space (although the Phong model now has already become old)

this is the phong light term model : Image of the Phong light term model

every of those stages are called light terms

ambient is meant to recreate the GI light effect we can observe in the real world amongst non specular surfaces although the phong light term doesn't take into account the difference in surfaces, this means within the Phong model all surfaces have the same shading

I would propose the Cook–Torrance as a replacement of the old Phong model because it includes the idea of the microfacets allowing a more realistic way to render the light on the surfaces (the added "roughness" texture)

but Cook–Torrance still lacks a way to solve the ambient term (it is the same as Phong)

the problem with Ambient is that it should be calculated in real time as the specular is calculated in real time, and it's calculation should be way more complex than the current "light level" calculation ambient doesn't have a "direction", it only is "light level" but this light level is highly dependable on the lights around the surfaces, the form of those surfaces, the colours they have, the medium through it gets transmitted, the qualities of the surfaces it lands on and a long etc... as you cans see there a lot of elements here that currently IdTechX lacks info about. and if this has to be calculated per pixel per frame with the possibility of very expansive a well as expensive sceneries you get the idea that calculating it might eat all the resources very quickly.

if you take a look on the solutions tripple A games used in the last generation of consoles you get the idea, all the GI solutions are static, in the current generation I think only Unreal Tech proposes a GI realtime solution, and I think Cryengine proposed a GI system for the PC back in the last gen time, but I don't know the extent of their use, I guess Crysis 3 and Ryse, but I bet it demands a High-to-highend GPU

I guess a solution could be Voxelize the watchable space, and use octrees to speedup part of the calculus of an approximation of those effects, at least the spatial part, but idk.

BielBdeLuna commented 9 years ago

how does my portalsky map work on your OTE?

ghost commented 9 years ago

I created a smaller skybox using the portalsky entity, then the brushes on the main level as the modwiki and darkmod forums suggested. I've seen some newer game engine projects using CUDA for real-time raytracing and GI, but this will only be available to people with high end systems to have a playable speed.

ghost commented 9 years ago

Looking closely at the ambient light, I noticed that it does render bump and spec, however the light is so bright and floods the area so much that it drowns out those effects up to the point that it is barely visible.

BielBdeLuna commented 9 years ago

lower the ambient light then, you can use dark grey ambient light.

you have not created a "skybox" as this is a texture and not a box for the sky elements.

the portal sky explanation in modwiki only explains the functionality of quake 4 and d3xp portalsky (static portal sky) there are the other two that I added in my mod, those two are the ones that replicate half life 2 portal skies,

in quake4/d3xp the portal sky replicates what a info_portalsky sees from it's point of view, on the "portalsky" material, if you move the info_portalsky remains static

in half life 2 the info_portalsky keeps following the movement of the player (but divides it by 16) so a smaller model of the surroundings can recreate a larger surroundings in the world the player experiences

this is what I added to the d3xp info_portalsky: a Global portal sky that follows the player since the start of the level, and it keeps following him when inactive, and another called Local portal sky that only starts to follow the player when triggered, and always start to it's spawn position when reactivated.

take a look in info.def

ghost commented 9 years ago

I have looked into the def as well as the info on the local/global portalsky entities. I used the standard portalsky entity in the map. Going to try local next. I've been looking into the Darkmods code for sky materials, thinking of setting up skies like that to add some effect. I'm not sure why that glitch occurs, as the portalsky did work correctly the first time I used it.

ghost commented 9 years ago

Did as BielBdeLuna suggested, Ambientlight should be used with low values in brightness and saturation.