Texture Splatting [OpenGL]

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
reason
Posts: 5
Joined: Tue Oct 25, 2011 10:06 am

Re: Texture Splatting [OpenGL]

Post by reason »

Ohh, and its been a few days now since i commented. So ive lost interest anyways :P switching to ogre.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Texture Splatting [OpenGL]

Post by hybrid »

Yeah, freat bug report you made there. And your previous post is - really incredible - 60 *seconds* old. Can't really imagine why no one answered you in between. So best of luck with your patience and skills for problem reporting at the next engine.
ACE247
Posts: 704
Joined: Tue Mar 16, 2010 12:31 am

Re: Texture Splatting [OpenGL]

Post by ACE247 »

'Reason' yeah have fun with OGRE its so abstracted and messy... Well I wont say any more.
reason
Posts: 5
Joined: Tue Oct 25, 2011 10:06 am

Re: Texture Splatting [OpenGL]

Post by reason »

by hybrid » Sat Oct 29, 2011 11:14 am

Yeah, freat bug report you made there. And your previous post is - really incredible - 60 *seconds* old. Can't really imagine why no one answered you in between. So best of luck with your patience and skills for problem reporting at the next engine.
Do you really think my brain is a peanut or something?

Lets take look at this example:
Hey, guys can you help me fix this error? It says "....."
3 days later.. No answer concerning your post.
The error is still there even when i did "......"
60 seconds later
Ohh, and by the way.. I gave up.. Seems like it wasent the right thing for me "........"
You obviously cant see the connection between the posts. Maybe you have a social disorder or something, and if that is the case then i must excuse myself, but if not then you should start taking a better look at the posts before you bomb me with your invalid arguments for no reason.

Im just a game enthusiast trying to learn new stuff, but obviously you guys dont want me to learn anything.

As for this:
by ACE247 » Sat Oct 29, 2011 1:40 pm
'Reason' yeah have fun with OGRE its so abstracted and messy... Well I wont say any more.
Have you ever tried the new terrain system in ogre? You can input a 61441x61441 pixel height map, and still get a stable fps. (this does not mean that i hate Irrlicht, infact it is one of the best game engines ive ever tried.)

Oh, and have i ever said that i dislike Irrlicht?? Because you guys obviously think so.

This is not personal, so no offence. And also i might have som english errors.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Texture Splatting [OpenGL]

Post by hybrid »

reason wrote:Only problem is:
by roelor » Tue Jun 08, 2010 12:05 am

this doesnt work well on my intel gma 4500. framerate is low, (thats to be expected) but the terrain is transparant in the distance. (you can look through the terrain).

by freetimecoder » Wed Jun 09, 2010 9:03 am

Hi,

Is it transparent only in the distance or everywhere? Only in the distance. Does it look like on the screenshot, ecxept the transparency? Looks like on the screenshots. What OpenGL/GLSL version do you have? OpenGL 2.1 Does it give any errors in the console? Dont think so.

greetings
Thank you :)
Ok, so this is your problem report. At first and second glance there's even no report from you. Only once we learn that you put your report inside the reply from freetimecoder we can get a slight idea about what you mean. Next post tells us that you have many RAM and an unknown gfx card, again with lots of RAM. Guess what might help us more to know instead of the amount of RAM you have...
So next time you respond to a thread more than a year old you should expect longer turn around times anyway. And with regard to your report, you should be happy with any response. A proper report would contain screenshots, a console log, the whole hardware list that is of interest, and a fully working demo which reproduces the problem. In that case you might decrease your waiting times by orders of magnitude probably. But since this is an external add-on, it may take still a little longer because no one might work with it regularly. And last, it might also help to get familiar with this community first, before demanding any action to be taken. 4 postings is not what we call a power user. So make your credits, fix this add-on and help all osx users out there. Might help you in the future when looking for help :idea:
ACE247
Posts: 704
Joined: Tue Mar 16, 2010 12:31 am

Re: Texture Splatting [OpenGL]

Post by ACE247 »

WOAOW!! Problem report? Problematic report...
PS do you have any idea how that terrain works? Didn't think so. I can make the same thing in irrlicht thanks to the magic of guess what? Shaders and proper programming. :lol:
reason
Posts: 5
Joined: Tue Oct 25, 2011 10:06 am

Re: Texture Splatting [OpenGL]

Post by reason »

Thing is hybrid.

I may be a noob.
I may be unexperienced.
I may be a nonperfect human being.

but that doesnt give you the right to deprive me the right to ask for help. I never expected him or anyone to reply me.

Just to make it clear.
by reason » Fri Oct 28, 2011 11:49 pm

Ohh, and its been a few days now since i commented. So ive lost interest anyways switching to ogre.
This does not mean that i hate Irrlicht!!
by ACE247 » Tue Nov 01, 2011 2:40 pm

WOAOW!! Problem report? Problematic report...
PS do you have any idea how that terrain works? Didn't think so. I can make the same thing in irrlicht thanks to the magic of guess what? Shaders and proper programming.
You probably can, and wouldnt doubt it, but i cant and thats why im going to test Ogre, because its easier for ME. Maybe not for you.

Thanks for your opinions, but lets make peace guys. Im a n00b trying to learn, so lets just leave it at it.
And also respect hybrid, you are probably extremely skilled compared to me.
wiedzmin112
Posts: 30
Joined: Tue Oct 18, 2011 3:48 pm

Re: Texture Splatting [OpenGL]

Post by wiedzmin112 »

My splatting editor :)

http://www.youtube.com/watch?v=iKYeCssIgjg


Sorry for low quality

Very thx for your code.
ACE247
Posts: 704
Joined: Tue Mar 16, 2010 12:31 am

Re: Texture Splatting [OpenGL]

Post by ACE247 »

Hey nice editor! :) Almost missed this. What are you using to handle your GUI, QT?
wiedzmin112
Posts: 30
Joined: Tue Oct 18, 2011 3:48 pm

Re: Texture Splatting [OpenGL]

Post by wiedzmin112 »

I'm using Visual Studio Products.
First I export functions to dll by extern "C" __delspec(dllexport) ...
and later create GUI in Visual Studio C# 2010(I build dll in VS C++ 2010) and import this functions to C#

Code: Select all

 
using System.Runtime.InteropServices;
...(namespace main class)...
    public partial class Main : Form
    {
 
        public const string DLLName = "DarkMap Dynamic Library.dll";
        #region PInvoke
        [DllImport(@DLLName, CallingConvention = CallingConvention.Cdecl)]
        internal static extern void InitEditor(IntPtr window);
        [DllImport(@DLLName, CallingConvention = CallingConvention.Cdecl)]
        internal static extern void UpdateEditor();
        [DllImport(@DLLName, CallingConvention = CallingConvention.Cdecl)]
        internal static extern IntPtr GetGrid();
        [DllImport(@DLLName, CallingConvention = CallingConvention.Cdecl)]
        internal static extern IntPtr GetNodeFromMouse(int type);
        [DllImport(@DLLName, CallingConvention = CallingConvention.Cdecl)]
        internal static extern void Deselect();
        [DllImport(@DLLName, CallingConvention = CallingConvention.Cdecl)]
        internal static extern void ResetEditor();
.....
 
Working very good.

For keyboard and mouse events first i check event from c# and send to c++ dll like this

Code: Select all

 
        private void Main_KeyDown(object sender, KeyEventArgs e)
        {
            AltDown = e.Alt;
            if (e.Alt)
                Input.InputKeyDown(256);
            else
                Input.InputKeyUp(256);
 
            if (e.Control)
                Input.InputKeyDown(255);
            else
                Input.InputKeyUp(255);
            Input.InputKeyDown(e.KeyValue);
        }
 
Sorry for my bad english (and small off-topic ;p - later i create another topic)

wiedzmin112
Katsankat
Posts: 178
Joined: Sun Mar 12, 2006 4:15 am
Contact:

Re: Texture Splatting [OpenGL]

Post by Katsankat »

Excellent :D

Do you know if there is a way to remove this line?

Code: Select all

terrain->setMaterialFlag(video::EMF_LIGHTING,false);
Sinsemilla
Posts: 38
Joined: Mon Jan 09, 2012 5:07 pm

Re: Texture Splatting [OpenGL]

Post by Sinsemilla »

Hi, sorry if i bump an old thread, i am not really sure if this is the right place to ask this.

I try to get the terrain splatting code to work with the water from this topic (http://irrlicht.sourceforge.net/forum/v ... =4&t=45627). Unfortunately there are some problems when i try to use both in combination together. There is no shore effect anymore as one can see in the sreenshot below. freetimecoder mentioned that the terrain splatting is not usable for the textures at once for a shader, i guess this is exactly what needs to be changed. The question i have now, is what would be the best way to achieve this?

Image

This is how it looks when its used on a terrain rendered as in example 12:

Image

The first screenshot is from the example where i added the code for the water, you can download the changed example from here:
http://www.mediafire.com/?72595cv8ldgx3a1

Thanks in advance for any advice
Bl00drav3n
Posts: 48
Joined: Sun Apr 22, 2012 11:55 pm
Location: Vienna
Contact:

Re: Texture Splatting [OpenGL]

Post by Bl00drav3n »

I really like that code, but I've got some questions.

Does this line of code actually do anything?
freetimecoder wrote:

Code: Select all

material.MaterialTypeParam =pack_texureBlendFunc(video::EBF_DST_COLOR,video::EBF_ONE);
Additionally, I always get black edges when using the alpha channel:
Image
Alpha-Texture:
Image

Actually the fragment shader output of the second pass should be blended with the color value already stored in the framebuffer, but instead it is blended with 0. I don't understand what is causing this.

Edit:
I guess it's an Irrlicht bug?
If I use the following code, everything works right:

Code: Select all

driver->setMaterial(material);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
driver->drawMeshBuffer(((scene::ITerrainSceneNode*)array_Nodes[i].Node)->getRenderBuffer());
glDisable(GL_BLEND);
I tried to change the pack_textureBlendFunc values to EBF_SRC_ALPHA and EBF_ONE_MINUS_SRC_ALPHA, but that resulted in black borders again. Here is a screenshot of my "bruteforce"-method:
Image

Edit2:
Actually I just found out that MaterialTypeParam is used by COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL for alpha testing.

Code: Select all

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glEnable(GL_ALPHA_TEST);
 
glAlphaFunc(GL_GREATER, material.MaterialTypeParam);
But there is definitly something wrong as it renders perfectly when enabling blending just before or right after COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL::OnSetMaterial() is called, which is pretty strange because this method enables blending too.
Bl00drav3n
Posts: 48
Joined: Sun Apr 22, 2012 11:55 pm
Location: Vienna
Contact:

Re: Texture Splatting [OpenGL]

Post by Bl00drav3n »

Did anybody have a look on this yet?

Edit:
I just took another look on the Irrlicht files and found out that this blending operations do not work with EMT_TRANSPARENT_ALPHA_CHANNEL but only with EMT_ONETEXTURE_BLEND, so in the constructor you need to fix this:

Code: Select all

//Create the shader material
shaderMaterial = driver->getGPUProgrammingServices()->addHighLevelShaderMaterial(
        vertShader, "main", video::EVST_VS_1_1,
        fragShader, "main", video::EPST_PS_1_1,
        this, video::EMT_ONETEXTURE_BLEND);
 
The default blending operation is EBO_MIN, so we have to set it to EBO_ADD and set src and dst to EBF_SRC_ALPHA and EBF_ONE_MINUS_SRC_ALPHA respectively to get the desired result:

Code: Select all

if(array_Nodes[i].Node->getType()==scene::ESNT_TERRAIN){
    video::SMaterial material = array_Nodes[i].Node->getMaterial(0);
    material.MaterialType = (video::E_MATERIAL_TYPE)shaderMaterial;
    material.BlendOperation = video::EBO_ADD;
    material.MaterialTypeParam = pack_textureBlendFunc(video::EBF_SRC_ALPHA ,video::EBF_ONE_MINUS_SRC_ALPHA);
 
    driver->setMaterial(material);
    driver->drawMeshBuffer(((scene::ITerrainSceneNode*)array_Nodes[i].Node)->getRenderBuffer());
}
Here is the result:
Image
Post Reply