Modifying inbuilt material shaders

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!

Modifying inbuilt material shaders

Postby robmar » Fri Jul 20, 2012 4:39 pm

I suppose that there must be a standard set of shaders in GLSL and HLSL somewhere within the Irrlicht source code to rener the range of materials.

Anyone know where they are located?

I´d like to add a geometry shader so that the standard shaders can efficiently replicate objects with position offsets.
robmar
 
Posts: 565
Joined: Sun Aug 14, 2011 11:30 pm

Re: Modifying inbuilt material shaders

Postby Nadro » Sat Jul 21, 2012 12:25 am

Any GLSL and HLSL shaders aren't built-in an engine (only in OGL ES2 from a ogl-es branch). Irrlicht use fixed pipeline for built-in materials.

BTW. Only OpenGL driver supports a geometry shaders.
NBK Game Studio - Official Site:
http://www.nbkgamestudio.pl/
Nadro
 
Posts: 1000
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Modifying inbuilt material shaders

Postby robmar » Sat Jul 21, 2012 1:29 am

So the rendering is not performed by shader, not for transparent, for any other type of render?

Do OpenGL and D3D have standard render materials "built in"? It doesn´t seem very orthogonal...
robmar
 
Posts: 565
Joined: Sun Aug 14, 2011 11:30 pm

Re: Modifying inbuilt material shaders

Postby hybrid » Sat Jul 21, 2012 11:15 am

The normal map and parallay materials are using shaders. These are contained as strings in the respective material renderers.
hybrid
Admin
 
Posts: 13946
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany

Re: Modifying inbuilt material shaders

Postby robmar » Sat Jul 21, 2012 12:36 pm

Thanks for that!
robmar
 
Posts: 565
Joined: Sun Aug 14, 2011 11:30 pm

Re: Modifying inbuilt material shaders

Postby Nadro » Sat Jul 21, 2012 3:45 pm

hybrid wrote:The normal map and parallay materials are using shaders. These are contained as strings in the respective material renderers.

But these shaders are written in ASM. I thought that author asked only about HLSL/GLSL stuff :)
NBK Game Studio - Official Site:
http://www.nbkgamestudio.pl/
Nadro
 
Posts: 1000
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Modifying inbuilt material shaders

Postby robmar » Sat Jul 21, 2012 4:56 pm

yeah, didnt know they were in ASM! :) What more is there not to know!

I´m trying to find a way to combine 4 render textures into one final render texture each frame, where I need to use a shader to combine the pixel data from source to target, but as its af 2048 pixels wide, it has to be done ganz schnell fast.

Has to be done on a pixel->pixel basic, so all source pixels map to the same target render texture pixel location.

Should I make a plane mesh node and place it to cover the entire viewport, with an orthogonal camera, then use drawall, with a shader on the plane node to handle this, or am I missing a more obvious way to do this??
Last edited by robmar on Sat Jul 21, 2012 7:21 pm, edited 1 time in total.
robmar
 
Posts: 565
Joined: Sun Aug 14, 2011 11:30 pm

Re: Modifying inbuilt material shaders

Postby robmar » Sat Jul 21, 2012 7:20 pm

So would you just use a full screen quad with a shader, would that be the best way??
robmar
 
Posts: 565
Joined: Sun Aug 14, 2011 11:30 pm

Re: Modifying inbuilt material shaders

Postby hendu » Sun Jul 22, 2012 5:11 pm

Use a screen quad with a shader, yes. See the code snippets forum for some screen quads.
hendu
 
Posts: 1557
Joined: Sat Dec 18, 2010 12:53 pm

Re: Modifying inbuilt material shaders

Postby robmar » Sun Jul 22, 2012 6:15 pm

Thanks Hendu, think I found it in the postprocess sample, which I now see is similar to your Improved Quad post.

I wonder if all those setTransform calls are needed for each render?

I don´t really understand the coordinate system as I should, my head is frustrated with frustums! I´ve been trying to find a good tutorial if anyone knows one.

So with the calls below will the quad always fill the viewport exactly with the pixels undistorted, so that the shader will be able to set each screen pixel with the same texture-screen xy resolution addressing? - I mean pixel 0,0 in the texture will map to the screen 0,0, given texture and screen resolution is the same.


cpp Code: Select all
 
    // create screen quad vertices
    Vertices[0] = video::S3DVertex(-1.f, -1.f, 0.f, 0.f, 0.f, 1.f, video::SColor(255,255,255,255), 0.f, 1.f);
    Vertices[1] = video::S3DVertex(-1.f,  1.f, 0.f, 0.f, 0.f, 1.f, video::SColor(255,255,255,255), 0.f, 0.f);
    Vertices[2] = video::S3DVertex( 1.f,  1.f, 0.f, 0.f, 0.f, 1.f, video::SColor(255,255,255,255), 1.f, 0.f);
    Vertices[3] = video::S3DVertex( 1.f, -1.f, 0.f, 0.f, 0.f, 1.f, video::SColor(255,255,255,255), 1.f, 1.f);
 
    // clear the projection matrix
    Device->getVideoDriver()->setTransform(video::ETS_PROJECTION, core::IdentityMatrix);
   
    // clear the view matrix
    Device->getVideoDriver()->setTransform(video::ETS_VIEW, core::IdentityMatrix);
 
    // set the transform
    Device->getVideoDriver()->setTransform(video::ETS_WORLD, core::IdentityMatrix );
   
    // select the post proc material
    Device->getVideoDriver()->setMaterial(getMaterial());
 
    // render the screen quad
    Device->getVideoDriver()->drawIndexedTriangleList(Vertices, 4, Indices, 2);
 
robmar
 
Posts: 565
Joined: Sun Aug 14, 2011 11:30 pm

Re: Modifying inbuilt material shaders

Postby hendu » Sun Jul 22, 2012 6:46 pm

I wonder if all those setTransform calls are needed for each render?


Yes, unless you know for sure that some matrix is already identity. Fast call anyway.

So with the calls below will the quad always fill the viewport exactly with the pixels undistorted, so that the shader will be able to set each screen pixel with the same texture-screen xy resolution addressing? - I mean pixel 0,0 in the texture will map to the screen 0,0, given texture and screen resolution is the same.


Yes. You do need to set the current material to point sampling to have no filtering.
hendu
 
Posts: 1557
Joined: Sat Dec 18, 2010 12:53 pm

Re: Modifying inbuilt material shaders

Postby robmar » Mon Jul 23, 2012 10:06 am

Thanks again hendu, especially that point on point sampling, I´ll look that up....

Can´t find anything on how to set point sampling... why is this so hard at times?!
robmar
 
Posts: 565
Joined: Sun Aug 14, 2011 11:30 pm

Re: Modifying inbuilt material shaders

Postby hendu » Mon Jul 23, 2012 10:42 am

material.setFlag(EMF_BILINEAR_FILTER, false);

Also disable trilinear and aniso if you set those for that material.
hendu
 
Posts: 1557
Joined: Sat Dec 18, 2010 12:53 pm

Re: Modifying inbuilt material shaders

Postby robmar » Mon Jul 23, 2012 11:02 am

How did I miss that flag!! :) Really, thanks again!
robmar
 
Posts: 565
Joined: Sun Aug 14, 2011 11:30 pm


Return to Advanced Help

Who is online

Users browsing this forum: No registered users and 1 guest