Range scaling in TSE Atlas Shader - need some help
by Tim Holt · in Torque Game Engine Advanced · 06/13/2006 (11:17 am) · 4 replies
I'd like to make a variant on the default atlas shader that uses the range from viewer to pixel to scale a few things. Specifically I'd like to have the detail texture be more intense at closer ranges, and fade out at longer range.
Firstly I'm not really clear on where I'm going to get the depth to pixel in the pixel shader. Would this be in hpos? Or is it worldPos? I managed to make something like this work in a cg shader once (see http://update.multiverse.net/forum/viewtopic.php?t=323&highlight=shader&theme=multiverse) but not sure how in the hlsl world.
Any suggestions on how to do this calculation? Shaders I confess are a total mystery to me, despite years of software development. "Magic" variables that appear out of nowhere. There's a layer higher up with them I don't get :^(
Firstly I'm not really clear on where I'm going to get the depth to pixel in the pixel shader. Would this be in hpos? Or is it worldPos? I managed to make something like this work in a cg shader once (see http://update.multiverse.net/forum/viewtopic.php?t=323&highlight=shader&theme=multiverse) but not sure how in the hlsl world.
Any suggestions on how to do this calculation? Shaders I confess are a total mystery to me, despite years of software development. "Magic" variables that appear out of nowhere. There's a layer higher up with them I don't get :^(
#2
07/10/2006 (10:19 pm)
Ive played lots with the detail textures in the atlas surface shader and pretty much torn it limb from limb....if you want the Detrail texture you can adjust their size(assuming you can get them re-enabled in3.5)by adjusting the OUT.detailCoord = realPos / 51; play with the numbers and the sizes look much better I set mine to 8 ...is this close to what your looking for?Your probably looking for somthing else because ive seen your post and you shader knowledge is DOUBLE that of mine so I assume you trying for somthing else....when you do find a nicer way of sharping the Atlas textures please let this old hippy know....the kids are never quiet enough to let me concentrate!!LOL!!
#3
07/10/2006 (11:36 pm)
Incidentally - the more you make them repeat the more obvious their tiling is in the distance.
#4
07/11/2006 (8:45 am)
I did end up using the fog code for the range basis. If you look in the Atlas shader code you can see how it calculates the fog. The tricky thing with fog is that it seems to turn around and use the range value and the height of a point to calculate fog intensity at a given point. That way you don't get your sky fogged out but you do get lower ground areas fogged.
Associate Kyle Carter
Anyway, HPOS.z in the pixel shader is a good bet, you can also try seeing what the fog code does, as it's range based as well.