pfxParser issue

This topic contains 7 replies, has 2 voices, and was last updated by  joel 10 months, 3 weeks ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #54992

    joel
    Member

    I have been using the 2016_r2 examples to try and get some of our existing models and fx files to work with the new architecture. our current system is using 3.2 and we are looking at updating but as you know it’s a big change so we are just testing the waters. using the deferred shading example i am hacking a few things together. as i was doing this i was able to get a new model with our textures working. However when i started to change the textures in each of the effects i was getting the same textures no matter what. stepping through things i noticed that the pfxParser was changing the textures that were on the effects when i used the getEffect function. it always returned the first two textures in the list pfx file texture list. no matter what. so i stepped into the code further and found where this was happening.

    bool PfxReader::readEffect(Effect& asset, uint32 id) const
    {
    const assets::PfxParserEffect& parserEffect = getParserEffect(id);
    // Create room for per-texture data
    const std::vector<PFXParserEffectTexture>& effectTextures = parserEffect.textures;
    uint32 numTextures = (uint32)effectTextures.size();
    m_textures.reserve(numTextures);
    asset.material.setEffectName(parserEffect.name);
    asset.fileName = m_fileName;
    // Initialize each Texture
    for (uint32 i = 0; i < numTextures; ++i)
    {
    int32 iTexIdx = findTextureByName(effectTextures.name);
    if (iTexIdx < 0)
    {
    Log(Log.Debug, “Effect ‘%s’ requests non-existent texture: %s\n”, parserEffect.name.c_str(),
    effectTextures.name.c_str());
    return false;
    }
    asset.textures.push_back(assets::EffectTexture());
    EffectTexture& theTexture = asset.textures.back();

    const assets::PFXParserTexture& parserTex = *getTexture((uint32)asset.textures.size() – 1);
    theTexture.name = parserTex.name;
    theTexture.fileName = parserTex.fileName;
    theTexture.flags = 0;
    theTexture.unit = parserEffect.textures.number;
    theTexture.minFilter = parserTex.minFilter;
    theTexture.magFilter = parserTex.magFilter;
    theTexture.mipFilter = parserTex.mipFilter;
    theTexture.wrapR = parserTex.wrapR;
    theTexture.wrapS = parserTex.wrapS;
    theTexture.wrapT = parserTex.wrapT;
    }

    the getTexture line is only ever returning the first items in the list.
    I changed that line to reference the iTexIdx instead. as you can see below.

    bool PfxReader::readEffect(Effect& asset, uint32 id) const
    {
    const assets::PfxParserEffect& parserEffect = getParserEffect(id);
    // Create room for per-texture data
    const std::vector<PFXParserEffectTexture>& effectTextures = parserEffect.textures;
    uint32 numTextures = (uint32)effectTextures.size();
    m_textures.reserve(numTextures);
    asset.material.setEffectName(parserEffect.name);
    asset.fileName = m_fileName;
    // Initialize each Texture
    for (uint32 i = 0; i < numTextures; ++i)
    {
    int32 iTexIdx = findTextureByName(effectTextures.name);
    if (iTexIdx < 0)
    {
    Log(Log.Debug, “Effect ‘%s’ requests non-existent texture: %s\n”, parserEffect.name.c_str(),
    effectTextures.name.c_str());
    return false;
    }
    asset.textures.push_back(assets::EffectTexture());
    EffectTexture& theTexture = asset.textures.back();

    const assets::PFXParserTexture& parserTex = *getTexture(iTexIdx);
    theTexture.name = parserTex.name;
    theTexture.fileName = parserTex.fileName;
    theTexture.flags = 0;
    theTexture.unit = parserEffect.textures.number;
    theTexture.minFilter = parserTex.minFilter;
    theTexture.magFilter = parserTex.magFilter;
    theTexture.mipFilter = parserTex.mipFilter;
    theTexture.wrapR = parserTex.wrapR;
    theTexture.wrapS = parserTex.wrapS;
    theTexture.wrapT = parserTex.wrapT;
    }

    after doing this everything is working great. So I am not sure if this is a problem with the parser or if this is what is intended and I am using things very differently but i wanted to throw it out there and see what you guys think and you can hopefully give me some insight.

    thanks

    #54996

    Theo
    Member

    Hi Joel,

    In order to understand what’s happening here, we need to see the pfx file in question.

    Could you also confirm that you are using the 2016_r2 sdk?

    Regards,
    Theo

    #55015

    joel
    Member

    here is the pfx file it’s a bit big but just copy pasted for you.also I am using 2016_r2

    [HEADER]
    VERSION 01.00.00.00
    DESCRIPTION OGLESDeferredShading Effects. Multiple Render Target versions.
    COPYRIGHT Imagination Technologies
    [/HEADER]

    ///////////////////////////////////////////////////////////////////////////
    //// ////
    //// GBUFFER EFFECTS ////
    //// ////
    ///////////////////////////////////////////////////////////////////////////

    ///////////////////////////////////////////////////////////////////////////
    //// RenderGBuffer: Effects for tangent-space models(bumpmapped) ////
    ///////////////////////////////////////////////////////////////////////////

    [EFFECT]
    NAME RenderGBuffer

    // GLOBALS UNIFORMS
    UNIFORM uWorldViewProjMatrix WORLDVIEWPROJECTION
    UNIFORM uWorldViewMatrix WORLDVIEW
    UNIFORM uWorldViewIT WORLDVIEWIT

    UNIFORM sTexture TEXTURE0
    UNIFORM sBumpMap TEXTURE1

    // ATTRIBUTES
    ATTRIBUTE inVertex POSITION
    ATTRIBUTE inNormal NORMAL
    ATTRIBUTE inTexCoord UV0
    ATTRIBUTE inTangent TANGENT

    // CUSTOM SEMANTICS
    UNIFORM uFarClipDistance CUSTOMSEMANTIC_FARCLIPDISTANCE
    UNIFORM uSpecularStrength CUSTOMSEMANTIC_SPECULARSTRENGTH
    UNIFORM uDiffuseColor CUSTOMSEMANTIC_DIFFUSECOLOUR

    TEXTURE 0 FootBones_diffuse
    TEXTURE 1 FootBones_1k_normalmap

    // SHADERS
    VERTEXSHADER GBufferVertexShader
    FRAGMENTSHADER GBufferFragmentShader
    [/EFFECT]

    [VERTEXSHADER]
    NAME GBufferVertexShader

    [GLSL_CODE]
    #version 300 es

    #define VERTEX_ARRAY 0
    #define NORMAL_ARRAY 1
    #define TEXCOORD_ARRAY 2
    #define TANGENT_ARRAY 3

    layout(location = VERTEX_ARRAY) in highp vec3 inVertex;
    layout(location = NORMAL_ARRAY) in highp vec3 inNormal;
    layout(location = TEXCOORD_ARRAY) in mediump vec2 inTexCoord;
    layout(location = TANGENT_ARRAY) in highp vec3 inTangent;

    uniform mat4 uWorldViewProjMatrix;
    uniform mat4 uWorldViewMatrix;
    uniform mat3 uWorldViewIT;

    out mediump vec2 vTexCoord;
    out highp vec3 vNormal;
    out highp vec3 vTangent;
    out highp vec3 vBinormal;
    out highp vec3 vViewPos;

    void main()
    {
    gl_Position = uWorldViewProjMatrix * vec4(inVertex, 1.0);

    // Transform normal from model space to eye space
    vNormal = uWorldViewIT * inNormal;
    vTangent = uWorldViewIT * inTangent;
    vBinormal = cross(vNormal, vTangent);

    // Pass the vertex position in view space for depth calculations
    vViewPos = (uWorldViewMatrix * vec4(inVertex, 1.0)).xyz;

    // Pass the texture coordinates to the fragment shader
    vTexCoord = inTexCoord;
    }
    [/GLSL_CODE]
    [/VERTEXSHADER]

    [FRAGMENTSHADER]
    NAME GBufferFragmentShader

    [GLSL_CODE]
    #version 300 es

    uniform sampler2D sTexture;
    uniform sampler2D sBumpMap;

    uniform highp float uFarClipDistance;
    uniform lowp float uSpecularStrength;
    uniform lowp vec3 uDiffuseColor;

    in mediump vec2 vTexCoord;
    in highp vec3 vNormal;
    in highp vec3 vTangent;
    in highp vec3 vBinormal;
    in highp vec3 vViewPos;

    layout(location = 0) out lowp vec4 oAlbedo;
    layout(location = 1) out highp vec3 oNormal;
    layout(location = 2) out highp vec4 oDepth;

    void main()
    {
    // Calculate the albedo
    lowp vec3 albedo = texture(sTexture, vTexCoord).rgb * uDiffuseColor;
    // Pack the specular exponent with the albedo
    oAlbedo = vec4(albedo, uSpecularStrength);

    // Calculate viewspace perturbed normal
    highp vec3 bumpmap = normalize(texture(sBumpMap, vTexCoord).rgb * 2.0 – 1.0);
    highp mat3 tangentSpace = mat3(normalize(vTangent), normalize(vBinormal), normalize(vNormal));
    highp vec3 normalVS = tangentSpace * bumpmap;

    // Scale the normal range from [-1,1] to [0, 1] to pack it into the RGB_U8 texture
    oNormal.xyz = normalVS * 0.5 + 0.5;

    // Pack the depth value into 4 channels
    // Pack the depth value into 4 channels
    highp float scaledDepth = length(vViewPos) / uFarClipDistance;
    highp vec4 enc = vec4(1.0, 255.0, 65025.0, 160581375.0) * scaledDepth;
    enc = fract(enc);
    enc -= enc.yzww * vec4(1.0/255.0,1.0/255.0,1.0/255.0,0.0);

    oDepth = enc;
    }
    [/GLSL_CODE]
    [/FRAGMENTSHADER]

    ///////////////////////////////////////////////////////////////////////////
    //// ////
    //// RenderGBufferFloor: Effects for non-bumpmapped models ////
    //// ////
    ///////////////////////////////////////////////////////////////////////////
    [EFFECT]
    NAME RenderGBufferFloor

    // GLOBALS UNIFORMS
    UNIFORM uWorldViewProjMatrix WORLDVIEWPROJECTION
    UNIFORM uWorldViewIT WORLDVIEWIT
    UNIFORM uWorldViewMatrix WORLDVIEW

    // ATTRIBUTES
    ATTRIBUTE inVertex POSITION
    ATTRIBUTE inNormal NORMAL
    ATTRIBUTE inTexCoord UV0

    // CUSTOM SEMANTICS
    UNIFORM uFarClipDistance CUSTOMSEMANTIC_FARCLIPDISTANCE

    UNIFORM uSpecularStrength CUSTOMSEMANTIC_SPECULARSTRENGTH
    UNIFORM uDiffuseColor CUSTOMSEMANTIC_DIFFUSECOLOUR

    // SHADERS
    VERTEXSHADER GBufferFloorVertexShader
    FRAGMENTSHADER GBufferFloorFragmentShader
    [/EFFECT]

    [VERTEXSHADER]
    NAME GBufferFloorVertexShader

    [GLSL_CODE]
    #version 300 es

    #define VERTEX_ARRAY 0
    #define NORMAL_ARRAY 1
    #define TEXCOORD_ARRAY 2

    layout(location = VERTEX_ARRAY) in highp vec3 inVertex;
    layout(location = NORMAL_ARRAY) in highp vec3 inNormal;
    layout(location = TEXCOORD_ARRAY) in mediump vec2 inTexCoord;

    uniform mat4 uWorldViewProjMatrix;
    uniform mat4 uWorldViewMatrix;
    uniform mat3 uWorldViewIT;

    out mediump vec2 vTexCoord;
    out highp vec3 vNormal;
    out highp vec3 vViewPos;

    void main()
    {
    gl_Position = uWorldViewProjMatrix * vec4(inVertex, 1.0);

    // Transform normal from model space to eye space
    vNormal = uWorldViewIT * inNormal;

    // Pass the vertex position in view space for depth calculations
    vViewPos = (uWorldViewMatrix * vec4(inVertex, 1.0)).xyz;

    // Pass the texture coordinates to the fragment shader
    vTexCoord = inTexCoord;
    }
    [/GLSL_CODE]
    [/VERTEXSHADER]

    [FRAGMENTSHADER]
    NAME GBufferFloorFragmentShader

    [GLSL_CODE]
    #version 300 es

    uniform sampler2D sTexture;

    uniform lowp float uSpecularStrength;
    uniform lowp vec3 uDiffuseColor;
    uniform highp float uFarClipDistance;

    in highp vec3 vNormal;
    in highp vec2 vTexCoord;
    in highp vec3 vViewPos;

    layout(location = 0) out lowp vec4 oAlbedo;
    layout(location = 1) out highp vec3 oNormal;
    layout(location = 2) out highp vec4 oDepth;

    void main()
    {
    // Pack the specular exponent with the albedo
    oAlbedo = vec4(texture(sTexture, vTexCoord).rgb * uDiffuseColor, uSpecularStrength);

    // Pack the normal
    oNormal.xyz = normalize(vNormal) * .5 + .5;

    // Pack the depth value into 4 channels
    highp float scaledDepth = length(vViewPos) / uFarClipDistance;
    highp vec4 enc = vec4(1.0, 255.0, 65025.0, 160581375.0) * scaledDepth;
    enc = fract(enc);
    enc -= enc.yzww * vec4(1.0/255.0,1.0/255.0,1.0/255.0,0.0);

    oDepth = enc;
    }
    [/GLSL_CODE]
    [/FRAGMENTSHADER]

    ///////////////////////////////////////////////////////////////////////////
    //// ////
    //// DEFERRED LIGHT SHADERS ////
    //// ////
    ///////////////////////////////////////////////////////////////////////////

    //
    // Calculates the lighting for a point light source
    //
    [EFFECT]
    NAME RenderPointLight

    // GLOBALS UNIFORMS
    UNIFORM uWorldViewProjMatrix WORLDVIEWPROJECTION
    UNIFORM uWorldViewMatrix WORLDVIEW
    UNIFORM uLightColorIntensity LIGHTCOLOR

    UNIFORM sAlbedo TEXTURE0
    UNIFORM sNormals TEXTURE1
    UNIFORM sDepth TEXTURE2

    // CUSTOM SEMANTICS
    UNIFORM uFarClipDistance CUSTOMSEMANTIC_FARCLIPDISTANCE

    UNIFORM uLightViewPosition CUSTOMSEMANTIC_POINTLIGHT_VIEWPOSITION

    // ATTRIBUTES
    ATTRIBUTE inVertex POSITION

    // SHADERS
    VERTEXSHADER DeferredVertexShader
    FRAGMENTSHADER PointLightFragmentShader
    [/EFFECT]

    //
    // Vertex shader that is shared amongst (most) deferred light shaders
    //
    [VERTEXSHADER]
    NAME DeferredVertexShader

    [GLSL_CODE]
    #version 300 es

    #define VERTEX_ARRAY 0

    layout(location = VERTEX_ARRAY) in highp vec3 inVertex;

    uniform mat4 uWorldViewProjMatrix;
    uniform mat4 uWorldViewMatrix;

    out highp vec3 vPositionVS;
    out highp vec3 vViewDirVS;
    out mediump vec2 vTexCoord;

    void main()
    {
    gl_Position = uWorldViewProjMatrix * vec4(inVertex, 1.0);
    gl_Position.xyz = gl_Position.xyz / gl_Position.w;
    gl_Position.w = 1.0;

    vTexCoord = (gl_Position.xy + 1.0) * 0.5;

    // Calculate the view-space position for lighting calculations
    vPositionVS = (uWorldViewMatrix * vec4(inVertex, 1.0)).xyz;

    // Pass the view direction
    vViewDirVS = vPositionVS;
    }
    [/GLSL_CODE]
    [/VERTEXSHADER]

    [FRAGMENTSHADER]
    NAME PointLightFragmentShader

    [GLSL_CODE]
    #version 300 es

    uniform sampler2D sAlbedo;
    uniform sampler2D sNormals;
    uniform sampler2D sDepth;

    uniform highp float uFarClipDistance;
    uniform highp vec3 uLightColorIntensity;

    uniform highp mat3 uWorldIT;
    uniform highp vec3 uLightViewPosition;

    in highp vec3 vPositionVS;
    in highp vec3 vViewDirVS;
    in mediump vec2 vTexCoord;

    layout(location = 0) out lowp vec4 oColor;

    void main()
    {
    //
    // Read GBuffer attributes
    //
    highp vec4 depthTex = texture(sDepth, vTexCoord);
    highp vec4 albedoSpec = texture(sAlbedo, vTexCoord);
    highp vec3 normalTex = texture(sNormals, vTexCoord).xyz;

    // reconstruct original depth value
    highp float depth = dot(depthTex, vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/160581375.0));

    //
    // Reconstruct common vectors and world space position
    //
    highp vec3 positionVS = normalize(vPositionVS) * depth * uFarClipDistance;
    highp vec3 lightDirection = uLightViewPosition – positionVS;
    highp float lightDistance = length(lightDirection);
    lightDirection /= lightDistance;

    //
    // Calculate lighting terms
    //
    highp vec3 normal = normalize(normalTex * 2.0 – 1.0);
    highp float n_dot_l = max(dot(lightDirection, normal), 0.0);
    highp vec3 diffuse = n_dot_l * albedoSpec.rgb;

    highp vec3 viewDirection = normalize(vViewDirVS);
    highp vec3 reflectedLightDirection = reflect(lightDirection, normal);
    highp float v_dot_r = max(dot(viewDirection, reflectedLightDirection), 0.0);
    diffuse += vec3(pow(v_dot_r, 16.0) * albedoSpec.a);

    //Subtracting a small number and clamping makes for a much better falloff look.
    highp float attenuation = max(1. / (1. + 1. * lightDistance * lightDistance) -.001, 0.);
    oColor = vec4(diffuse * uLightColorIntensity * attenuation, 1.0);
    }
    [/GLSL_CODE]
    [/FRAGMENTSHADER]

    //
    // Calculates the lighting for a directional light source
    //
    [EFFECT]
    NAME RenderDirectionalLight

    // GLOBALS UNIFORMS
    UNIFORM uLightColorIntensity LIGHTCOLOR

    UNIFORM sAlbedo TEXTURE0
    UNIFORM sNormals TEXTURE1

    // CUSTOM SEMANTICS
    UNIFORM uLightDirection CUSTOMSEMANTIC_DIRECTIONALLIGHT_DIRECTION

    // SHADERS
    VERTEXSHADER DirectionalLightVertexShader
    FRAGMENTSHADER DirectionalLightFragmentShader
    [/EFFECT]

    [VERTEXSHADER]
    NAME DirectionalLightVertexShader

    [GLSL_CODE]
    #version 300 es

    const highp vec2 positions[4]=vec2[4]
    (
    vec2(-1.,-1.),
    vec2( 1.,-1.),
    vec2(-1., 1.),
    vec2( 1., 1.)
    );

    out mediump vec2 vTexCoord;
    void main()
    {
    highp vec2 position = positions[gl_VertexID];

    gl_Position = vec4(position, 0.5, 1.);
    vTexCoord = position * .5 – .5; //Map -1..1->0..1
    }
    [/GLSL_CODE]
    [/VERTEXSHADER]

    [FRAGMENTSHADER]
    NAME DirectionalLightFragmentShader

    [GLSL_CODE]
    #version 300 es

    uniform sampler2D sAlbedo;
    uniform sampler2D sNormals;

    uniform highp vec3 uLightColorIntensity;
    uniform highp vec4 uLightDirection;

    in mediump vec2 vTexCoord;

    layout(location = 0) out lowp vec4 oColor;

    void main()
    {
    // Fetch required gbuffer attributes
    lowp vec3 albedo = texture(sAlbedo, vTexCoord).rgb;
    highp vec3 normalTex = texture(sNormals, vTexCoord).xyz;
    highp vec3 normal = normalTex.xyz * 2.0 – vec3(1.0);

    // Calculate simple diffuse lighting
    highp float n_dot_l = max(dot(-uLightDirection.xyz, normal.xyz), 0.0);
    lowp vec3 color = albedo * (n_dot_l * uLightColorIntensity + vec3(.2, .2, .1));

    oColor = vec4(color, 1.0);
    }
    [/GLSL_CODE]
    [/FRAGMENTSHADER]

    ///////////////////////////////////////////////////////////////////////////
    //// ////
    //// AUXILIARY SHADERS ////
    //// ////
    ///////////////////////////////////////////////////////////////////////////

    //
    // Renders the geometry using a single color passed as an uniform.
    //
    [EFFECT]
    NAME RenderSolidColor

    // GLOBALS UNIFORMS
    UNIFORM uWorldViewProjMatrix WORLDVIEWPROJECTION
    UNIFORM uConstantColor MATERIALCOLORAMBIENT

    // ATTRIBUTES
    ATTRIBUTE inVertex POSITION

    // SHADERS
    VERTEXSHADER VertexShader
    FRAGMENTSHADER SolidColorFragmentShader
    [/EFFECT]

    [VERTEXSHADER]
    NAME VertexShader

    [GLSL_CODE]
    #version 300 es

    layout(location = 0) in highp vec3 inVertex;

    uniform mat4 uWorldViewProjMatrix;

    void main()
    {
    // pass-through position and texture coordinates
    gl_Position = uWorldViewProjMatrix * vec4(inVertex, 1.0);
    }
    [/GLSL_CODE]
    [/VERTEXSHADER]

    [FRAGMENTSHADER]
    NAME SolidColorFragmentShader

    [GLSL_CODE]
    #version 300 es

    uniform lowp vec4 uConstantColor;

    layout(location = 0) out lowp vec4 oColor;

    void main()
    {
    oColor = uConstantColor;
    }
    [/GLSL_CODE]
    [/FRAGMENTSHADER]

    [EFFECT]
    NAME RenderNullColor

    // GLOBALS UNIFORMS
    UNIFORM uWorldViewProjMatrix WORLDVIEWPROJECTION

    // ATTRIBUTES
    ATTRIBUTE inVertex POSITION

    // SHADERS
    VERTEXSHADER VertexShader
    FRAGMENTSHADER NullFragmentShader
    [/EFFECT]

    [FRAGMENTSHADER]
    NAME NullFragmentShader

    [GLSL_CODE]
    #version 300 es
    void main() { }
    [/GLSL_CODE]
    [/FRAGMENTSHADER]

    ////////////////////////////////////////////////////////////////
    ///////////// Custom Shaders //////////////////////////////////
    ////////////////////////////////////////////////////////////////
    [EFFECT]
    NAME ach_x3
    // GLOBALS UNIFORMS
    UNIFORM uWorldViewProjMatrix WORLDVIEWPROJECTION
    UNIFORM uWorldViewMatrix WORLDVIEW
    UNIFORM uWorldViewIT WORLDVIEWIT

    UNIFORM sTexture TEXTURE0
    UNIFORM sBumpMap TEXTURE1

    // ATTRIBUTES
    ATTRIBUTE inVertex POSITION
    ATTRIBUTE inNormal NORMAL
    ATTRIBUTE inTexCoord UV0
    ATTRIBUTE inTangent TANGENT

    // CUSTOM SEMANTICS
    UNIFORM uFarClipDistance CUSTOMSEMANTIC_FARCLIPDISTANCE
    UNIFORM uSpecularStrength CUSTOMSEMANTIC_SPECULARSTRENGTH
    UNIFORM uDiffuseColor CUSTOMSEMANTIC_DIFFUSECOLOUR

    TEXTURE 0 ach_x_diffuse
    TEXTURE 1 ach_x_normal

    // SHADERS
    VERTEXSHADER GBufferVertexShader
    FRAGMENTSHADER GBufferFragmentShader
    [/EFFECT]
    [EFFECT]
    NAME achilles1
    // GLOBALS UNIFORMS
    UNIFORM uWorldViewProjMatrix WORLDVIEWPROJECTION
    UNIFORM uWorldViewMatrix WORLDVIEW
    UNIFORM uWorldViewIT WORLDVIEWIT

    UNIFORM sTexture TEXTURE0
    UNIFORM sBumpMap TEXTURE1

    // ATTRIBUTES
    ATTRIBUTE inVertex POSITION
    ATTRIBUTE inNormal NORMAL
    ATTRIBUTE inTexCoord UV0
    ATTRIBUTE inTangent TANGENT

    // CUSTOM SEMANTICS
    UNIFORM uFarClipDistance CUSTOMSEMANTIC_FARCLIPDISTANCE
    UNIFORM uSpecularStrength CUSTOMSEMANTIC_SPECULARSTRENGTH
    UNIFORM uDiffuseColor CUSTOMSEMANTIC_DIFFUSECOLOUR

    TEXTURE 0 achilles_diffuse
    TEXTURE 1 achilles_normal

    // SHADERS
    VERTEXSHADER GBufferVertexShader
    FRAGMENTSHADER GBufferFragmentShader
    [/EFFECT]
    [EFFECT]
    NAME Abductor_Digiti_Minimi_Right2S1
    // GLOBALS UNIFORMS
    UNIFORM uWorldViewProjMatrix WORLDVIEWPROJECTION
    UNIFORM uWorldViewMatrix WORLDVIEW
    UNIFORM uWorldViewIT WORLDVIEWIT

    UNIFORM sTexture TEXTURE0
    UNIFORM sBumpMap TEXTURE1

    // ATTRIBUTES
    ATTRIBUTE inVertex POSITION
    ATTRIBUTE inNormal NORMAL
    ATTRIBUTE inTexCoord UV0
    ATTRIBUTE inTangent TANGENT

    // CUSTOM SEMANTICS
    UNIFORM uFarClipDistance CUSTOMSEMANTIC_FARCLIPDISTANCE
    UNIFORM uSpecularStrength CUSTOMSEMANTIC_SPECULARSTRENGTH
    UNIFORM uDiffuseColor CUSTOMSEMANTIC_DIFFUSECOLOUR

    TEXTURE 0 Abductor_Digiti_Minimi_tendon_diffuse
    TEXTURE 1 Abductor_Digiti_Minimi_tendon_normal

    // SHADERS
    VERTEXSHADER GBufferVertexShader
    FRAGMENTSHADER GBufferFragmentShader
    [/EFFECT]
    [EFFECT]
    NAME pasted_NOlines
    // GLOBALS UNIFORMS
    UNIFORM uWorldViewProjMatrix WORLDVIEWPROJECTION
    UNIFORM uWorldViewMatrix WORLDVIEW
    UNIFORM uWorldViewIT WORLDVIEWIT

    UNIFORM sTexture TEXTURE0
    UNIFORM sBumpMap TEXTURE1

    // ATTRIBUTES
    ATTRIBUTE inVertex POSITION
    ATTRIBUTE inNormal NORMAL
    ATTRIBUTE inTexCoord UV0
    ATTRIBUTE inTangent TANGENT

    // CUSTOM SEMANTICS
    UNIFORM uFarClipDistance CUSTOMSEMANTIC_FARCLIPDISTANCE
    UNIFORM uSpecularStrength CUSTOMSEMANTIC_SPECULARSTRENGTH
    UNIFORM uDiffuseColor CUSTOMSEMANTIC_DIFFUSECOLOUR

    TEXTURE 0 pasted_NOlines_diffuse
    TEXTURE 1 extensorDigitorum_normal

    // SHADERS
    VERTEXSHADER GBufferVertexShader
    FRAGMENTSHADER GBufferFragmentShader
    [/EFFECT]
    [EFFECT]
    NAME Abductor_Hallucis1
    // GLOBALS UNIFORMS
    UNIFORM uWorldViewProjMatrix WORLDVIEWPROJECTION
    UNIFORM uWorldViewMatrix WORLDVIEW
    UNIFORM uWorldViewIT WORLDVIEWIT

    UNIFORM sTexture TEXTURE0
    UNIFORM sBumpMap TEXTURE1

    // ATTRIBUTES
    ATTRIBUTE inVertex POSITION
    ATTRIBUTE inNormal NORMAL
    ATTRIBUTE inTexCoord UV0
    ATTRIBUTE inTangent TANGENT

    // CUSTOM SEMANTICS
    UNIFORM uFarClipDistance CUSTOMSEMANTIC_FARCLIPDISTANCE
    UNIFORM uSpecularStrength CUSTOMSEMANTIC_SPECULARSTRENGTH
    UNIFORM uDiffuseColor CUSTOMSEMANTIC_DIFFUSECOLOUR

    TEXTURE 0 Abductor_Hallucis_diffuse
    TEXTURE 1 Abductor_Digiti_Minimi_tendon_normal

    // SHADERS
    VERTEXSHADER GBufferVertexShader
    FRAGMENTSHADER GBufferFragmentShader
    [/EFFECT]
    [EFFECT]
    NAME extensorDigitorum1
    // GLOBALS UNIFORMS
    UNIFORM uWorldViewProjMatrix WORLDVIEWPROJECTION
    UNIFORM uWorldViewMatrix WORLDVIEW
    UNIFORM uWorldViewIT WORLDVIEWIT

    UNIFORM sTexture TEXTURE0
    UNIFORM sBumpMap TEXTURE1

    // ATTRIBUTES
    ATTRIBUTE inVertex POSITION
    ATTRIBUTE inNormal NORMAL
    ATTRIBUTE inTexCoord UV0
    ATTRIBUTE inTangent TANGENT

    // CUSTOM SEMANTICS
    UNIFORM uFarClipDistance CUSTOMSEMANTIC_FARCLIPDISTANCE
    UNIFORM uSpecularStrength CUSTOMSEMANTIC_SPECULARSTRENGTH
    UNIFORM uDiffuseColor CUSTOMSEMANTIC_DIFFUSECOLOUR

    TEXTURE 0 extensorDigitorum_diffuse
    TEXTURE 1 extensorDigitorum_normal

    // SHADERS
    VERTEXSHADER GBufferVertexShader
    FRAGMENTSHADER GBufferFragmentShader
    [/EFFECT]
    [EFFECT]
    NAME FHB_muscle
    // GLOBALS UNIFORMS
    UNIFORM uWorldViewProjMatrix WORLDVIEWPROJECTION
    UNIFORM uWorldViewMatrix WORLDVIEW
    UNIFORM uWorldViewIT WORLDVIEWIT

    UNIFORM sTexture TEXTURE0
    UNIFORM sBumpMap TEXTURE1

    // ATTRIBUTES
    ATTRIBUTE inVertex POSITION
    ATTRIBUTE inNormal NORMAL
    ATTRIBUTE inTexCoord UV0
    ATTRIBUTE inTangent TANGENT

    // CUSTOM SEMANTICS
    UNIFORM uFarClipDistance CUSTOMSEMANTIC_FARCLIPDISTANCE
    UNIFORM uSpecularStrength CUSTOMSEMANTIC_SPECULARSTRENGTH
    UNIFORM uDiffuseColor CUSTOMSEMANTIC_DIFFUSECOLOUR

    TEXTURE 0 FHB_muscle_diffuse
    TEXTURE 1 Abductor_Digiti_Minimi_tendon_normal

    // SHADERS
    VERTEXSHADER GBufferVertexShader
    FRAGMENTSHADER GBufferFragmentShader
    [/EFFECT]
    [EFFECT]
    NAME FDB_muscle
    // GLOBALS UNIFORMS
    UNIFORM uWorldViewProjMatrix WORLDVIEWPROJECTION
    UNIFORM uWorldViewMatrix WORLDVIEW
    UNIFORM uWorldViewIT WORLDVIEWIT

    UNIFORM sTexture TEXTURE0
    UNIFORM sBumpMap TEXTURE1

    // ATTRIBUTES
    ATTRIBUTE inVertex POSITION
    ATTRIBUTE inNormal NORMAL
    ATTRIBUTE inTexCoord UV0
    ATTRIBUTE inTangent TANGENT

    // CUSTOM SEMANTICS
    UNIFORM uFarClipDistance CUSTOMSEMANTIC_FARCLIPDISTANCE
    UNIFORM uSpecularStrength CUSTOMSEMANTIC_SPECULARSTRENGTH
    UNIFORM uDiffuseColor CUSTOMSEMANTIC_DIFFUSECOLOUR

    TEXTURE 0 FDB_muscle_diffuse
    TEXTURE 1 Abductor_Digiti_Minimi_tendon_normal

    // SHADERS
    VERTEXSHADER GBufferVertexShader
    FRAGMENTSHADER GBufferFragmentShader
    [/EFFECT]
    [EFFECT]
    NAME achilles_B
    // GLOBALS UNIFORMS
    UNIFORM uWorldViewProjMatrix WORLDVIEWPROJECTION
    UNIFORM uWorldViewMatrix WORLDVIEW
    UNIFORM uWorldViewIT WORLDVIEWIT

    UNIFORM sTexture TEXTURE0
    UNIFORM sBumpMap TEXTURE1

    // ATTRIBUTES
    ATTRIBUTE inVertex POSITION
    ATTRIBUTE inNormal NORMAL
    ATTRIBUTE inTexCoord UV0
    ATTRIBUTE inTangent TANGENT

    // CUSTOM SEMANTICS
    UNIFORM uFarClipDistance CUSTOMSEMANTIC_FARCLIPDISTANCE
    UNIFORM uSpecularStrength CUSTOMSEMANTIC_SPECULARSTRENGTH
    UNIFORM uDiffuseColor CUSTOMSEMANTIC_DIFFUSECOLOUR

    TEXTURE 0 achilles_B_diffuse
    TEXTURE 1 achilles_normal

    // SHADERS
    VERTEXSHADER GBufferVertexShader
    FRAGMENTSHADER GBufferFragmentShader
    [/EFFECT]
    [EFFECT]
    NAME bones
    // GLOBALS UNIFORMS
    UNIFORM uWorldViewProjMatrix WORLDVIEWPROJECTION
    UNIFORM uWorldViewMatrix WORLDVIEW
    UNIFORM uWorldViewIT WORLDVIEWIT

    UNIFORM sTexture TEXTURE0
    UNIFORM sBumpMap TEXTURE1

    // ATTRIBUTES
    ATTRIBUTE inVertex POSITION
    ATTRIBUTE inNormal NORMAL
    ATTRIBUTE inTexCoord UV0
    ATTRIBUTE inTangent TANGENT

    // CUSTOM SEMANTICS
    UNIFORM uFarClipDistance CUSTOMSEMANTIC_FARCLIPDISTANCE
    UNIFORM uSpecularStrength CUSTOMSEMANTIC_SPECULARSTRENGTH
    UNIFORM uDiffuseColor CUSTOMSEMANTIC_DIFFUSECOLOUR

    TEXTURE 0 FootBones_diffuse
    TEXTURE 1 FootBones_1k_normalmap

    // SHADERS
    VERTEXSHADER GBufferVertexShader
    FRAGMENTSHADER GBufferFragmentShader
    [/EFFECT]

    [EFFECT]
    NAME Skin_facingRatio_Mat
    ATTRIBUTE inVertex POSITION
    ATTRIBUTE inNormal NORMAL
    ATTRIBUTE inTangent TANGENT
    ATTRIBUTE inBiNormal BINORMAL
    ATTRIBUTE inTexCoord UV0
    ATTRIBUTE inBoneIndex BONEINDEX
    ATTRIBUTE inBoneWeights BONEWEIGHT
    UNIFORM ambientMaterial MATERIALCOLORAMBIENT
    UNIFORM diffuseMaterial CUSTOMSEMANTIC_DIFFUSECOLOUR
    UNIFORM specularMaterial CUSTOMSEMANTIC_SPECULARSTRENGTH
    UNIFORM shininess MATERIALSHININESS
    UNIFORM eyePos EYEPOSMODEL
    UNIFORM ViewProjMatrix WORLDVIEWPROJECTION
    UNIFORM WorldMatrix WORLD_MATRIX
    UNIFORM inLight0 LIGHTPOSMODEL0
    UNIFORM inLight1 LIGHTPOSMODEL1
    UNIFORM inLight2 LIGHTPOSMODEL2
    UNIFORM lightColor0 LIGHTCOLOR0
    UNIFORM lightColor1 LIGHTCOLOR1
    UNIFORM lightColor2 LIGHTCOLOR2
    UNIFORM BoneCount BONECOUNT
    UNIFORM BoneMatrixArray BONEMATRIXARRAY
    UNIFORM BoneMatrixArrayIT BONEMATRIXARRAYIT
    UNIFORM isHighlighted IS_HIGHLIGHTED
    UNIFORM isClearLayer IS_CLEAR_LAYER
    VERTEXSHADER skinVertShader
    FRAGMENTSHADER skinFragShader
    [/EFFECT]

    [VERTEXSHADER]
    NAME skinVertShader
    [GLSL_CODE]
    attribute highp vec3 inVertex;
    attribute mediump vec3 inNormal;
    attribute mediump vec2 inTexCoord;

    uniform highp mat4 ViewProjMatrix;
    uniform highp mat4 WorldMatrix;
    uniform mediump vec4 inLight0;
    uniform mediump vec4 inLight1;
    uniform mediump vec4 inLight2;
    uniform lowp int LightCount;
    uniform mediump vec3 eyePos;

    varying mediump vec3 Light0;
    varying mediump vec3 Light1;
    varying mediump vec3 Light2;
    varying mediump vec2 TexCoord;
    varying mediump vec3 outNormal;
    varying mediump vec3 eyeVector;
    varying highp vec4 outPosition;

    void main()
    {
    highp vec4 position = vec4(inVertex, 1.0);

    if(inLight0.w > 0.0){
    Light0 = normalize(inLight0.xyz – position.xyz); //Light0.w > 0 tells us that Light0 is the lights position
    }else{
    Light0 = inLight0.xyz;
    }

    if(inLight1.w > 0.0){
    Light1 = normalize(inLight1.xyz – position.xyz); //Light1.w > 0 tells us that Light1 is the lights position
    }else{
    Light1 = inLight1.xyz;
    }

    if(inLight2.w > 0.0){
    Light2 = normalize(inLight2.xyz – position.xyz); //Light1.w > 0 tells us that Light1 is the lights position
    }else{
    Light2 = inLight2.xyz;
    }

    position = WorldMatrix * position;
    outPosition = position;
    gl_Position = ViewProjMatrix * position;

    TexCoord = inTexCoord;
    outNormal = inNormal;
    eyeVector = normalize(eyePos – position.xyz);

    }
    [/GLSL_CODE]
    [/VERTEXSHADER]

    [FRAGMENTSHADER]
    NAME skinFragShader
    [GLSL_CODE]
    uniform mediump int isClearLayer;
    uniform mediump vec3 effectState;

    uniform lowp int isHighlighted;

    varying mediump vec3 outNormal;
    varying mediump vec3 Light0;
    varying mediump vec3 Light1;
    varying mediump vec3 Light2;
    varying mediump vec3 eyeVector;

    void main()
    {
    highp float facingRatio = 1.0;
    highp float alpha = 0.4;
    if(isClearLayer == 1)
    {
    highp vec3 N = normalize(outNormal);
    highp vec3 L = normalize(Light0);
    highp vec3 E = normalize(eyeVector);
    facingRatio = min(1.0, max(0.0, dot(N, E) * 2.0 – 0.25));
    alpha = 0.4 + 0.3 * (1.0 – facingRatio);
    }

    //blue
    //const highp vec3 diffuseFacing = vec3(0.05, 0.1, 0.40); //rgb(13,26,102)
    //const highp vec3 diffuseNonFacing = vec3(0.19, 0.76, 0.9454); //rgb(48,194,241)

    //gray
    const highp vec3 diffuseFacing = vec3(0.1, 0.1, 0.1);
    const highp vec3 diffuseNonFacing = vec3(0.9, 0.9, 0.9);

    highp vec3 color;
    color = diffuseFacing * facingRatio + diffuseNonFacing * (1.0 – facingRatio);

    if(isHighlighted == 1)
    {
    highp float greyScale = (color.x * 0.299 + color.y * 0.587 + color.z * 0.114);
    highp float shiftValR = 0.0;
    highp float shiftValG = 0.368 + ( 0.146 * greyScale);
    highp float shiftValB = 0.647 + ( 0.251 * greyScale);

    color.xyz = vec3(shiftValR,shiftValG,shiftValB);

    }

    gl_FragColor = vec4(color, alpha);
    }
    [/GLSL_CODE]
    [/FRAGMENTSHADER]

    [EFFECT]
    NAME Nerves1
    // GLOBALS UNIFORMS
    UNIFORM uWorldViewProjMatrix WORLDVIEWPROJECTION
    UNIFORM uWorldViewMatrix WORLDVIEW
    UNIFORM uWorldViewIT WORLDVIEWIT

    UNIFORM sTexture TEXTURE0
    UNIFORM sBumpMap TEXTURE1

    // ATTRIBUTES
    ATTRIBUTE inVertex POSITION
    ATTRIBUTE inNormal NORMAL
    ATTRIBUTE inTexCoord UV0
    ATTRIBUTE inTangent TANGENT

    // CUSTOM SEMANTICS
    UNIFORM uFarClipDistance CUSTOMSEMANTIC_FARCLIPDISTANCE
    UNIFORM uSpecularStrength CUSTOMSEMANTIC_SPECULARSTRENGTH
    UNIFORM uDiffuseColor CUSTOMSEMANTIC_DIFFUSECOLOUR

    TEXTURE 0 FootBones_diffuse
    TEXTURE 1 FootBones_1k_normalmap

    // SHADERS
    VERTEXSHADER GBufferVertexShader
    FRAGMENTSHADER GBufferFragmentShader
    [/EFFECT]
    [EFFECT]
    NAME Vessel1
    // GLOBALS UNIFORMS
    UNIFORM uWorldViewProjMatrix WORLDVIEWPROJECTION
    UNIFORM uWorldViewMatrix WORLDVIEW
    UNIFORM uWorldViewIT WORLDVIEWIT

    UNIFORM sTexture TEXTURE0
    UNIFORM sBumpMap TEXTURE1

    // ATTRIBUTES
    ATTRIBUTE inVertex POSITION
    ATTRIBUTE inNormal NORMAL
    ATTRIBUTE inTexCoord UV0
    ATTRIBUTE inTangent TANGENT

    // CUSTOM SEMANTICS
    UNIFORM uFarClipDistance CUSTOMSEMANTIC_FARCLIPDISTANCE
    UNIFORM uSpecularStrength CUSTOMSEMANTIC_SPECULARSTRENGTH
    UNIFORM uDiffuseColor CUSTOMSEMANTIC_DIFFUSECOLOUR

    TEXTURE 0 FootBones_diffuse
    TEXTURE 1 FootBones_1k_normalmap

    // SHADERS
    VERTEXSHADER GBufferVertexShader
    FRAGMENTSHADER GBufferFragmentShader
    [/EFFECT]
    [EFFECT]
    NAME Inferior_Extensor_Retinaculum1
    // GLOBALS UNIFORMS
    UNIFORM uWorldViewProjMatrix WORLDVIEWPROJECTION
    UNIFORM uWorldViewMatrix WORLDVIEW
    UNIFORM uWorldViewIT WORLDVIEWIT

    UNIFORM sTexture TEXTURE0
    UNIFORM sBumpMap TEXTURE1

    // ATTRIBUTES
    ATTRIBUTE inVertex POSITION
    ATTRIBUTE inNormal NORMAL
    ATTRIBUTE inTexCoord UV0
    ATTRIBUTE inTangent TANGENT

    // CUSTOM SEMANTICS
    UNIFORM uFarClipDistance CUSTOMSEMANTIC_FARCLIPDISTANCE
    UNIFORM uSpecularStrength CUSTOMSEMANTIC_SPECULARSTRENGTH
    UNIFORM uDiffuseColor CUSTOMSEMANTIC_DIFFUSECOLOUR

    TEXTURE 0 Inferior_Extensor_Retinaculum_transparency
    TEXTURE 1 Inferior_Extensor_Retinaculum_normal

    // SHADERS
    VERTEXSHADER GBufferVertexShader
    FRAGMENTSHADER GBufferFragmentShader
    [/EFFECT]

    [TEXTURE]
    NAME Abductor_Digiti_Minimi_tendon_bump
    PATH Abductor_Digiti_Minimi_tendon_bump.pvr
    MINIFICATION LINEAR
    MAGNIFICATION LINEAR
    MIPMAP LINEAR
    [/TEXTURE]
    [TEXTURE]
    NAME Abductor_Digiti_Minimi_tendon_diffuse
    PATH Abductor_Digiti_Minimi_tendon_diffuse.pvr
    MINIFICATION LINEAR
    MAGNIFICATION LINEAR
    MIPMAP LINEAR
    [/TEXTURE]

    [TEXTURE]
    NAME FootBones_diffuse
    PATH FootBones_diffuse.pvr
    MINIFICATION LINEAR
    MAGNIFICATION LINEAR
    MIPMAP LINEAR
    [/TEXTURE]

    [TEXTURE]
    NAME FootBones_1k_normalmap
    PATH FootBones_1k_normalmap.pvr
    MINIFICATION LINEAR
    MAGNIFICATION LINEAR
    MIPMAP LINEAR
    [/TEXTURE]

    [TEXTURE]
    NAME Abductor_Digiti_Minimi_tendon_normal
    PATH Abductor_Digiti_Minimi_tendon_normal.pvr
    MINIFICATION LINEAR
    MAGNIFICATION LINEAR
    MIPMAP LINEAR
    [/TEXTURE]
    [TEXTURE]
    NAME Abductor_Hallucis_diffuse
    PATH Abductor_Hallucis_diffuse.pvr
    MINIFICATION LINEAR
    MAGNIFICATION LINEAR
    MIPMAP LINEAR
    [/TEXTURE]
    [TEXTURE]
    NAME ach_x_bump
    PATH ach_x_bump.pvr
    MINIFICATION LINEAR
    MAGNIFICATION LINEAR
    MIPMAP LINEAR
    [/TEXTURE]
    [TEXTURE]
    NAME ach_x_normal
    PATH ach_x_normal.pvr
    MINIFICATION LINEAR
    MAGNIFICATION LINEAR
    MIPMAP LINEAR
    [/TEXTURE]
    [TEXTURE]
    NAME ach_x_diffuse
    PATH ach_x_diffuse.pvr
    MINIFICATION LINEAR
    MAGNIFICATION LINEAR
    MIPMAP LINEAR
    [/TEXTURE]
    [TEXTURE]
    NAME achilles_B_diffuse
    PATH achilles_B_diffuse.pvr
    MINIFICATION LINEAR
    MAGNIFICATION LINEAR
    MIPMAP LINEAR
    [/TEXTURE]
    [TEXTURE]
    NAME achilles_diffuse
    PATH achilles_diffuse.pvr
    MINIFICATION LINEAR
    MAGNIFICATION LINEAR
    MIPMAP LINEAR
    [/TEXTURE]
    [TEXTURE]
    NAME achilles_normal
    PATH achilles_normal.pvr
    MINIFICATION LINEAR
    MAGNIFICATION LINEAR
    MIPMAP LINEAR
    [/TEXTURE]
    [TEXTURE]
    NAME extensorDigitorum_diffuse
    PATH extensorDigitorum_diffuse.pvr
    MINIFICATION LINEAR
    MAGNIFICATION LINEAR
    MIPMAP LINEAR
    [/TEXTURE]
    [TEXTURE]
    NAME extensorDigitorum_normal
    PATH extensorDigitorum_normal.pvr
    MINIFICATION LINEAR
    MAGNIFICATION LINEAR
    MIPMAP LINEAR
    [/TEXTURE]
    [TEXTURE]
    NAME FDB_muscle_diffuse
    PATH FDB_muscle_diffuse.pvr
    MINIFICATION LINEAR
    MAGNIFICATION LINEAR
    MIPMAP LINEAR
    [/TEXTURE]
    [TEXTURE]
    NAME FHB_muscle_diffuse
    PATH FHB_muscle_diffuse.pvr
    MINIFICATION LINEAR
    MAGNIFICATION LINEAR
    MIPMAP LINEAR
    [/TEXTURE]
    [TEXTURE]
    NAME Inferior_Extensor_Retinaculum_normal
    PATH Inferior_Extensor_Retinaculum_normal.pvr
    MINIFICATION LINEAR
    MAGNIFICATION LINEAR
    MIPMAP LINEAR
    [/TEXTURE]
    [TEXTURE]
    NAME Inferior_Extensor_Retinaculum_transparency
    PATH Inferior_Extensor_Retinaculum_transparency.pvr
    MINIFICATION LINEAR
    MAGNIFICATION LINEAR
    MIPMAP LINEAR
    [/TEXTURE]
    [TEXTURE]
    NAME pasted_NOlines_diffuse
    PATH pasted_NOlines_diffuse.pvr
    MINIFICATION LINEAR
    MAGNIFICATION LINEAR
    MIPMAP LINEAR
    [/TEXTURE]

    #55017

    Theo
    Member

    Ok. I think we have a misunderstanding here.
    Let’s clarify a few more things:

    – If you are moving to our new sdk: then we have already ported the deferredshading ogles to work with our new sdk using our legacy pfx. The example is part of the sdk pakage. You will find it under Example/Advance/DeferredShading/OGLES

    For vulkan we are using new pfx which is xml driven and will be used from now on. The legacy pfx is deprecated.

    – We see no reson for you to port the deferredshading from 3.2 to 16.2 since we have already done it for you.
    If you still want to do it. then it should be pretty simple to diff with our port.
    You have to be aware that you need to create the descriptor sets, pipelines, renderpasses, fbo (once again it is alreay done in 16.2).

    #55020

    joel
    Member

    i wasn’t trying to port the the defferredshading example. i am using your example and tweaking it so that i can use my models with the new framework. the example is using the legacy pfx. in fact there is only one example that has an xml based example and the documentation shows nothing about the xml style version. if you want people to use the new ways you should get some documentation that explains how to use the new system. here is a copy of the exact pfx before i did any changes to it.

    [HEADER]
    VERSION 01.00.00.00
    DESCRIPTION OGLESDeferredShading Effects. Multiple Render Target versions.
    COPYRIGHT Imagination Technologies
    [/HEADER]

    ///////////////////////////////////////////////////////////////////////////
    //// ////
    //// GBUFFER EFFECTS ////
    //// ////
    ///////////////////////////////////////////////////////////////////////////

    ///////////////////////////////////////////////////////////////////////////
    //// RenderGBuffer: Effects for tangent-space models(bumpmapped) ////
    ///////////////////////////////////////////////////////////////////////////
    [EFFECT]
    NAME RenderGBuffer

    // GLOBALS UNIFORMS
    UNIFORM uWorldViewProjMatrix WORLDVIEWPROJECTION
    UNIFORM uWorldViewMatrix WORLDVIEW
    UNIFORM uWorldViewIT WORLDVIEWIT

    UNIFORM sTexture TEXTURE0
    UNIFORM sBumpMap TEXTURE1

    // ATTRIBUTES
    ATTRIBUTE inVertex POSITION
    ATTRIBUTE inNormal NORMAL
    ATTRIBUTE inTexCoord UV0
    ATTRIBUTE inTangent TANGENT

    // CUSTOM SEMANTICS
    UNIFORM uFarClipDistance CUSTOMSEMANTIC_FARCLIPDISTANCE

    UNIFORM uSpecularStrength CUSTOMSEMANTIC_SPECULARSTRENGTH
    UNIFORM uDiffuseColor CUSTOMSEMANTIC_DIFFUSECOLOUR

    // SHADERS
    VERTEXSHADER GBufferVertexShader
    FRAGMENTSHADER GBufferFragmentShader
    [/EFFECT]

    [VERTEXSHADER]
    NAME GBufferVertexShader

    [GLSL_CODE]
    #version 300 es

    #define VERTEX_ARRAY 0
    #define NORMAL_ARRAY 1
    #define TEXCOORD_ARRAY 2
    #define TANGENT_ARRAY 3

    layout(location = VERTEX_ARRAY) in highp vec3 inVertex;
    layout(location = NORMAL_ARRAY) in highp vec3 inNormal;
    layout(location = TEXCOORD_ARRAY) in mediump vec2 inTexCoord;
    layout(location = TANGENT_ARRAY) in highp vec3 inTangent;

    uniform mat4 uWorldViewProjMatrix;
    uniform mat4 uWorldViewMatrix;
    uniform mat3 uWorldViewIT;

    out mediump vec2 vTexCoord;
    out highp vec3 vNormal;
    out highp vec3 vTangent;
    out highp vec3 vBinormal;
    out highp vec3 vViewPos;

    void main()
    {
    gl_Position = uWorldViewProjMatrix * vec4(inVertex, 1.0);

    // Transform normal from model space to eye space
    vNormal = uWorldViewIT * inNormal;
    vTangent = uWorldViewIT * inTangent;
    vBinormal = cross(vNormal, vTangent);

    // Pass the vertex position in view space for depth calculations
    vViewPos = (uWorldViewMatrix * vec4(inVertex, 1.0)).xyz;

    // Pass the texture coordinates to the fragment shader
    vTexCoord = inTexCoord;
    }
    [/GLSL_CODE]
    [/VERTEXSHADER]

    [FRAGMENTSHADER]
    NAME GBufferFragmentShader

    [GLSL_CODE]
    #version 300 es

    uniform sampler2D sTexture;
    uniform sampler2D sBumpMap;

    uniform highp float uFarClipDistance;
    uniform lowp float uSpecularStrength;
    uniform lowp vec3 uDiffuseColor;

    in mediump vec2 vTexCoord;
    in highp vec3 vNormal;
    in highp vec3 vTangent;
    in highp vec3 vBinormal;
    in highp vec3 vViewPos;

    layout(location = 0) out lowp vec4 oAlbedo;
    layout(location = 1) out highp vec3 oNormal;
    layout(location = 2) out highp vec4 oDepth;

    void main()
    {
    // Calculate the albedo
    lowp vec3 albedo = texture(sTexture, vTexCoord).rgb * uDiffuseColor;
    // Pack the specular exponent with the albedo
    oAlbedo = vec4(albedo, uSpecularStrength);

    // Calculate viewspace perturbed normal
    highp vec3 bumpmap = normalize(texture(sBumpMap, vTexCoord).rgb * 2.0 – 1.0);
    highp mat3 tangentSpace = mat3(normalize(vTangent), normalize(vBinormal), normalize(vNormal));
    highp vec3 normalVS = tangentSpace * bumpmap;

    // Scale the normal range from [-1,1] to [0, 1] to pack it into the RGB_U8 texture
    oNormal.xyz = normalVS * 0.5 + 0.5;

    // Pack the depth value into 4 channels
    // Pack the depth value into 4 channels
    highp float scaledDepth = length(vViewPos) / uFarClipDistance;
    highp vec4 enc = vec4(1.0, 255.0, 65025.0, 160581375.0) * scaledDepth;
    enc = fract(enc);
    enc -= enc.yzww * vec4(1.0/255.0,1.0/255.0,1.0/255.0,0.0);

    oDepth = enc;
    }
    [/GLSL_CODE]
    [/FRAGMENTSHADER]

    ///////////////////////////////////////////////////////////////////////////
    //// ////
    //// RenderGBufferFloor: Effects for non-bumpmapped models ////
    //// ////
    ///////////////////////////////////////////////////////////////////////////
    [EFFECT]
    NAME RenderGBufferFloor

    // GLOBALS UNIFORMS
    UNIFORM uWorldViewProjMatrix WORLDVIEWPROJECTION
    UNIFORM uWorldViewIT WORLDVIEWIT
    UNIFORM uWorldViewMatrix WORLDVIEW

    // ATTRIBUTES
    ATTRIBUTE inVertex POSITION
    ATTRIBUTE inNormal NORMAL
    ATTRIBUTE inTexCoord UV0

    // CUSTOM SEMANTICS
    UNIFORM uFarClipDistance CUSTOMSEMANTIC_FARCLIPDISTANCE

    UNIFORM uSpecularStrength CUSTOMSEMANTIC_SPECULARSTRENGTH
    UNIFORM uDiffuseColor CUSTOMSEMANTIC_DIFFUSECOLOUR

    // SHADERS
    VERTEXSHADER GBufferFloorVertexShader
    FRAGMENTSHADER GBufferFloorFragmentShader
    [/EFFECT]

    [VERTEXSHADER]
    NAME GBufferFloorVertexShader

    [GLSL_CODE]
    #version 300 es

    #define VERTEX_ARRAY 0
    #define NORMAL_ARRAY 1
    #define TEXCOORD_ARRAY 2

    layout(location = VERTEX_ARRAY) in highp vec3 inVertex;
    layout(location = NORMAL_ARRAY) in highp vec3 inNormal;
    layout(location = TEXCOORD_ARRAY) in mediump vec2 inTexCoord;

    uniform mat4 uWorldViewProjMatrix;
    uniform mat4 uWorldViewMatrix;
    uniform mat3 uWorldViewIT;

    out mediump vec2 vTexCoord;
    out highp vec3 vNormal;
    out highp vec3 vViewPos;

    void main()
    {
    gl_Position = uWorldViewProjMatrix * vec4(inVertex, 1.0);

    // Transform normal from model space to eye space
    vNormal = uWorldViewIT * inNormal;

    // Pass the vertex position in view space for depth calculations
    vViewPos = (uWorldViewMatrix * vec4(inVertex, 1.0)).xyz;

    // Pass the texture coordinates to the fragment shader
    vTexCoord = inTexCoord;
    }
    [/GLSL_CODE]
    [/VERTEXSHADER]

    [FRAGMENTSHADER]
    NAME GBufferFloorFragmentShader

    [GLSL_CODE]
    #version 300 es

    uniform sampler2D sTexture;

    uniform lowp float uSpecularStrength;
    uniform lowp vec3 uDiffuseColor;
    uniform highp float uFarClipDistance;

    in highp vec3 vNormal;
    in highp vec2 vTexCoord;
    in highp vec3 vViewPos;

    layout(location = 0) out lowp vec4 oAlbedo;
    layout(location = 1) out highp vec3 oNormal;
    layout(location = 2) out highp vec4 oDepth;

    void main()
    {
    // Pack the specular exponent with the albedo
    oAlbedo = vec4(texture(sTexture, vTexCoord).rgb * uDiffuseColor, uSpecularStrength);

    // Pack the normal
    oNormal.xyz = normalize(vNormal) * .5 + .5;

    // Pack the depth value into 4 channels
    highp float scaledDepth = length(vViewPos) / uFarClipDistance;
    highp vec4 enc = vec4(1.0, 255.0, 65025.0, 160581375.0) * scaledDepth;
    enc = fract(enc);
    enc -= enc.yzww * vec4(1.0/255.0,1.0/255.0,1.0/255.0,0.0);

    oDepth = enc;
    }
    [/GLSL_CODE]
    [/FRAGMENTSHADER]

    ///////////////////////////////////////////////////////////////////////////
    //// ////
    //// DEFERRED LIGHT SHADERS ////
    //// ////
    ///////////////////////////////////////////////////////////////////////////

    //
    // Calculates the lighting for a point light source
    //
    [EFFECT]
    NAME RenderPointLight

    // GLOBALS UNIFORMS
    UNIFORM uWorldViewProjMatrix WORLDVIEWPROJECTION
    UNIFORM uWorldViewMatrix WORLDVIEW
    UNIFORM uLightColorIntensity LIGHTCOLOR

    UNIFORM sAlbedo TEXTURE0
    UNIFORM sNormals TEXTURE1
    UNIFORM sDepth TEXTURE2

    // CUSTOM SEMANTICS
    UNIFORM uFarClipDistance CUSTOMSEMANTIC_FARCLIPDISTANCE

    UNIFORM uLightViewPosition CUSTOMSEMANTIC_POINTLIGHT_VIEWPOSITION

    // ATTRIBUTES
    ATTRIBUTE inVertex POSITION

    // SHADERS
    VERTEXSHADER DeferredVertexShader
    FRAGMENTSHADER PointLightFragmentShader
    [/EFFECT]

    //
    // Vertex shader that is shared amongst (most) deferred light shaders
    //
    [VERTEXSHADER]
    NAME DeferredVertexShader

    [GLSL_CODE]
    #version 300 es

    #define VERTEX_ARRAY 0

    layout(location = VERTEX_ARRAY) in highp vec3 inVertex;

    uniform mat4 uWorldViewProjMatrix;
    uniform mat4 uWorldViewMatrix;

    out highp vec3 vPositionVS;
    out highp vec3 vViewDirVS;
    out mediump vec2 vTexCoord;

    void main()
    {
    gl_Position = uWorldViewProjMatrix * vec4(inVertex, 1.0);
    gl_Position.xyz = gl_Position.xyz / gl_Position.w;
    gl_Position.w = 1.0;

    vTexCoord = (gl_Position.xy + 1.0) * 0.5;

    // Calculate the view-space position for lighting calculations
    vPositionVS = (uWorldViewMatrix * vec4(inVertex, 1.0)).xyz;

    // Pass the view direction
    vViewDirVS = vPositionVS;
    }
    [/GLSL_CODE]
    [/VERTEXSHADER]

    [FRAGMENTSHADER]
    NAME PointLightFragmentShader

    [GLSL_CODE]
    #version 300 es

    uniform sampler2D sAlbedo;
    uniform sampler2D sNormals;
    uniform sampler2D sDepth;

    uniform highp float uFarClipDistance;
    uniform highp vec3 uLightColorIntensity;

    uniform highp mat3 uWorldIT;
    uniform highp vec3 uLightViewPosition;

    in highp vec3 vPositionVS;
    in highp vec3 vViewDirVS;
    in mediump vec2 vTexCoord;

    layout(location = 0) out lowp vec4 oColor;

    void main()
    {
    //
    // Read GBuffer attributes
    //
    highp vec4 depthTex = texture(sDepth, vTexCoord);
    highp vec4 albedoSpec = texture(sAlbedo, vTexCoord);
    highp vec3 normalTex = texture(sNormals, vTexCoord).xyz;

    // reconstruct original depth value
    highp float depth = dot(depthTex, vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/160581375.0));

    //
    // Reconstruct common vectors and world space position
    //
    highp vec3 positionVS = normalize(vPositionVS) * depth * uFarClipDistance;
    highp vec3 lightDirection = uLightViewPosition – positionVS;
    highp float lightDistance = length(lightDirection);
    lightDirection /= lightDistance;

    //
    // Calculate lighting terms
    //
    highp vec3 normal = normalize(normalTex * 2.0 – 1.0);
    highp float n_dot_l = max(dot(lightDirection, normal), 0.0);
    highp vec3 diffuse = n_dot_l * albedoSpec.rgb;

    highp vec3 viewDirection = normalize(vViewDirVS);
    highp vec3 reflectedLightDirection = reflect(lightDirection, normal);
    highp float v_dot_r = max(dot(viewDirection, reflectedLightDirection), 0.0);
    diffuse += vec3(pow(v_dot_r, 16.0) * albedoSpec.a);

    //Subtracting a small number and clamping makes for a much better falloff look.
    highp float attenuation = max(1. / (1. + 1. * lightDistance * lightDistance) -.001, 0.);
    oColor = vec4(diffuse * uLightColorIntensity * attenuation, 1.0);
    }
    [/GLSL_CODE]
    [/FRAGMENTSHADER]

    //
    // Calculates the lighting for a directional light source
    //
    [EFFECT]
    NAME RenderDirectionalLight

    // GLOBALS UNIFORMS
    UNIFORM uLightColorIntensity LIGHTCOLOR

    UNIFORM sAlbedo TEXTURE0
    UNIFORM sNormals TEXTURE1

    // CUSTOM SEMANTICS
    UNIFORM uLightDirection CUSTOMSEMANTIC_DIRECTIONALLIGHT_DIRECTION

    // SHADERS
    VERTEXSHADER DirectionalLightVertexShader
    FRAGMENTSHADER DirectionalLightFragmentShader
    [/EFFECT]

    [VERTEXSHADER]
    NAME DirectionalLightVertexShader

    [GLSL_CODE]
    #version 300 es

    const highp vec2 positions[4]=vec2[4]
    (
    vec2(-1.,-1.),
    vec2( 1.,-1.),
    vec2(-1., 1.),
    vec2( 1., 1.)
    );

    out mediump vec2 vTexCoord;
    void main()
    {
    highp vec2 position = positions[gl_VertexID];

    gl_Position = vec4(position, 0.5, 1.);
    vTexCoord = position * .5 – .5; //Map -1..1->0..1
    }
    [/GLSL_CODE]
    [/VERTEXSHADER]

    [FRAGMENTSHADER]
    NAME DirectionalLightFragmentShader

    [GLSL_CODE]
    #version 300 es

    uniform sampler2D sAlbedo;
    uniform sampler2D sNormals;

    uniform highp vec3 uLightColorIntensity;
    uniform highp vec4 uLightDirection;

    in mediump vec2 vTexCoord;

    layout(location = 0) out lowp vec4 oColor;

    void main()
    {
    // Fetch required gbuffer attributes
    lowp vec3 albedo = texture(sAlbedo, vTexCoord).rgb;
    highp vec3 normalTex = texture(sNormals, vTexCoord).xyz;
    highp vec3 normal = normalTex.xyz * 2.0 – vec3(1.0);

    // Calculate simple diffuse lighting
    highp float n_dot_l = max(dot(-uLightDirection.xyz, normal.xyz), 0.0);
    lowp vec3 color = albedo * (n_dot_l * uLightColorIntensity + vec3(.2, .2, .1));

    oColor = vec4(color, 1.0);
    }
    [/GLSL_CODE]
    [/FRAGMENTSHADER]

    ///////////////////////////////////////////////////////////////////////////
    //// ////
    //// AUXILIARY SHADERS ////
    //// ////
    ///////////////////////////////////////////////////////////////////////////

    //
    // Renders the geometry using a single color passed as an uniform.
    //
    [EFFECT]
    NAME RenderSolidColor

    // GLOBALS UNIFORMS
    UNIFORM uWorldViewProjMatrix WORLDVIEWPROJECTION
    UNIFORM uConstantColor MATERIALCOLORAMBIENT

    // ATTRIBUTES
    ATTRIBUTE inVertex POSITION

    // SHADERS
    VERTEXSHADER VertexShader
    FRAGMENTSHADER SolidColorFragmentShader
    [/EFFECT]

    [VERTEXSHADER]
    NAME VertexShader

    [GLSL_CODE]
    #version 300 es

    layout(location = 0) in highp vec3 inVertex;

    uniform mat4 uWorldViewProjMatrix;

    void main()
    {
    // pass-through position and texture coordinates
    gl_Position = uWorldViewProjMatrix * vec4(inVertex, 1.0);
    }
    [/GLSL_CODE]
    [/VERTEXSHADER]

    [FRAGMENTSHADER]
    NAME SolidColorFragmentShader

    [GLSL_CODE]
    #version 300 es

    uniform lowp vec4 uConstantColor;

    layout(location = 0) out lowp vec4 oColor;

    void main()
    {
    oColor = uConstantColor;
    }
    [/GLSL_CODE]
    [/FRAGMENTSHADER]

    [EFFECT]
    NAME RenderNullColor

    // GLOBALS UNIFORMS
    UNIFORM uWorldViewProjMatrix WORLDVIEWPROJECTION

    // ATTRIBUTES
    ATTRIBUTE inVertex POSITION

    // SHADERS
    VERTEXSHADER VertexShader
    FRAGMENTSHADER NullFragmentShader
    [/EFFECT]

    [FRAGMENTSHADER]
    NAME NullFragmentShader

    [GLSL_CODE]
    #version 300 es
    void main() { }
    [/GLSL_CODE]
    [/FRAGMENTSHADER]

    As you can see the example comes with the legacy.pfx style and you don’t have documentation on the new format. So I am not really sure what you are trying to tell me. I am only using your example to try and figure out how to get our old system working with the new framework. the question still remains as to why your code does not grab the correct textures as listed in the pfx file. it was ignoring them until i made the change in code. if i can avoid making changes in the framework i want to because i lose track of the changes when updates happen and it’s a pain. i would love some insight into using the new pfx format so that we are not stuck updating that later as well. I just want to make sure that I am not doing anything overly wrong when i expect the textures that are listed on the pfx file to be the ones that show up on screen. I noticed that your examples don’t reference textures in the pfx files. is that expected? is what I am doing incorrect. just reading through the code that i posted did not make sense it will never use the matched texture name index to get the texture which just seems wrong. Sorry i know this was alot of questions just trying to get a good understanding. You guys have made an amazing product that we love to use and have been very succesful with. This new version looks great but it is such a big change that it is causing some frustration and i sometimes don’t know if i am doing something wrong or if i am misunderstanding things. thanks again for the help

    #55021

    joel
    Member

    after reading back through your answer again. i have a question. We are using powerVR as the framework for our engine that is running on ios, android, and through emscripten to the web. we want to have one version of the system for a bit because performance is not a huge issue. everything we have already works fine with high framerates. the question now is if we are going to continue with ogles then will we only want to use the legacy pfx or will we want to update to the xml type that is in the skinning example? (by the way the skinning example is the only one for ios that i cannot get to run). I really want to get our upgrade path going and that is the research that i am doing right now but I am not sure of the roadmap. Thanks again for the help

    #55022

    Theo
    Member

    First of all, thank you for using and appreciating our SDK.

    The reason why you don’t see any change is because the textures are taken from the pod file (or the model), not the pfx. The framework does not automaticaly create the textures when using the legacy PFX format.

    What you have to do is look for a assetManager.getTextureWithCaching(…) section and change that to get the textures from the pfx instead of the podfile.

    Apologies for not releasing the new pfx format documentation. We are currently cleaning up the documentation and will nbe making it available very soon.

    #55023

    joel
    Member

    That is great news on the documentation. i look forward to seeing it. thanks for all of the help.

    1 user thanked author for this post.
Viewing 8 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic.