Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Nyssa

Member Since 08 Nov 2007
Offline Last Active Apr 05 2013 06:28 PM
-----

Posts I've Made

In Topic: normal mapping gpu particles ?

15 March 2013 - 07:06 PM

Have you got textured particles working first? I'll assume you have....

 

If you haven't already tried normal mapping, a quick google search for "normal map directx" will turn up alot of working normal mapping example to get you started on normal mapping a regular mesh.

 

After that, creating normal mapped particles is a simple extension of this. Your particle vertices and texture coordinates are made up from something similar to:

float2 textureCoords[4] = {float2(0.0, 0.0), float2(1.0, 0.0), float2(1.0, 1.0), float2(0.0, 1.0)};
float2 cornerPosition[4] = {float2(-0.5, 0.5), float2(0.5, 0.5), float2(0.5, -0.5), float2(-0.5, -0.5)};

 

You would transform each particles cornerPosition into world space.Tangents (for normal mapping) for your vertices can be created using the tutorial here. The surface normal for each particle will always need to be in the direction of the light source I think (surfaceNormal = normalize(lightPos - particlePos);). 


In Topic: Help with CGFX

05 March 2013 - 04:09 AM

 Is there any benefit (other than the fact I can use techniques and passes) of using effects instead of the individual programs

 

Not that I know of. I personally use programs rather than effects. I guess the downside is you need to do all the state changes manually, but you're doing that already anyway.


In Topic: Help with CGFX

05 March 2013 - 03:16 AM

  It is sad though, that CG is not able to output an effect file as DX bytecode

 

cgD3D10GetCompiledProgram will return a ID3D10Blob object. From that object you can call GetBufferPointer and that will be the compiled code for a program. It is that data that you pass into say ID3D10Device::CreateVertexShader to create your shadersIf you're after the whole effect file as byte code then I don't think cg will do that (or directx for that matter).

 

 requires you to use their runtime instead of DX's

 

If you can do without effects and just use programs, then you could also compile these shaders in an offline mode and save the compiled data to file. That way your runtime engine could just use dx libs instead of cg? Runtime loading would also be a bit faster. Of course though you would need to check that all this works with the cross-platformness of your engine.


In Topic: Help with CGFX

05 March 2013 - 01:28 AM

cgD3D10GetCompiledProgram is suppose to return the compiled shader code. You might be right in that you could loose technique information. You may also loose any data that was compiled out.

 

I had ALOT of issues with using cg in a similar situation to yours. Kept hitting a limitation with cg, made a work around for it then hit another limitation....this went on for a while. In the end I used HLSL2GLSL. It was made for dx9 and pre ogl3 but the source is available so you can modify it to work with dx10 and suit your own needs. There is also an updated forked version made for unity so that might be worth checking out too.


In Topic: read a texture with directx 10 in c++

27 February 2013 - 06:07 PM

This page has an example of reading a texture from the CPU side.


PARTNERS