Author Topic: [INFO] Shader Stuff- HLSL instruction limits  (Read 10456 times)

0 Members and 3 Guests are viewing this topic.

Barabas

  • Master Knight
  • *
    • View Profile
  • Faction: Neutral
  • MP nick: Bassa Bar
  • WB
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #240 on: February 02, 2012, 08:35:25 PM »
quoting myself, since I was redirected here :P

Does anyone have any experience with editing the module_postfx.py file?
Looks like you can do quite a bit to the overal look of things, but I'm not quite sure what paramter does what.

Quote
#  4) shader parameters1 [ HDRRange, HDRExposureScaler, LuminanceAverageScaler, LuminanceMaxScaler ]
#  5) shader parameters2 [ BrightpassTreshold, BrightpassPostPower, BlurStrenght, BlurAmount ]
#  6) shader parameters3 [ AmbientColorCoef, SunColorCoef, SpecularCoef, -reserved ]

Any advise is appreciated! :)

xenoargh

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #241 on: February 02, 2012, 09:09:43 PM »
See the documentation; short version is that putting in new HDR skies is non-trivial.  All that stuff is used to produce color multipliers and change the final gamma, per-pixel, with bloom where it exceeds the threshold.

Barabas

  • Master Knight
  • *
    • View Profile
  • Faction: Neutral
  • MP nick: Bassa Bar
  • WB
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #242 on: February 02, 2012, 10:08:20 PM »
It doesn't have a whole lot to do with the skies itself though. That's the skyboxes.py. And you can alter the ground ambient color and other ground related things in Groud_specs.py. This module_postfx.py is more about the general lighting on the scene, which can be set per skybox configuration.

I looked around a bit and it seems that it controls a few things that are used in the post-processing, like the amount of bloom and when it starts blooming. Also parameters for the auto-exposure feature. And the last few parameters are for the intensity of the ambient sun and specular colors (these were quite obvious and can also be tested in the editor).

this is what I have so far:
Quote
#   HDRRange  = The amount that the image gets multiplied with before doing any of the calculations (and later divided with)
#   HDRExposureScaler = ?
#   LuminanceAverageScaler = ?
#   LuminanceMaxScaler = ?
#   BrightpassThreshold = the point after which stuff starts to glow (after applying the HDRRange )
#   BrightpassPostPower = ?
#   BlurStrength = power of the blur pow(blur,BlurStrength)
#   BlurAmount = How bright the blur is
#   AmbientColorCoef/SunColorCoef/SpecularCoef = multipliers for the ambient sun and specular colors.

You can look up what happens exactly in the postfx.fx (but I dont understand how everything turns out visualy exactly)

xenoargh

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #243 on: February 02, 2012, 10:27:51 PM »
The skies factor in with some things, like water, I think.

Anyhow, these are my guesses.  Haven't messed with this much, since it's pretty much a global setting.

HDRRange is set up in the vertex shaders, mainly, for stuff with specular.
HDRExposureScalar is probably a measurement of how much more to boost stuff, like exposure in a camera.  IDK why they used two params to do very similar things, though.
LuminanceAverageScaler is probably an average sample of the buffer to provide a clue how bright things are, and if necessary tone down the bloom.  You can see it operating on snow maps or on the overworld when you scroll over a snowy area.
 LuminanceMaxScale is probably just a cutoff.
BrightpassThreshold = It's what is "bright" and needs bloom.  I think it's contingent on specular being enabled for the given model as well.
BrightpassPostPower = some variable used to exponentiate the brightness, most likely.

I'm not sure about BlurStrength / BlurAmount; I would think that BlurAmount would be the distance and Strength would be the power used in the falloff equation.  Which is probably why changing BlurAmount changes perceived brightness.

AmbientColorCoef:  extra factors to skew final results depending on whether the object is subject to bloom or is / not in the shadow depth volume, presumably.

xenoargh

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #244 on: February 14, 2012, 04:39:35 AM »
Got plant shader working with vertex offset via worldspace position.  Pretty much worked as planned :-)

Much work needed to finish vertex colors, trees will be a lot of work, even with some help from MeshLab.  More when it's ready to make a presentation.

Oh, and it also effects strategic map flora, so the strategic map is finally lively-looking :D

xenoargh

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #245 on: February 14, 2012, 09:16:05 AM »

mr.master

  • Grandmaster Knight
  • *
  • A Proud Christian, A Member of Knights Of WEe, 6-1
    • View Profile
  • Faction: Neutral
  • MP nick: WEe
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #246 on: February 14, 2012, 09:18:27 AM »
Sweet. Excelent stuff Xeno. Do want this so badly lol.



xenoargh

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #247 on: February 14, 2012, 09:20:28 AM »
I'll make it (and the source, of course) available soonish; I kind of need to finish some other things first, but it's all coming along.  I would also show off the Moar Metal shader at its current point but, ah, I'd like there to be a few surprises ;)

Anyhow, it was really easy to write this thing, it pretty much worked like I planned it. 

