Ooops
March 01, 2021, 04:30:13 AM

Author Topic: some notes about custom lighting shading of surfaces...  (Read 2631 times)

Offline RemiD

  • Hero Member
  • *****
  • Posts: 1152
some notes about custom lighting shading of surfaces...
« on: March 17, 2018, 11:15:36 AM »
Hello,

Some notes for those who want to do experiments with custom lighting shading of surfaces (in this case using vertices colors, but the same rules applies with texels colors)

For static surfaces, this is easier, since they are never changing their orientations / positions, so you only have to get the global position of each vertex ( using TFormPoint() )
However for turning moving animating surfaces (characters, weapons, projectiles, vehicles), you have to get the global position and the global normal vector of each vertex ( using TFormPoint() and TFormVector() )

and then, it works well :
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline Rick Nasher

  • Hero Member
  • *****
  • Posts: 791
Re: some notes about custom lighting shading of surfaces...
« Reply #1 on: March 17, 2018, 07:28:22 PM »
Really like the lighting effects. Looks really nice.
_______________________________________
 B3D + physics + shaders + X-platform = AGK!
:D ..ALIENBREED *LIVES* (thanks to Qube).. :D
_______________________________________

Offline RemiD

  • Hero Member
  • *****
  • Posts: 1152
Re: some notes about custom lighting shading of surfaces...
« Reply #2 on: March 17, 2018, 09:06:10 PM »
The lighting shading on the static surfaces is precalculated before the mainloop, and the lighting shading on the turning moving animating surfaces is updated during the mainloop, it is fast enough as long as there are not too many lights in an area, and not too many turning moving animating surfaces in an area (and in view), and the turning moving animating surfaces don't have too many vertices / triangles. (but in this scene there are 9 lights, maybe it is not necessary to have so many lights in such a small area !)

What is frustrating is that DX7 lighting shading is fast, but you can't customize the formulas... Else i could achieve the same result but very fast.
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline RemiD

  • Hero Member
  • *****
  • Posts: 1152
Re: some notes about custom lighting shading of surfaces...
« Reply #3 on: March 23, 2018, 11:04:43 PM »
nice shades and blends of colors, just for the pleasure of the eyes : 8)

DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline Rick Nasher

  • Hero Member
  • *****
  • Posts: 791
Re: some notes about custom lighting shading of surfaces...
« Reply #4 on: March 24, 2018, 06:27:04 AM »
Really looking nice indeed.

I've done something similar before, but real-time, for I don't know how to actually do this pre-calculated in AGK, but works fast enough so can't complain.. (yet) :-)
_______________________________________
 B3D + physics + shaders + X-platform = AGK!
:D ..ALIENBREED *LIVES* (thanks to Qube).. :D
_______________________________________

Offline RemiD

  • Hero Member
  • *****
  • Posts: 1152
Re: some notes about custom lighting shading of surfaces...
« Reply #5 on: March 24, 2018, 08:10:39 AM »
@Rick>>these lights only light shade the surface of one area, so they do not go through floors walls ceilings. Not sure if you can do this with AGK lights (i hope so, this can be useful). Also the lighting shading is precalculated on static surfaces and only updated on turning moving animating surfaces (so faster to update)
Also this is lighting shading using vertices colors, so different than lighting shading using pixels (no idea how it is done and i don't think that it can be precalculated).

Just consider that this uses only Blitz3d and Directx7, so it is rather a nice result 8)
(but of course per pixel lighting looks much better, especially for spot lights)

Now i need to add more things in these rooms...
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline RemiD

  • Hero Member
  • *****
  • Posts: 1152
Re: some notes about custom lighting shading of surfaces...
« Reply #6 on: March 27, 2018, 10:54:46 PM »
Something that i have noticed recently, even if it is to be expected, is that if you want to create a custom lighting shading system using vertices colors, you can't use copyentity(), because it creates a copy of a source mesh / surface and so if you have several shapes which refer to the same surface, and if you change the colors of the vertices, they will all look the same (like the source surface) and therefore the different shapes will not be lighted shaded correctly.

