Jump to content
  • Advertisement
Sign in to follow this  
sirlemonhead

really basic HLSL questions

This topic is 3032 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

Hey, Just trying to learn HLSL after having a reasonably ok grasp of the fixed function pipeline in Direct3D9 I want to stick with D3D9 (my video card is old) but move to shaders. I'd ideally like to keep things simple and allow myself to add an OpenGL renderer in future, so i'm not using the effects framework. Here are my questions: 1: I have numerous render state settings I need to replicate in a pixel shader. For example, one blend- SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA) and another one as example, SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ZERO); SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCCOLOR); What is the best way to write shader code to do these various blends? Do I make one big shader and use if () blocks, using a constant table to tell the shader what type of blend to use? I've been told that using conditional blocks like this in a shader is really bad (and i'd ideally like to use vs and ps 2.0 to keep things compatible with older cards) do I make seperate pixel shaders for each blend mode I want? It just seems sorta..messy to me to do things like this. 2: Really stupid question, many blends require to blend with the pixel value thats already in the backbuffer, so you can eg blend a pane of glass on top of a scene. How do you access the backbuffer pixel value? When I say backbuffer I just mean wherever d3d is currently rendering to. Those are the only two questions I can think of for now actually. Any help would be appreciated :)

Share this post


Link to post
Share on other sites
Advertisement
I think that most people would still set render states to do things like alpha blending and what not rather than writing a shader to do the same behavior. Most of the time using the render states makes a lot more sense than writing a shader for it.

Where shaders come in handy is when you want to do more complex things, like deferred rendering, different kinds of lighting models, postfx like motion blur, etc. So generally you would use a combination of render states and shaders.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!