Results 1 to 6 of 6

Thread: water effect work on ogles 2.0 again

  1. #1
    Lesser Wizard
    Join Date
    Feb 2013
    Posts
    142

    Default water effect work on ogles 2.0 again

    in example 8

    mesh = 0;//smgr->addHillPlaneMesh( "myHill",
    // core::dimension2d<f32>(20,20),
    // core::dimension2d<u32>(40,40), 0, 0,
    // core::dimension2d<f32>(0,0),
    // core::dimension2d<f32>(10,10));

    I try the water effect in OGLES2.0 good in ios 7.1 emulator

    so i enable the effect again

    please add stones.jpg and water.jpg in bin/game/ directory

    https://plus.google.com/photos/10618...41018774360364

    download site
    https://github.com/fatalfeel/proton_sdk_source

  2. #2
    Lesser Wizard
    Join Date
    Feb 2013
    Posts
    142

    Default demo on mobile

    https://plus.google.com/photos/10618...41018774360364

    today successful on android and ios


    Heil Proton
    Heil Proton
    Heil Proton

    all demo here
    https://plus.google.com/photos/10618...65088859640225

    Quote Originally Posted by feelthat View Post
    in example 8

    mesh = 0;//smgr->addHillPlaneMesh( "myHill",
    // core::dimension2d<f32>(20,20),
    // core::dimension2d<u32>(40,40), 0, 0,
    // core::dimension2d<f32>(0,0),
    // core::dimension2d<f32>(10,10));

    I try the water effect in OGLES2.0 good in ios 7.1 emulator

    so i enable the effect again

    please add stones.jpg and water.jpg in bin/game/ directory

    https://plus.google.com/photos/10618...41018774360364

    download site
    https://github.com/fatalfeel/proton_sdk_source
    Last edited by feelthat; 02-09-2015 at 09:46 AM.

  3. #3
    Lesser Wizard
    Join Date
    Feb 2013
    Posts
    142

    Default add spot light and directional light Ref

    https://code.google.com/p/jpcsp/sour...er.vert?r=1639

    i will follow above code to add spot light

    Quote Originally Posted by feelthat View Post
    https://plus.google.com/photos/10618...41018774360364

    today successful on android and ios


    Heil Proton
    Heil Proton
    Heil Proton

    all demo here
    https://plus.google.com/photos/10618...65088859640225

  4. #4
    Lesser Wizard
    Join Date
    Feb 2013
    Posts
    142

    Default add spot light today in ogles2!!!

    add spot light today in ogles2!!!

    the way to use spot and directional light

    SLight spotLightData;
    ILightSceneNode* scnode = smgr->addLightSceneNode(0, core::vector3df(0,5,20), video::SColorf(1.0f, 1.0f, 1.0f, 1.0f), 100.0f, -1);

    spotLightData = scnode->getLightData();

    spotLightData.Type = video::ELT_DIRECTIONAL;
    spotLightData.Direction = core::vector3df(0,0.3,1);
    spotLightData.Falloff = 60.0f;
    spotLightData.OuterCone = 20;
    scnode->setLightData(spotLightData);
    Last edited by feelthat; 02-12-2015 at 12:56 AM.

  5. #5
    Lesser Wizard
    Join Date
    Feb 2013
    Posts
    142

    Default Fixed pipeline function explain for GLSL

    Matrix_V.transformVect(CurrentLight.Position) = vce3( ViewMatrix * vec4(CurrentLight.Position,1)) -> get xyz

    LightDirInView(Matrix_V, CurrentLight.Direction) = Matrix_V.rotateVect( CurrentLight.Direction )
    => vec3(ViewMatrix * vec4(CurrentLight.Direction, 0)) ->get xyz

    Homogeneous coordinates

    Until then, we only considered 3D vertices as a (x,y,z) triplet. Let’s introduce w. We will now have (x,y,z,w) vectors.

    This will be more clear soon, but for now, just remember this :

    If w == 1, then the vector (x,y,z,1) is a position in space.
    If w == 0, then the vector (x,y,z,0) is a direction.

    ref. http://www.opengl-tutorial.org/begin...al-3-matrices/

    - - - Updated - - -

    //faster for spot light in GLSL

    void CLightSceneNode::setLightData(const video::SLight& light)
    {
    video::IVideoDriver* driver = SceneManager->getVideoDriver();

    LightData = light;

    if( driver->getDriverType() == video::EDT_OGLES2 )
    {
    LightData.OuterCone = (float)cos(LightData.OuterCone * 3.141615926 / 180.0f);
    LightData.InnerCone = (float)cos(LightData.InnerCone * 3.141615926 / 180.0f);
    }
    }

    //then in vsh

    void spotLight(in int index, in vec3 position, in vec3 normal, inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
    {
    vec3 L = uLightPosition[index] - position;
    float D = length(L);
    L = normalize(L);

    //must do outside or become flashlight follow camera
    //vec3 NSpotDir = (uViewMatrix * vec4(uLightDirection[index],0)).xyz;
    vec3 NSpotDir = normalize(uLightDirection[index]);

    //dot(NSpotDir and lightvector) = cos(angle)
    float spotEffect = dot(NSpotDir, -L);

    //if (spotEffect >= cos(radians(uLightOuterCone[index])))
    if (spotEffect >= uLightOuterCone[index] ) //-->simplize
    {
    float Attenuation = 1.0 / (uLightAttenuation[index].x + uLightAttenuation[index].y * D +
    uLightAttenuation[index].z * D * D);

    Attenuation *= pow(spotEffect, uLightFallOff[index]);

    ambient += uLightAmbient[index] * Attenuation;

    float NdotL = dot(normal, L);
    .
    .
    .
    }
    }

  6. #6
    Lesser Wizard
    Join Date
    Feb 2013
    Posts
    142

    Default direction and position transform

    if (LightCount > 0)
    {
    services->setPixelShaderConstant(MaterialAmbientID, reinterpret_cast<f32*>(&MaterialAmbient), 4);
    services->setPixelShaderConstant(MaterialDiffuseID, reinterpret_cast<f32*>(&MaterialDiffuse), 4);
    services->setPixelShaderConstant(MaterialEmissiveID, reinterpret_cast<f32*>(&MaterialEmissive), 4);
    services->setPixelShaderConstant(MaterialSpecularID, reinterpret_cast<f32*>(&MaterialSpecular), 4);
    services->setPixelShaderConstant(MaterialShininessID, &MaterialShininess, 1);

    //Matrix = V;
    Matrix_V = V;

    for (s32 i = 0; i < LightCount; ++i)
    {
    SLight CurrentLight = driver->getDynamicLight(i);

    //Matrix.transformVect(CurrentLight.Position);

    //Matrix_V.transformVect-> vec3(Vmatrix*vec4(Position, 1))
    //Matrix_V.rotateVect -> vec3(Vmatrix*vec4(Direction,0))
    switch (CurrentLight.Type)
    {
    case ELT_DIRECTIONAL:
    LightType[i] = 2;
    //put on Position, for the same use as opengl and oges1
    Matrix_V.rotateVect(-CurrentLight.Position, CurrentLight.Direction);
    break;
    case ELT_SPOT:
    LightType[i] = 1;
    Matrix_V.transformVect(CurrentLight.Position);
    Matrix_V.rotateVect(CurrentLight.Direction);
    CurrentLight.Direction = LightDirInView(Matrix_V, CurrentLight.Direction);
    break;
    default: // ELT_POINT
    Matrix_V.transformVect(CurrentLight.Position);
    LightType[i] = 0;
    break;
    }

    LightPosition[i] = CurrentLight.Position;
    LightDirection[i] = CurrentLight.Direction;
    LightAttenuation[i] = CurrentLight.Attenuation;
    LightAmbient[i] = CurrentLight.AmbientColor;
    LightDiffuse[i] = CurrentLight.DiffuseColor;
    LightSpecular[i] = CurrentLight.SpecularColor;
    LightOuterCone[i] = CurrentLight.OuterCone;
    LightFallOff[i] = CurrentLight.Falloff;
    }

    MAX_SHADER_LIGHTS = 8;
    services->setPixelShaderConstant(LightTypeID, reinterpret_cast<s32*>(LightType), MAX_SHADER_LIGHTS);
    services->setPixelShaderConstant(LightPositionID, reinterpret_cast<f32*>(LightPosition), 3*MAX_SHADER_LIGHTS);
    services->setPixelShaderConstant(LightDirectionID, reinterpret_cast<f32*>(LightDirection), 3*MAX_SHADER_LIGHTS);
    services->setPixelShaderConstant(LightAttenuationID,reinter pret_cast<f32*>(LightAttenuation), 3*MAX_SHADER_LIGHTS);
    services->setPixelShaderConstant(LightAmbientID, reinterpret_cast<f32*>(LightAmbient), 4*MAX_SHADER_LIGHTS);
    services->setPixelShaderConstant(LightDiffuseID, reinterpret_cast<f32*>(LightDiffuse), 4*MAX_SHADER_LIGHTS);
    services->setPixelShaderConstant(LightSpecularID, reinterpret_cast<f32*>(LightSpecular), 4*MAX_SHADER_LIGHTS);
    services->setPixelShaderConstant(LightOuterConeID, reinterpret_cast<f32*>(LightOuterCone), MAX_SHADER_LIGHTS);
    services->setPixelShaderConstant(LightFallOffID, reinterpret_cast<f32*>(LightFallOff), MAX_SHADER_LIGHTS);
    }


    Quote Originally Posted by feelthat View Post
    Matrix_V.transformVect(CurrentLight.Position) = vce3( ViewMatrix * vec4(CurrentLight.Position,1)) -> get xyz

    LightDirInView(Matrix_V, CurrentLight.Direction) = Matrix_V.rotateVect( CurrentLight.Direction )
    => vec3(ViewMatrix * vec4(CurrentLight.Direction, 0)) ->get xyz

    Homogeneous coordinates

    Until then, we only considered 3D vertices as a (x,y,z) triplet. Let’s introduce w. We will now have (x,y,z,w) vectors.

    This will be more clear soon, but for now, just remember this :

    If w == 1, then the vector (x,y,z,1) is a position in space.
    If w == 0, then the vector (x,y,z,0) is a direction.

    ref. http://www.opengl-tutorial.org/begin...al-3-matrices/

    - - - Updated - - -

    //faster for spot light in GLSL

    void CLightSceneNode::setLightData(const video::SLight& light)
    {
    video::IVideoDriver* driver = SceneManager->getVideoDriver();

    LightData = light;

    if( driver->getDriverType() == video::EDT_OGLES2 )
    {
    LightData.OuterCone = (float)cos(LightData.OuterCone * 3.141615926 / 180.0f);
    LightData.InnerCone = (float)cos(LightData.InnerCone * 3.141615926 / 180.0f);
    }
    }

    //then in vsh

    void spotLight(in int index, in vec3 position, in vec3 normal, inout vec4 ambient, inout vec4 diffuse, inout vec4 specular)
    {
    vec3 L = uLightPosition[index] - position;
    float D = length(L);
    L = normalize(L);

    //must do outside or become flashlight follow camera
    //vec3 NSpotDir = (uViewMatrix * vec4(uLightDirection[index],0)).xyz;
    vec3 NSpotDir = normalize(uLightDirection[index]);

    //dot(NSpotDir and lightvector) = cos(angle)
    float spotEffect = dot(NSpotDir, -L);

    //if (spotEffect >= cos(radians(uLightOuterCone[index])))
    if (spotEffect >= uLightOuterCone[index] ) //-->simplize
    {
    float Attenuation = 1.0 / (uLightAttenuation[index].x + uLightAttenuation[index].y * D +
    uLightAttenuation[index].z * D * D);

    Attenuation *= pow(spotEffect, uLightFallOff[index]);

    ambient += uLightAmbient[index] * Attenuation;

    float NdotL = dot(normal, L);
    .
    .
    .
    }
    }

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •