Code Monkey home page Code Monkey logo

Comments (5)

ivalylo avatar ivalylo commented on May 30, 2024

BC4 and BC5 are very easy to implement even if you don't know ISPC.

inline void load_block_interleaved_alpha(float block[16], uniform rgba_surface* uniform src, int xx, uniform int yy)
{
    for (uniform int y = 0; y<4; y++)
    for (uniform int x = 0; x<4; x++)
    {
        uniform uint8* uniform src_ptr = &src->ptr[min((yy * 4 + y), src->height-1)*src->stride];
        uint8* rgb = src_ptr + min((xx * 4 + x), src->width-1);

        block[y*4+x] = (int)rgb[0];
    }
}

inline void CompressBlockBC4(uniform rgba_surface src[], int xx, uniform int yy, uniform uint8 dst[])
{
	float block[16];
    uint32 data[2];

	load_block_interleaved_alpha(block, src, xx, yy);
    CompressBlockBC3_alpha(block, data);

	store_data(dst, (src->width+3)&~3, xx, yy, data, 2);
}

export void CompressBlocksBC4_ispc(uniform rgba_surface src[], uniform uint8 dst[])
{	
	for (uniform int yy = 0; yy<(src->height+3)/4; yy++)
	foreach (xx = 0 ... (src->width+3)/4)
	{
		CompressBlockBC4(src, xx, yy, dst);
	}
}

This also support non multiple of 4 textures

from ispctexturecompressor.

alecazam avatar alecazam commented on May 30, 2024

These are missing from the binary builds, and result in an incomplete BC compressor. These formats are important, and as suggested the change is small since BC3 alpha can be reused. Also the BC3 alpha compression issue reported in another Issue should be fixed prior to re-using that code for BC4/BC5.

from ispctexturecompressor.

iOrange avatar iOrange commented on May 30, 2024

Made a pull-request with BC4 and BC5 API.
#31

from ispctexturecompressor.

chloekek avatar chloekek commented on May 30, 2024

The pull request was merged. Can this be closed?

from ispctexturecompressor.

telecran-telecrit avatar telecran-telecrit commented on May 30, 2024

@tbdbj @ivalylo It applied here too https://github.com/telecran-telecrit/ISPCTextureCompressor (for BC4 and BC5).

from ispctexturecompressor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.