Code Monkey home page Code Monkey logo

nvtt_samples's Introduction

NVTT 3 Samples

This repository contains a number of samples showing how to use NVTT 3, a GPU-accelerated texture compression and image processing library.

This includes several small samples intended as tutorials:

  • mini_bc7 shows how to load an image and turn it into a one-mipmap DDS file using BC7 block compression. It's small enough that it can be rewritten in 250 characters (without error checking):
#include<nvtt/nvtt.h>
int main(int n,char**v){if(n==3){nvtt::Surface i;i.load(v[1]);nvtt::Context c(1);nvtt::CompressionOptions o;o.setFormat(nvtt::Format_BC7);nvtt::OutputOptions p;p.setFileName(v[2]);c.outputHeader(i,1,o,p);c.compress(i,0,0,o,p);}}
  • mipmap shows how to generate mipmaps from an image, and describes linear-space filtering and premultiplied alpha.
  • cuda_input shows how to use NVTT 3's low-level GPUInputBuffer API to compress a texture directly from a GPU buffer. This API accelerates compression by avoiding CPU-GPU data transfers.
  • c_wrapper_demo shows how to use NVTT 3's C wrapper, which allows other compilers and programming languages to use NVTT 3. It covers the high-level and low-level APIs.
  • to_slope_space shows how to use nvtt::Surface::channel(). It converts a normal map to a slope-space BC5 normal map.

This also includes the source code for several tools from NVTT 3 ported to use the nvpro-samples framework, which show how to use almost all of the functionality in NVTT 3:

  • compress is a general command-line tool for compressing images to DDS files, and uses similar flags as the Texture Tools Exporter's command-line interface. It supports many types of images, including normal maps. It can also compress multiple files at once (the batchCompress tool was merged into it in June 2023)
  • decompress decompresses DDS files to other formats.
  • imgdiff reports error metrics between image files.

For comprehensive API documentation, please see the docs/ folder in the NVTT 3 distribution.

Build Instructions

To build these samples, you'll need the NVTT 3 SDK. For cuda_input, you'll also need the CUDA Toolkit. Then do one of the following:

You can then use CMake to generate and subsequently build the project.

nvtt_samples's People

Contributors

mklefrancois avatar nbickford-nv avatar nvmheyer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nvtt_samples's Issues

Program crashes when trying to open some types of DDS textures

I wanted to modify the game Witcher 3, and faced with the fact that some textures dds format does not open. Perhaps the implementation of the image itself is proprietary, and to you should not be a claim. But at least the program should report that it does not support this type of images. And not a stupid pop up. (When you try to open goes noise on the speakers).

There are textures in the link:
Texture 'alnus.dds' (Diffuse) opens without problems (NVTT is probably the only software that opens it)

Texture 'alnus_n.dds' (Normal Map) and 'alnus_s.dds' (Specular) do not open, the program crashes when trying to open them. Maybe it has something to do with sRGB modes ? It is possible that another program that pulls textures from the game, breaks the texture.

https://drive.google.com/drive/folders/1Esy2ZBMjccM790nux28qR2l5eomjL9g7?usp=sharing

In file nvtt_samples/compress/compress.cpp std::path is used wrongly

In file nvtt_samples/compress/compress.cpp std::path is used wrongly

See line 410
output = input.replace_extension("dds");

replace_extension modifies the @input and as a result the program doesn't work with non-explicit output file:

Replacing the line with:
output = input;
output.replace_extension("dds");

fixes the issue

Something wrong with the alpha channel

I used the compress code to compress a png file. After I got the dds file I put it into photoshop which has got plugin nvidia-texture-tools-exporter and found that some alpha channels were wrong.

This is the original png file. It is round-bordered.
3011000_best

This is the dds image, which I have transferred to png format with photoshop.
3011000_best_dds

the arguments are
-astc_ldr_6x6 3011000_best.png

It looks like that every 6 by 6 block share the same alpha channel.

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.