Le MAlin 76 on 6/5/2014 at 06:35
The New Dark allow to apply a lut map (1 or2d) with the functions alpha Incidence and rgb incidence. But how use that correctly. Apparently the engine use the vertex to apply the colors corrections so it's look strange.
Quote:
rgb func <function> <func_param>*
---------------------------------
Generate vertex color based on one of the following functions:
INCIDENCE <r:float> <g:float> <b:float> <max_dist:float> <lut_texture>
View angle to surface. The view angle between 0 and 90 degrees is used to look up the final
output value in a 1D or 2D texture, where the horizontal texture axis represents the
incidence angle (left is 0 and right is 90). If a 2D texture is used, the vertical texture
axis represents the distance (in world units, i.e. feet) from surface to viewer, from closest
distance on the top row, to "max_dist" on the bottom row. This gives the author full control
to produce any kind of linear or non-linear function based on view angle and distance. The
texture must be at least 2 pixels wide, or it will be discarded.
All RGB channels from the LUT texture are used, so it's possible to have individual functions
for each channel and get color changes depending on view angle.
The "r" "g" "b" param is the base color value, which is multiplied with the incidence function
result.
...
alpha func <function> <func_param>*
-----------------------------------
Generate vertex alpha based on one of the following functions:
INCIDENCE <alpha:float> <max_dist:float> <lut_texture>
See "rgb func INCIDENCE" for a description of the function.
Only the B channel from RGB or RGBA LUT textures is used, the rest are ignored.
The "alpha" param is the alpha base value, which is multiplied with the incidence function
vfig on 21/3/2023 at 14:41
appending this here since this is the only thread i can find about the INCIDENCE functions in .mtl materials
i am trying to use an incidence func (tried with both a 1d and a 2d lut), but it isnt working as expected anywhere.
on a model (for convenience i used a table and added a .mtl for its top texture) it works more or less as described, and the rgb/alpha indeed varies—though it appears to be calculating the "view angle" actually as the angle from the player's head position] to a single point at a corner of the table's OBB (not even its origin). it doesnt actually seem to be taking the view angle into account at all, as—looking up and down vertically doesnt change the modulation as "view angle" ought to mean—edit: as vertices below the camera appear to have the same modulation as vertices further away at a much shallower angle.
on terrain textures though, its a total bust. it has the same problem with it using the "angle to the player's head", but taken relative to the center point of the terrain polygon. which is utterly useless!
(for what its worth, the distance modulation seems to work: at least on the table it seems to be using distance from object origin. but on terrain it is using distance from poly center, which again is pretty useless)
so to me this looks like a newdark bug.
ZylonBane on 21/3/2023 at 16:05
Quote Posted by vfig
it doesnt actually seem to be taking the view angle into account at all, as looking up and down vertically doesnt change the modulation as "view angle" ought to mean.
Why would it? In real life, if you're standing near a shiny reflective surface, does the reflection on the surface change just from moving your head up and down? No it does not. The reflection only changes if you move. That's what this feature is intended to simulate. "Angle" refers to the angle between the surface and the camera, not the camera facing angle.
A surface that rendered differently depending on which direction you're looking would be bizarre.
vfig on 22/3/2023 at 04:17
yeah my explanation isnt very clear. i dont mean the same point of the surface should modulate differently, but that by looking straight down vs looking to the horizon i can see different areas of the surface that have a higher or lower angle of incidence, so i should see a difference in modulation between those different areas.
i didnt see such a change; assuming this is supposed to be per-vertex (its clearly not per pixel), i expected to see a difference in modulation between the far vertices at a low angle and the near vertices at a high angle—but they all appeared identical.
possibly i dont have the right setup here, and shouldnt be expecting sensible results with large flat polys. i can try with a different model with more subdivisions, but then that runs counter to the general caution about render passes on high poly objects because of its one-draw-call-per-poly behaviour? doesnt sound promising.
Skol on 22/3/2023 at 16:11
Perhaps unrelated, but if you're just going for specular highlights on textures, I've seen it used in Katharsis. Check the tiles in the underwater dining room (-356, 227, -345) using the texture floor07. Here is the .mtl:
Code:
terrain_scale 128 128
tile_factor 2
render_pass
{
texture tex/envmaps/nrwstrk
alpha 0.5
blend SRC_ALPHA ONE
uv_source PROJECTION
uv_mod SCALE 1 1
}
render_pass
{
texture $texture
shaded
...Which doesn't use incidence at all. But I figure for specular highlights it would
seem like incidence funcs are the way to go.
ZylonBane on 25/3/2023 at 19:36
Years ago when all these features first dropped, I tried using the incidence funcs and multiple texture passes to simulate sparkle on snowy terrain. So bright points would fade in and out as you moved around. It turned out decently realistic.
vfig on 25/3/2023 at 22:05
hmm, yeah. the use case i was looking into was fading a cubemap reflection with incidence. but a sparkly texture isnt going to show discontinuities at polygon edges. thats something i hadnt considered.
Skol on 24/4/2023 at 03:25
I think you can do specular highlights on terrain using alpha func incidence, sort of maybe:
Code:
render_pass {
texture tex/cobbysp
alpha func incidence 1.0 1000 tex/gradient
blend SRC_ALPHA ONE
shaded
}
Where tex/cobbysp is a sort-of-not-really specular map, the non-specular parts being full transparent. For a wet cobblestone look, I used that early-2000s plastic wrap filter in PS and masked out all but the brightest bits. It's vertex-based, but I'm using a huge texture generating more polys, and there's not a lot of expected continuity from, like, one rock to another on cobblestone anyway.
So it doesn't just work for sparkly textures. It also works for kind of blobby textures if the texture is big enough and you got enough vertices to play with? Cool, I guess?