소스 검색

Update about texture export in readme.

master
Palash Bansal 2 년 전
부모
커밋
1c98b0ce8b
No account linked to committer's email address
2개의 변경된 파일19개의 추가작업 그리고 8개의 파일을 삭제
  1. 17
    8
      README.md
  2. 2
    0
      plugins/tweakpane/src/tpImageInputGenerator.ts

+ 17
- 8
README.md 파일 보기



TODO: add examples for texture export TODO: add examples for texture export


Textures and Uint8 Data Textures can be exported as a data url or copied to a new canvas
```typescript
// get a base64 data url
const dataUrl = textureToDataUrl(texture, 4096, false, 'image/png') // texture or data texture, max-size, flipY, mimeType
// or copy to a new canvas
const canvas = textureToCanvas(texture, 4096) // texture or data texture, max-size
```

Data Textures of type Half float and Float can be exported with `viewer.export`
```typescript
const dataTex = await viewer.load('https://example.com/file.hdr')
const blob = await viewer.export(dataTexture, {exportExt: 'exr'})
```
Check the example [hdr-to-exr](https://threepipe.org/examples/#hdr-to-exr/) to see a demo of HDR to EXR conversion.

TODO: add support to export unsigned byte textures as png, jpeg, webp

### Exporting Images ### Exporting Images


Exporting Textures as Images with image of types ImageBitmap, HTMLImageElement, Exporting Textures as Images with image of types ImageBitmap, HTMLImageElement,
const dataUrl = await imageBitmapToBase64(texture.image, 'image/png', 0.85); const dataUrl = await imageBitmapToBase64(texture.image, 'image/png', 0.85);
``` ```


Data Textures of type Half float and Float can be exported with `viewer.export`
```typescript
const dataTex = await viewer.load('https://example.com/file.hdr')
const blob = await viewer.export(dataTexture, {exportExt: 'exr'})
```
Check the example [hdr-to-exr](https://threepipe.org/examples/#hdr-to-exr/) to see a demo of HDR to EXR conversion.

TODO: add support to export unsigned byte textures as png, jpeg, webp
TODO: add support for texture export as images in AssetExporter TODO: add support for texture export as images in AssetExporter


### Exporting Render Targets ### Exporting Render Targets

+ 2
- 0
plugins/tweakpane/src/tpImageInputGenerator.ts 파일 보기

// } // }
if (cc.isTexture) { if (cc.isTexture) {
// console.warn('here') // console.warn('here')
// todo: use textureToCanvas for data texture
if (cc.image && !cc.image.tp_src) { if (cc.image && !cc.image.tp_src) {
if (cc.image instanceof ImageBitmap || cc.image instanceof HTMLImageElement || cc.image instanceof HTMLVideoElement) { // todo: support playback in video if (cc.image instanceof ImageBitmap || cc.image instanceof HTMLImageElement || cc.image instanceof HTMLVideoElement) { // todo: support playback in video
cc.image.tp_src = imageBitmapToBase64(cc.image, 160) cc.image.tp_src = imageBitmapToBase64(cc.image, 160)
// data texture // data texture
if (!src && tex.isDataTexture) { if (!src && tex.isDataTexture) {
if (tex.type !== HalfFloatType && tex.type !== FloatType) { if (tex.type !== HalfFloatType && tex.type !== FloatType) {
// todo: use textureToCanvas for data texture
console.error('Only Float and HalfFloat Data texture export is supported', vcv, tex, config) console.error('Only Float and HalfFloat Data texture export is supported', vcv, tex, config)
return return
} }

Loading…
취소
저장