Jump to content
  • Advertisement

Freakdesign

Member
  • Content Count

    32
  • Joined

  • Last visited

Community Reputation

124 Neutral

About Freakdesign

  • Rank
    Member

Personal Information

  • Interests
    Art
    Design
    Production
    Programming
  1. Freakdesign

    modelling a Dodekaeder ?

    hi in my project i use huge 3d - constructs of spheres tiled in Quads i heard about Dodekaeder 3d-constructs and they match my goal a construct where all faces looks as the others actual i created a 64*64 mesh for each Quad of the sphere and thats the main problem... the spaces between points at the north/south pole are little, at equator the spaces are big if my objects are constructed as a Dodekaeder the spaces are all the same i need a formula which can create a spherevertexes like a dodekaeder or some good links to samples thx for help
  2. arrrg :) ok its late, too much coffee and too much other things i found it float3 tNormalWorldSpace = mul(VertexNormal, (float3x3)eff_World); changed to : float3 tNormalWorldSpace = normalize(mul(VertexNormal, (float3x3)eff_World)); and it works.. sometime its better to take a break..... i do so now.. Greets from Germany
  3. Hello ok heres my problem... i create a mesh from xfile... fine i place it in the world....fine i use Vertex/Pixelshader 3.0, but im very new to that :) it changes Lightning when scaled... scale bigger gets brighter scale smaller gets darker with FixedFunction Pipe i can use Renderstate.NormalizeNormals how can i use that in my shader? IMG static const int MAX_LIGHTS = 20; //-------------------------------------------------------------------------------------- // Variables from Outer Space //-------------------------------------------------------------------------------------- //Matrizen float4x4 eff_World : WORLD; // World float4x4 eff_VP : VIEWPROJECTION; // View + Projektion //Materials float4 eff_MaterialAmbient : MATERIALAMBIENT; // Material's ambient color float4 eff_MaterialDiffuse : MATERIALDIFFUSE; // Material's diffuse color //Light float4 eff_LightAmbient; // Ambient Light float4 eff_LightDiffuse[MAX_LIGHTS]; // Array of Light's diffuse color float4 eff_LightPosition[MAX_LIGHTS]; // Array Light's Position in world space //Texture bool eff_HasTexture; texture eff_Texture1; // Color texture for mesh int eff_NumberLights = 1; //-------------------------------------------------------------------------------------- // Texture samplers //-------------------------------------------------------------------------------------- sampler MeshTextureSampler = sampler_state { Texture = <eff_Texture1>; MipFilter = LINEAR; MinFilter = LINEAR; MagFilter = LINEAR; }; //-------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------- struct VSTEXTURE_OUTPUT { float4 Position : POSITION; float4 Diffuse : COLOR; float2 TexCoord : TEXCOORD0; }; //-------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------- VSTEXTURE_OUTPUT VSTexture( float4 VertexPosition : POSITION, float3 VertexNormal : NORMAL, float2 VertexTexCoord : TEXCOORD0 ) { VSTEXTURE_OUTPUT Out; //----------------------------------------------------------------------------- //Calc VertexPosition + Normale //----------------------------------------------------------------------------- // position (view space) float4 tPositionWorldSpace = mul( VertexPosition, eff_World); // Normal (World) float3 tNormalWorldSpace = mul(VertexNormal, (float3x3)eff_World); //----------------------------------------------------------------------------- // scan Lights and calculate total Diffuse //----------------------------------------------------------------------------- float4 vTotalLightDiffuse = float4(0,0,0,0); float power =2; for(int i=0; i<eff_NumberLights; i++ ) { float3 tNormalLightDir = normalize(tPositionWorldSpace - eff_LightPosition[0]); float4 LightFact = max(0,dot( tNormalWorldSpace, -tNormalLightDir)); // Look here....Calculating Lightning // Baselight(Ambiente) + Ambiente * AmbLight + Diffuse * DiffLight // Thought it has to be: // Ambiente * AmbLight + Diffuse * DiffLight // but its soooo dark vTotalLightDiffuse.rgb += eff_LightAmbient * LightFact * power + eff_MaterialAmbient * eff_LightAmbient * LightFact*power + eff_MaterialDiffuse * eff_LightDiffuse * LightFact*power; } //----------------------------------------------------------------------------- // Output Section //----------------------------------------------------------------------------- // position transformed to View+Projecion Out.Position = mul(tPositionWorldSpace, eff_VP); Out.Diffuse.a = eff_MaterialDiffuse.a; Out.Diffuse.rgb = vTotalLightDiffuse; //----------------------------------------------------------------------------- // TextureCoords, only pass through //----------------------------------------------------------------------------- if ( eff_HasTexture ) { Out.TexCoord = VertexTexCoord; } else { Out.TexCoord =0; } return Out; } //-------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------- // Pixel shader Input structure //-------------------------------------------------------------------------------------- struct PS_INPUT { float2 TextureUV : TEXCOORD0; float4 Diffuse : COLOR0; }; //-------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------- // Pixel shader output structure //-------------------------------------------------------------------------------------- struct PS_OUTPUT { float4 RGBColor : COLOR0; // Pixel color }; //-------------------------------------------------------------------------------------- //PIXEL SHADER //-------------------------------------------------------------------------------------- PS_OUTPUT RenderScenePS( PS_INPUT In) { PS_OUTPUT Output; // Lookup mesh texture and modulate it with diffuse if( eff_HasTexture ) { Output.RGBColor = tex2D(MeshTextureSampler, In.TextureUV) * In.Diffuse; } else { Output.RGBColor = In.Diffuse; } return Output; } //-------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------- // Techniques //-------------------------------------------------------------------------------------- technique TSkinOnly { pass P0 { VertexShader = compile vs_3_0 VSTexture(); PixelShader = compile ps_3_0 RenderScenePS(); } } I'm sure it something very simple.... heeelp
  4. Freakdesign

    Shader didnt work correctly, all is black

    yes i tried... Output.RGBColor.a = 1.0f; Output.RGBColor.r = 1.0f; Output.RGBColor.g = 1.0f; Output.RGBColor.b = 1.0f; return Output it stays black :(
  5. heyho i used the fixed function pipe in my actual project... all fine now i decided to implement VS + PS Shader and i get on a strange Problem: testing the shader on a tree looks like this: you see all is black. VS Shader is working.. i know it because i put a Vertexmovement into the treevertices an that black tree is animated. But where is the color??? here my .fx file for the shader float4x4 eff_World : WORLD; // World float4x4 eff_VP : VIEWPROJECTION; // View + Projektion float4x4 eff_View : VIEW; float4x4 eff_Projection : PROJECTION; float4 eff_MaterialAmbient: MATERIALAMBIENT; // Material's ambient color float4 eff_MaterialDiffuse: MATERIALDIFFUSE; // Material's diffuse color float4 eff_LightAmbient; // ARGB Light's diffuse color float4 eff_LightDiffuse[MAX_LIGHTS]; // Light's Position in world space float4 eff_LightPosition[MAX_LIGHTS]; float4 eff_LightDirection[MAX_LIGHTS]; float4 eff_LightAttenuation[MAX_LIGHTS]; float eff_LightRange[MAX_LIGHTS]; texture eff_Texture1; // Color texture for mesh float appTime; //for animate use int eff_NumberLights = 1; // Texture samplers sampler MeshTextureSampler = sampler_state { Texture = <eff_Texture1>; MipFilter = LINEAR; MinFilter = LINEAR; MagFilter = LINEAR; }; // Vertex shader output structure //------------------------------------------------------------------------------ struct VS_OUTPUT { float4 Position : POSITION; // vertex position float2 TextureUV : TEXCOORD0; // vertex texture coords float4 Diffuse : COLOR0; // vertex diffuse color }; // This shader computes standard transform and lighting //------------------------------------------------------------------------------ VS_OUTPUT UNILightVS( float4 vPos : POSITION, float3 vNormal : NORMAL, float2 vTexCoord0 : TEXCOORD0, uniform int nNumLights, uniform bool bTexture, uniform bool bAnimate ) { VS_OUTPUT Output; float4 vAnimatedPos = vPos; float3 vNormalWorldSpace; //Animation the vertex based on time and the vertex's object space position if (bAnimate ) vAnimatedPos += float4(vNormal , 0) * (sin(appTime*3 +5.5)+0.5)*5; float4 tPositionWorldSpace = mul( vAnimatedPos, eff_World); // Transform the position from object space to homogeneous projection space Output.Position = mul(tPositionWorldSpace, eff_VP); // Transform the normal from object space to world space vNormalWorldSpace = normalize(mul(vNormal, (float3x3)eff_World)); // Compute simple directional lighting equation float3 vTotalLightDiffuse = float3(0,0,0); for(int i=0; i<nNumLights; i++ ) vTotalLightDiffuse += eff_LightDiffuse * max(0,dot(vNormalWorldSpace, eff_LightDirection)); Output.Diffuse.rgb = eff_MaterialDiffuse * vTotalLightDiffuse + eff_MaterialAmbient * eff_LightAmbient; Output.Diffuse.a = 1.0f; //tested this but no changes //Output.Diffuse.r = 1.0f; //Output.Diffuse.g = 1.0f; //Output.Diffuse.b = 1.0f; // Just copy the texture coordinate through if( bTexture ) Output.TextureUV = vTexCoord0; else Output.TextureUV = 0; return Output; } // Pixel shader output structure //------------------------------------------------------------------------------ struct PS_OUTPUT { float4 RGBColor : COLOR0; // Pixel color }; // This shader outputs the pixel's color by modulating the texture's // color with diffuse material color //------------------------------------------------------------------------------ PS_OUTPUT RenderScenePS( VS_OUTPUT In, uniform bool bTexture ) { PS_OUTPUT Output; // Lookup mesh texture and modulate it with diffuse if( bTexture ) Output.RGBColor = tex2D(MeshTextureSampler, In.TextureUV) * In.Diffuse; else Output.RGBColor = In.Diffuse; //tested this... it stays black //Output.RGBColor.a = 1.0f; //Output.RGBColor.r = 1.0f; //Output.RGBColor.g = 1.0f; //Output.RGBColor.b = 1.0f; return Output; } //------------------------------------------------------------------------------// Jo... //------------------------------------------------------------------------------ technique RenderSceneUNILight { pass P0 { //Arguments: 1 light , notexture, animated VertexShader = compile vs_1_1 UNILightVS(1, false, true); //Arguments: no texture PixelShader = compile ps_1_1 RenderScenePS(false); } } here the Methods for setup shader 'declare shadereffect Private i_Effect As Effect 'technique name declaration Private Const MyTechnik As String = "RenderSceneUNILight" 'other stuff '----------------------------- 'Creating the effect from file '----------------------------- Dim shaderFlags As ShaderFlags shaderFlags = shaderFlags.NoPreShader i_Effect = Me.CreateEffectFromFile( _ Par.Path_Shader + "\" + "StandardHLSL.fx", _ Nothing, Nothing,shaderFlags, Nothing ) 'other stuff '--------------------------- 'setting up Shader Variables 'all is capsuled by property, i posted only the "Set" code 'i changed the Variable names from "Value" to something more informational '--------------------------- i_Effect.SetValue(EffectHandle.FromString("eff_World"), pWeltMatrix) i_Effect.SetValue(EffectHandle.FromString("eff_VP"), Cam.ViewProjection) i_Effect.SetValue(EffectHandle.FromString("eff_LightRange"), Me.i_lightRange) i_Effect.SetValue(EffectHandle.FromString("eff_LightAttenuation"), Me.i_lightAttenuation) i_Effect.SetValue(EffectHandle.FromString("eff_LightPosition"), Me.i_lightPosition) i_Effect.SetValue(EffectHandle.FromString("eff_LightDirection"), Me.i_lightDirection) 'Light.DiffuseColor i_Effect.SetValue(EffectHandle.FromString("eff_LightDiffuse"), Me.i_lightDiffuse) 'Light.AmbientColor i_Effect.SetValue(EffectHandle.FromString("eff_LightAmbient"), me.i_LightAmbient) 'tmpMaterial.AmbientColor i_Effect.SetValue(EffectHandle.FromString("eff_MaterialAmbient"), ColorValue.FromColor(color.White)) 'tmpMaterial.DiffuseColor i_Effect.SetValue(EffectHandle.FromString("eff_MaterialDiffuse"), ColorValue.FromColor(color.White)) 'other stuff '------------------ 'Render '------------------ iter = pR.Eff.Begin(FX.None) '-->leads to "Return i_Effect.Begin(pFX)" For i = 0 To iter - 1 pR.Eff.BeginPass(i) '--> leads to "i_Effect.BeginPass(p)" Call RenderSubSet(AttribtID) pR.Eff.EndPass() '--->leads to "i_Effect.EndPass()" Next pR.Eff.Ende() '-->leads to "Call i_Effect.End()" My Problems are: 1. why i cant see any diffuse color on the object (notice that Vertexanimation works fine) 2. how can the object be black when i hardcode the output to Color White??? thx in advance [Edited by - Freakdesign on October 19, 2005 11:42:01 AM]
  6. Oh great! i've tried your 3 alternative and it works perfektly. especialy your link to "love_your_z_buffer" link (funny name hehe) with the really helpful calculator helped a lot to bring more understanding into use of z-buffer and what values it use :))). My NearPlane now changes with Cam-Height above terrain and i got rid of these flicker fx. my Nearplane was static 1.0f, now my Nearplane varies from 1.0f (Cam near Ground) to something about 50 (Cam in high Orbit) it is as you said... it very effektiv. Special thanks again Jack, also greets from my friend called Fred, who started this little project with me in Sep2004 :) now i give my best to produce more little problems :)) FreakDesign ps: sorry for my bad english, its hard to explain problems in a foreign language... but it worked :)
  7. Hello world... in my actual project, a strategical Roleplaygame, i've now created the world and Characters. everything is fine but one thing is bad: I've created the terrain(64*32 tiles, each has 64*64 verts) by using a fractal and the water is a plane at height zero. This creates many verts and faces which are close to zero or maybe at zero. These (Terrain)faces gets in a Zbuffer-Fight with the waterplane when i move the Cam. The result is flickering faces. With Objects i have the same Problem, but Objects can be created without faces too near together..., the fractal terrain cant because its fractal How will Terrain always win the Zbuffer-Fight with the water? Or is there any technique to avoid flicker in case of near faces by giving some sort of priority?? What distance(Face to Face) is minimum distance at which directx dont get in problems? thanks for all help FreakDesign [Edited by - Freakdesign on February 14, 2005 4:17:26 PM]
  8. hi around... i'm actually at the point where i added multiple Lightning in my project and i read in the D3D SDK that a Software-Vertex-Processing-Device supports unlimited active Lights ! unlimited sounds like heaven for me because i need min. about 12 active lights. any other setting for the device (mixed-,hardware- and pure hardware processing) seams to be limited to the hardware caps of the GPU, in most cases 8 active lights. i tested it, but i get more then 50% loss of frames when using about 20-30 Lights( from 50frames(mixed VP, cutted Lights) to 22frames(software VP) ) my question: is there any chance to add (Software)Lights to the scene when i use Mixed Vertex Processing? i hope mixed means hard- and software benefits :), if i could use 8 hardware lights plus some software lights that would be best i think, if it is possible..., but i found no way to mix the lights... is there any Graphicadapter with more then 8 active lights supported by hardware? my ati radeon 9800 pro only has only 8 Lights supported by hardware thanks for answers... Frakdesign
  9. ok, i did it half the way..... it was easier than expected :) Screenie1, Screenie2 what you think? looks pretty good for the prepreprealphaomega-Version hehe ok some little problems are left, like Lights that has range beyound the neighborgrid are cut there..., but that can be handled. so i think positiv and come up with a loud "SOLVED!" *ting* *opens a boddle* *cheers*
  10. Thanks for your post jollyjeffers. I'm glad to meet you (virtually) because i often read your Article you linked to. Good Work! I cant say i have understood it completly yet, but it gave me more clearness with shadows and how to understand stencils, zbuffer and other renderstuff :) You really greatly helped me with your hint, that i can have more than 8 Lights... hehe, i really thought i couldnt specify more than 8. Good to know that i can have a "big" Collection of Lights and have only 8(or until hardwarecap) enabled at the same time. At the moment i think i will follow that what u called "the easiest way" Quote:- the easiest is to employ some sort of algorithm that determines the 8 most relevent lights and enables only those. Some sort of heuristic based on "area of effect", brightness and/or colour are good. The Shadowvolume technique seems to be to slow for todays hardware when rendering more then 4 lights, that little scene runs with 15frames. I have really a great number of Meshes in Camview which have to calculated its Edges, but.. it looks very well. Probably i have to update my hardware (AMD2200+,1GB Ram, Geforce4Ti4400) or have to use vertexshaders, but thats may be beyound my personel capacity(because Assembler) btw: i'm coding with VB.Net, is it possible for managed VB Code to use HLSL/Vertexshader i will update here if i progress something :) FreakDesign
  11. Freakdesign

    DirectX 9 Lighting

    probably you forgot the Device.Lights(0).Update ? this hast to be done after every change to take effect and i dont found it in your snippet other thing is that i have to specify a Lightnumber(Device.Lights(0)) in my project as the Device.Lights is an array of the maximum Lights your Hardware provides hope this helps..
  12. hi around... for my actual project, a roleplay game, my actual state is as follows: - 1 planet(64 Slices *32 Stacks, each with a 64*64 Grid), - 1st Light(general Ambient Light) - 2nd Light(sun, rays diffuse and Specular), - 3rd Light(Moon, rays low diffuse), - can place any x-file in world and move, scale, turn them - Clouds(sphere with texture) Lighting is managed as follows: Each Grid from Planet tests for his 4 Corners the 2 Lights(Sun/Moon) the angle to this Light, in case actual Light is from "Backface" it is gradually dimmed until complete disabled for entire Grid here a screenie, screenie2 now my Problem: i want to create "small" Lights, such as a fireplace or other small moveable Lights. i'm not sure how to make Lights, which are not real Lights from the Direct3D.Device. i heard the former actual generation of GraphicHardware has a maximum of Lightnumber of 8 Lights. Thats not enough for that what i plan... it has to be about 50-100 Lights i guess is there a good technique to simulate a light without using a "hardware" Light,which should i use? at the moment i plan to try rendering the scene as normal and then rendering with a "daylight" from CameraPosition into another Surface. For every "Fakelight" it would be calculated a small Transparent shere into screencoordinates, scaled relativly to distance, which i merge with the surface so that areas without such a sphere is blended totaly transparent. so i get a picture only with the "fakelight" radius. This i would lay "over" the normal rendered and bring it to front. As it is only theoretical at the moment it sounds usefull, but i have no experience with that stuff ^^ other alternative i thought is to take a 4th Light, which jumps at rendering time to each place when a item is rendered(must be in range of "small" Light), but this is difficult when there are 2 Lights near together, and 1 Grid is one Mesh so this would stay dark except 1 small light for such a huge area, but it would cast diffuse lightning, which looks good :) (probably i can add there until 4 Lights, but this doesnt helps when i need 5-20 lights) ok, hope for your tips or tutoriallinks :) FreakDesign
  13. Freakdesign

    Spherical Coords Math Problem

    hi all i have a problem with generating Texture Coordinates to a given sphere. there is a thread in Directx-Forum which discribes the problem... started this thread with hope some persons experienced in mathmatics could solve the problem LinkTo Gamedev-Directx Forum thanks and regards
  14. ok, i've attempted to take over the code of darookie (thnks for post btw) here is my coding and result: for i=0 to numverts-3 step 3 Dim fix as Boolean=False if not fix and (0.5 <= (math.Abs(vb(i).tu - vb(i+1).tu))) then fix = true end if if not fix and (0.5 <= (math.Abs(vb(i).tu - vb(i+2).tu))) then fix = true end if if not fix and (0.5 <= (math.Abs(vb(i+1).tu - vb(i+2).tu))) then fix = true end if if fix then if vb(i).tu < 0.5f then vb(i).tu += 1f end if if vb(i+1).tu < 0.5f then vb(i+1).tu += 1f end if if vb(i+2).tu < 0.5f then vb(i+2).tu +=1f end if end if next Screen looks somewhat shaked ^^, i hope i put your pseudocode correctly in my project... i tryed also to modify the calcs of the vb(i).Tv TexCoord to test the idea of _RMcl_, but i got bad results ok i found a big bug on other place.. always good i think :), but here im stucked on (this Shot (wireframe)) you can see that everything is fine but the last face. Solid here that one which uses 1 or 2 vertices of the starting verts. this face got completly bad Textureadresses(tu/tv). it seems to bee mirrored and flipped up/down and shows the whole texture (from 1,x to 0,x).. code for TextureCoords-generation: '' loop through the vertices for i = 0 to Numverts - 1 vert = vb(i) dim v2 as new Vector2(vert.NX , vert.NZ) v2.Normalize '' calculate texture coordinates from normals if v2.y > 0 then vb(i).Tu = 0.5 + math.Acos(v2.x) / (Math.PI*2) else vb(i).Tu = 0.5 - math.Acos(v2.x) / (Math.PI*2) end if vb(i).Tv = 0.5f + math.Asin( vb(i).Ny )/(math.PI) next as i know each vertice can only store one set of TextureCoords(tu/tv)... how can i tell a vertice to use Coords 0,0 (Starting face) _and_ use 1,0 in case of Faces that ends up with the same vertice??? uuhh... headaches... or... is it a good idea to modify all VertexRow-Positions at Createtime so that the "last row" can be nothing?? ok a bit loss from texture would survive.. hm... thank god, its christmas... best ideas coming when writing posts hehe, may be that works EDIT: How can i display Images direct in my Post? i only know the A HREF="url>"Text</A Command [Edited by - Freakdesign on December 22, 2004 3:30:22 PM]
  15. Hi all here i am with another Sphere-TextureMapping-Thread.... i searched in Gamedev Forums and googled it, found many and readed it all, but i cant figure out where is the mistake. here the problem: i have a sphere and a 2D-Texture. when i try to generate TextureCoords i only get "uncomplete" Mappings. a image says much more, so here's a screenshot: look here codesnippet for Mapping: '' loop through the vertices for i = 0 to Numverts - 1 'actual Vertice vertex = vb(i) dim v2 as new Vector2(vertex.Nx , vertex.Nz) call v2.Normalize '-------------------------------- ' calculate texture coordinates '-------------------------------- 'the "U" Coordinate if v2.Y > 0 then vb(i).Tu = (0.5 + math.Acos( v2.X ) / (2*math.PI)) else vb(i).Tu = (0.5 - math.Acos( v2.X ) / (2*math.PI)) end if 'the "V" Coordinate vb(i).Tv = (math.Asin(vb(i).Ny ) / math.PI+0.5 ) '-------------------------------- ' invert Normals to show it correct for looking from outside call vb(i).InvertNormals Next i tryed the Mappingformula from http://www.mvps.org/directx/articles/spheremap.htm but it appears mirrored and turned 90 degrees look: look here here's a snippet of my mapping code, where i tryed to use the Technique shown on this site: '' loop through the vertices for i = 0 to Numverts - 1 vert = vb(i) dim v2 as new Vector2(vert.Nx , vert.Nz) call v2.Normalize '' calculate texture coordinates vb(i).tu =((Math.Asin(v2.X)/math.PI)+0.5) vb(i).tv =((Math.Asin(v2.Y)/Math.PI)+0.5) ' invert Normals call vb(i).InvertNormals Next i want to have a mapping without artefacts, stretched in äquatorial area, compressed at north/south pole hope u can help me... i run out of energy thanks
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!