Jump to content
  • Advertisement
Sign in to follow this  
Halsafar

HLSL for Dummies

This topic is 4739 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've discovered a rather neat method of PS/VS and that is using HLSL. Apparently is use's fx files to do its dirty work. I have been reviewing the HLSL Workshop tutorial with the SDK and using EffectEdit to go through some of the tutorials of FX file manipulation. I got a pretty nice looking skull going on :) My problems are many and my questions are going unanswered. Instead of asking a million questions and getting a jargon of answers I feel the best question is: Is there a book or an article or a tutorial which defines HLSL and what it exactly is for Dummies. I am completly clueless on this topic, I need a lamen's approach. Thanks, Halsafar

Share this post


Link to post
Share on other sites
Advertisement
I would recommend you to download this pdf file from ATI’s developer site. In my opinion, this tutorial is very helpful and interesting.
http://www.ati.com/developer/ShaderX2_IntroductionToHLSL.pdf

Share this post


Link to post
Share on other sites
Indeed, a very nice tutorial. I read the first page and skimmed the rest, a very interesting read indeed. I shall sit down and study the entire document.

I would love a sample application on the side to show an FX file in action for rendering basic primitives so I can look at some of the theory and see it in work. Please do not recommend the SDK sample as it does not provide the basics, just a huge wrap around the framework which is ugly and difficult to navigate.

This HLSL seems like a rather diffucult task to tackle. All help is appreciated.

Thanks,
Halsafar

Share this post


Link to post
Share on other sites
Take a look at this book. As a COMPLETE DX noob it is a great way to get started from square one, up through shader introductions, etc.

J

Share this post


Link to post
Share on other sites
Even though it's focus is animation, there is a very clear and concise HLSL sample in the DirectMesh SDK. Basically, to render a primitive using HLSL, you need to take the following steps:

Initialization
(1) Compile the effect (D3DXCreateEffectFromFile*())
(2) Load all other resources (textures, ect...)

Rendering
(1) ID3DXEffect::Begin()
(2) For each pass:
   (2a) ID3DXEffect::BeginPass()
   (2b) Setup constants ID3DXEffect::SetValue()
   (2c) ID3DXEffect::CommitChanges()
   (2d) Setup device RS's, stream sources, ect... (like normal)
   (2e) Draw
   (2f) ID3DXEffect::EndPass()
(3) ID3DXEffect::End()

Share this post


Link to post
Share on other sites
Well I am not a DX Noob. But a certain part of the book will be indeed worth the read.



As for the code example, so I see that you render with the Effect in control (->BeginPass()). Thats pretty cool.

I will investigate the D3DMESH example as well.


Is this the prefered choice to aid in texture blending for terrain splatting?
Or is this just 'a' choice for PS/VS to aid in terrain texture splatting.

Share this post


Link to post
Share on other sites
Hi there,

HLSL stands for "High Level Shader Language" and it is just that - a way to write shaders (both PS and VS) in a language with a syntax somewhat like C instead of having to write them in assembly manually. It is a *great* tool and once you learn how to use it it'll increase your shader productivity a lot! (just like you can probably write more/better code in C++ than if you had to code in x86 assembly)

HLSL uses a compiler to compile your HLSL-shaders into "normal" assembly shaders which are then loaded and used by DX.

Effect files (.fx files) are another layer available in DX that *uses* HLSL shaders as well as being a tool for managing your shaders, render states, passes etc. It is actually not nessesary to use .fx files to use HLSL.

Thus you should consider HLSL a tool in writing shaders in general - not a tool for doing *specific* graphical things better/more easily. Which tasks that benefits from shaders is a completely seperate discussion from whether or not you should use HLSL.

Hope this clears things up a bit for you :)

- Kasper Fauerby

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!