## Recommended Posts

Hello everyone,
I'm currently working on my own game engine which is using direct3d for rendering, however I have no idea how to write shaders and make post-process effects.
People recommend OpenGL Shading language cookbook, but I have no idea will I be able to write shaders for direct3d with this information.
I also saw that there are DirectX ShaderX book series. Are they different editions of the same information or I have to read from shaderx1 to the last so I can keep up?

##### Share on other sites
Writing an entire engine without having any experience with shaders is really not a good idea, start with basic games before you work on a huge advanced project like an engine.

Direct3D uses a C-like language called HLSL, which is similar to the shading language GLSL used by OpenGL. Since you're talking about shaders in the context of post-processing effects I'll assume you're using fixed function pipeline functionality in D3D9 to do your 'regular' rendering, since D3D10 and beyond require you to write shaders for all your rendering tasks.

A good place to start with HLSL is the DirectX SDK, which contains a good amount of samples and tutorials on how to implement basic functionality with shaders.
I recommend you practice and experiment with shaders a lot, since they can be quite tough to wrap your head around in the beginning.
It might be a good idea to abandon the use of the fixed function pipeline altogether and force yourself to do all your rendering tasks with shaders. This will give you a much better understanding of what shaders are and what they can do.

The ShaderX books are not meant for teaching people shader programming. They contain explanations and implementation of advanced rendering techniques, so they won't be useful to you at this point. Edited by Radikalizm

##### Share on other sites
Actually I'm currently stuck only with the rendering part [img]http://public.gamedev.net//public/style_emoticons/default/tongue.png[/img]
I have already implemented Event System working with Lua, Bullet physics and scene graph. Also memory pool and resource cache, managing my memory, Loading assets from zip and custom engine format. I don't have only world editor and "proper" rendering..
Now I'm going to check the DXSDK Samples...
P.S. I actually don't have idea about any rendering teckniques. For example how to get better frame rate. Or how to render +8 lights(Maybe I can calc the most valuable lights for one object and enable them before rendering it ;/ ). Can I find everything I need in the samples or I will need external info source? Edited by Nickie

##### Share on other sites
I don't want to turn this into a 'how to build a game engine' thread, but I do hope you realize that an engine is much more than just a few systems slapped together, right?

The DXSDK samples will provide you with the basics of how to write shaders, that's pretty much it. They have advanced samples, but I've never found them to be really useful.

[quote]I actually don't have idea about any rendering teckniques. For example how to get better frame rate. Or how to render +8 lights(Maybe I can calc the most valuable lights for one object and enable them before rendering it[/quote]

Worrying about the performance of a system without having even written it is something you really shouldn't do, premature optimization mostly leads to more problems than it solves.

How your rendering system works is completely up to you. There are a lot of ways to set up a renderering system, each of them having a set of advantages and disadvantages, and each implementation of these setups can differ based on what your requirements are.
Since you're writing an engine you'll probably want to provide the option for a user to decide which setup applies to his/her needs, and add the ability for the user to implement a custom setup if required, just like you should with any other system.

The 8 lights maximum (it's actually a guaranteed minimum rather than a maximum) is a limit imposed by the fixed function pipeline, this limit does not exist in a shader-based approach where the lighting calculations are completely up to you. How lights are handled and how many lights you can include in a scene again depend on your rendering setup. There are techniques like deferred rendering and light pre-pass rendering which potentially allow for thousands of active dynamic lights in a scene while sacrificing other qualities like material variation. This is in contrast to forward rendering where you can have a huge range of materials while compromising on the amount of lights you could realistically use.

There are enough tutorials on how to build a basic shader-based rendering setup like proper forward rendering or deferred rendering, but when you get to the much more complex features a proper general purpose rendering engine should have you'll pretty much be on your own.

##### Share on other sites
working on Directx 9.0 c while running one sample error warning X3571: pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them how to solve error with which DX SDK

##### Share on other sites
[quote]I don't want to turn this into a 'how to build a game engine' thread, but I do hope you realize that an engine is much more than just a few systems slapped together, right?[/quote]
Yeah I understand it. Its actually something like hobby project, I want to prove myself I can do it(and to find out what I can't do so I can start learning it).
[quote]Worrying about the performance of a system without having even written it is something you really shouldn't do, premature optimization mostly leads to more problems than it solves.[/quote]
I found that for my personal problem. After reading so many books and everyone in them is talking abour performance. There is always one voice that is shouting in my head that I shoud do things well in favour of performance, even when I don't know how to do it. However I've have always known that this is wrong.

Also I'm not english speaker(and I'm sure u already know that) and most terms sound quite non-natural or strange in bulgarian so I can't "understand" them in my own language. I need to fully understand nature of one process so I can get what it actually mean. (for example deferred rendering... I've heard it but not image appear in my head)
However after I saw it from your reply I can now google it and find tutorial for it. Thats what I want to thank you for.

##### Share on other sites
I don't think an "engine" means what you think it means.  An engine is not related to rendering only, but to the framework that is used to create an application as a whole as well as a collection of tools for asset and content creation.

