🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

How do I edit a texture that is already on a model in OpenGL?

Started by
21 comments, last by hplus0603 1 year, 11 months ago

Just fyi yaboiryan, you are doing this completely wrong.

https://sentarmeenunanube.blogspot.com/2019/06/what-is-splat-map.html
See the 4th image, its GroundA,B,C,D. You need an actual image. The same as you upload your grass texture,dirt texture etc as openGL textures. Upload an actual 512x512 (or bigger), image that holds Red, Green, and Blue pixels.

Your terrain pixel value = Red * texture2D(grass) + Green texture2D(dirt) + Blue * texture2D(rock)
There is no looping or anything else. You look up 4 texture2D(), and the pixel value is a mix of all 3 values blended. You can definitely at a later time add more than 3 types of terrrain, but for now you need to get rid of your uniform and you need to do this with a “Splat Map” texture.

Start with this method first, you can even edit your texture in Photoshop and just save to disk and re-run your program instead of real-time painting in the game. But if you want to paint in game, you can get that working later. For now you need the basic terrain working properly.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

Advertisement

FWIW, it's often more intuitive to use mix() (lerp) instead of add(). That way, you don't need to scale them all to sum up to 1.

blends = texture2D(splat);
outColor = mix(
  mix(
    mix(
      mix(texture2D(base), texture2D(rock), blends.r),
      texture2D(sand),
      blends.g),
    texture2D(grass),
    blends.b),
  texture2D(leaves),
  blends.a)

And, yes, this means that with a RGBA blend texture, when using mix(), you get to blend five separate layers, because you start with the bottom ("base" here) and then paint over each of the other four, each weighted by one of the channels.

enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement