Thread: "Better" Texture Rendering

Page 1 of 3 123 LastLast
Results 1 to 10 of 27
  1. #1 "Better" Texture Rendering 
    nice


    Join Date
    Jul 2014
    Posts
    740
    Thanks given
    382
    Thanks received
    562
    Rep Power
    4239
    This tutorial will show how u can make ur texture rendering look much nicer with little to no effort.
    This applies to OSRS, 317 and probably < 500 revs, when i use the term "rs renderer" i am referring to the renderer used in the 317/osrs client

    So, the rs renderer clamps/stretches texture coordinates when rendering a textured triangle, which means that if the coordinate is out of bounds(0-1 or if it's easier to think of, 0-4095 for a 64x64 texture) it'll simply be given the edge color
    If you looked at the rasterizer in the client, you may have seen something like this:
    Code:
    				if (u < 0) {
    					u = 0;
    				} else if (u > 4032) {
    					u = 4032;
    				}
    which clamps the u(x) coordinate, now instead of clamping u would ideally want to repeat the texture, which means that once it goes out of bounds, it starts from 0, for example if you have the following texture coordinates
    u = 1.2
    v = 1.45
    they become 0.2 and 0.45 when you repeat the texture.

    This is very simple to implement, also lets make it toggleable

    1) Open the Graphics3D/Rasterizer class(whatever it's called in ur client) and create a new variable called repeatTexture
    2) Open the Model class, create a new boolean array called repeatTexture and make sure to initialize it properly in the model constructors, merge method
    3) find the method that calls the triangle drawing methods(could be called rasterize or something) and add the following lines(put them after the triangle alpha check for example, just has to be before the draw calls):
    Code:
                if (repeatTexture == null) {
                    Rasterizer.repeatTexture = false;
                } else {
                    Rasterizer.repeatTexture = repeatTexture[face];
                }
    4) Open the Graphics3D/Rasterizer class and find the textured scanline drawing method could be called something like drawTexturedScanline, find the parts that clamp the coordinate
    Code:
    				if (u < 0) {
    					u = 0;
    				} else if (u > 4032) {
    					u = 4032;
    				}
    and replace it with
    Code:
                    if (!repeatTexture) {
                        if (u < 0) {
                            u = 0;
                        } else if (u > 4032) {
                            u = 4032;
                        }
                    }
    the same for 128x128 textures, instead of 4032 it's 16256, and now the final part, just before you store the pixel, repeat it by AND'ing it with 4095, 16383
    Example:
    Code:
                            if (repeatTexture) {
                                raster[offset] = texels[(vA & 0x3f80) + (uA >> 7) & 16383] >>> lightness;
                            } else {
                                raster[offset] = texels[(vA & 0x3f80) + (uA >> 7)] >>> lightness;
                            }
    this was extremely simple, wasn't it(NOTE: this makes the textures a little brighter, so u need to account for that if u don't want it to be this way, however imo it looks better)? now let me show some before vs after images/gifs

    Spoiler for Before:

    Attached image
    Attached image
    Attached image
    Attached image
    Attached image


    Spoiler for After:

    Attached image
    Attached image
    Attached image
    Attached image
    Attached image


    those are just a few examples, the main benefit of this is that u don't have to worry about the coordinates going out of bounds when u define the texture coordinates, this has saved me a lot of time(from spending 15-30mins or sometimes even longer for a nice textured model, it now takes 1-2mins and looks really good)
    NOTE: this does not decrease the performance at all
    Attached image
    Reply With Quote  
     


  2. #2  
    Registered Member
    rebecca's Avatar
    Join Date
    Aug 2017
    Posts
    1,071
    Thanks given
    862
    Thanks received
    915
    Rep Power
    5000
    seen so many servers (clients) with this problem, ty soic
    Reply With Quote  
     

  3. Thankful users:


  4. #3  
    Extreme Donator

    Benneh's Avatar
    Join Date
    Nov 2015
    Posts
    199
    Thanks given
    133
    Thanks received
    102
    Rep Power
    464
    Nice stuff suic
    Quote Originally Posted by Corey View Post
    Vouch for Benneh

    Worked with him for a month. He's professional and always on time with posts, always interested in how the server is doing and how he can can improve and help in any way.
    Reply With Quote  
     

  5. Thankful user:


  6. #4  


    Omar's Avatar
    Join Date
    Dec 2007
    Posts
    279
    Thanks given
    640
    Thanks received
    783
    Rep Power
    5000
    would rep but need to rep 25 people :uhm:
    Attached image
    Reply With Quote  
     

  7. Thankful user:


  8. #5  
    nice


    Join Date
    Jul 2014
    Posts
    740
    Thanks given
    382
    Thanks received
    562
    Rep Power
    4239
    Quote Originally Posted by Omar View Post
    would rep but need to rep 25 people :uhm:
    hopefully it'll get changed back to 10 soon™
    Attached image
    Reply With Quote  
     

  9. Thankful user:


  10. #6  
    Donator

    TeJay's Avatar
    Join Date
    Jul 2017
    Posts
    630
    Thanks given
    217
    Thanks received
    283
    Rep Power
    1754
    Very nice work.
    Attached image
    Spoiler for Services:
    Attached image
    Reply With Quote  
     

  11. Thankful user:


  12. #7  
    plz dont take my wizard mind bombs Women's Avatar
    Join Date
    Mar 2010
    Posts
    1,881
    Thanks given
    724
    Thanks received
    1,162
    Rep Power
    4763
    contributor caught contributing, nice suic
    Reply With Quote  
     

  13. Thankful users:


  14. #8  
    ᗪ乇尺乇乙乙乇ᗪ

    lumplum's Avatar
    Join Date
    Nov 2015
    Posts
    1,145
    Thanks given
    529
    Thanks received
    1,463
    Rep Power
    5000
    tyvm thesuic12 very nice
    Attached image
    Reply With Quote  
     

  15. Thankful users:


  16. #9  
    🎶 As you're falling down 🎶


    uint32_t's Avatar
    Join Date
    Feb 2015
    Posts
    1,396
    Thanks given
    6,177
    Thanks received
    776
    Rep Power
    5000
    Nice contribution
    Quote Originally Posted by Idiot Bird View Post
    Quote Originally Posted by Velocity View Post
    lol np mate looks like the community brought ur rep down to ur IQ
    Not too sure about that, it's at 0 . It would have to go minus to even be remotely close to his IQ.
    Reply With Quote  
     

  17. Thankful user:


  18. #10  
    08-13, SpawnScape Owner

    jet kai's Avatar
    Join Date
    Dec 2009
    Age
    28
    Posts
    870
    Thanks given
    630
    Thanks received
    957
    Rep Power
    5000
    that lava dragon model looks sooo cooool! is that custom or osrs?
    Reply With Quote  
     

  19. Thankful user:


Page 1 of 3 123 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. [718] Texture Rendering
    By Mateo in forum Help
    Replies: 2
    Last Post: 07-20-2016, 06:52 AM
  2. Replies: 5
    Last Post: 10-22-2011, 05:27 PM
  3. [PI] Better NPC Quotes/Shouts
    By MrClassic in forum Snippets
    Replies: 12
    Last Post: 09-03-2011, 07:13 PM
  4. Replies: 11
    Last Post: 02-15-2008, 10:13 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •