10 Sep 2013, 8:26
Thank you very much!
Sample is perfectly organised to understand.
Everything is clear except shader parameters binding and multiple programs.
1. Shader parameters (questions are inlined):
From vertex shader
// This part came probably from engine
// What uniform parameters does engine set ?
// How to change them from code ?
// Is it possible to add our own uniform parameters ?
// Is it possible to process multiple lights with vector of uLightPosition
uniform mat4 uModelMatrix;
uniform mat4 uCameraViewMatrix; uniform mat4 uCameraViewProjectionMatrix;
uniform vec4 uLightPosition[2];
//This part came from line 368-372
// geom->AddAttribute(...) API
attribute vec4 aPosition;
attribute vec3 aNormal;
attribute vec3 aBinormal;
attribute vec3 aTangent;
attribute vec2 aTexCoord0;
// Fragment shader
// From where this uniform parameters were set ?
// Why lighting uniforms are arrays of 2 while only first element was used ?
uniform lowp vec4 uLightColorAmbient[2];
uniform lowp vec4 uLightColorDiffuse[2];
uniform lowp vec4 uLightColorSpecular[2];
uniform highp vec4 uLightAttenuation[2];
// This part came from IFixedParameters line 311-315
uniform lowp vec4 uMaterialColorAmbient;
uniform lowp vec4 uMaterialColorDiffuse;
uniform lowp vec4 uMaterialColorSpecular;
uniform mediump float uMaterialShininess;
// This part came from 278, 284, 290 by SetUnit(...) API
uniform lowp sampler2D uTexture0; // Diffuse color
uniform lowp sampler2D uTexture1; // Normal map
uniform lowp sampler2D uTexture2; // Specular color
2. Multiple programs.
I understand in simple case engine uses IFixedProgram to render objects.
In our case we use IShaderProgram and SetNumberOfNodes(1), so only 1 program is used.
I wonder is it possible to attach several programs to material to execute one by one ? Or any other technique is available ?
Thank you.
Sample is perfectly organised to understand.
Everything is clear except shader parameters binding and multiple programs.
1. Shader parameters (questions are inlined):
From vertex shader
// This part came probably from engine
// What uniform parameters does engine set ?
// How to change them from code ?
// Is it possible to add our own uniform parameters ?
// Is it possible to process multiple lights with vector of uLightPosition
uniform mat4 uModelMatrix;
uniform mat4 uCameraViewMatrix; uniform mat4 uCameraViewProjectionMatrix;
uniform vec4 uLightPosition[2];
//This part came from line 368-372
// geom->AddAttribute(...) API
attribute vec4 aPosition;
attribute vec3 aNormal;
attribute vec3 aBinormal;
attribute vec3 aTangent;
attribute vec2 aTexCoord0;
// Fragment shader
// From where this uniform parameters were set ?
// Why lighting uniforms are arrays of 2 while only first element was used ?
uniform lowp vec4 uLightColorAmbient[2];
uniform lowp vec4 uLightColorDiffuse[2];
uniform lowp vec4 uLightColorSpecular[2];
uniform highp vec4 uLightAttenuation[2];
// This part came from IFixedParameters line 311-315
uniform lowp vec4 uMaterialColorAmbient;
uniform lowp vec4 uMaterialColorDiffuse;
uniform lowp vec4 uMaterialColorSpecular;
uniform mediump float uMaterialShininess;
// This part came from 278, 284, 290 by SetUnit(...) API
uniform lowp sampler2D uTexture0; // Diffuse color
uniform lowp sampler2D uTexture1; // Normal map
uniform lowp sampler2D uTexture2; // Specular color
2. Multiple programs.
I understand in simple case engine uses IFixedProgram to render objects.
In our case we use IShaderProgram and SetNumberOfNodes(1), so only 1 program is used.
I wonder is it possible to attach several programs to material to execute one by one ? Or any other technique is available ?
Thank you.