Graphics Emulated Mipmapping Support for shaders

hamdrax24

Member
GM Version: gm1.4
Target Platform: Windows(shader in hlsl)
Download: https://drive.google.com/open?id=0B9GpO3R0buCHVW5RenNNMGM3dG8
Links: N/A

Summary:
This function allows for mipmapping in the pixel shader by using a script to create a mipmap texture and a shader function to sample the texture to find the appropriate texture.

Tutorial:
The first thing we have to do is to is to create our mipmaptexture from our original image; we use a script to that draws the image repeatedly according to the defined mipmaplevel in a different position and scale until it look something like this:
https://drive.google.com/open?id=0B9GpO3R0buCHc0ZfZnVVTFFieUk
we then save it into a surface with twice the width but the same height as the image;
https://drive.google.com/open?id=0B9GpO3R0buCHc0ZfZnVVTFFieUk
With that out of the way all we now need is to change how we sample the texture, with the function "get_mipmap_texcoord" in the shader "mipmap" we can sample each level of the mipmaptexture to get the image on the defined mipmaplevel (note: the mipmaplevel is passed as an argument in the sampler;function; 0.0 is for original texture)

Because the process is emulated there are some problems that would occur, i will address these problems later on but for now i advice you stick to mipmaplevel 0.0-2.0;
 

Attachments

Top