Jump to content
  • Advertisement
Sign in to follow this  
remigius

OpenGL Locking rendertarget texture for Tron-like glow

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

Good morning, I've been having some problems with texture locking. I've been trying to recreate an (admittedly unefficient) Tron-like glow with Managed DirectX. To this end I'm rendering the glowing parts of my scene to a texture using the RenderToSurface function in Managed DirectX. But when I want to lock the texture so I can blur the glowing parts, I get a DX3D_INVALID_CALL. My texture format and type for locking match up, so that's not the problem. In fact, changing the Usage parameter of the RTS texture from Usage.RenderTarget to Usage.Dynamic solves my problem, but cuts back performance to 1/6th. So I guess the Usage.RenderTarget implicitly forces you to use LockFlags.WriteOnly for performance reasons. My problem however is that I can't go about blurring my glow texture when it's write only. From what I could tell, NVidia uses shaders to perform the blurring operation in the RenderToSurface step in their sample, but they're using a shader written in assembler and I was just glad I could write a basic shader in HLSL... So, I got three questions.: 1. Does Usage.RenderTarget indeed imply you can only lock a texture with LockFlags.WriteOnly? 2. If so, is there any other way I can lock this RTS texture for Read/Write? 3. Would anyone happen have some sample code on Tron glow in DirectX9, preferrable Managed, that uses HLSL shaders or doesn't use shaders at all? I did find an excellent example about Tron glow on this forum, but it was written in OpenGL and to be honest I couldn't understand one bit of it :) Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
I'm at work and have no SDK docs available so this is all from memory -- if anyone finds I'm wrong please correct this. But if I recall well:

Quote:

1. Does Usage.RenderTarget indeed imply you can only lock a texture with LockFlags.WriteOnly?
2. If so, is there any other way I can lock this RTS texture for Read/Write?

1. Yes.
2. No.

As for (3) I wouldn't know although I remember a Gamasutra article on the Tron glow a year or so ago. It was quite in-depth and I think you should seek it out!

Greetz,

Illco

Share this post


Link to post
Share on other sites
Thanks for the info :)

That's exactly the article that started this mad endavour to recreate the effect in Managed DX. The concepts of the article are quite clear to me (I admit, after some re-reads ;). My main problem is to get it working in C#, especially how I am going to do the blurring efficiently... guess I'll have to buy a book on HLSL some day.

Aside from the general lack of documentation of the Managed API, my endavours are further hindered by the fact that I can only use PS 1.4 for my project... I did find some very nice shaders (http://vvvv.meso.net/tiki-index.php?page=User+Shaders) that give you the glow effect, but these require PS 2.0. Well, hopefully these are still useful for someone else. Be sure to check em out if you are looking for a nice effect, they're free and look awesome!

I did find a shader in PS 1.1 for blurring, but I'm having some troubles getting it to work properly for me... I was using a Sprite object before to render the glow texture to cover the entire screen, but now that I'm using the shader I found, I need to render it with a custom not-pre-transformed vertex format. That part I got working, but me math abilities are too lacking to figure out how to map it to the entire screen.... any clues, anyone? :)

Share this post


Link to post
Share on other sites
Just wanted to share my results. Using the PS1.1 blur shader I was able to create the effect below. Not quite what I was hoping for, but a small victory nonetheless :)

Share this post


Link to post
Share on other sites
Nice effect!
If you're looking for Managed DX material, there are a few decent books (from what I've read about them). I've heard really good stuff about the Managed DirectX 9 Kick Start book. One of the profs at my last college really liked it too.

Here's the results of a search of Managed DX books here at GameDev: Click Me!

Just out of curiosity, what release of the SDK are you using?

Share this post


Link to post
Share on other sites
I'm using the februari 2005 update of the SDK, think I'll move to summer 2005 soon... hopefully they'll finally have reached a conclusion in the managed render loop discussion by then :)

Managed DirectX 9 Kick Start was my first book about game programming, so of course I like it. It's a shame though that it has been written for an older version of the API (summer 2003?), so a lot of code samples from the book won't compile on the newer releases anymore... Various Set/Get methods have been changed to properties and many method parameters have been changed... alas with no documentation to match, like much of the rest of the API :/

I recently picked up another book on Managed DirectX by Tom Miller, called Beginning 3D game programming. It covered a lot of topics on how to put Managed DirectX to use for various hands-on aspects of game programming, like texture pools, skeletal animation etc. It focussed more on writing a complete game, while the Kickstart book is more of a collection of examples on how to use the API. Too bad the final game in the book is left unfinished, guess Tom had to get it to the publisher fast ;)

Could anyone recommend a book on using HLSL in combination with Managed DirectX for creating some nice game effects? I've been trying to translate various DX/C++ examples for creating effects like shadows, glow, water etc., but the general lack of documentation of the Managed API makes this a difficult chore.

Share this post


Link to post
Share on other sites
Does the Managed DirectX 9 Kick Start book make mention of a web site?
You could try looking there... Tom Miller might have updated the code samples to work with the newer SDKs.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!