best way to use ID3DXEffect and textures.

Started by
3 comments, last by Guimo 18 years, 7 months ago
ShaderA: texture ambient; texture bumpmap; texture pecular; ObjectA uses ShaderA where I set the textures and render with the effect ObjectB uses ShaderA where I set the textures and render with the effect OR ShaderA: texture ambient = "metal_a.png"; texture bumpmap = "metal_b.png"; texture specular = "metal_s.png"; ShaderB: texture ambient = "stone_a.png"; texture bumpmap = "stone_b.png"; texture specular = "stone_s.png"; ObjectA uses ShaderA render with the effect ObjectB uses ShaderB render with the effect so ShaderA and ShaderB are EXACTLY the same effect but have different textures. Is it better to have more of the same effects or use the same effect but set the textures everytime!? The 1st situation result in more Effect->SetTestures() and the 2nd one will have more Effects loaded.
Advertisement
I think it is better to set the texture, because if you duplicate a lot of effect files, it will become a maintenance nightmare.
-----Quat
In general, setting new effects is more expensive than setting new textures.

You could use a single shader that did not specify any particular textures to load. Instead, it could use annotations and semantics to indicate which variables in the shader are to be used as diffuse, specular, and bumpmap samplers, respectively.

Then for each mesh that you're trying to render, the application could set the different textures of that mesh to the appropriate variables in the shader by using the annotations and semantics from the shader.

neneboricua
ah that means I have it already the correct way, thx guys :)
Let me tell that is not an easy question.

Your first option is more appropiate for games. It is an open model where the app can access the variables inside the shader. It corresponds to the DXSAS 0.8 model.

The second option is a closed model that corresponds to the DXSAS 1.0 model and is harder to use.

The idea in SAS 0.8 is that the programmer can acces the shaders and modify its values. That means the artist maybe wont get the result he expected for his model in his 3D app (be it Max, Maya, XSI). A green may look like a yellow or a texture won't be appropiate. This model gives controll to the programmer.

The idea in SAS 1.0 is that the artist can create a package with a model and design the effects as he wants them to look. The host app can load the model and provide lights, cameras, time and rendertargets. But it just can't access the shader attributes. That means you will need a different and specific shader for each model (not each object). The advantages is that the model will always look as the artist expected. And the artist is the one that will decide your presentation so thats important.

So, I think you should select which model you want to support. Power to the artist or to the programmer?

Luck!
Guimo


This topic is closed to new replies.

Advertisement