-
Posts
295 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Posts posted by Gandi
-
-
Thanks for getting those out so quick!
So I created a .mat file (see below) which uses you shader but it is causing LE to crash when the material loads. I looked in the log and it doesn't give any info on why it died. But here is my .mat file.
texture0="abstract::decal.dds" blend=1 depthmask=1 depthtest=1 overlay=1 zsort=1 cullface=1 castshadows=0 shader="abstract::decal.vert","abstract::decal.frag" shadowshader="abstract::mesh_shadow.vert",""
where's the sense of setting castshadows=0 and then defining a shadowshader?
why it crashes? i dont know...
Are you just creating a mesh and applying the material to the mesh, or are you loading a .gmf?
If you create a mesh what is the minimum number of verts do I need, or is that handled in the shader?
yes.. i am creating a mesh.
the minimum should be 9 i guess (otherwise the shader doesnt make sense..
3 in each direction, so you got a 1x1 field for rendering your decal.
Also, what is the difference between the shader you've done vs what wh1sp3r did?
I have to admit.. i dont know what whisper "did"??
And finally, how do you get LE to go into wiremesh mode? I'm using Gamelib and have tried to use "game.engine.SetWireframe(true)" with no luck. Any suggestions?
Wireframe(1);
-
sure.. it aint something secret..
decal.vert
Include "abstract::MeshMatrix.vert" uniform float apptime; uniform vec2 buffersize; uniform float meshlayerrange; uniform float meshlayerheight; uniform vec3 cameraposition; uniform float camerazoom; varying vec3 T,B,N; varying vec2 texcoord0; varying vec2 texcoord1; varying vec3 cubecoord; varying vec3 vertexposition; varying vec4 modelvertex; varying vec4 projectionspace; varying vec4 refractionspace; varying vec4 fragcolor; #ifdef LW_PARALLAXMAP varying vec3 eyevec; #endif void main(void) { vec4 vertexcameraposition; Include "abstract::GetMatrix.vert" fragcolor = gl_Color*color; modelvertex = gl_Vertex; mat3 nmat = mat3(mat[0].xyz,mat[1].xyz,mat[2].xyz); mat[3].y=0.0; modelvertex = mat * modelvertex; vec2 posNeu = floor(modelvertex.xz/terrainscale.x)*terrainscale.x; vec2 move = modelvertex.xz-posNeu; modelvertex.xz=posNeu; modelvertex.y += GetTerrainHeight(modelvertex.xz); vertexposition = modelvertex.xyz; vertexcameraposition = gl_ModelViewProjectionMatrix * modelvertex; texcoord0=gl_MultiTexCoord0.xy-move.xy/2/terrainscale.x; texcoord1=gl_MultiTexCoord1.xy-move.xy/2/terrainscale.x; nmat = gl_NormalMatrix * nmat; N = normalize( nmat * gl_Normal ); #ifdef LW_BUMPMAP T = normalize( nmat * gl_MultiTexCoord2.xyz ); B = normalize( nmat * gl_MultiTexCoord3.xyz ); #endif gl_Position = vertexcameraposition; #ifdef LW_PARALLAXMAP modelvertex = gl_ModelViewMatrix * modelvertex; mat3 TBN_Matrix; TBN_Matrix[0] = T; TBN_Matrix[1] = B; TBN_Matrix[2] = N; eyevec = vec3(-modelvertex) * TBN_Matrix; #endif }
decal.frag
#extension GL_ARB_draw_buffers : enable uniform vec3 cameraposition; uniform vec2 buffersize; uniform vec2 camerarange; include "abstract::greyscale.txt" include "abstract::DepthToZPosition.frag" #ifdef LW_DETAIL uniform sampler2D LW_DETAIL; #endif #ifdef LW_DIFFUSE uniform sampler2D LW_DIFFUSE; #endif #ifdef LW_SPECULARMAP uniform sampler2D LW_SPECULARMAP; #endif #ifdef LW_BUMPMAP uniform sampler2D LW_BUMPMAP; #endif #ifdef LW_BLOOM uniform sampler2D LW_BLOOM; #endif #ifdef LW_CUBEMAP uniform samplerCube LW_CUBEMAP; #endif #ifdef LW_PARALLAXMAP uniform sampler2D LW_PARALLAXMAP; varying vec3 eyevec; #endif #ifdef LE_REFRACTION uniform sampler2D LE_REFRACTION; uniform sampler2D LE_DEPTHBUFFER; uniform float refractionstrength = 0.01; #endif #ifdef LW_POMMAP vec3 vLightTS=vec3(0.577,0.577,0.577); varying vec3 eyevec; float depthP = .15; float nMinSamples = 20; float nMaxSamples = 50; #endif #ifdef LW_MESHLAYER varying float vegetationfade; #endif #ifdef LW_ALPHABLEND uniform sampler2D LW_ALPHABLEND_INCOMINGCOLOR; uniform sampler2D LW_ALPHABLEND_INCOMINGNORMAL; #endif varying vec3 vertexposition; varying vec3 T,B,N; varying vec2 texcoord0; varying vec2 texcoord1; varying vec3 cubecoord; varying vec4 modelvertex; varying vec4 fragcolor; float fOcclusionShadow = 1.0; uniform sampler2D texture14; uniform float terrainsize; uniform vec3 terrainscale; uniform float bumpscale; uniform float specular; uniform float gloss; //Terrain color map uniform sampler2D texture12; void main(void) { vec4 diffuse = fragcolor; vec3 normal; float shininess = 0.0; vec2 texcoord=texcoord0;// only use this because of parallax mapping float selfillumination = 0.0; vec2 terraincoord; float terrainresolution; if(texcoord0.x>1 || texcoord0.x<0 || texcoord0.y<0 || texcoord0.y>1) // For greater UV values then 1 just pass a variable to the shader and check if UV > the variable.. discard; #ifdef LW_PARALLAXMAP texcoord += (texture2D(LW_PARALLAXMAP,texcoord).x * 0.04 - 0.036) * normalize(eyevec).xy; #endif #ifdef LW_POMMAP // for POM, the heightmap is in the alpha of the diffuse so save ur diffuse with DXT5 I chose this because the alpha of DXT5 is higher precision Include "abstract::POM.frag" #endif #ifdef LW_DIFFUSE diffuse *= texture2D(LW_DIFFUSE,texcoord);//*fOcclusionShadow; #endif #ifdef LW_ALPHATEST if (diffuse.w<0.5) { discard; } #endif normal = N; #ifdef LW_BUMPMAP //Use terrain normals terraincoord=vec2(vertexposition.x,-vertexposition.z) / terrainsize + 0.5; terrainresolution = terrainsize / terrainscale.x; terraincoord += 0.5 / terrainresolution; vec3 worldNormal = ((texture2D(texture14,terraincoord).xyz - 0.5) * 2.0).xyz; normal = normalize(gl_NormalMatrix*worldNormal); #ifdef LW_DETAIL normal += texture2D(LW_DETAIL,texcoord * 4.0).xyz * 2.0 - 1.0; #endif normal.z /= bumpscale; normal = T * normal.x + B * normal.y + N * normal.z; normal = normalize(normal); #ifdef LW_SPECULAR shininess = bumpcolor.a*specular;//*fOcclusionShadow #endif #ifdef LW_SPECULARMAP shininess = texture2D(LW_SPECULARMAP,texcoord).x*specular;//*fOcclusionShadow #endif #else normal=normalize(normal); #endif #ifdef LW_TERRAINCOLOR //Use terrain color terraincoord=vec2(vertexposition.x,-vertexposition.z) / terrainsize + 0.5; terrainresolution = terrainsize / terrainscale.x; terraincoord.x -= 0.5 / terrainresolution; //terraincoord.y += 0.5 / terrainresolution; vec4 terraincolor = texture2D(texture12,terraincoord); diffuse = vec4( greyscale(diffuse.xyz) * 2.0 * terraincolor.xyz,diffuse.w); #ifdef LW_MESHLAYER float temp_w=diffuse.w; diffuse = diffuse * (1.0-vegetationfade) + terraincolor * vegetationfade; diffuse.w=temp_w; #endif shininess = terraincolor.w; #endif #ifdef LE_REFRACTION diffuse.a=0.25; vec4 refractionvector = vec4( gl_FragCoord.x/buffersize.x, gl_FragCoord.y/buffersize.y, gl_FragCoord.z, 1.0 ); vec4 refractionvector2 = refractionvector + refractionstrength * vec4(normal,0.0); if (gl_FragCoord.z<DepthToZPosition(texture2DProj(LE_DEPTHBUFFER,refractionvector2).x)) { refractionvector=refractionvector2; } vec4 transparency = texture2DProj(LE_REFRACTION,refractionvector); diffuse = transparency * diffuse; #endif vec3 adjustednormal = normal*0.5+0.5; float adjustedgloss = gloss; //Diffuse gl_FragData[0] = diffuse; //Normal #ifdef LW_FULLBRIGHT gl_FragData[1] = vec4(1.0,1.0,1.0,diffuse.w); #else gl_FragData[1] = vec4(adjustednormal,diffuse.w); #endif //Bloom #ifdef LW_BLOOM gl_FragData[3] = texture2D(LW_BLOOM,texcoord) * fragcolor; #else gl_FragData[3] = vec4(0,0,0,diffuse.w); #endif shininess=clamp(shininess,0,1)*0.5; gl_FragData[2]=vec4(shininess,gloss,0.0,diffuse.w); /* float c; float temp; temp=adjustednormal.x*100.0; c=int(temp); temp=adjustednormal.y*100.0; c+=int(temp)/100.0; temp=adjustednormal.z*100.0; c+=int(temp)/100.0/100.0; gl_FragData[1].x = c; */ }
i pretty much just copied the mesh.vert and mesh.frag and made some changes..
also didnt test it with parallax and bumpmap, etc..
-
ok.. i just wrote a shader for terrain decals..
as you can see the vertices of the decal just align to the vertices of the terrain. now you maybe say: but what if i want to move it in smooth steps?
heres the answer:
at the pictures you can see the visible areas of my decal.
i create the mesh with its size+1*terrainscale. so i got 2 triangle strips left as a buffer.
when i now move the decal it moves the UV coordinates instead of the vertices until the distance moved is > then 1x terrainscale.
in the pictures the red rectangle is the visible area and the blue one is the invisible.
in picture 2 i moved the "mesh" a bit to the right, top corner. as you can see the mesh didnt really moved, but the visible area did.
when the visible area would leave the mesh, the mesh moves +1xterrainscale.
the shader i wrote basically does that:
aligns the vertices to the terrain-grid
moves the UV
discards any pixel that has UV > 1 or <0 (can be changed by parsing a max UV value to the shader)
the advantage of this system is, that it does all the work on the GPU
that it aligns the decal perfectly to the terrain
that it doesnt need that many vertices.
disadvantage:
decals atm cant be rotated
i got some errors with clipping as the mesh's y-coordinate is stored as 0 and so it sometimes doesnt get rendered if you dont look straight down (should be solveable somehow )
-
i have to admit i didnt read the whole post^^
but shouldnt the mesh shader with LW_MESHLAYER defined do exactly what you want?
-
Blah Blah, my mum is definately better than your mum.
Would you all please stop now and start working again?
-
I dont really get what you are trying atm..
I was able to read all the models-paths and texture paths from a .sbx file..
then i loaded them all ans stored them in a container.
after that i called the LoadScene() which should just create the terrain and place the models..
if i understood it right i dont have to split the file into two parts as:
"If a model with the specified filename has already been loaded, it'll return a reference to that to avoid loading assets twice. "
and
"If a texture with the specified filename has already been loaded, it'll return a reference to that to avoid loading assets twice. "
so shouldnt it take the pointers to the already loaded models/textures?
-
another way would be:
1) create the full mesh (with 100% size)..
-apply the UV's so it fits when its 100% grown
2) create a shader which makes the crack visible depending on a variable you later parse to the shader..
something like
if(texcoord.x<size)
outputcolor.a=0.0;
where size is a float that goes from 0 to the max. U value
now all you have to do is update the size parameter depending on how fast you want your crack to grow..
so you dont have to update any mesh, and you could add something like a little alpha blending at the end of the crack.
€: if you dont use the color of the mesh you could just for instance use the color.a value as the size, so you just have to change the color of the mesh at runtime..
-
Multithreading works fine with LE, you just need to keep all engine commands in one core.
You can still do OpenGL commands on another core, like drawing a progress bar.
that sounds good ^^ problem is just: where do i know from how much i have loaded yet/how much is to be loaded, so i get the progressbar from 0%-100%....
-
Hi!
I'm trying to implement some kind of progress bar for loading my scene.
My first attemt: Parsing the .sbx file and loading all the models/textures in the main thread separately und updating the image in between.
seems to work.. but as soon as i call LoadScene (after loading all the models/textures) there still comes a huge "lag".
Is there another way for something like that (i read multithreading doesnt work :-/ ) or any way of reducing this lag??
-
Hi!
I want to change the resolution of my window and fullscreen/normal screen.
everything works fine as long as:
1) i dont change between fullscreen/windowed screen
or
2) the new resolution is smaller then the old one ( then also fullscreen/windowed screen changes work)
thats my code:
void Resize(int w, int h, int d, int f, int flag) { int wa = GraphicsWidth(); int ha = GraphicsHeight(); ::Graphics(w,h,d,f, flag); if(wa==w && ha==h) return; std::vector<TBuffer> bu; for(uint i=0; i< buffer.size(); i++) { TBuffer b = CreateBuffer(w,h,flags[i]); bu.push_back(; FreeBuffer(buffer[i]); } buffer.swap(bu); bu.clear(); delete &bu; menu->SetSize(GraphicsWidth(), GraphicsHeight()); }
buffer contains all my buffers and flags contains the buffer-flags..
-
Yeah I know how to unzip files, but I thought this was an easy-to-implement and though useful function, so I made a request.
-
I want to store game specific data in a .pak file which I load with the C++ ifstream.
However, if I do something like:
ifstream file; file.open(AbstractPath("abstract::myfile.txt"));
it obviously doesn't work, because only the engine's LoadXY() - functions can read from zip-files.
However, I'm pretty sure that the engine can already extract files from .pak's because of the cache:: - protocol, so something like
ifstream file; //This returns the path of the cached file str path = CacheFile("abstract::myfile.txt"); file.open(path);
Would be great^^
-
LoadScene() DrawImage( Loadingscreen ) Flip()
Why would you expect anything to show up when the game is loading with that order of commands? It's probably just displaying whatever random bits are in the video buffer.
DrawImage( Loadingscreen )
Flip()
LoadScene()
LoadScene() should be irrelevant, I draw the image on the back buffer, then I display the back buffer on the monitor using Flip() ... or am I missing something here?
-
Alphablending is off but it should not matter because i'm not rendering lights anyway. I just do:
LoadScene()
DrawImage( Loadingscreen )
Flip()
-
Thanks a lot
Gandi
-
Hey, I've run into some really weird problem while implementing a loading screen. Once you start the game, you see the main menu and when clicking on "start game" it displays the loading state with a green bar while it loads the scene and game specific data (what an incredibly creative idea^^)
My main loop looks basically like this: (pseudo code)
while (!AppTerminate()) { switch ( GameState ) { case MainMenu: DrawMainMenu(); break; case LoadingScreen: LoadNextPiece(); DrawLoadingScreen(); break; case Ingame: UpdateFramework(); RenderFramework(); } Flip(); }
Note that during loading stage, I'm not rendering _anything_ except the loading screen, which consists of two images... but it magically blends it with the terrain viewed from the top...
I'll show a few images so you can see what I mean:
This is the loading screen before LoadScene() gets called, looks pretty normal (except for the ugly loading bar^^)
---
This is the loading screen after LoadScene() got called. The terrain you can see is the terrain of the scene loaded.
Although this happens to look quite funny, it's definately not what I wanted and I have no idea how to fix this.
Any help would be appreciated
Gandi
-
Hi!
i want to create a plane, which is billboarded (rotating around its center)
but i just dont get it to work
is there any material / shader which does that for me?
does it even work if a plane i created with CreatePlane() ?
-
Okay, so I have to do this for all the internal buffers of Framework?
-
So it should work if I simply do:
Graphics(800,600);
... because in my case, the window is resized to the new resolution, but it is just plain black^^ I'm using framework and displaying a few images and texts. Do I have to reload those images?
-
Yeah, that would be cooler. I may try it myself. I want to try and keep the complexity at about the same level as Dungeon Defense, only a couple enemy units, a couple defensive systems and yourself in a small arena. Then we could record the whole process and compare the results and the code w/ Dungeon Defense to see where LE is behind, ahead, what could be improved, etc. Would be an excellent tutorial for others as well if we documented the whole process well enough.
I figure a team of about 5 would be needed to do it in 4 weeks (longer if doing part time).
- Character modeler/animator - Only 4-5 character models needed, another 4-5 defensive system models.
- Particle effects, explosions
- Programmer
- Level designer/modeler
- Extra person to help out where needed. Should have a decent grasp of modeling/programming/etc.
So if I do it all myself I could expect to have it finished in only 2-3 years. Anybody have some free time and want to team up?
if you need some help.. i would like to
i preffer doin graphical things like particles etc.
- Character modeler/animator - Only 4-5 character models needed, another 4-5 defensive system models.
-
doesnt work on my pc..
get:
Fatal error!
System.Runtime.InteropServices.SEHException error in UDK:
Eine externe Komponente hat eine Ausnahme ausgelöst.
bei GuardedMain(Char* , HINSTANCE__* , HINSTANCE__* , Int32 )
bei ManagedGuardedMain(Char* CmdLine, HINSTANCE__* hInInstance, HINSTANCE__* hPrevInstance, Int32 nCmdShow)Address = 0x2e6e6ea (filename not found)
Address = 0x2e6146d (filename not found)
Address = 0x2e637c9 (filename not found)
-
same article i was workin with ^^
just that u got much better results then me...
demo doesnt work with my radeon..
if someone can write an glsl code for that:
float3x3 compute_tangent_frame(float3 N, float3 P, float2 UV) { float3 dp1 = ddx(P); float3 dp2 = ddy(P); float2 duv1 = ddx(UV); float2 duv2 = ddy(UV); float3x3 M = float3x3(dp1, dp2, cross(dp1, dp2)); float2x3 inverseM = float2x3( cross( M[1], M[2] ), cross( M[2], M[0] ) ); float3 T = mul(float2(duv1.x, duv2.x), inverseM); float3 B = mul(float2(duv1.y, duv2.y), inverseM); return float3x3(normalize(T), normalize(, N); }
i think i can pretty much provide results like that..
-
hmm if i pass a texture as heightmap it wraps it and now it seems to clamp it.. is there a way of telling it what it shall do?
-
I'm rendering my heightmap in its own render call. then i want to use its color buffer in another shader. i pass it to the shader and it works fine.. as long as the UV-coordinates dont get greater then 1
as soon as they are greater the last pixels of the texture get stretched along the rest of my "surface".
is there some way of getting rid of that?
thats how i do it:
1) SetShader(heightmapShader)
SetBuffer(heightmapBuffer)
DrawImage(.....)
2) BindTexture(GetColorBuffer(heightmapBuffer),....)
no compression dds
in Game Artwork
Posted
Hi!
im creating an image where i want to set the color of a pixel exactly..
so i created a 4x4 image for testing..
lets say every stripe is 1x4 pixel (don't mind the black border. its just for seeing the borders of the different versions)
1.) the image with the colors i want
2.) the image i get when using the TextureTools i DL'ed at the dl section of the forum
3.) the image i get when using nvidia dds tools with photoshop.
as you can see i get several outputs, but not the one i want to get..
i want to get the color of the 1st texture.
and now plz dont say i should just store the colors in my program, as i just used the 4 px for testing.
this should have like 256x4 pixel later.
is there any other format then dds i can use with LE.
i just want to get the color information of the texture at a specific location in my shader..
greetings
Gandi