Code Monkey home page Code Monkey logo

Comments (14)

vorg avatar vorg commented on May 28, 2024

It would make it more clear what's happening as instanced color is multiplied by base color.
I call it tint in glsl anyway https://github.com/pex-gl/pex-renderer/blob/master/glsl/PBR.frag#L1411

from pex-renderer.

vorg avatar vorg commented on May 28, 2024

currently we have

renderer.geometry({
  positions: [],
  normals: [],
  vertexColors: []
  offsets:  { data: [], divisor: 1 },
  colors: { data: [], divisor: 1 }
})
renderer.geometry({
  positions: [],
  normals: [],
  colors: []
  offsets:  { data: [], divisor: 1 },
  tints: { data: [], divisor: 1 }
})

from pex-renderer.

vorg avatar vorg commented on May 28, 2024

Another reason to use colors not vertexColors is glTF vertex color attribute is named COLOR_0 https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#meshes

from pex-renderer.

vorg avatar vorg commented on May 28, 2024

Added this to 3.0.0 milestone as it's breaking and we change it now or never..

Still undecided on the tints name though. Probably better than instanceColors though.

from pex-renderer.

dmnsgn avatar dmnsgn commented on May 28, 2024

Yes, that's probably going to be formalised in glTF 3.0. Meanwhile I am also undecided.
instanceColors is more explicit but that means than anything that is instanced should follow the convention.

from pex-renderer.

vorg avatar vorg commented on May 28, 2024

@dmnsgn any updates on that? e.g. progress of gltf discussion or maybe we should do research how babylon or three.js are naming things

from pex-renderer.

vorg avatar vorg commented on May 28, 2024

ThreeJS is actually vertexColors and instanced colors and offsets https://github.com/mrdoob/three.js/blob/master/examples/webgl_buffergeometry_instancing.html#L153

BabylonJS seem not to have instanced color support?
https://doc.babylonjs.com/how_to/how_to_use_instances

from pex-renderer.

vorg avatar vorg commented on May 28, 2024

I would propose that unless we are willing to use instance* prefix we should close those issue and wait for GLTF to clarify.

geometry.set({
   positions: [],
   normals: [],
   vertexColors: [],
   offsets: [],
   scales: [],
   rotations: [],
   colors: []
})

vs 

geometry.set({
   positions: [],
   normals: [],
   colors: [],
   instanceOffsets: [],
   instanceScales: [],
   instanceRotations: [],
   instanceColors: []
})

from pex-renderer.

dmnsgn avatar dmnsgn commented on May 28, 2024

I agree. What's your gut feeling about instance* prefix? I am leaning toward this option as it makes it really explicit.

from pex-renderer.

vorg avatar vorg commented on May 28, 2024

One thing about instance* prefix is that it would make it clear what's supported and what's instanced. We could then drop the requirement for { divisor: 1 } as it would be redundant.

The question is though: do we want to support custom (instanced or not) attributes as we have custom shaders? There are generally 3 options:

  • you add way to add arbitrary attribute
  • you hack your data into know attributes (if you have custom shader you can write custom handling)
  • we add data_0, data_1, data_2, data_3 attributes

Writing this here just for reference because I think we should strive to do minimum work and not implement any of the above yet.

from pex-renderer.

vorg avatar vorg commented on May 28, 2024

@dmnsgn @simonharrisco if we go ahead with this:

geometry.set({
   positions: [],
   normals: [],
   colors: [],
   instanceOffsets: [],
   instanceScales: [],
   instanceRotations: [],
   instanceColors: []
})

Then is it still this:

geometry.set({
 instanceOffsets: { data: [], divisor: 1 }
})

or is this now also (or only) valid:

geometry.set({
 instanceOffsets: [] // divisor is assumed as this is instanced attribute and defaults to 1
})

https://github.com/pex-gl/pex-renderer/blob/master/geometry.js#L106

this is similar to allowing both:

geometry.set({
 positions: { buffer: {}, offset: N, string: M }
})
geometry.set({
 positions: []
})

from pex-renderer.

vorg avatar vorg commented on May 28, 2024

Good thing is all old examples will throw "unknown attribute" if we try to set e.g. offset https://github.com/pex-gl/pex-renderer/blob/master/geometry.js#L111

That will be easy to spot and fix instead of silent errors.

from pex-renderer.

simonharrisco avatar simonharrisco commented on May 28, 2024
geometry.set({
 instanceOffsets: [] // divisor is assumed as this is instanced attribute and defaults to 1
})

Seems more user friendly and feels nice with the other properties

from pex-renderer.

vorg avatar vorg commented on May 28, 2024

To complicate things glTF uses TRANSLATION, ROTATION, and SCALE in EXT_mesh_gpu_instancing and doesn't support color or material properties as of today.

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.