As far as learning DirectX, check the SDK documentation.  It is very helpful.  You should be comfortable with the pipeline and the different resources needed by each stages.

Also, the best book I found is Frank Luna's "Introduction to 3D Game Programming with DirectX 11".  I highly recommend it. He has intro to the linear algebra stuff you need to know and introduces the xna math library. He also goes into a lot of general techniques such as shadows / reflections using the stencil buffer, lighting, deferred rendering, SSAO, and much more. He also has a chapter dedicated to DirectCompute. By the time you finish the book, you'll have a very firm grasp on DX11.

##### Share on other sites
[quote name='french_hustler' timestamp='1343241448' post='4963025']
I don't think an "engine" means what you think it means. An engine is not related to rendering only, but to the framework that is used to create an application as a whole as well as a collection of tools for asset and content creation[/quote]

He clearly stated in his second post that he has been working on other systems besides rendering too.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
627719
• Total Posts
2978790
• ### Similar Content

• Hello! As an exercise for delving into modern OpenGL, I'm creating a simple .obj renderer. I want to support things like varying degrees of specularity, geometry opacity, things like that, on a per-material basis. Different materials can also have different textures. Basic .obj necessities. I've done this in old school OpenGL, but modern OpenGL has its own thing going on, and I'd like to conform as closely to the standards as possible so as to keep the program running correctly, and I'm hoping to avoid picking up bad habits this early on.
Reading around on the OpenGL Wiki, one tip in particular really stands out to me on this page:
For something like a renderer for .obj files, this sort of thing seems almost ideal, but according to the wiki, it's a bad idea. Interesting to note!
So, here's what the plan is so far as far as loading goes:
Set up a type for materials so that materials can be created and destroyed. They will contain things like diffuse color, diffuse texture, geometry opacity, and so on, for each material in the .mtl file. Since .obj files are conveniently split up by material, I can load different groups of vertices/normals/UVs and triangles into different blocks of data for different models. When it comes to the rendering, I get a bit lost. I can either:
Between drawing triangle groups, call glUseProgram to use a different shader for that particular geometry (so a unique shader just for the material that is shared by this triangle group). or
Between drawing triangle groups, call glUniform a few times to adjust different parameters within the "master shader", such as specularity, diffuse color, and geometry opacity. In both cases, I still have to call glBindTexture between drawing triangle groups in order to bind the diffuse texture used by the material, so there doesn't seem to be a way around having the CPU do *something* during the rendering process instead of letting the GPU do everything all at once.
The second option here seems less cluttered, however. There are less shaders to keep up with while one "master shader" handles it all. I don't have to duplicate any code or compile multiple shaders. Arguably, I could always have the shader program for each material be embedded in the material itself, and be auto-generated upon loading the material from the .mtl file. But this still leads to constantly calling glUseProgram, much more than is probably necessary in order to properly render the .obj. There seem to be a number of differing opinions on if it's okay to use hundreds of shaders or if it's best to just use tens of shaders.
So, ultimately, what is the "right" way to do this? Does using a "master shader" (or a few variants of one) bog down the system compared to using hundreds of shader programs each dedicated to their own corresponding materials? Keeping in mind that the "master shaders" would have to track these additional uniforms and potentially have numerous branches of ifs, it may be possible that the ifs will lead to additional and unnecessary processing. But would that more expensive than constantly calling glUseProgram to switch shaders, or storing the shaders to begin with?
With all these angles to consider, it's difficult to come to a conclusion. Both possible methods work, and both seem rather convenient for their own reasons, but which is the most performant? Please help this beginner/dummy understand. Thank you!

• I want to make professional java 3d game with server program and database,packet handling for multiplayer and client-server communicating,maps rendering,models,and stuffs Which aspect of java can I learn and where can I learn java Lwjgl OpenGL rendering Like minecraft and world of tanks

• A friend of mine and I are making a 2D game engine as a learning experience and to hopefully build upon the experience in the long run.

-What I'm using:
C++;. Since im learning this language while in college and its one of the popular language to make games with why not.     Visual Studios; Im using a windows so yea.     SDL or GLFW; was thinking about SDL since i do some research on it where it is catching my interest but i hear SDL is a huge package compared to GLFW, so i may do GLFW to start with as learning since i may get overwhelmed with SDL.
-Questions
Knowing what we want in the engine what should our main focus be in terms of learning. File managements, with headers, functions ect. How can i properly manage files with out confusing myself and my friend when sharing code. Alternative to Visual studios: My friend has a mac and cant properly use Vis studios, is there another alternative to it?

• Both functions are available since 3.0, and I'm currently using glMapBuffer(), which works fine.
But, I was wondering if anyone has experienced advantage in using glMapBufferRange(), which allows to specify the range of the mapped buffer. Could this be only a safety measure or does it improve performance?
Note: I'm not asking about glBufferSubData()/glBufferData. Those two are irrelevant in this case.
• By xhcao
Before using void glBindImageTexture(    GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format), does need to make sure that texture is completeness.

• 9
• 21
• 14
• 12
• 42