Page 53 of 56

Re: XEffects - Reloaded - New Release (V 1.3)

Posted: Wed May 20, 2015 1:23 am
by mongoose7
Well, I just compiled it for myself and ...

Selecting Direct3D, everything is OK, but ...
Selecting OpenGL it is really weird. Not only do the dwarves have no shadows, they have no form either. It's like a weird postprocessing effect.

I ran this on Irrlicht 1.8.1. It used to work, though I may have run it on 1.8 then. It looks as if XEffects and Irrlicht are no longer friends.

I'm sorry but I cannot give you any more help. As I said, I don't use XEffects myself.

You could probably display the intermediate results in the same way you display the shadow map, and perhaps compare the DX and OGL versions as you do this until you find a point of difference. Maybe the OGL shader code is not correct. I ran it on the latest video drivers for the GTX 660 Ti.

Re: XEffects - Reloaded - New Release (V 1.3)

Posted: Wed May 20, 2015 8:19 am
by Harch
Thanks, I will try to do something :( Or I go to directx. And what do you use for effects xEffects instead?

Re: XEffects - Reloaded - New Release (V 1.3)

Posted: Wed May 20, 2015 8:39 am
by Harch
Removed from the scene and a transparent cube, and all lights. The result was as a picture with error (with transparent cube) o_O

Re: XEffects - Reloaded - New Release (V 1.3)

Posted: Wed May 20, 2015 1:04 pm
by Harch
At random determined that an error in this code (comment from the line item). When use a transparency "render()" function is not working. Why could it be?

Code: Select all

 
for(u32 i = 0;i < ShadowNodeArraySize;++i)
            {
                if(ShadowNodeArray[i].shadowMode == ESM_CAST || ShadowNodeArray[i].shadowMode == ESM_EXCLUDE)
                        continue;
 
                const u32 CurrentMaterialCount = ShadowNodeArray[i].node->getMaterialCount();
                core::array<irr::s32> BufferMaterialList(CurrentMaterialCount);
                core::array<irr::video::ITexture*> BufferTextureList(CurrentMaterialCount);
 
                for(u32 m = 0;m < CurrentMaterialCount;++m)
                {
                    BufferMaterialList.push_back(ShadowNodeArray[i].node->getMaterial(m).MaterialType);
                    BufferTextureList.push_back(ShadowNodeArray[i].node->getMaterial(m).getTexture(0));
 
                    ShadowNodeArray[i].node->getMaterial(m).MaterialType = (E_MATERIAL_TYPE)Shadow[ShadowNodeArray[i].filterType];
                    ShadowNodeArray[i].node->getMaterial(m).setTexture(0, currentShadowMapTexture);
                }
 
                ShadowNodeArray[i].node->OnAnimate(device->getTimer()->getTime());
                ShadowNodeArray[i].node->render(); //<<<---------------------------------------------------- render() don't work with transparent o_O !!!THIS!!!
 
                for(u32 m = 0;m < CurrentMaterialCount;++m)
                {
                    ShadowNodeArray[i].node->getMaterial(m).MaterialType = (E_MATERIAL_TYPE)BufferMaterialList[m];
                    ShadowNodeArray[i].node->getMaterial(m).setTexture(0, BufferTextureList[m]);
                }
                //if(i == 0)
                {
                    //...
                    driver->setRenderTarget(outputTarget, true, true, SColor(0x0)); //My tests...
                    irr::video::ITexture* rt = ScreenQuad.rt[1];
                    irr::core::recti srcrect = irr::core::recti(irr::core::vector2di(0, 0), rt->getSize());
                    irr::core::recti destrect = irr::core::recti(irr::core::vector2di(0, 0), irr::core::vector2di((int) (rt->getSize().Width), (int) (rt->getSize().Height)));
                    driver->draw2DImage(rt, destrect, srcrect);
                    driver->setRenderTarget(ScreenQuad.rt[1], true, true, SColor(0xffffffff));
                    //smgr->drawAll();
                    //...
                    printf("%d", i);
                    //getch();
                }
            }
 

Re: XEffects - Reloaded - New Release (V 1.3)

Posted: Thu May 21, 2015 1:17 am
by mongoose7
The render function is the one that displays the model. It is the only part of the code that actually does something!

I think there may be a problem with the shaders. Irrlicht only shows warnings if there is an error, otherwise it doesn't show them. So I think you should go into that code and print the warnings. As a guide, I think devsh's version prints GLSL warnings so you could look there.

My thinking is that the default version of GLSL is 1.1 or 1.2 or 1.5 (I don't remember which one). Previously, if you used features from a later version, the GLSL compiler would accept it. I think the compilers are more strict now.

This is the only thing I can think of except trying the other Irrlicht versions, like trunk and shader-pipeline. Or devsh's.

BTW The shaders are in the file EffectShaders.h.

Re: XEffects - Reloaded - New Release (V 1.3)

Posted: Thu May 21, 2015 11:53 am
by Harch
Maybe... But I rendered shadow map at each stage and find the difference between these two cases. It occurs just after this function. And I'm not very good at programming shaders ... Therefore such a difficult shader I hardly get correct ... Please, anybody can see who understands this?
In simple shaders I understand, but it is very difficult shader :(

mongoose7, thank you so much for helping me. And what do you use for effects?

Re: XEffects - Reloaded - New Release (V 1.3)

Posted: Fri May 22, 2015 2:38 am
by mongoose7
I wrote my own shaders. I didn't like the fact that XEffects subtracts shadows from the scene. I chose to add light where there are no shadows.

Re: XEffects - Reloaded - New Release (V 1.3)

Posted: Fri May 22, 2015 7:22 am
by Harch
Why is your approach is better?
And you did not create it as xEffects? Share your lighting system can? Or it is a secret? :(

Re: XEffects - Reloaded - New Release (V 1.3)

Posted: Fri May 22, 2015 11:51 am
by mongoose7
I'm not saying it is better. Though I guess you have seen that the XEffects lights don't light, they just remove shadows, so you have to render the scene anyway, or turn lighting off. I could put up an example but I need to think about how.

Re: XEffects - Reloaded - New Release (V 1.3)

Posted: Fri May 22, 2015 8:58 pm
by Harch
xEffects not want to work, I'll be grateful for your example...

Re: XEffects - Reloaded - New Release (V 1.3)

Posted: Sat May 23, 2015 1:14 am
by mongoose7
It will take a couple of days. You can't use DX?

Re: XEffects - Reloaded - New Release (V 1.3)

Posted: Sat May 23, 2015 6:58 pm
by Harch
I can, but I write a cross-platform, so use OpengL. DX is not installed.

Re: XEffects - Reloaded - New Release (V 1.3)

Posted: Sun May 24, 2015 9:46 am
by Harch
While mongoose7 is preparing an example may be someone who understands the shaders, look, why xEffects not work with a transparent material, please?

Re: XEffects - Reloaded - New Release (V 1.3)

Posted: Wed May 27, 2015 3:27 pm
by christianclavet
Interesting discussion. I was able to make it work with 1.9 SVN on GL but the rendering fail with some models and I didn't know why. Your idea that transparency could be an issue may be right. I've checked with a model that I have that I'm sure have transparent parts, and the shadow projection fail. Removing the object and shadow projection is fine again. Perhaps something is done with the ALPHA channel in the shader that make the shader fail.

Have you tried theses types of objects on DX? Is the rendering ok there?

EDIT: Checked the source code perhaps there is something in the EffectHandler.cpp file as (starting line 358):

Code: Select all

// Render all the excluded and casting-only nodes.
        for(u32 i = 0;i < ShadowNodeArraySize;++i)
        {
            if(ShadowNodeArray[i].shadowMode != ESM_CAST && ShadowNodeArray[i].shadowMode != ESM_EXCLUDE)
                    continue;
 
            const u32 CurrentMaterialCount = ShadowNodeArray[i].node->getMaterialCount();
            core::array<irr::s32> BufferMaterialList(CurrentMaterialCount);
            BufferMaterialList.set_used(0);
            
            for(u32 m = 0;m < CurrentMaterialCount;++m)
            {
                BufferMaterialList.push_back(ShadowNodeArray[i].node->getMaterial(m).MaterialType);
            
                switch(BufferMaterialList[m])
                {
                    case EMT_TRANSPARENT_ALPHA_CHANNEL_REF:
                        ShadowNodeArray[i].node->getMaterial(m).MaterialType = (E_MATERIAL_TYPE)WhiteWashTRef;
                        break;
                    case EMT_TRANSPARENT_ADD_COLOR:
                        ShadowNodeArray[i].node->getMaterial(m).MaterialType = (E_MATERIAL_TYPE)WhiteWashTAdd;
                        break;
                    case EMT_TRANSPARENT_ALPHA_CHANNEL:
                        ShadowNodeArray[i].node->getMaterial(m).MaterialType = (E_MATERIAL_TYPE)WhiteWashTAlpha;
                        break;
                    default:
                        ShadowNodeArray[i].node->getMaterial(m).MaterialType = (E_MATERIAL_TYPE)WhiteWash;
                        break;
                }
            }
 
Theses lines change the material type. So maybe for a unknown reason the current Irrlicht is not rendering the same way with the material taken.
The whitewash material is defined from line 54:

Code: Select all

WhiteWash = gpu->addHighLevelShaderMaterial(
            sPP.ppShader(SHADOW_PASS_1V[shaderExt]).c_str(), "vertexMain", video::EVST_VS_2_0,
            sPP.ppShader(WHITE_WASH_P[shaderExt]).c_str(), "pixelMain", video::EPST_PS_2_0,
            depthMC, video::EMT_SOLID);
 
        WhiteWashTRef = gpu->addHighLevelShaderMaterial(
            sPP.ppShader(SHADOW_PASS_1V[shaderExt]).c_str(), "vertexMain", video::EVST_VS_2_0,
            sPP.ppShader(WHITE_WASH_P[shaderExt]).c_str(), "pixelMain", video::EPST_PS_2_0,
            depthMC, video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF);
 
        WhiteWashTAdd = gpu->addHighLevelShaderMaterial(
            sPP.ppShader(SHADOW_PASS_1V[shaderExt]).c_str(), "vertexMain", video::EVST_VS_2_0,
            sPP.ppShader(WHITE_WASH_P_ADD[shaderExt]).c_str(), "pixelMain", video::EPST_PS_2_0,
            depthMC, video::EMT_TRANSPARENT_ALPHA_CHANNEL);
 
        WhiteWashTAlpha = gpu->addHighLevelShaderMaterial(
            sPP.ppShader(SHADOW_PASS_1V[shaderExt]).c_str(), "vertexMain", video::EVST_VS_2_0,
            sPP.ppShader(WHITE_WASH_P[shaderExt]).c_str(), "pixelMain", video::EPST_PS_2_0,
            depthMC, video::EMT_TRANSPARENT_ALPHA_CHANNEL);
Theses are calling a material named WHITEWASH defined in EffectShaders.h and here is the definition:

Code: Select all

const char* WHITE_WASH_P[ESE_COUNT] = {"uniform sampler2D ColorMapSampler;\n"
""
"void main() "
"{"
"   float alpha = texture2D(ColorMapSampler, gl_TexCoord[1].xy).a;\n"
""
"    gl_FragColor = vec4(1.0, 1.0, 1.0, alpha);\n"
"}"
,
"sampler2D ColorMapSampler : register(s0);\n"
""
"float4 pixelMain(float4 Color: TEXCOORD0, float2 Texcoords: TEXCOORD1) : COLOR0"
"{"
"   float alpha = tex2D(ColorMapSampler, Texcoords).a;\n"
""
"   return float4(1.0, 1.0, 1.0, alpha);\n"
"}"};
 
 
const char* WHITE_WASH_P_ADD[ESE_COUNT] = {"uniform sampler2D ColorMapSampler;\n"
"float luminance(vec3 color)"
"{"
"   return clamp(color.r * 0.3 + color.g * 0.59 + color.b * 0.11, 0.0, 1.0);\n"
"}"
"void main() "
"{"
"   vec4 diffuseTex = texture2D(ColorMapSampler, gl_TexCoord[1].xy);\n"
"   //diffuseTex *= gl_TexCoord[2];\n"
""
"    gl_FragColor = vec4(1.0, 1.0, 1.0, luminance(diffuseTex.rgb));\n"
"}"
,
"sampler2D ColorMapSampler : register(s0);\n"
""
"float luminance(float3 color)"
"{"
"   return clamp(color.r * 0.3 + color.g * 0.59 + color.b * 0.11, 0.0, 1.0);\n"
"}"
""
"float4 pixelMain(float4 Color : TEXCOORD0, float2 Texcoords : TEXCOORD1, float4 VColor : TEXCOORD2) : COLOR0"
"{"
"   float4 diffuseTex = tex2D(ColorMapSampler, Texcoords);\n"
"   diffuseTex *= VColor;\n"
""
"   return float4(1.0, 1.0, 1.0, luminance(diffuseTex.rgb));\n"
"}"};const char* WHITE_WASH_P[ESE_COUNT] = {"uniform sampler2D ColorMapSampler;\n"
""
"void main() "
"{"
"   float alpha = texture2D(ColorMapSampler, gl_TexCoord[1].xy).a;\n"
""
"    gl_FragColor = vec4(1.0, 1.0, 1.0, alpha);\n"
"}"
,
"sampler2D ColorMapSampler : register(s0);\n"
""
"float4 pixelMain(float4 Color: TEXCOORD0, float2 Texcoords: TEXCOORD1) : COLOR0"
"{"
"   float alpha = tex2D(ColorMapSampler, Texcoords).a;\n"
""
"   return float4(1.0, 1.0, 1.0, alpha);\n"
"}"};
 
 
const char* WHITE_WASH_P_ADD[ESE_COUNT] = {"uniform sampler2D ColorMapSampler;\n"
"float luminance(vec3 color)"
"{"
"   return clamp(color.r * 0.3 + color.g * 0.59 + color.b * 0.11, 0.0, 1.0);\n"
"}"
"void main() "
"{"
"   vec4 diffuseTex = texture2D(ColorMapSampler, gl_TexCoord[1].xy);\n"
"   //diffuseTex *= gl_TexCoord[2];\n"
""
"    gl_FragColor = vec4(1.0, 1.0, 1.0, luminance(diffuseTex.rgb));\n"
"}"
,
"sampler2D ColorMapSampler : register(s0);\n"
""
"float luminance(float3 color)"
"{"
"   return clamp(color.r * 0.3 + color.g * 0.59 + color.b * 0.11, 0.0, 1.0);\n"
"}"
""
"float4 pixelMain(float4 Color : TEXCOORD0, float2 Texcoords : TEXCOORD1, float4 VColor : TEXCOORD2) : COLOR0"
"{"
"   float4 diffuseTex = tex2D(ColorMapSampler, Texcoords);\n"
"   diffuseTex *= VColor;\n"
""
"   return float4(1.0, 1.0, 1.0, luminance(diffuseTex.rgb));\n"
"}"};
Here is a screen showing the shadow projection failing when an object containing transparent material is rendered:
Image
If you look at the picture, the "contour" is draw, but the shadow mass is absent. Also the "contour" is draw all over the image and not clipped. I'm using a directional light and using VSM.
EDIT: I'm adding the source of XEffect I'm using with Irrlicht SVN 1.9 if someone need it:
http://irrrpgbuilder.sourceforge.net/files/XEffects.zip

Re: XEffects - Reloaded - New Release (V 1.3)

Posted: Wed May 27, 2015 8:27 pm
by Harch
I've been tested. It seems to me, to blame the material DepthT. When I replaced it on Depth, then everything was drawn well, but no shadows from transparent objects. Above I wrote, after a string terminated rendering to a texture map with shadows in the case of transparent objects.

On DirectX everything works correctly.