Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Cybird

using bitmap for placing objects on heightmap

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

Well, I Currently have my terrain engine working well and I''ve think of a way to put some objects on the terrain, such as roads, trees, ect. For this, I wanna use a bitmap in witch, for example, roads are painted in red, trees in greeen ect... Now, as I use a Pixel shader written in HLSL for my terrain blending operations, I wanna know how can I do this. I don''t know why this piece of code don''t work in HLSL

//Items on the map
float4 fItems = tex2D (SamplerItems, Tex);

//Grass texture
loat4 Grass = tex2D(SamplerGrass,Tex); 

//Rock texture
float4 Rock = tex2D(SamplerRock,Tex); 

//earth texture
float4 Mud = tex2D(SamplerMud, Tex);

//Snow texture
float4 Snow = tex2D(SamplerSnow, Tex);

float4 red;
red.r = 1.0f;
red.g = 0.0f;
red.b = 0.0f;
red.a = 0.0f;

//I wanna return the rock color where my infos bitmap is painted in red
if ( red==fItems )  return Rock;

float4 BlendingWeights = tex2D(SamplerBlending, Tex);

//Blending factors encoded in a texture
float a = BlendingWeights.a;
float b = BlendingWeights.r;
float c = BlendingWeights.g;
float d = BlendingWeights.b;
return (a * Snow) + (d*Grass) + (c * Mud) + (b*Rock);
 
Well it seems to be logical this way but the compiler do not accpept the line "if ( red == fItems ) return Rock; Thanx for your help!

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!