The solution is to not use copyentity() and instead to use loadmesh() (for static surfaces) or loadanimmesh() (for rigged skinned animated surfaces) so that each shape has its own surface.


Now you may say that it will be slower to render because there are more different unique surfaces, and this is true, but if you also use a smart "hidden surfaces culling" system, this is not an issue. (only the shapes in the active area and in view will be rendered...)
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline RemiD

  • Hero Member
  • *****
  • Posts: 1152
Re: some notes about custom lighting shading of surfaces...
« Reply #7 on: March 31, 2018, 07:34:20 PM »
I just found (yesterday) that it is possible to set a vertex color at more than 255,255,255, (not sure how high you can go)
So this means that it is possible to have a "uniform light intensity", whatever the color.
The formula is :
Code: [Select]
CurCoef# = Float(ColR+ColG+ColB)/Float(255+255+255) ;255+255+255 corresponds to white
TweakCoef# = 1.0+(1.0-CurCoef)
ColR = ColR*TweakCoef : ColG = ColG*TweakCoef : ColB = ColB*TweakCoef

Compare the lighting intensity of the 1st screenshot to the lighting intensity of the 3rd screenshot
Quite surprising... Not sure if this is documented somewhere, but i have never read about this anywhere.
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline Rick Nasher

  • Hero Member
  • *****
  • Posts: 791
Re: some notes about custom lighting shading of surfaces...
« Reply #8 on: March 31, 2018, 08:22:25 PM »
Oops, could have told you that if I'd known you didn't and that Blitz allows this too.
I've done 1255 as a test and gave a nice oversaturated effect.
_______________________________________
 B3D + physics + shaders + X-platform = AGK!
:D ..ALIENBREED *LIVES* (thanks to Qube).. :D
_______________________________________

Offline STEVIE G

  • Hero Member
  • *****
  • Posts: 516
Re: some notes about custom lighting shading of surfaces...
« Reply #9 on: March 31, 2018, 09:09:26 PM »
I just found (yesterday) that it is possible to set a vertex color at more than 255,255,255, (not sure how high you can go)
So this means that it is possible to have a "uniform light intensity", whatever the color.
The formula is :
Code: [Select]
CurCoef# = Float(ColR+ColG+ColB)/Float(255+255+255) ;255+255+255 corresponds to white
TweakCoef# = 1.0+(1.0-CurCoef)
ColR = ColR*TweakCoef : ColG = ColG*TweakCoef : ColB = ColB*TweakCoef

Compare the lighting intensity of the 1st screenshot to the lighting intensity of the 3rd screenshot
Quite surprising... Not sure if this is documented somewhere, but i have never read about this anywhere.

If I remember you can also set the color to be negative which gives some really nice effects.

Offline RemiD

  • Hero Member
  • *****
  • Posts: 1152
Re: some notes about custom lighting shading of surfaces...
« Reply #10 on: April 01, 2018, 09:04:30 AM »
Quote
you can also set the color to be negative which gives some really nice effects.
not so nice, rather buggy, see : https://www.syntaxbomb.com/index.php/topic,4290.msg14330.html#msg14330
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline peteswansen

  • Jr. Member
  • **
  • Posts: 60
Re: some notes about custom lighting shading of surfaces...
« Reply #11 on: April 04, 2018, 09:41:46 PM »
thanks for your posts Remi regarding shaders and coloring,  I read my Blitz 3D manual and was able to figure out vertex coloring in my programs-  it is very nice!

Offline RemiD

  • Hero Member
  • *****
  • Posts: 1152
Re: some notes about custom lighting shading of surfaces...
« Reply #12 on: April 05, 2018, 08:23:04 AM »
the cool thing is that you can create a unique lighting shading system (if your surfaces are subdivided enough).

see how the floors, walls, ceilings are subdivided, in "normal" view and in "wireframe" view :

you don't need to subdivide small surfaces like items or small furnitures / containers, only big surfaces like floors, walls, ceilings, doors...

Just a precision : to color your meshes (surfaces), you want to use textures, and to light shade your meshes (surfaces), you want to use vertices colors.
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal