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

0 Members and 2 Guests are viewing this topic.

xenoargh

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #15 on: December 11, 2011, 12:12:25 AM »
OK, done testing it; the principle Idea works; now I just, uh, need to adjust about... every single specular  :lol:  The problem is that all the existing speculars lack color shifts, which makes them look a little flat and lifeless now.  Oh well, that's a trade I can live with.

Maybe not today; gotta go do IRL in about 15 minutes.  Oh well, at least it's possible now; been wanting to do this since I looked at Narf's stuff in OpenBRF.

Barabas

  • Master Knight
  • *
    • View Profile
  • Faction: Neutral
  • MP nick: Bassa Bar
  • WB
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #16 on: December 11, 2011, 12:12:57 AM »
Well, like I said, I tried that and it didn't work.

That's weird...

Cause thats all I did there, for as far as I can remember.

And I get this:

with a spec map like this:


We are talking about the ps_main_standart right?

From what I understand you use the spec coefficients in open brf to define the color right? Its much easier imo to use the specular texture.

xenoargh

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #17 on: December 11, 2011, 12:17:29 AM »
Hmm.  I really didn't get that result over here, but I didn't try anything that saturated, either.  I'll have to play around with Rainbow Brite tomorrow night, see what's possible  :lol:

Barabas

  • Master Knight
  • *
    • View Profile
  • Faction: Neutral
  • MP nick: Bassa Bar
  • WB
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #18 on: December 11, 2011, 12:26:47 AM »
Alright, well it is supposed to work :p
Everything multiplies there anyway, so.

If you have any other cool ideas for ways of using textures or anything. I'm all ears. I can't really think of anything  :shock:

Computica

  • Master Knight
  • *
  • "Cosmic Kalypso!"
    • View Profile
  • Faction: Swadian
  • MP nick: Computica
  • M&BWBWF&S
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #19 on: December 11, 2011, 07:59:40 AM »
Alright, well it is supposed to work :p
Everything multiplies there anyway, so.

If you have any other cool ideas for ways of using textures or anything. I'm all ears. I can't really think of anything  :shock:
I've been trying to figure out how to make the plant/tree shaders wobble. Does anyone know how to that in HLSL?


"The God you don't believe in does not exist"
"No need for bombs, when hate will do."

Chaingun

  • Squire
  • *
  • When you least expect a backstab...
    • View Profile
  • Faction: Neutral
  • MP nick: IG_Ctz_Chaingun
  • WB
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #20 on: December 11, 2011, 08:19:17 AM »
Conceptually you can just add an offset to vertex position modulated by sine functions of time + position. Now I have no idea for Warband whether you can edit vertex shader and if so whether there's a time parameter to modulate with.
Software Engineer.

Barabas

  • Master Knight
  • *
    • View Profile
  • Faction: Neutral
  • MP nick: Bassa Bar
  • WB
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #21 on: December 11, 2011, 11:00:19 AM »
Conceptually you can just add an offset to vertex position modulated by sine functions of time + position. Now I have no idea for Warband whether you can edit vertex shader and if so whether there's a time parameter to modulate with.

There is. It's not easy to make them wobble realisticly though. And you have to find some way to wobble only the tips not the roots ^^
Using the position within the model coordinates doesn't work as automaticaly generated flora doesn't have those.

Eiríkr Rauði

  • Turanien by any other name
  • Master Knight
  • *
  • Ain't Misbehavin'
    • View Profile
  • Faction: Neutral
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #22 on: December 11, 2011, 12:26:17 PM »
Alright, well it is supposed to work :p
Everything multiplies there anyway, so.

If you have any other cool ideas for ways of using textures or anything. I'm all ears. I can't really think of anything  :shock:
I've been trying to figure out how to make the plant/tree shaders wobble. Does anyone know how to that in HLSL?

Shing a ding!

You'll probably want to talk to Slawomir or Tuls from the WFaS mod.


"...as such any opportunity I get to mute him, I will gladly exploit."

Barabas

  • Master Knight
  • *
    • View Profile
  • Faction: Neutral
  • MP nick: Bassa Bar
  • WB
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #23 on: December 11, 2011, 12:44:34 PM »
I just managed to compile everything using vs_3_0 and ps_3_0 ^^
And it works in-game as well... apart from the fog, that somehow dissapeared  :shock: :o
Same for underwater effects  :(

!!This might not be the best idea if you don't know what you're doing!! (like me)
« Last Edit: December 11, 2011, 12:57:22 PM by Barabas »

xenoargh

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #24 on: December 11, 2011, 01:26:22 PM »
What should be done is to make it PS / VS 2 compliant; this can be done with vertex painting methods (VS 2 is not allowed to read pixels, but may read vertex colors).  The hard part is randomizing the system a bit so that the results exhibit some patterns of gross and tip motion that are dissimilar and feel natural.  I did this with another engine by generating per-object uniforms sent to the shader, but there are probably ways to achieve a similar sense of randomness via using the world-space coordinates of the thing.

Barabas

  • Master Knight
  • *
    • View Profile
  • Faction: Neutral
  • MP nick: Bassa Bar
  • WB
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #25 on: December 11, 2011, 02:21:15 PM »
Does anyone know why compiling with vs and ps 3 would break the fog?
If we can fix that you would be able to actually read textures in the vertex shader =)

xenoargh

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #26 on: December 11, 2011, 07:22:55 PM »
Fog may be using FFP; I don't have a better answer yet until I've had a chance to look at some things.  I'm not entirely sure that using VS 3.0 is as trouble-free as VS 2, though; you may run into fairly severe ATI / nVidia issues, and I don't think the engine returns a lot of details if a shader crashes.

Barabas

  • Master Knight
  • *
    • View Profile
  • Faction: Neutral
  • MP nick: Bassa Bar
  • WB
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #27 on: December 11, 2011, 07:30:19 PM »
Ahh.. alright. I already wondered where the Out.Fog went after the vertex shader. Never comes back into the pixel shaders.
It's not very important anyway.

xenoargh

  • Grandmaster Knight
  • *
    • View Profile
  • Faction: Neutral
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #28 on: December 11, 2011, 07:38:51 PM »
You can re-implement fog, though, I think; you'd have to get world-space coordinates for the vertex and compare to the camera's position; I *think* that is possible without having to send it a uniform... maybe get the length of the eye vector?  Should be possible to get the fog's strength, attenuation etc. from the existing inputs; it's probably just not getting along with the pixel shader. 

Might get into a fair amount of math on the pixel shader, though. 

I should prolly shut up, I will have to look at various things before my competence with HLSL and the DX rendering system is vaguely useful, so this may all be wrongo; sorry if it causes any wasted time ;)

Barabas

  • Master Knight
  • *
    • View Profile
  • Faction: Neutral
  • MP nick: Bassa Bar
  • WB
Re: [INFO] Shader Stuff- HLSL instruction limits
« Reply #29 on: December 11, 2011, 07:42:24 PM »
What it does is this:

Code: [Select]
float3 P = mul(matWorldView, vPosition); //position in view space
//apply fog
float d = length(P);
float4 vWorldPos = (float4)mul(matWorld,vPosition);
Out.Fog = get_fog_amount_new(d, vWorldPos.z);
And get_fog_amount_new does nothing else then call get_fog_amount(d) which is:
Code: [Select]
return 1.0f / exp2(d * fFogDensity);
So it could be fairly easy to add that in the pixel shader.