Author Topic: Shader limitation  (Read 3824 times)

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Shader limitation
« on: May 05, 2013, 12:08:57 pm »
In javadoc for GLSLShader class are mentioned four texture layers, but most of newer mobile GPUs support 8 texture units. Is supported more than four texture units?
What is maximal length of arrays in shader? In javadoc are arrays with length of 8. Is it maximal size? When I set array length of 16, will I get 16 positions of lights?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Shader limitation
« Reply #1 on: May 05, 2013, 08:18:21 pm »
...but most of newer mobile GPUs support 8 texture units.
Sure? At least the Adreno 320 still reports 4 for GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS. Support for more units is kinda build-in, but has never been activated or tested. Even most desktop gpus don't support more, so i fail to see the point somehow to bother with that ATM.
What is maximal length of arrays in shader? In javadoc are arrays with length of 8. Is it maximal size? When I set array length of 16, will I get 16 positions of lights?
Regarding lights, you have 8 available (because there are 8 hardware lights in ES 1.x). If you write your own shader, you can set as many lights as you want. Where in the docs am i talking about a limit of 8 for an array's length? I can't anything like that... ???

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: Shader limitation
« Reply #2 on: May 06, 2013, 12:31:47 pm »
I probably looked at another number, maybe at texture processor units. No, but every array for light is length of 8 (ex. uniform vec3 lightPositions[8]). Ok, thanks for info.
« Last Edit: May 06, 2013, 02:45:26 pm by Thomas. »

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: Shader limitation
« Reply #3 on: May 06, 2013, 03:06:01 pm »
...If you write your own shader, you can set as many lights as you want...
Are you sure? More than 8 lights do not work (9th light does nothing)
« Last Edit: May 06, 2013, 03:19:34 pm by Thomas. »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Shader limitation
« Reply #4 on: May 06, 2013, 04:12:50 pm »
That's not what i meant. If you rely on jPCT's light implementation, 8 is the limit (per object, you can have more in the scene). If you want to use more, you have to manage them yourself in your own data structures and uniforms.

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: Shader limitation
« Reply #5 on: May 06, 2013, 05:21:44 pm »
OK, I just do not like, when is anything in my code limited from unknown reasons (I have to also limit number of lights in shader). Anyway, more than 8 per-pixel lights are to expensive for mobile devices, but if I ever need more, I can simple manage myself.

edit: You probably know how I generate light shader. Will be faster (+0.5ms) if I manage lights myself? I need to speed up the rendering process. Real map is running on SGS3 about 40fps and on Tegra3 and other lower devices it is unplayable...
« Last Edit: May 06, 2013, 08:56:25 pm by Thomas. »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Shader limitation
« Reply #6 on: May 06, 2013, 09:22:40 pm »
edit: You probably know how I generate light shader. Will be faster (+0.5ms) if I manage lights myself?
I see no reason, why it should be any faster...