• Advertisement

_OskaR

Member
  • Content count

    65
  • Joined

  • Last visited

Community Reputation

144 Neutral

About _OskaR

  • Rank
    Member

Personal Information

  • Interests
    Programming
  1. Hi, I have an OpenGL application but without possibility to wite own shaders. I need to perform small VS modification - is possible to do it in an alternative way? Do we have apps or driver modifictions which will catch the shader sent to GPU and override it?
  2. Looks like the rendering takes only small part of each frame. I'm loosing ~90% of performance because of using eglMakeCurrent funcion in each frame (twice). Drawing scene - 1-2ms, eglMakeCurrent - 10-20ms. I found info that better not to use it so often but I need to draw on two screens.
  3. I tried for 1024x1024 - 22 fps and 512x512 - 36 fps. I also checked it for single FBO (still rendering twice, the same amount of bind/unbind operations etc.) - 30 fps instead of 23 (1024x768). Strange. Maybe if we use another buffer, the data needs to be moved somewhere and we have performance loss?
  4. Hi   I added FBO support but looks like the performance is much lower than I expected. I'm using two screens (scene rendered for two cameras). Without FBO I have 55 fps. After adding it (texture 1024x768) - it's only 26 fps.   I also checked different configurations: 1. "Slower" - scene rendered 4 times + 2 quads with texture: Camera1 to FBO1 Camera2 to FBO2 Screen1: Camera1 - fullscreen, Camera2 - FBO2, shown on small quad Screen2: Camera2 - fullscreen, Camera1 - FBO1, shown on small quad Results (for different texture size): 256x256 - 50 fps 1024x768 - 30 fps 2048x2048 - 9 fps   2. "Faster" - scene rendered 2 times + 4 quads with texture: Camera1 to FBO1 Camera2 to FBO2 Screen1: Camera1 - FBO1, fullscreen, Camera2 - FBO2, shown on small quad Screen2: Camera2 - FBO2, fullscreen, Camera1 - FBO1, shown on small quad 256x256 - 43 fps 1024x768 - 23 fps 2048x2048 - 8 fps   I'm using device with Vivante gc2000.   Part of code: // ## rendering to texture1 ##: glViewport(0, 0, 1024, 768); glBindFramebuffer(GL_FRAMEBUFFER, m_FBO); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // drawing scene glBindFramebuffer(GL_FRAMEBUFFER, 0); glViewport(0, 0, 1024, 768); // ## rendering to texture2 ##: // (performed for 2nd FBO) eglMakeCurrent(...);// setting screen1 // drawing fullscreen quad with FBO1 // drawing small quad with FBO2 eglSwapBuffers(...);// for screen1 eglMakeCurrent(...);// setting screen2 // drawing fullscreen quad with FBO2 // drawing small quad with FBO1 eglSwapBuffers(...);// for screen2 Do I need to change/add something or the device is not enough fast for using FBO?
  5. For example - we have 4 points - (0,0,0), (0,1,1), (1,0,0), (1,0,1) and location of the camera - (0.3,y,0.4). U want to check the "y". It's impossible to do it using "int Height(BYTE *pointHeightMap, float x, float z)" function only. U need values between the vertices.
  6. Marble

    U can use shaders. Try to dl Rendermonkey from ATI website - maybe U'll find an example.
  7. Just read materials about texturing - if U texture, U should use texture coordinates. Also U can generate coordinates using shaders - sometimes it's useful.
  8. I created terrain using diamond-square algorithm. I modified noise function from LINK Terrain looks good but I'm thinking about creating sth more complex like canyons, tablelands but I don't know how to do it, where the next level of detail depends on the previous one. I do not know whether it is possible to create something like LINK (4:50) using this algorithm (flat surfaces, long curves, sth like multi-layer mountains etc.).
  9. Everything works good. But when I change small part: // terrain=texture2D(firstTexture,fragmentTexCoord3+vec2(type[0],type[1]));//+0.5*texture2D(firstTexture,fragmentTexCoord3); // if(numLOD==1) terrain=vec4(0.1,0.9,0.1,0);// - terrain should be shader and green or not modified (with grid texture). But I don't see 1st LOD (I see few long lines only) Other LODs are ok. I don't understand why - I changed color only - the geometry should be the same. If it will be helpful - I store vertices/normals as tangents/binormals in 2nd LOD or next - 1st is empty. Magic? When I change color, numLOD==1, my shader wants to use data which doesn't exist? //Sorry for few posts - I lost whole day to put it on this forum - afer posting, I couldn't connect to the forum, after connecting 1hr later - empty post. Mod can connect parts if necessary.
  10. ... // Fragment #version 150 precision highp float; uniform sampler2D firstTexture; uniform sampler2D gridTexture; uniform sampler2D noiseTexture; uniform sampler2D lut; uniform float param2; uniform float timer; uniform int numLOD; in vec2 fragmentTexCoord2; in vec3 normal; in vec4 point2; in vec2 tShape; in float tc6; out vec4 fragColor; void main (void) { vec2 fragmentTexCoord3=fragmentTexCoord2;//+(eye.xy*height*0.01); vec4 terrain; float rnd=texture2D(noiseTexture,fragmentTexCoord3).r*0.2; fragmentTexCoord3=(fragmentTexCoord3*0.9+0.05*0.25); if(param2>0.5) { vec4 type=texture2D(lut,vec2(tShape[1]+rnd,tShape[0]+rnd)); if(type.x>0.99) type.x=0.99; if(type.y>0.99) type.y=0.99; terrain=texture2D(firstTexture,fragmentTexCoord3+vec2(type[0],type[1]));//*ok // if(numLOD==1) // terrain=vec4(0.1,0.9,0.1,0);//************* vec3 light_position2=vec3(0.3*cos(0.03*timer),0,0.3*sin(0.03*timer)); vec3 light=normalize(light_position2); float intensity3 = max(dot(normal,light), 0.0); fragColor = 0.5* terrain * (0.3+0.7*intensity3); } else { // fragColor=vec4(0,0,1,0);// fragColor = texture2D(gridTexture,fragmentTexCoord3); } const float C = 1.0; const float far = 1000000000.0; const float offset = 1.0; gl_FragDepth = (log(C * tc6 + offset) / log(C * far + offset)); } I'm using param2 to switch between shaded, textured terrain and terrain with grid texture (I don't draw lines - too slow). If numLOD==1 I draw 1st only. For other values - 2nd, 3rd etc. (using "tangents/binormals" as vertices/normals. ...
  11. ... // Fragment #version 150 precision highp float; uniform sampler2D firstTexture; uniform sampler2D gridTexture; uniform sampler2D noiseTexture; uniform sampler2D lut; uniform float param2; uniform float timer; uniform int numLOD; in vec2 fragmentTexCoord2; in vec3 normal; in vec4 point2; in vec2 tShape; in float tc6; out vec4 fragColor; void main (void) { vec2 fragmentTexCoord3=fragmentTexCoord2;//+(eye.xy*height*0.01); vec4 terrain; float rnd=texture2D(noiseTexture,fragmentTexCoord3).r*0.2; fragmentTexCoord3=(fragmentTexCoord3*0.9+0.05*0.25); if(param2>0.5) { vec4 type=texture2D(lut,vec2(tShape[1]+rnd,tShape[0]+rnd)); if(type.x>0.99) type.x=0.99; if(type.y>0.99) type.y=0.99; terrain=texture2D(firstTexture,fragmentTexCoord3+vec2(type[0],type[1]));//*ok // if(numLOD==1) // terrain=vec4(0.1,0.9,0.1,0);//************* vec3 light_position2=vec3(0.3*cos(0.03*timer),0,0.3*sin(0.03*timer)); vec3 light=normalize(light_position2); float intensity3 = max(dot(normal,light), 0.0); fragColor = 0.5* terrain * (0.3+0.7*intensity3); } else { // fragColor=vec4(0,0,1,0);// fragColor = texture2D(gridTexture,fragmentTexCoord3); } const float C = 1.0; const float far = 1000000000.0; const float offset = 1.0; gl_FragDepth = (log(C * tc6 + offset) / log(C * far + offset)); } I'm using param2 to switch between shaded, textured terrain and terrain with grid texture (I don't draw lines - too slow). If numLOD==1 I draw 1st only. For other values - 2nd, 3rd etc. (using "tangents/binormals" as vertices/normals. ... [Edited by - _OskaR on August 21, 2010 5:00:18 PM]
  12. ... // Geometry #version 150 core #extension GL_EXT_geometry_shader4 : enable precision highp float; layout(triangles) in; layout(max_vertices = 3) out; uniform int numLOD[]; in vec2 fragmentTexCoord[];// in vec3 nvec[];// in vec4 point[]; in vec2 t_shape[]; in vec4 glPositionIn[]; out vec2 fragmentTexCoord2; out vec4 point2;// out float param;// out vec3 normal;// out vec2 tShape;// out float tc6;// void main() { float coordParam=1024;//65536.0f; for(int i=0;i<numLOD[0];i++) coordParam=coordParam*0.5f; coordParam=1.0; vec3 tcx; vec3 tcy; param=1; if((fragmentTexCoord[0].x==fragmentTexCoord[2].x)) { tcx=vec3(0.0,0.25,0.0); tcy=vec3(0.25,0.25,0.0); } else { tcx=vec3(0,0.25,0.25); tcy=vec3(0,0.25,0); } int i=0; for(int i = 0; i < 3; i++) //2 { // fragmentTexCoord2 = fragmentTexCoord[i]; tShape=t_shape[i]; normal = nvec[i]; point2=point[i]; fragmentTexCoord2 = vec2(tcx[i]*coordParam,tcy[i]*coordParam); gl_Position = glPositionIn[i]; tc6 = gl_Position.z; EmitVertex(); } EndPrimitive(); } ...
  13. After few modifications sth's wrong too. So code: // Vertex #version 150 core precision highp float; uniform mat4 projectionMatrix; uniform mat4 modelViewMatrix; uniform mat4 cameraMatrix; uniform float param1; uniform float timer; uniform int numLOD; in vec4 vertex; in vec3 normal; in vec3 binormal; in vec4 tangent; in vec2 texCoord; out vec2 fragmentTexCoord;// out vec3 nvec;// out vec4 point;// out vec2 t_shape;// out vec4 glPositionIn;// vec4 vertex2; vec3 cameraLocation; void main(void) { fragmentTexCoord = texCoord; vec3 normal2 = normal; vertex2=vertex; if(numLOD==1) { // vertex2.xyz=tangent;//tangent; // normal2=binormal; } else { vertex2=tangent;//tangent; normal2=normalize(binormal); } nvec = normalize(normal2); vec3 terrAngle=normalize(vertex2.xyz); float tAngle=dot(nvec,terrAngle); float odl=sqrt(vertex2[0]*vertex2[0]+vertex2[1]*vertex2[1]+vertex2[2]*vertex2[2]); float factor=0.2*0.5; float radius=7000000; float maxHeight=200000; vec4 point2 = projectionMatrix*modelViewMatrix*vertex2; t_shape=vec2(tAngle,((radius+maxHeight-odl)/maxHeight)); glPositionIn = point2; } In tangents/binormals I have 2nd model (vertices/normals). ...
  14. Sth is bad with my shaders (GLSL 1.5, nVidia). In fragment shader for: if(param>0.5) color=vec4(0,0,1,0);everything's good. But after small modification: if(param>0.5) color=vec4(0,0,1,0); else color=vec4(0,1,0,0);: Quote:Fragment shader compile error: 0(145) : error C0000: syntax error, unexpected '=' at token "=" 0(145) : error C0501: type name expected at token "=" 0(145) : warning C7022: unrecognized profile specifier "C" 0(145) : warning C7022: unrecognized profile specifier "loat" 0(148) : error C0000: syntax error, unexpected '=' at token "=" 0(148) : error C0501: type name expected at token "=" 0(148) : warning C7022: unrecognized profile specifier "gl_FragDepth" 0(148) : error C0000: syntax error, unexpected '*' at token "*" 0(148) : error C0501: type name expected at token "*" 0(148) : warning C7022: unrecognized profile specifier "C" 0(148) : error C7531: pointers require "#extension GL_NV_shader_buffer_load : en able" before use 0(148) : error C0502: syntax error at token "C" Another vesrion:if(param>0.5) { color=vec4(0,0,1,0); } else { color=vec4(0,1,0,0); }and: Quote:Fragment shader compile error: 0(149) : warning C7022: unrecognized profile specifier "st" 0(149) : error C0502: syntax error at token "st" 0(152) : error C0000: syntax error, unexpected '=' at token "=" 0(152) : error C0501: type name expected at token "=" 0(152) : warning C7022: unrecognized profile specifier "gl_FragDepth"Also I have errors when I use:if(param>0.5) { color=vec4(0,0,1,0); } What's going on? This is very strange for me but I have more important problem. I haveuniform int numLOD;In fragment shader:if(numLOD==1) terrain=vec4(0.1,0.9,0.1,0);When I run my application I see only first LOD so whole model is green and it's ok (max level is 15). But when I use if(numLOD<1000) { // } else { vertex2.xyz=vec3(0,0,0); }in vertex shader, I have a lot of artifacts, when I use normals instead vertex2 - I have same artifacts too - even if I don't use normals later. Also it should be impossible that this number was greather than 1000. I installed new drivers - nothing helped.
  15. I'm looking for good method to texturing large areas. My previous ideas doesn't work so I foud: LINK But sth's wrong: IMG1 - looks ok IMG2 - lower altitude - in right up croner, triangles doesn't look god IMG3 - even lower altitude - this effect "moves" like wave IMG4 - almost ground - ok I changed few mipmapping options but it doesn't help. It seems to me that at a greater distance, it wasn't possible to determine which color texture, because it is too small. When the camera is very far, given the texture represents only one color and there's no problem. But how to fix it? New texture atlas for other distances? Also I want to use noise correctly. I wrote: float noise=0.0; float move=0.03; float noiseColor=texture2D(noiseTexture,fract(uv)).r; for(int i=0;i<numLOD;i++) { noise=noise+noiseColor*move; move=move*0.5; } and add the noise to the slope/altitude vector. Effect: IMG5 - high altitude - maybe good pattern but it's very grainy IMG6 - ground - looks much worse Of course I can change start value of move to 0.00001 but it's not solution. I heard about multiple samping but looks like it requires to use different coorinates - and I have no idea how to take it.
  • Advertisement