2 registered members (Akow, 1 invisible),
1,404
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Help needed: Conversion of rendermonkey 1.6 FX
#64478
02/16/06 17:51
02/16/06 17:51
|
Joined: Feb 2006
Posts: 4
gemini_xzq
OP
Guest
|
OP
Guest
Joined: Feb 2006
Posts: 4
|
I tried to do the conversion according to the previous thread: web page But it did not work for me, Is there any experts who know what exactly need to be edited in the fx file so that i can implement the shader in 3dgs as well? Thanks. Code for teapot.fx: Code:
//**************************************************************// // Effect File exported by RenderMonkey 1.6 // // - Although many improvements were made to RenderMonkey FX // file export, there are still situations that may cause // compilation problems once the file is exported, such as // occasional naming conflicts for methods, since FX format // does not support any notions of name spaces. You need to // try to create workspaces in such a way as to minimize // potential naming conflicts on export. // // - Note that to minimize resulting name collisions in the FX // file, RenderMonkey will mangle names for passes, shaders // and function names as necessary to reduce name conflicts. //**************************************************************//
//--------------------------------------------------------------// // Textured Bump //--------------------------------------------------------------// //--------------------------------------------------------------// // Pass 0 //--------------------------------------------------------------// string Textured_Bump_Pass_0_Model : ModelData = "teapot.mdl"; //"../../../Program Files/ATI Research Inc/RenderMonkey 1.6/Examples/Media/Models/Teapot.3ds";
float3 fvLightPosition < string UIName = "fvLightPosition"; string UIWidget = "Numeric"; bool UIVisible = " true"; float UIMin = -100.00; float UIMax = 100.00; > = ( -100.00, 100.00, -100.00 ); float3 fvEyePosition < string UIName = "fvEyePosition"; string UIWidget = "Numeric"; bool UIVisible = " false"; float UIMin = -100.00; float UIMax = 100.00; > = ( 0.00, 0.00, -100.00 ); float4x4 matView : View; float4x4 matViewProjection : ViewProjection;
struct VS_INPUT { float4 Position : POSITION0; float2 Texcoord : TEXCOORD0; float3 Normal : NORMAL0; float3 Binormal : BINORMAL0; float3 Tangent : TANGENT0; };
struct VS_OUTPUT { float4 Position : POSITION0; float2 Texcoord : TEXCOORD0; float3 ViewDirection : TEXCOORD1; float3 LightDirection: TEXCOORD2; };
VS_OUTPUT Textured_Bump_Pass_0_Vertex_Shader_vs_main( VS_INPUT Input ) { VS_OUTPUT Output;
Output.Position = mul( matViewProjection, Input.Position ); Output.Texcoord = Input.Texcoord; float3 fvObjectPosition = mul( matView, Input.Position ); float3 fvViewDirection = fvEyePosition - fvObjectPosition; float3 fvLightDirection = fvLightPosition - fvObjectPosition; float3 fvNormal = mul( matView, Input.Normal ); float3 fvBinormal = mul( matView, Input.Binormal ); float3 fvTangent = mul( matView, Input.Tangent ); Output.ViewDirection.x = dot( fvTangent, fvViewDirection ); Output.ViewDirection.y = dot( fvBinormal, fvViewDirection ); Output.ViewDirection.z = dot( fvNormal, fvViewDirection ); Output.LightDirection.x = dot( fvTangent, fvLightDirection ); Output.LightDirection.y = dot( fvBinormal, fvLightDirection ); Output.LightDirection.z = dot( fvNormal, fvLightDirection ); return( Output ); }
float4 fvAmbient < string UIName = "fvAmbient"; string UIWidget = "ColorPicker"; bool UIVisible = " true"; > = ( 0.37, 0.37, 0.37, 1.00 ); float4 fvSpecular < string UIName = "fvSpecular"; string UIWidget = "ColorPicker"; bool UIVisible = " true"; > = ( 0.49, 0.49, 0.49, 1.00 ); float4 fvDiffuse < string UIName = "fvDiffuse"; string UIWidget = "ColorPicker"; bool UIVisible = " true"; > = ( 0.89, 0.89, 0.89, 1.00 ); float fSpecularPower < string UIName = "fSpecularPower"; string UIWidget = "Numeric"; bool UIVisible = " true"; float UIMin = 1.00; float UIMax = 100.00; > = 25.00;
texture base_Tex < string ResourceName = "Fieldstone.tga"; //"..\..\..\program files\ati research inc\rendermonkey 1.6\Examples\Media\Textures\Fieldstone.tga"; >; sampler2D baseMap = sampler_state { Texture = (base_Tex); ADDRESSU = WRAP; ADDRESSV = WRAP; MINFILTER = LINEAR; MAGFILTER = LINEAR; MIPFILTER = LINEAR; }; texture bump_Tex < string ResourceName = "FieldstoneBumpDOT3.tga"; //"..\..\..\program files\ati research inc\rendermonkey 1.6\Examples\Media\Textures\FieldstoneBumpDOT3.tga"; >; sampler2D bumpMap = sampler_state { Texture = (bump_Tex); ADDRESSU = WRAP; ADDRESSV = WRAP; MINFILTER = LINEAR; MAGFILTER = LINEAR; MIPFILTER = LINEAR; };
struct PS_INPUT { float2 Texcoord : TEXCOORD0; float3 ViewDirection : TEXCOORD1; float3 LightDirection: TEXCOORD2; };
float4 Textured_Bump_Pass_0_Pixel_Shader_ps_main( PS_INPUT Input ) : COLOR0 { float3 fvLightDirection = normalize( Input.LightDirection ); float3 fvNormal = normalize( ( tex2D( bumpMap, Input.Texcoord ).xyz * 2.0f ) - 1.0f ); float fNDotL = dot( fvNormal, fvLightDirection ); float3 fvReflection = normalize( ( ( 2.0f * fvNormal ) * ( fNDotL ) ) - fvLightDirection ); float3 fvViewDirection = normalize( Input.ViewDirection ); float fRDotV = max( 0.0f, dot( fvReflection, fvViewDirection ) ); float4 fvBaseColor = tex2D( baseMap, Input.Texcoord ); float4 fvTotalAmbient = fvAmbient * fvBaseColor; float4 fvTotalDiffuse = fvDiffuse * fNDotL * fvBaseColor; float4 fvTotalSpecular = fvSpecular * pow( fRDotV, fSpecularPower ); return( saturate( fvTotalAmbient + fvTotalDiffuse + fvTotalSpecular ) ); }
//--------------------------------------------------------------// // Technique Section for Textured Bump //--------------------------------------------------------------// technique Textured_Bump { pass Pass_0 { VertexShader = compile vs_2_0 Textured_Bump_Pass_0_Vertex_Shader_vs_main(); PixelShader = compile ps_2_0 Textured_Bump_Pass_0_Pixel_Shader_ps_main(); }
}
|
|
|
Re: Help needed: Conversion of rendermonkey 1.6 FX
[Re: Matt_Aufderheide]
#64480
02/17/06 03:03
02/17/06 03:03
|
Joined: Feb 2006
Posts: 4
gemini_xzq
OP
Guest
|
OP
Guest
Joined: Feb 2006
Posts: 4
|
I converted the code accordingly to the thread by Steempipe at this url Here is my converted code: Code:
bmap basebmp = <Fieldstone.tga>; bmap bumpbmp = <FieldstoneBumpDOT3.tga>;
material teapot_fx { Flags = Tangent; skin1 = basebmp; skin2 = bumpbmp;
effect = " float4x4 matView; float4x4 matWorldViewProj;
float3 fvLightPosition = { -100.00, 100.00, -100.00 }; float3 fvEyePosition = { 0.00, 0.00, -100.00 };
struct VS_INPUT { float4 Position : POSITION0; float2 Texcoord : TEXCOORD0; float3 Normal : NORMAL0; float3 Binormal : BINORMAL0; float3 Tangent : TANGENT0; };
struct VS_OUTPUT { float4 vPosition : POSITION0; float2 vTexcoord : TEXCOORD0; float3 vViewDirection : TEXCOORD1; float3 vLightDirection: TEXCOORD2; };
VS_OUTPUT main_vs( VS_INPUT Input ) { VS_OUTPUT Output;
Output.vPosition = mul( matWorldViewProj, Input.Position ); Output.vTexcoord = Input.Texcoord; float3 fvObjectPosition = mul( Input.Position, matView ); float3 fvViewDirection = fvEyePosition - fvObjectPosition; float3 fvLightDirection = fvLightPosition - fvObjectPosition; float3 fvNormal = mul( matView, Input.Normal ); float3 fvBinormal = mul( matView, Input.Binormal ); float3 fvTangent = mul( matView, Input.Tangent ); Output.vViewDirection.x = dot( fvTangent, fvViewDirection ); Output.vViewDirection.y = dot( fvBinormal, fvViewDirection ); Output.vViewDirection.z = dot( fvNormal, fvViewDirection ); Output.vLightDirection.x = dot( fvTangent, fvLightDirection ); Output.vLightDirection.y = dot( fvBinormal, fvLightDirection ); Output.vLightDirection.z = dot( fvNormal, fvLightDirection ); return( Output ); }
float4 fvAmbient = { 0.37, 0.37, 0.37, 1.00 }; float4 fvSpecular = { 0.49, 0.49, 0.49, 1.00 }; float4 fvDiffuse = { 0.89, 0.89, 0.89, 1.00 }; float fSpecularPower = { 25.00 };
texture entSkin1;
sampler2D baseMap = sampler_state { Texture = (entSkin1); ADDRESSU = WRAP; ADDRESSV = WRAP; MINFILTER = LINEAR; MAGFILTER = LINEAR; MIPFILTER = LINEAR; };
texture entSkin2;
sampler2D bumpMap = sampler_state { Texture = (entSkin2); ADDRESSU = WRAP; ADDRESSV = WRAP; MINFILTER = LINEAR; MAGFILTER = LINEAR; MIPFILTER = LINEAR; };
struct PS_INPUT { float2 Texcoord : TEXCOORD0; float3 ViewDirection : TEXCOORD1; float3 LightDirection: TEXCOORD2; };
float4 main_ps( PS_INPUT Input ) : COLOR0 { float3 fvLightDirection = normalize( Input.LightDirection ); float3 fvNormal = normalize( ( tex2D( bumpMap, Input.Texcoord ).xyz * 2.0f ) - 1.0f ); float fNDotL = dot( fvNormal, fvLightDirection ); float3 fvReflection = normalize( ( ( 2.0f * fvNormal ) * ( fNDotL ) ) - fvLightDirection ); float3 fvViewDirection = normalize( Input.ViewDirection ); float fRDotV = max( 0.0f, dot( fvReflection, fvViewDirection ) ); float4 fvBaseColor = tex2D( baseMap, Input.Texcoord ); float4 fvTotalAmbient = fvAmbient * fvBaseColor; float4 fvTotalDiffuse = fvDiffuse * fNDotL * fvBaseColor; float4 fvTotalSpecular = fvSpecular * pow( fRDotV, fSpecularPower ); return( saturate( fvTotalAmbient + fvTotalDiffuse + fvTotalSpecular ) ); }
technique Textured_Bump { pass Pass_0 { VertexShader = compile vs_2_0 main_vs(); PixelShader = compile ps_2_0 main_ps(); } }
"; }
action teapot_illumination { my.material = teapot_fx; my.nofog = on; } Here's the image of the teapot in rendermonkey 1.6 rendermonkey [image]http://img15.imgspot.com/?u=/u/06/46/22/3dgsrendermonkey21140148518.JPG[/image] Here's the image of the teapot in 3DGS V6.31.4: 3dgs [image]http://img15.imgspot.com/?u=/u/06/46/22/3dgsrendermonkey11140148459.JPG[/image] I used MED to import the model from the format 3ds to mdl. However, I cannot render the model properly in 3dgs. Anyone knows what i need to change for my code?
Last edited by gemini_xzq; 02/17/06 03:04.
|
|
|
Re: Help needed: Conversion of rendermonkey 1.6 FX
[Re: Logimator]
#64483
02/17/06 15:05
02/17/06 15:05
|
Joined: Feb 2006
Posts: 4
gemini_xzq
OP
Guest
|
OP
Guest
Joined: Feb 2006
Posts: 4
|
sure, no problem. Will be working on VB UI to automate this process of conversion. Here is the converted code: Note: The changes/modification to the FX file in teapot_fx.effect is in blue Code:
bmap basebmp = <Fieldstone.tga>; bmap bumpbmp = <FieldstoneBumpDOT3.tga>;
material teapot_fx { Flags = Tangent; skin1 = basebmp; skin2 = bumpbmp;
effect = " float4x4 matView; float4x4 matWorldViewProj; float3 fvLightPosition = ( -100.00, 100.00, -100.00 ); float3 fvEyePosition = ( 0.00, 0.00, -100.00 );
texture mtlSkin1; texture mtlSkin2;
sampler2D baseMap = sampler_state { Texture = (mtlSkin1); ADDRESSU = WRAP; ADDRESSV = WRAP; MINFILTER = LINEAR; MAGFILTER = LINEAR; MIPFILTER = LINEAR; };
sampler2D bumpMap = sampler_state { Texture = (mtlSkin2); ADDRESSU = WRAP; ADDRESSV = WRAP; MINFILTER = LINEAR; MAGFILTER = LINEAR; MIPFILTER = LINEAR; };
struct VS_INPUT { float4 Position : POSITION0; float2 Texcoord : TEXCOORD0; float3 Normal : NORMAL0; float3 Binormal : BINORMAL0; float3 Tangent : TANGENT0; };
struct VS_OUTPUT { float4 Position : POSITION0; float2 Texcoord : TEXCOORD0; float3 ViewDirection : TEXCOORD1; float3 LightDirection: TEXCOORD2;
};
VS_OUTPUT Textured_Bump_Pass_0_Vertex_Shader_vs_main( VS_INPUT Input ) { VS_OUTPUT Output;
Output.Position = mul( Input.Position, matWorldViewProj); Output.Texcoord = Input.Texcoord; float3 fvObjectPosition = mul( matView, Input.Position ); float3 fvViewDirection = fvEyePosition - fvObjectPosition; float3 fvLightDirection = fvLightPosition - fvObjectPosition; float3 fvNormal = mul( matView, Input.Normal ); float3 fvBinormal = mul( matView, Input.Binormal ); float3 fvTangent = mul( matView, Input.Tangent ); Output.ViewDirection.x = dot( fvTangent, fvViewDirection ); Output.ViewDirection.y = dot( fvBinormal, fvViewDirection ); Output.ViewDirection.z = dot( fvNormal, fvViewDirection ); Output.LightDirection.x = dot( fvTangent, fvLightDirection ); Output.LightDirection.y = dot( fvBinormal, fvLightDirection ); Output.LightDirection.z = dot( fvNormal, fvLightDirection ); return( Output ); } float4 fvAmbient = ( 0.37, 0.37, 0.37, 1.00 ); float4 fvSpecular = ( 0.49, 0.49, 0.49, 1.00 ); float4 fvDiffuse = ( 0.89, 0.89, 0.89, 1.00 ); float fSpecularPower = 25.00 ;
struct PS_INPUT { float2 Texcoord : TEXCOORD0; float3 ViewDirection : TEXCOORD1; float3 LightDirection: TEXCOORD2; };
float4 Textured_Bump_Pass_0_Pixel_Shader_ps_main( PS_INPUT Input ) : COLOR0 { float3 fvLightDirection = normalize( Input.LightDirection ); float3 fvNormal = normalize( ( tex2D( bumpMap, Input.Texcoord ).xyz * 2.0f ) - 1.0f ); float fNDotL = dot( fvNormal, fvLightDirection ); float3 fvReflection = normalize( ( ( 2.0f * fvNormal ) * ( fNDotL ) ) - fvLightDirection ); float3 fvViewDirection = normalize( Input.ViewDirection ); float fRDotV = max( 0.0f, dot( fvReflection, fvViewDirection ) ); float4 fvBaseColor = tex2D( baseMap, Input.Texcoord ); float4 fvTotalAmbient = fvAmbient * fvBaseColor; float4 fvTotalDiffuse = fvDiffuse * fNDotL * fvBaseColor; float4 fvTotalSpecular = fvSpecular * pow( fRDotV, fSpecularPower ); return( saturate( fvTotalAmbient + fvTotalDiffuse + fvTotalSpecular ) ); }
technique Textured_Bump { pass Pass_0 { VertexShader = compile vs_1_1 Textured_Bump_Pass_0_Vertex_Shader_vs_main(); PixelShader = compile ps_2_0 Textured_Bump_Pass_0_Pixel_Shader_ps_main(); } } "; }
action teapot_illumination { my.material = teapot_fx; my.nofog = on; }
|
|
|
|