cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

morf
Adept I

Rendermonkey: Importing submeshs with different materials...

Hi,

I understand it is an old util, but, I want to use RenderMonkey as a sandbox for shader development.

However, our models are typical game assets, so they contain many textures mapped onto submeshes.

I have trawled the documentation, but as far as I can see, RenderMonkey cant support such a feature, in that it can only have one texture per shader.

Having said that, I do explicitly express the texture sampler in my pixel shader, so maybe that is where I am going wrong?!

Is there anyway I can acheive the above?

Thanks

0 Likes
1 Solution

Update..

Ok, Im not totally sure why, but I have resolved the issue by reversing my crappy lookup.

it now reads..

if ( id>3 ) return tex2D(Texture4, uv );

if ( id>2 ) return tex2D(Texture3, uv );

if ( id>1 ) return tex2D(Texture2, uv );

if ( id>0 ) return tex2D(Texture1, uv );

return tex2D(Texture0, uv);

I will close this one

View solution in original post

0 Likes
3 Replies
plohrmann
Staff

Hello,

Although it is possible to get RenderMonkey to display multiple meshes, it was not designed to do so. It does support multiple textures for a single mesh though - take a look at the default DirectX effect called "Multiple Render Targets". The first pass will render two different textures, and the second pass applies these two textures to the surface of the teapot. Once you have a pass, you can right-click on the pass node and "Add Texture Object" which will add a sampler to a texture.

I hope that helps,

Peter

0 Likes

Hi, creating multiple passes was not something I wanted to do, as I simply wanted a drag and drop solution, that would apply the same shaders.

I did try a different approach(albeit ugly) where I pass a texture ID in on the PS input

struct VS_OUTPUT

{

   float4          position : POSITION0;

   float3          normal : TEXCOORD0;

   float2          uv : TEXCOORD1;

   int4          texture_id : TEXCOORD2;

};

Then, I have the ugly routine..

float4 get_diffuse( int id, const float2 uv )

{

    if ( id<1 ) return tex2D(Texture0, uv);

   if ( id<2 ) return tex2D(Texture1, uv);

   if ( id<3 ) return tex2D(Texture2, uv);

   if ( id<4 ) return tex2D(Texture3, uv);

   if ( id<5 ) return tex2D(Texture4, uv);

   return float4(1,0,1,1);

}

However, the logic of this works fine, but depending on the render position, the id changes, which I have yet to fathom.

Even if I ensure the VShader sets it to the same value for every vertex, I still get wieird noise.

I presume, some sort of interpolation is happening, but I cannot fathom why, as the values are the same.

Currently debugging the PS shaders in PIX to try and work it out.

Would the above approach actually ever work?

0 Likes

Update..

Ok, Im not totally sure why, but I have resolved the issue by reversing my crappy lookup.

it now reads..

if ( id>3 ) return tex2D(Texture4, uv );

if ( id>2 ) return tex2D(Texture3, uv );

if ( id>1 ) return tex2D(Texture2, uv );

if ( id>0 ) return tex2D(Texture1, uv );

return tex2D(Texture0, uv);

I will close this one

0 Likes