Code Monkey home page Code Monkey logo

Comments (9)

vorg avatar vorg commented on September 23, 2024

Which reminds me of #310 Consider renaming maps to textures which would cause

uBaseColorMap
uBaseColorMapTexCoordTransform

uBaseColorTexture
uBaseColorTextureTransform //yay!

from pex-renderer.

dmnsgn avatar dmnsgn commented on September 23, 2024

So new components will look like that:

// basic
const material = {
  baseColorTexture: texture
};

// or with transform
const material = {
  baseColorTexture: {
     texture,
     transform: textureTransform
  }
};

Fine by me. Renaming in pex-shaders is needed as well yes, so that's a big breaking change where we need to be careful with VSCode search & replace.

from pex-renderer.

vorg avatar vorg commented on September 23, 2024

Well it's actually not that simple as transform in KHR_texture_transform is an object with offset, rotation and scale and not a matrix so it could be confusing.

So it would have to baseColorTexture.transformMatrix (still shorter) and uBaseColorTextureTransformMatrix

from pex-renderer.

dmnsgn avatar dmnsgn commented on September 23, 2024

At the moment, materials texture.texCoordTransformMatrix is not set directly. Instead, the more user friendly texture.offset/rotation/scale is used and the matrix only computed on set(). So you can either provide:

  • { texture, offset?, rotation?, scale? }
  • { texture, texCoordTransformMatrix }

The three questions:

  • is renaming texCoordTransformMatrix to transformMatrix okay
  • can we still allow texture.offset/rotation/scale and compute texture.transformMatrix in material system (render-pipeline?)
  • can we animate update these properties at runtime, if so, how do you tell texture.transformMatrix to be recomputed?

from pex-renderer.

vorg avatar vorg commented on September 23, 2024

Instead, the more user friendly texture.offset/rotation/scale is used

Is it? :D I thought all we have is texCoordTransformMatrix

is renaming texCoordTransformMatrix to transformMatrix okay

Yes

can we still allow texture.offset/rotation/scale and compute texture.transformMatrix in material system (render-pipeline?)

How to name and pack given uniforms is up to renderer. Are there any other use cases for Material System? As of now the most appropriate place is standard material.

can we animate update these properties at runtime, if so, how do you tell texture.transformMatrix to be recomputed?

Are we thinking arcade game scrolling textures here? :)

from pex-renderer.

dmnsgn avatar dmnsgn commented on September 23, 2024

Instead, the more user friendly texture.offset/rotation/scale is used

Is it? :D I thought all we have is texCoordTransformMatrix

Yep, here we compute the matrix:

pex-renderer/material.js

Lines 122 to 134 in 5cced07

if (map && map.texture) {
mat2x3.identity(tempMat2x3)
mat2x3.translate(tempMat2x3, map.offset || [0, 0])
mat2x3.rotate(tempMat2x3, -map.rotation || 0)
mat2x3.scale(tempMat2x3, map.scale || [1, 1])
map.texCoordTransformMatrix = mat3.fromMat2x3(
map.texCoordTransformMatrix
? mat3.identity(map.texCoordTransformMatrix)
: mat3.create(),
tempMat2x3
)
}

can we still allow texture.offset/rotation/scale and compute texture.transformMatrix in material system (render-pipeline?)

How to name and pack given uniforms is up to renderer. Are there any other use cases for Material System? As of now the most appropriate place is standard material.

No but maybe in a shared space if basic renderer or any other wants to use textures and texture transform?

can we animate update these properties at runtime, if so, how do you tell texture.transformMatrix to be recomputed?

Are we thinking arcade game scrolling textures here? :)

Thinking texture spritesheet or something ;)

from pex-renderer.

vorg avatar vorg commented on September 23, 2024

Oh that's leftover code that has not been ported yet. The thing with material system is that renderers are building materials atm. And texture matrix update system would have to know all possible texture names or sniff for objects with texture property in material components, not optimal.

My plan for standard material was to support all possible 2d/3d mesh like scenarios that would involve textures and where texture transforms make sense. Other renderers like particles/lines/trails would less. Although i see usecase for spritesheets in those. Will it be full matrix with translate rotate scale though? Or rather offset, size as vec4? Just don't want to force generalization that is not there.

from pex-renderer.

vorg avatar vorg commented on September 23, 2024

Update.

Given that we udate uBaseColorMap to uBaseColorTexture we would end up with uBaseColorTextureTexCoordTransform so maybe we should rename this too to uBaseColorTextureTransformMatrix and following material prop:

const material = {
  baseColorMap: {
     texture: texture,
     transformMatrix: mat3
  }
}

from pex-renderer.

dmnsgn avatar dmnsgn commented on September 23, 2024

Suggested naming:

const material = {
  baseColorTexture: {
     texture: texture,
     matrix: mat3,
     texCoord: int,
  }
}

uniform mat3 uBaseColorTextureMatrix;

Flags:
USE_BASE_COLOR_TEXTURE
USE_BASE_COLOR_TEXTURE_MATRIX
BASE_COLOR_TEXTURE_TEX_COORD

from pex-renderer.

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.