Using SpecBump shaders inside ogre... interesting?

The place for artists, modellers, level designers et al to discuss their approaches for creating content for OGRE.
Post Reply
Foxer
Gnoblar
Posts: 16
Joined: Tue Nov 08, 2005 7:31 pm

Using SpecBump shaders inside ogre... interesting?

Post by Foxer »

Ok, so I used this code in the material file:

Code: Select all

material Material_#1203/Stripsmiddle3
{
	technique
	{
		pass
		{
			diffuse 1.0 1.0 1.0 1
			specular 1.0 1.0 1.0 1 20

			vertex_program_ref BumpMap_vs
			{
				param_named_auto view_proj_matrix worldviewproj_matrix
				param_named_auto inv_view_matrix inverse_worldview_matrix
				param_named_auto light_position light_position_object_space 0
				param_named_auto eye_position camera_position_object_space
			}

			fragment_program_ref BumpMap_ps
			{
				param_named bumpiness float 0.6
				param_named_auto ambient ambient_light_colour
				param_named Ka float 0.3
				param_named_auto diffuse light_diffuse_colour 0
				param_named Kd float 1
				param_named_auto specular light_specular_colour 0
				param_named Ks float 1
				param_named specular_power float 64
			}

			texture_unit
			{
				texture panel_c.jpg
			}

			texture_unit
			{
				texture panel_norm.jpg
			}
		}
	}
}
panel_c.jpg is the diffuse map high detail jpg
panel_norm.jpg is the normal map, also in hd jpg

This code was used for pixel shader and vertex shader:

Code: Select all

//CG Pixel Shader ps_2_0
fragment_program BumpMap_ps cg
{
    source BumpMap_ps.source
    profiles ps_2_0 arbfp1 fp20
    entry_point main

    default_params
    {
        param_named Ka float 0.30
        param_named Kd float 1.0
        param_named Ks float 1.0
        param_named_auto ambient ambient_light_colour
        param_named_auto diffuse light_diffuse_colour 0
        param_named_auto specular light_specular_colour 0
        param_named bumpiness float 1.0
        param_named specular_power float 64.0
        
    }
}

//CG Vertex Shader vs_2_0
vertex_program BumpMap_vs cg
{
    source BumpMap_vs.source
    profiles vs_2_0 arbvp1
    entry_point main

    default_params
    {
        param_named_auto view_proj_matrix worldViewProj_matrix
        param_named_auto inv_view_matrix inverse_worldView_matrix
        param_named_auto light_position light_position_object_space 0
        param_named_auto eye_position camera_position_object_space
    }
}
This along with BumpMap_vs.source and BumpMap_ps.source were placed in the shaders folder.

Although, in ogre it renders a mix between the diffuse and normal map:
http://fltc.firstones.com/a0.04/0.04/screenshot_1.png

Sure it looks dandy, but not like it's supposed to be...
Could anyone explain why the shaders dont work and what might have been done wrong...

Closer at the error:
Image
You can clearly see the red stripes that shouldnt appear on the mesh, also there is no bump...
Lioric
Google Summer of Code Mentor
Google Summer of Code Mentor
Posts: 295
Joined: Fri Aug 06, 2004 10:25 pm

Post by Lioric »

You are using the Render Monkey specular bump shader, have you modified it to work with Ogre?

It wont work directly if you dont modify it, as it uses a different stream (tangent and binormal)

And you must to calculate the binormal in the shader (or you can calculate it in your application and add a vertex element if you have a reason to do so)

Look at this oFusion tutorial about Using Render Monkey shaders and the SpcularBump, it will show how to calculate the binormal and how to adapt the vertex stream to be used in Ogre

Click on the image for the tutorial:

Image

The second part covers the reflective specular bump

Image
Foxer
Gnoblar
Posts: 16
Joined: Tue Nov 08, 2005 7:31 pm

Post by Foxer »

Thanks for the reply :wink:
Yes, I followed the tutorial at oFusion's site.
The thing is, it looks fine inside 3ds Max - the way it's supposed to, but not in OGRE.

Currently, the files made with Rendermonkey and after editing them were placed in the folder: ogredirectory/media/Shaders/

Maybe it has something to do with that?
User avatar
Game_Ender
Ogre Magi
Posts: 1269
Joined: Wed May 25, 2005 2:31 am
Location: Rockville, MD, USA

Post by Game_Ender »

Foxer wrote: The thing is, it looks fine inside 3ds Max - the way it's supposed to, but not in OGRE.
Do you mean it looks fine in the oFusion window in 3DS Max because that is Ogre.
Foxer
Gnoblar
Posts: 16
Joined: Tue Nov 08, 2005 7:31 pm

Post by Foxer »

Yes, it looks exactly like this:
Image
Foxer
Gnoblar
Posts: 16
Joined: Tue Nov 08, 2005 7:31 pm

Post by Foxer »

It seems that it's not using the shader information...
In 3ds Max, if you disable the pixel and vertex shaders, you get a mix between the two images (getting the error result)

Could anyone point out why this may not be working? It works fine in ogre preview window...
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67
Contact:

Post by sinbad »

Check the Ogre.log, perhaps in your application it's not loading something correctly because a file is in the wrong place or similar.
Foxer
Gnoblar
Posts: 16
Joined: Tue Nov 08, 2005 7:31 pm

Post by Foxer »

Well, seems that you pointed me to the right location (i'm not programming it, Hornet is, acctually)...

Code: Select all

08:14:52: Error in material Material_#1281/panel_c at line 10 of hyperion.material: Invalid vertex_program_ref entry - vertex program BumpMap_vs has not been defined.
08:14:52: Error in material Material_#1281/panel_c at line 18 of hyperion.material: Invalid fragment_program_ref entry - fragment program BumpMap_ps has not been defined.
08:14:52: Error in material Material_#1281/gpanels_c at line 53 of hyperion.material: Invalid vertex_program_ref entry - vertex program BumpMap_vs has not been defined.
08:14:52: Error in material Material_#1281/gpanels_c at line 61 of hyperion.material: Invalid fragment_program_ref entry - fragment program BumpMap_ps has not been defined.
08:14:52: Error in material Material_#1281/gpanels_b at line 96 of hyperion.material: Invalid vertex_program_ref entry - vertex program BumpMap_vs has not been defined.
08:14:52: Error in material Material_#1281/gpanels_b at line 104 of hyperion.material: Invalid fragment_program_ref entry - fragment program BumpMap_ps has not been defined.
08:14:52: Error in material Material_#1281/gpanels_a at line 138 of hyperion.material: Invalid vertex_program_ref entry - vertex program BumpMap_vs has not been defined.
08:14:52: Error in material Material_#1281/gpanels_a at line 146 of hyperion.material: Invalid fragment_program_ref entry - fragment program BumpMap_ps has not been defined.
08:14:52: Error in material Material_#1281/gpanels_dark at line 181 of hyperion.material: Invalid vertex_program_ref entry - vertex program BumpMap_vs has not been defined.
08:14:52: Error in material Material_#1281/gpanels_dark at line 189 of hyperion.material: Invalid fragment_program_ref entry - fragment program BumpMap_ps has not been defined.
08:14:52: Error in material Material_#1281/panel_b at line 235 of hyperion.material: Invalid vertex_program_ref entry - vertex program BumpMap_vs has not been defined.
08:14:52: Error in material Material_#1281/panel_b at line 243 of hyperion.material: Invalid fragment_program_ref entry - fragment program BumpMap_ps has not been defined.
08:14:52: Error in material Material_#1281/panel_a at line 277 of hyperion.material: Invalid vertex_program_ref entry - vertex program BumpMap_vs has not been defined.
08:14:52: Error in material Material_#1281/panel_a at line 285 of hyperion.material: Invalid fragment_program_ref entry - fragment program BumpMap_ps has not been defined.
08:14:52: Error in material Material_#1281/hwin at line 319 of hyperion.material: Invalid vertex_program_ref entry - vertex program BumpMap_vs has not been defined.
08:14:52: Error in material Material_#1281/hwin at line 327 of hyperion.material: Invalid fragment_program_ref entry - fragment program BumpMap_ps has not been defined.
It seems that those entries havent been defined... do I have to define them in the Material file?
Foxer
Gnoblar
Posts: 16
Joined: Tue Nov 08, 2005 7:31 pm

Post by Foxer »

Something seems to be wrong with the BumpMap_vs.cg file:

Code: Select all

Error #: 9
Function: CgProgram::loadFromSource
Description: Unable to compile Cg program BumpMap_vs: CG ERROR : The compile returned an error.
(51) : warning C7011: implicit cast from "float4" to "float3"
(61) : warning C7011: implicit cast from "float4" to "float3"
(0) : error C3001: no program defined
. 
File: \OgreDev\Dagon\PlugIns\CgProgramManager\src\OgreCgProgramManagerDll.cpp
Line: 60
Stack unwinding: <<beginning of stack>>
joi
Gnome
Posts: 327
Joined: Tue Feb 22, 2005 8:11 pm
Location: brazil

Post by joi »

Cant say i didnt tried.
Last edited by joi on Sun May 21, 2006 5:29 pm, edited 1 time in total.
maya 7.0, vs 2005, ogre 1.2
Foxer
Gnoblar
Posts: 16
Joined: Tue Nov 08, 2005 7:31 pm

Post by Foxer »

So, basically, you are saying that atleast 12 people get the same error because their graphics driver is not up-to-date?
And simply put the fact that it renders it fine realtime in 3ds Max, which is same as Ogre...

So, I think it doesnt have anything to do with drivers...
Something with the shaders, still...
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Post by jacmoe »

I am pretty sure that CG went up to version 1.4 with Dagon.
Check that the right cg.dll is available. :wink:

Couldn't find it in the Dagon notes, though.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Foxer
Gnoblar
Posts: 16
Joined: Tue Nov 08, 2005 7:31 pm

Post by Foxer »

Well, oFusion is still Azathoth...
Might that be the issue? Because we're using Dagon :wink:
Hornet
Halfling
Posts: 79
Joined: Mon Oct 18, 2004 7:33 am

Post by Hornet »

Were running OGRE 1.2, which I believe is dagon.

Should be right? I used a clean install of OGRE SDK and a clean install of the OGRE Source?
Foxer
Gnoblar
Posts: 16
Joined: Tue Nov 08, 2005 7:31 pm

Post by Foxer »

Replaced the Azathoth 1.0 cg file with Dagon's 1.4 cg file and now i get the same error in 3ds Max - it doesnt know how to use the shaders and the ship appears invisible.. (not accounting to the parts that dont use the bumpspec shader)

Does anyone have an idea what changed with the 1.4 and how I should configure the shaders according to the changes?

Thanks :)
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Post by jacmoe »

I think you need to tell Lioric at the oFusion Forum. :wink:

I saw a related post about this not too long ago.. But I can't find it. Maybe a peek at the nVidia changelog will help?
I think it has to do with parameter passing, but I'm not sure.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Foxer
Gnoblar
Posts: 16
Joined: Tue Nov 08, 2005 7:31 pm

Post by Foxer »

I read the changlog a while ago and it said something about complete rewrite of the code... so it should be faster now, but the code I am using just wont fit with it...

I'll go check oFusion forums and see if I can get something from there ;)
Thanks for your help :)
Post Reply