Convert .Fx Shader To Ogre Format By Manually

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
cycheng
Gnoblar
Posts: 13
Joined: Thu Aug 31, 2006 3:35 pm

Convert .Fx Shader To Ogre Format By Manually

Post by cycheng »

Code: Select all

//-----------------------------------------------------------------------------
// File: Convert .Fx Shader To Ogre Format By Manually 
//
// Desc: 
// Keywords : [Multi-Pass] [Cartoon Shader] [NPR.fx] [RenderColorTarget]
// 
// Article By 2003 - 2007 The ISGD Team 
//       R.O.C Taiwan, Shih Hsin University, Information Management Department,
//       Intelligent System & Game Design Laboratory.
//       IM SHU IS.GD Labs, 世新大學 資管系 智慧型系統暨é

Vectrex
Ogre Magi
Posts: 1266
Joined: Tue Aug 12, 2003 1:53 am
Location: Melbourne, Australia
x 1
Contact:

Post by Vectrex »

hi, do you have a zip file with the source for these? One of the free file hosters would do.

cycheng
Gnoblar
Posts: 13
Joined: Thu Aug 31, 2006 3:35 pm

Post by cycheng »

Yes! I have zip file for the source code and project file. But I do not have a free space to let you download it. Is there any problem to run the source code ?

( or could you give me your mail, I mail the zip file to you :) )

webteca
Kobold
Posts: 27
Joined: Wed Aug 01, 2007 3:29 pm
Location: Italy

Uhmm...

Post by webteca »

Hi cycheng,

I'm also playing with the Whiteboard shader in order to use it with Ogre, so I tried your code.

This is a screenshot:

Image

It seems to be ok for pass 1 but I'd expext a silhoutette-like rendering for pass 2. I'm going to take a deeper look at this.

Anyway, thanks a lot for sharing. You saved me a lot o time ;)
Roberto

P.S. there is a minor error in the Ogre.log: Error in material NPR_Whiteboard_Edge at line 75 of ShaderTesting.material: Invalid param_named_auto attribute - Parameter called worldViewProj does not exist.
In fact in NPR_Whiteboard_Edge_VS you declare a uniform float4x4 worldViewProj parameter, but worldViewProj is never used. I tried to remove it (also from the .material file) getting the same results but without this error in the log.

webteca
Kobold
Posts: 27
Joined: Wed Aug 01, 2007 3:29 pm
Location: Italy

Back again on NPR...

Post by webteca »

Ok. I finally got some time to spend on ATI's NPR-Whiteboard sample

This is what I finally got:

Image

As you can see I used (a slightly modified version of) the Compositor demo. As far as my test are concerned, the NPR_whiteboard provided by cycheng is ok if you change in file NPR_Whiteboard.hlsl:

Code: Select all

return edgeSqr > 0.07 * 0.07; 
with

Code: Select all

return edgeSqr < 0.07 * 0.07; 
You may also want to change, in ShaderTesting.compositor :

Code: Select all

texture rt0 512 512 PF_FLOAT16_GR 
with

Code: Select all

texture rt0 target_width target_height PF_FLOAT16_GR 
This further step obviously give you a better result with bigger resolutions.

In fact, this NPR_whiteboard shader is quite interesting: for example, you may change the Sobel filters sampling factor, tweaking some other parameters, and change a bit the edge fragment shader...

Here you are what you can get:

Image

I'm going to do more test on this... it seems to be a good starting point for understand more complex NPR shaders.

Roberto

P.S. Unfortunately the .cpp code do not work as expected, as it shows the behaviour reported in the previous post (I think that there is an error relateted to the compositor setup, but I did not investigate it).

Post Reply