Thread: "Better" Texture Rendering

Page 1 of 2 12 LastLast
Results 1 to 10 of 19
  1. #1 "Better" Texture Rendering 
    nice


    Join Date
    Jul 2014
    Posts
    667
    Thanks given
    293
    Thanks received
    344
    Discord
    View profile
    Rep Power
    2952
    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:








    Spoiler for After:








    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
    Reply With Quote  
     


  2. #2  
    what the dog doin

    mikan's Avatar
    Join Date
    Aug 2017
    Posts
    938
    Thanks given
    707
    Thanks received
    746
    Discord
    View profile
    Rep Power
    4941
    seen so many servers (clients) with this problem, ty soic
    Reply With Quote  
     

  3. Thankful users:


  4. #3  
    Royal-PS Management


    Join Date
    Nov 2015
    Posts
    174
    Thanks given
    111
    Thanks received
    80
    Discord
    View profile
    Rep Power
    431
    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  
    Mikan Fanboy



    Omar's Avatar
    Join Date
    Dec 2007
    Posts
    222
    Thanks given
    434
    Thanks received
    608
    Discord
    View profile
    Rep Power
    4799
    would rep but need to rep 25 people :uhm:
    [Only registered and activated users can see links. ]

    Spoiler for aaaa:




    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  7. Thankful user:


  8. #5  
    nice


    Join Date
    Jul 2014
    Posts
    667
    Thanks given
    293
    Thanks received
    344
    Discord
    View profile
    Rep Power
    2952
    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™
    Reply With Quote  
     

  9. Thankful user:


  10. #6  
    ✥Augury RSPS - Soon✥

    TeJay's Avatar
    Join Date
    Jul 2017
    Posts
    613
    Thanks given
    199
    Thanks received
    263
    Discord
    View profile
    Rep Power
    1450
    Very nice work.
    [Only registered and activated users can see links. ]
    Spoiler for Services:
    [Only registered and activated users can see links. ]

    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  11. Thankful user:


  12. #7  
    touched like seafood
    Women's Avatar
    Join Date
    Mar 2010
    Posts
    1,832
    Thanks given
    654
    Thanks received
    1,013
    Discord
    View profile
    Rep Power
    3151
    contributor caught contributing, nice suic


    When you ape the cops it ain't anarchy
    Reply With Quote  
     

  13. Thankful users:


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

    lumplum's Avatar
    Join Date
    Nov 2015
    Posts
    1,124
    Thanks given
    491
    Thanks received
    1,384
    Discord
    View profile
    Rep Power
    5000
    tyvm thesuic12 very nice
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  15. Thankful users:


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

    uint32_t's Avatar
    Join Date
    Feb 2015
    Posts
    1,355
    Thanks given
    5,812
    Thanks received
    666
    Discord
    View profile
    Rep Power
    3846
    Nice contribution
    [Only registered and activated users can see links. ]

    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
    25
    Posts
    757
    Thanks given
    405
    Thanks received
    403
    Discord
    View profile
    Rep Power
    2160
    that lava dragon model looks sooo cooool! is that custom or osrs?
    [Only registered and activated users can see links. ]

    [Only registered and activated users can see links. ]

    [Only registered and activated users can see links. ]

    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  19. Thankful user:


Page 1 of 2 12 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. Odd texture rendering
    By Technotik in forum Help
    Replies: 9
    Last Post: 01-15-2019, 10:02 AM
  2. [718] Texture Rendering
    By Mateo in forum Help
    Replies: 2
    Last Post: 07-20-2016, 06:52 AM
  3. Replies: 5
    Last Post: 10-22-2011, 05:27 PM
  4. [PI] Better NPC Quotes/Shouts
    By MrClassic in forum Snippets
    Replies: 12
    Last Post: 09-03-2011, 07:13 PM
  5. 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
  •