The hard part turned out to be applying the vertex colors to the geometry so that it could, y'know, work; I should really talk to Marco about certain issues I had with MeshLab that weren't anticipated that made things, erm, quite a bit more complicated; MeshLab is such a cool tool, but some things are not exactly intuitive :lol:
« Last Edit: February 14, 2012, 09:28:59 AM by xenoargh »

Barabas

  • Master Knight
  • *
    • View Profile
  • Faction: Neutral
  • MP nick: Bassa Bar
  • WB
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #248 on: February 14, 2012, 09:46:31 AM »
Oh, that looks quite nice! Much better then my petty attempts some while ago. It looked more like you had taken something instead of windy plants ^^

xenoargh

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #249 on: February 14, 2012, 10:00:06 AM »
Well, it's not terribly complicated, really.  Tell ya what:  I want to keep this stuff under wraps until I release, but in the spirit of the thread, I'll give you some really useful hints:

1.  You need to modulate the vertex's position in worldspace, using vertex colors as your control parameters to adjust the scale and frequency of the resulting sine curve.

2.  Because you're using vertex colors, this technique has one semi-serious drawback; it can't really be fully compatible with vertex color paint.  However, the flip side of that is that you actually save instructions on the pixel shader side, and for simple light / darkness you could reserve a vertex color to use as a multiplier (I didn't, though; leaves don't generally need it and it can be faked in the diffuse).

3.  It's important not to modulate the original vertex positions.  Firstly, they are constants and should not be messed with at all, if you want it to play nice with ATi.  Secondly, you need the originals to preserve the relationship with the shadow depth volume.  That is the only "tricky" part, but since I wrote GPL code to demonstrate that a couple of years ago and lots of articles have been written about flora shader stuff ever since Crysis demonstrated the mind-boggling things one can do with vertex shaders, I don't suppose that's a deep dark technical secret. 

4.  Like I said, the hard part was the technical-modeling end; I had grass and bushes looking nice in half an hour, but the trees took a long time and still aren't what I really wanted.  I'm talking to Marco about that; I ran into issues with MeshLab (prolly User Error on my part, it's a complex piece of software) that prevented me from doing it like I'd originally planned.

Anyhow, hope that's enough to give you some ideas, if not... well, I'm going as fast as I possibly can on the other stuff :-)
« Last Edit: February 14, 2012, 10:03:43 AM by xenoargh »

Barabas

  • Master Knight
  • *
    • View Profile
  • Faction: Neutral
  • MP nick: Bassa Bar
  • WB
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #250 on: February 14, 2012, 11:03:01 AM »
Thanks for the hints. I already knew about 1 & 2 (from earlier posts mostly), but I don't get the 3rd ^^. At least not how I should modify their position without modifying their position  :P

Do you have any ideas on how it affects performance? As I undertood the sinus stuff is not nice on the gpu.

I'll probably just wait for you to release some stuff, I don't have much time on my hands right now anyway.

(my experience with this stuff is virtually 0 before I started messing with it a few weeks back)

xenoargh

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #251 on: February 14, 2012, 06:03:15 PM »
Well, you're a much faster learner than me, it took me a while to start to get it, mainly because lighting equations and matrix mathematics were total Greek to me :lol:

Anyhow performance is fine; since this is actually saving an op or two on the pixel shader it's cheaper per texel, but  more expensive per vertex- not a huge amount though, it's not using a lot of fancy math. 

Sin / Cos aren't that expensive; it's what people tend to do with the next stage, i.e. taking the basic oscillations and applying more forces to it.  I went the cheapest route that I know of; it certainly ain't Crysis but it'll do for a mass-combat simulator :-)

Caba`drin

  • Administrator
  • *
  • It's time to toss the dice.
    • View Profile
  • Faction: Nord
  • MP nick: Caba_drin
  • M&BWBWF&S
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #252 on: February 14, 2012, 06:58:42 PM »
Looks great, xeno. Thanks for sharing, as always.



Belendor

  • Grandmaster Knight
  • *
  • If my destiny is to save the world, a beer please
    • View Profile
    • Olympus Studios
  • Faction: Nord
  • MP nick: CoR _Belendor
  • WBWF&SNW
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #253 on: February 14, 2012, 08:43:53 PM »
Awesomeness. :O

mark7

  • Sergeant
  • *
  • Sorry for my English!
    • View Profile
  • Faction: Bandit
  • WB
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #254 on: February 16, 2012, 09:27:23 PM »
Hi guys... What the error redefinition of formal parameter means at compilation?
I only add
Quote
struct VS_INPUT_SKYDOME
{
   float4 vPos               : POSITION0;   // Vertex position
   float2 vBillboard      : TEXCOORD4;
    float3 vNorm         : NORMAL0;      // Vertex normal
   float3 vTangent         : TANGENT0;      // Vertex tangent


};

VS_OUTPUT vs_skydome(float4 vPosition : POSITION0, const VS_INPUT_SKYDOME input )