Skip to content
This repository has been archived by the owner on Oct 20, 2020. It is now read-only.

Adds the possibility to enable/disable StateAttribute per StateSet #258

Open
jtorresfabra opened this issue Feb 19, 2015 · 2 comments
Open

Comments

@jtorresfabra
Copy link
Collaborator

In OSG you have the possibility of disable lighting in a node via stateset mode using:

node->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF );

If I understood well, in OSG the default behaviour when no lighting is diffuse*texture + emissive. That's if the texture environment is set to MODULATE which is also the default.

If the TexEnv is DECAL then it should be texture+emissive.

@jtorresfabra jtorresfabra changed the title Add the possibility to disable lighting Add the possibility to disable lighting per stateset Feb 19, 2015
@cedricpinson cedricpinson changed the title Add the possibility to disable lighting per stateset Adds the possibility to enable/disable StateAttribute per StateSet Apr 18, 2016
@cedricpinson
Copy link
Owner

cedricpinson commented Apr 18, 2016

ON|OFF in osg is used to enable/disable a state on opengl, in opengl es 2.0 there are a few state that exists, but on the users point on view it makes sense to still control StateAttribute.


   /* EnableCap */
    const GLenum CULL_FACE                      = 0x0B44;
    const GLenum BLEND                          = 0x0BE2;
    const GLenum DITHER                         = 0x0BD0;
    const GLenum STENCIL_TEST                   = 0x0B90;
    const GLenum DEPTH_TEST                     = 0x0B71;
    const GLenum SCISSOR_TEST                   = 0x0C11;
    const GLenum POLYGON_OFFSET_FILL            = 0x8037;
    const GLenum SAMPLE_ALPHA_TO_COVERAGE       = 0x809E;
    const GLenum SAMPLE_COVERAGE                = 0x80A0;

So adding a full implementation of mode in State like osg seems a bit overkill. To keep the implementation simple, we could:

Others questions, what happens to those attributes if they can be ON|OFF

  • ShadowReceive
  • Skinning
  • Morph
  • ShadowTexture
  • Texture
  • Light
  • Material
  • Billboard

@jtorresfabra
Copy link
Collaborator Author

jtorresfabra commented Apr 19, 2016

Modifying a bit your idea... I would add the following:

  • Attributes could be associated to modes or not. ( typical case StateAttribute = BlendFunc and GLMode = BLEND )
  • GLModes should be treated separately, so they have also (ON|OFF|OVERRIDE|PROTECTED)
  • In Compiler we first check if the StateAttribute is ON | OFF, if it is ON then check if it has Modes associated. If that's true and the Mode is ON then generate the shader with this attribute active.
  • If the StateAttribute does not have modes associated then you only check if it is ON|OFF to generate the shader.
  • This way we can enable/disable modes globally or per StateSet (using ss->setMode() for example), and also enable/disable attributes.
  • Also we can have custom modes not present in GLES 2. ( For example Lighting/Texturing/etc. )

To implement this we would need to keep track of modes separately.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants