Note that there are some explanatory texts on larger screens.

plurals
  1. PO.FX files mostly don't load and those that do dont work properly
    text
    copied!<p>Basically I made a .x file model class with animations and all and each model class has a pointer for an effect file class,so i make a bunch of different models and i make them all use a single effect like a glow for example, so around <code>DrawSubset()</code> in the render function of each model are <code>Begin()</code> and <code>End()</code> for the effect.The problem is 90% of my .fx files(I tried making in FX composer and Rendermonkey,I tried loading samples,even simple ones)they don't load and it says the effect is null and if something manages to load,it makes all the geometry grey or slices parts of it off.This is basically my code(oh and the d3d device pointer is properly set,don't worry,the problem is not there):</p> <pre><code>***FXfileEntity.h*** #pragma once #include &lt;d3d9.h&gt; #include &lt;d3dx9.h&gt; class CFXFileEntity{ private: LPDIRECT3DDEVICE9 m_d3dDevice; LPD3DXBUFFER pBufferErrors; D3DXEFFECT_DESC pEffectDesc; DWORD dwShaderFlags; D3DXHANDLE ambient, attenuation, bbmax, bbmin, bbsize, bcenter, bssize, bsmin, bsmax, diffuse, elapsed, emissive, envNormal, height, joint, jointW, jointWI, jointWIT, jointWV, jointWVI, jointWVIT, jointWVP, jointWVPI, jointWVPIT, last, normal, opacity, position, proj, projI, projIT, random, refraction, renderCT, renderDST, renderTC, renderTD, specular, specularP, standarGlob, TextureMat, time, UnitsScale, view, viewI, viewIT, viewP, viewPI, viewPIT, world, worldI, worldIT, worldV, worldVI, worldVIT, worldVP, worldVPI, worldVPIT; D3DXVECTOR4 amb4, att4, diff, emis, join, nor2, opa4, posit, ref4, rtc, spec, specP4; D3DXVECTOR3 att3, bbMax, bbMin, bbSiz, bCen, nor1, opa3, ref3, specP3; D3DXVECTOR2 opa2, ref2, rtd, specP2; float bsSiz, bsMin, bsMax, elapTime, heigtMap1, lasTime, opa1, ran, ref1, specP1, tim, unit; LPDIRECT3DTEXTURE9 envNorm, heightMapT, nor3, opa5, ref5, rct, rdst, stdG; D3DXMATRIX jWor, jWI, jWIT, jWV, jWVI, jWVIT, jWVP, jWVPI, jWVPIT, pro, proI, proIT, texM, vie, vieI, vieIT, vieP, viePI, viePIT, wor, worI, worIT, worV, worVI, worVIT, worVP, worVPI, worVPIT; public: LPD3DXEFFECT anEffect; UINT cPasses; CFXFileEntity(LPDIRECT3DDEVICE9 d3dDevice); ~CFXFileEntity(); HRESULT Load(LPCTSTR path); void Set(); }; </code></pre> <p>and for the function bodies:</p> <pre><code>#include "FXfileEntity.h" #include &lt;iostream&gt; CFXFileEntity::CFXFileEntity(LPDIRECT3DDEVICE9 d3dDevice) : m_d3dDevice(d3dDevice) { anEffect = NULL; pBufferErrors = NULL; dwShaderFlags = 0; cPasses = 0; } CFXFileEntity::~CFXFileEntity(void) { anEffect = NULL; pBufferErrors = NULL; dwShaderFlags = 0; cPasses = 0; } HRESULT CFXFileEntity::Load(LPCTSTR path) { HRESULT hr; hr=D3DXCreateEffectFromFile(m_d3dDevice,path,NULL,NULL,0,NULL,&amp;anEffect,NULL); if(!anEffect) { MessageBox(NULL, "fail", "f", MB_OK); } if(FAILED(hr)) { MessageBox(NULL, "hr failed", "hrf", MB_OK); } ambient = anEffect-&gt;GetParameterBySemantic( NULL, "Ambient" ); attenuation = anEffect-&gt;GetParameterBySemantic( NULL, "Attenuation" ); bbmax = anEffect-&gt;GetParameterBySemantic( NULL, "BoundingBoxMax" ); bbmin = anEffect-&gt;GetParameterBySemantic( NULL, "BoundingBoxMin" ); bbsize = anEffect-&gt;GetParameterBySemantic( NULL, "BoundingBoxSize" ); bcenter = anEffect-&gt;GetParameterBySemantic( NULL, "BoundingCenter" ); bssize = anEffect-&gt;GetParameterBySemantic( NULL, "BoundingSphereSize" ); bsmin = anEffect-&gt;GetParameterBySemantic( NULL, "BoundingSphereMin" ); bsmax = anEffect-&gt;GetParameterBySemantic( NULL, "BoundingSphereMax" ); diffuse = anEffect-&gt;GetParameterBySemantic( NULL, "Diffuse" ); elapsed = anEffect-&gt;GetParameterBySemantic( NULL, "ElapsedTime" ); emissive = anEffect-&gt;GetParameterBySemantic( NULL, "Emissive" ); envNormal = anEffect-&gt;GetParameterBySemantic( NULL, "EnviromentNormal" ); height = anEffect-&gt;GetParameterBySemantic( NULL, "Height" ); joint = anEffect-&gt;GetParameterBySemantic( NULL, "Joint" ); jointW = anEffect-&gt;GetParameterBySemantic( NULL, "JointWorld" ); jointWI = anEffect-&gt;GetParameterBySemantic( NULL, "JointWorldInverse" ); jointWIT = anEffect-&gt;GetParameterBySemantic( NULL, "JointWorldInverseTranspose" ); jointWV = anEffect-&gt;GetParameterBySemantic( NULL, "JointWorldView" ); jointWVI = anEffect-&gt;GetParameterBySemantic( NULL, "JointWorldViewInverse" ); jointWVIT = anEffect-&gt;GetParameterBySemantic( NULL, "JointWolrdViewInverseTranspose" ); jointWVP = anEffect-&gt;GetParameterBySemantic( NULL, "JointWorldViewProjection" ); jointWVPI = anEffect-&gt;GetParameterBySemantic( NULL, "JointWorldViewProjectionInverse" ); jointWVPIT = anEffect-&gt;GetParameterBySemantic( NULL, "JointWorldViewProjectionTranspose" ); last = anEffect-&gt;GetParameterBySemantic( NULL, "LastTime" ); normal = anEffect-&gt;GetParameterBySemantic( NULL, "Normal" ); opacity = anEffect-&gt;GetParameterBySemantic( NULL, "Opacity" ); position = anEffect-&gt;GetParameterBySemantic( NULL, "Position" ); proj = anEffect-&gt;GetParameterBySemantic( NULL, "Projection" ); projI = anEffect-&gt;GetParameterBySemantic( NULL, "ProjectionInverse" ); projIT = anEffect-&gt;GetParameterBySemantic( NULL, "ProjectionInverseTranspose" ); random = anEffect-&gt;GetParameterBySemantic( NULL, "Random" ); refraction = anEffect-&gt;GetParameterBySemantic( NULL, "Refraction" ); renderCT = anEffect-&gt;GetParameterBySemantic( NULL, "RenderColorTarget" ); renderDST = anEffect-&gt;GetParameterBySemantic( NULL, "RenderDepthStencilTarget" ); renderTC = anEffect-&gt;GetParameterBySemantic( NULL, "RenderTargetClipping" ); renderTD = anEffect-&gt;GetParameterBySemantic( NULL, "RenderTargetDimension" ); specular = anEffect-&gt;GetParameterBySemantic( NULL, "Specular" ); specularP = anEffect-&gt;GetParameterBySemantic( NULL, "SpecularPower" ); standarGlob = anEffect-&gt;GetParameterBySemantic( NULL, "StandardGlobal" ); TextureMat = anEffect-&gt;GetParameterBySemantic( NULL, "TextureMatrix" ); time = anEffect-&gt;GetParameterBySemantic( NULL, "Time" ); UnitsScale = anEffect-&gt;GetParameterBySemantic( NULL, "UnitsScale" ); view = anEffect-&gt;GetParameterBySemantic( NULL, "View" ); viewI = anEffect-&gt;GetParameterBySemantic( NULL, "ViewInverse" ); viewIT = anEffect-&gt;GetParameterBySemantic( NULL, "ViewInverseTranspose" ); viewP = anEffect-&gt;GetParameterBySemantic( NULL, "ViewProjection" ); viewPI = anEffect-&gt;GetParameterBySemantic( NULL, "ViewProjectionInverse" ); viewPIT = anEffect-&gt;GetParameterBySemantic( NULL, "ViewProjectionInverseTranspose" ); world = anEffect-&gt;GetParameterBySemantic( NULL, "World" ); worldI = anEffect-&gt;GetParameterBySemantic( NULL, "WorldInverse" ); worldIT = anEffect-&gt;GetParameterBySemantic( NULL, "WorldInverseTranspose" ); worldV = anEffect-&gt;GetParameterBySemantic( NULL, "WorldView" ); worldVI = anEffect-&gt;GetParameterBySemantic( NULL, "WorldViewInverse" ); worldVIT = anEffect-&gt;GetParameterBySemantic( NULL, "WorldViewInverseTranspose" ); worldVP = anEffect-&gt;GetParameterBySemantic( NULL, "WorldViewProjection" ); worldVPI = anEffect-&gt;GetParameterBySemantic( NULL, "WorldViewProjectionInverse" ); worldVPIT = anEffect-&gt;GetParameterBySemantic( NULL, "WorldViewProjectionInverseTranspose" ); D3DXHANDLE hTech; anEffect-&gt;FindNextValidTechnique( NULL, &amp;hTech ); anEffect-&gt;SetTechnique( hTech ); return hr; } void CFXFileEntity::Set() { m_d3dDevice-&gt;GetTransform( D3DTS_WORLD, &amp;wor ); m_d3dDevice-&gt;GetTransform( D3DTS_PROJECTION, &amp;pro ); m_d3dDevice-&gt;GetTransform( D3DTS_VIEW, &amp;vie ); D3DXMatrixInverse( &amp;proI, NULL, &amp;pro ); D3DXMatrixTranspose( &amp;proIT, &amp;proI ); D3DXMatrixInverse( &amp;vieI, NULL, &amp;vie ); D3DXMatrixTranspose( &amp;vieIT, &amp;vieI ); vieP = vie * pro; D3DXMatrixInverse( &amp;viePI, NULL, &amp;vieP ); D3DXMatrixTranspose( &amp;viePIT, &amp;viePI ); D3DXMatrixInverse( &amp;worI, NULL, &amp;wor ); D3DXMatrixTranspose( &amp;worIT, &amp;worI ); worV = wor * vie; D3DXMatrixInverse( &amp;worVI, NULL, &amp;worV ); D3DXMatrixTranspose( &amp;worVIT, &amp;worVI ); worVP= wor * vie * pro; D3DXMatrixInverse( &amp;worVPI, NULL, &amp;worVP ); D3DXMatrixTranspose( &amp;worVPIT, &amp;worVPI ); tim = (float)GetTickCount()/1000.0f; anEffect-&gt;SetFloat( time, tim ); anEffect-&gt;SetMatrix( proj, &amp;pro ); anEffect-&gt;SetMatrix( projI, &amp;proI ); anEffect-&gt;SetMatrix( projIT, &amp;proIT ); anEffect-&gt;SetMatrix( view, &amp;vie ); anEffect-&gt;SetMatrix( viewI, &amp;vieI ); anEffect-&gt;SetMatrix( viewIT, &amp;vieIT ); anEffect-&gt;SetMatrix( viewP, &amp;vieP ); anEffect-&gt;SetMatrix( viewPI, &amp;viePI ); anEffect-&gt;SetMatrix( viewPIT, &amp;viePIT ); anEffect-&gt;SetMatrix( world, &amp;wor ); anEffect-&gt;SetMatrix( worldI, &amp;worI ); anEffect-&gt;SetMatrix( worldIT, &amp;worIT ); anEffect-&gt;SetMatrix( worldV, &amp;worV ); anEffect-&gt;SetMatrix( worldVI, &amp;worVI ); anEffect-&gt;SetMatrix( worldVIT, &amp;worVIT ); anEffect-&gt;SetMatrix( worldVP, &amp;worVP ); anEffect-&gt;SetMatrix( worldVPI, &amp;worVPI ); anEffect-&gt;SetMatrix( worldVPIT, &amp;worVPIT ); } </code></pre> <p>and in the model class it renders here:</p> <pre><code>this-&gt;Effect-&gt;Set(); this-&gt;Effect-&gt;cPasses = 0; if( SUCCEEDED( Effect-&gt;anEffect-&gt;Begin(&amp;this-&gt;Effect-&gt;cPasses, 0) ) ){ for (DWORD i = 0; i &lt; this-&gt;Effect-&gt;cPasses; i++) { Effect-&gt;anEffect-&gt;BeginPass(i); pDrawMesh-&gt;DrawSubset(iMaterial); Effect-&gt;anEffect-&gt;EndPass(); } Effect-&gt;anEffect-&gt;End(); } </code></pre> <p>I tried different values on cPasses depending on what I see in the .fx file,it doesn't really make a difference.Without the .fx files my .x files render perfectly with textures and animations...I never thought .fx files would be so hard,it's like the most confusing part of DirectX by far!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload