Sign in to follow this  
EnochDagor

Post Process FX File Help

Recommended Posts

Ok, I'm getting frustrated. I can't figure this HLSL stuff out... I'm guessing that means I'll be obsolete here in a year or two... But until then, I'm gonna try. I went out to NVidia's website and downloaded an FX file called Post_Bloom.fx. I couldn't find it again on NVidia's site, but I did find another link to the same file: http://xwrite.sourceforge.net/misc/post_bloom.fx Anyway, I've tried figuring out how I'd render a single sphere using the effect. Every method that I have tried has failed (nothing renders). So, I'm guessing that I'm just not drawing a connection somewhere... and maybe someone could help. From what I've seen on the internet, I know that it has something to do with RenderTargets, but exactly what, I am not sure. I understand pretty much every language, so any sample source you can give me would be helpful as long as it applies to the FX file I mentioned above. Thanks!

Share this post


Link to post
Share on other sites
If you are new to HLSL, then I would suggest starting with much easier examples than a post-process effect like bloom; start out with an ambient lighting example, then move on to more complex shaders. As for the Post_Bloom.fx shader; it is a post-process effect as I mentioned earlier. This means that you render the scene onto a texture, then apply the effect to that texture, and then you render the texture to the screen. Here are some links to help you to get a better understanding of HLSL:

http://www.pieterg.com/Tutorials.php
http://www.equalmeans.net/~chriss/EQM/

On my site (that second link), try looking at the application code of the Normal Map Refraction sample, it shows how to render a scene to a texture. All you have to do then is apply the bloom effect to that texture, and render it to the screen.

Hope this helps,
-Chris

Share this post


Link to post
Share on other sites
I'm at work at the moment but I think I know the problem. I think the effect works just fine (because I get no errors)... I think the missing link was getting the result to the screen.

So here's what I do so far...

I render the Sphere mesh to a RenderTarget. I then set the "SceneMap" property of the FX file to the RenderTarget result. Now, here's where I get a little foggy...

I then go through and render to a new RenderTarget for each pass...


oFX.SetValue(oFX.GetParameter(Nothing, "SceneMap"), oTarg)
lPasses = oFX.Begin(FX.None)
For X = 0 to lPasses
'RenderTarg encapsulates the Render to Surface functionality for us
oRenderTarg.BeginScene(oTarg.GetSurfaceLevel(0))
oMesh.DrawSubset(0)
oRenderTarg.EndScene(Filter.None)
Next X



Now, I'm not sure what to do with the oTarg texture after each pass. Do I need to assign it to a value in the FX file? Which value, or does it change for the pass I am on? How can I do it 'intelligently'?

Finally, I never knew what to do after all of this was done. I saw an example with a Quad and I think I discounted the quad... but now I think I'm going to need to use it (which I believe was my missing link).

Now, another concern is how do I get only certain objects to Bloom/Glow? Do I do all this work first and then put the result texture on the device and then not clear the device after that (I'd clear the device before all of this work)?

In other words:

Device.BeginScene()
Device.Clear(...)
RenderBloomObjects() 'does the FX process and sets the quad onto the device
RenderEverythingElse
Device.EndScene()
Device.Present()

Sound right? But what about my depth buffer? Let's say that I render an object with bloom and it is closer to the camera then an object I render after the bloom?

-E

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this