Jump to content
  • Advertisement
Sign in to follow this  
RyxiaN

HLSL lists

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

Hi! So I'm creating a world editor with Direct3D 9 and I'm working on the terrain. Currently I'm rendering the ground cursor like this in the pixel shader:

void Texture(in PS_INPUT Input, out PS_OUTPUT Output) {
...
multitexturing stuff here
...

if (ShowGroundCursor) {
float texCoords = Input.TextureCoordinates;
texCoords -= GroundCursorPosition.xz;
texCoords = mul(texCoords, RotationMatrix(GroundCursorRotation));
texCoords += GroundCursorPosition.xz;
float4 cursorColor = tex2D(CursorSampler, (texCoords * (1 / GroundCursorSize)) - (GroundCursorPosition.xz * (1 / GroundCursorSize)) + 0.5);
Output.Color.rgb += cursorColor.rgb * GroundCursorColor;
}

...
}


With this I get a nice looking cursor on the terrain like this:
HLSL_LIST_Q_01.png

Now say I wanna have more than one ground effects like this. A dynamic amount of ground effects. Mainly because I believe that some spells in games do this (Consecration Spell in World of Warcraft, Selection circles in Warcraft 3, etc). So I figured I could write some GroundEffectManager class that contains details about all the ground effects that are to be rendered, simple. But how would you send this data to the shader? I heard that loops in HLSL isn't such a good idea... This goes for several other things I have planned for, such as lights? Sometimes there might be only the sun that shines, at other places there might be a couple of torches. How do todays games handle this stuff?

Thanks in advance!

edit:

forgot to mention what the RotationMatrix function does...
float2x2 RotationMatrix(float rotation) {
float c = cos(rotation);
float s = sin(rotation);

return float2x2(c, -s, s, c);
}

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!