Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 01:28
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (7th_zorro), 793 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Need some shader advice... #318296
04/06/10 20:11
04/06/10 20:11
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline OP
Serious User
DJBMASTER  Offline OP
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Hi shader gurus, I'm writing a HLSL editor and I need to clear up some confusion...

1) As I understand it, a shader 'fallback' is when the graphics card doesn't support the required shader model, and so it uses a 'lower' version of the shader.

I am currently allowing the user to build different versions eg, model 1.1, 2.0, 3.0 etc.

How do I chain these fallbacks together in HLSL?

2) Are the shader inputs/outputs consistent among all versions of the shader.

Eg, if the shader for model 2.0, takes in TEXCOORDs, does that mean that the shader for version 1.1, must also use this? Or can they vary.

I might seem like I'm talking rubbish, but I need to get this straight so my editor works correctly.

Thanks

Last edited by DJBMASTER; 04/06/10 20:12.
Re: Need some shader advice... [Re: DJBMASTER] #318410
04/07/10 14:37
04/07/10 14:37
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
G'day,

1:
A typical shader includes a whole bunch of variables and functions, and these can generally be named however the user wants (unless of course it's something the engine automatically provides such as many matrices).

What actually determines which of these functions are used for each shader, and what shader model is used, is the technique:
Code:
technique ArbitraryMeaninglessNameThatNeverGetsReferencedAnyway {
   pass AnotherMeaninglessName {
      // set some states, then:
      VertexShader = compile vs_2_0 VS();
      PixelShader = compile ps_2_0 PS();
   }
}


Now, the technique names can have meaning -- these (such as "lod1...lod3" or "_lm1..._lm3") are mentioned in the manual.

The engine will use the first technique it finds that's compatible with the user's hardware.
Eg:
Code:
technique Chicken {
   pass Legs {
      VertexShader = compile vs_3_0 myVertexShader3Function();
      PixelShader = compile ps_3_0 myPixelShader3Function();
   }
}

technique nickel {
   pass tongue {
      VertexShader = compile vs_2_0 aCompatibleFunction();
      PixelShader = compile ps_2_0 anotherOne();
   }
}

If the hardware supports shader model 3.0 or higher, the "Chicken" technique will automatically be used. Otherwise, the "nickel" technique will be used -- assuming the user's hardware supports shader model 2.0.

I know I spent a lot of time on this one, but I'm just not sure how much you know and how much you don't laugh

2: There's no reason they need to be. Except for accepting model data into the vertex shader, how the TEXCOORDs are used is completely up to the shader writer.

Jibb


Formerly known as JulzMighty.
I made KarBOOM!
Re: Need some shader advice... [Re: JibbSmart] #318424
04/07/10 15:48
04/07/10 15:48
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline OP
Serious User
DJBMASTER  Offline OP
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Thanks, that's great.

I knew about techniques and passes, it was just the fallbacks and the LODs that I was unsure about. Thanks for clearing this up for me.

Btw, I see the line 'technique fallback { pass one { } }' in quite a few shaders. Can you tell me what this does please?

Thanks again.

Re: Need some shader advice... [Re: DJBMASTER] #318433
04/07/10 16:27
04/07/10 16:27
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
No worries laugh

The line "technique fallback { pass one { } }" is usually the very last fallback. It basically renders the entity as if no shader was ever applied, and is to make sure that no matter what hardware the user has they'll at least be able to see the entities. No states need be mentioned because the engine automatically sets those based on the entity's flags (such as TRANSLUCENT, BRIGHT, OVERLAY, and so on).

I hope that makes sense.

Jibb


Formerly known as JulzMighty.
I made KarBOOM!

Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1