• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Turbochist

Members
  • Content count

    46
  • Joined

  • Last visited

Community Reputation

241 Neutral

About Turbochist

  • Rank
    Member
  1. Does bindBuffer operation depends on binded buffer size? For example I have an array of indices I want to draw, also I have a few vertex buffer(sources of my vertices) first is 100 vertices second is 10000000 vertices buffers(allready created buffers) for example. The question is that changing(or binding) vertex buffers depends on their sizes or not? Ofcource rendering and creating buffers depends on buffer size but for refine I'm interesting only bindBuffer operation performance. Thank for any advice.
  2. Hi. There is a problem. I make billboard picking, and i render it in one pass with two gl_FragData. First - is a billboard image and second is a quad color mask. Billboards are transparent, and pixel with zero alpha discarded in fragment shader. I dont want to sort them)) And discard works fine, but it's also discard zero pxels in second FragData, but I needn't that. Could is it possible to make discard in first FragData, but not in a second?   P.S. Sorting solves this but I dont want to sort.    Thanks.
  3. Thanks! But how to calculate distance from camera eye to the pixel of the depth? And what if I use logarithm z ? Is it not matter?
  4. I try to get the distance to the 3d objects by clicking, and I've made some "float to rgba" coded framebuffer texture, then gets a rgba and decode to the float back. And it's good till I use blending(you understand)...But I know that there some other way to get the distance to the fragment trough the depth, but I dont understand how to make it step by step.  Please could anybody help me to understand that problem, how to make depth texture, and how to retrieve real distance from eye to pixel from that. Thanks!
  5. I've solved it! Thanks all. This is becouse I have to multyply direction to the normalMatrix. Mistake is I mul direction to modelView.
  6. attribute vec3 aVertexNormal; attribute vec3 aVertexPosition; attribute vec2 aTextureCoord; uniform mat4 uPMatrix; uniform mat4 uMVMatrix; uniform mat3 uNMatrix; varying vec2 vTextureCoord; varying vec3 vTransformedNormal; varying vec4 vPosition; void main(void) { vTransformedNormal = uNMatrix * aVertexNormal; vTextureCoord = aTextureCoord; vPosition = uMVMatrix * vec4(aVertexPosition, 1.0); gl_Position = uPMatrix * vPosition; } And frag: precision highp float; varying vec2 vTextureCoord; varying vec3 vTransformedNormal; varying vec4 vPosition; uniform vec4 uColor; uniform sampler2D uSampler; #define MAX_POINT_LIGHTS 1 uniform int pointLightsQuantity; uniform vec4 pointLightsPositions[MAX_POINT_LIGHTS]; uniform vec3 pointLightsParamsv[MAX_POINT_LIGHTS * 3]; uniform float pointLightsParamsf[MAX_POINT_LIGHTS]; void main(void) { vec3 lightWeighting; vec3 lightDirection; vec3 normal; vec3 eyeDirection; vec3 reflectionDirection; float specularLightWeighting; float diffuseLightWeighting; lightDirection = normalize(pointLightsPositions[0].xyz); //float distance = length(dir); //float attenuation = 1.0/(1.0+0.1*distance+0.01*distance*distance); normal = normalize(vTransformedNormal); eyeDirection = normalize(-vPosition.xyz); reflectionDirection = reflect(-lightDirection, normal); specularLightWeighting = pow(max(dot(reflectionDirection, eyeDirection), 0.0), pointLightsParamsf[0]); diffuseLightWeighting = max(dot(normal, lightDirection), 0.0); lightWeighting = pointLightsParamsv[0] + pointLightsParamsv[1] * diffuseLightWeighting + pointLightsParamsv[2] * specularLightWeighting; vec4 cc = texture2D( uSampler, vTextureCoord.st ); gl_FragColor = vec4(lightWeighting, uColor.a) * cc * uColor; } uNMatrix is normal matrix. I dont' know..where is a mistake?
  7. Ok I dont translate direction, but how to direct the light to fragment now?
  8. I made only direction that translate to model view, but nothing.
  9. Hi. I've stucked. Point light source works fine, but directional not. Help please. pointLightPosition.xyz = modelViewMatrix * lightPos; pointLightPosition.w = 0.0; //vertex ... vPosition = modelViewMatrix * vec4(aVertexPosition, 1.0); gl_Position = projectionMatrix * vPosition; //fragment ... vec3 normal = normalize(uNMatrix * vNormal); vec3 lightDirection; if(pointLightsPositions[0].w == 0.0){ lightDirection = normalize(pointLightPosition.xyz); }else{ lightDirection = normalize(pointLightPosition.xyz - vPosition.xyz); } vec3 eyeDirection = normalize(-vPosition.xyz); float diffuseLightWeighting = max(dot(normal, lightDirection), 0.0); vec3 lightWeighting = ambient + diffuse * diffuseLightWeighting; ...
  10. It is not a bug, it is becouse algorithm wwork with flat sphere. And I need to calculate scattering on the mountain.
  11. I'm using http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter16.html And have a visual bug, when mountains higher than camera height. Here: Please help. P.S. next day i'll get with Brunetone scattering...
  12. I calculate lightWeighting with that: lightDirection = normalize(pointLightsPosition - vPosition.xyz); normal = normalize(vTransformedNormal); eyeDirection = normalize(-vPosition.xyz); reflectionDirection = reflect(-lightDirection, normal); specularLightWeighting = pow(max(dot(reflectionDirection, eyeDirection), 0.0), pointLightsParamsf[0]); diffuseLightWeighting = max(dot(normal, lightDirection), 0.0); lightWeighting = ambient + diffuse * diffuseLightWeighting + specular * specularLightWeighting;   It is point light source in pointLightsPosition, how to calculate lightWeighting if light source has a size like radius(Sun, lamp etc.)? Thanks.
  13. OpenGL

    Yes! Thank you very much WiredCat and Alex! I think I understand. Thank you!
  14. I'm using OpenGL ES. And have two types of calculation "dir" vector, which code is fastest? attribute vec2 order; code1: if( abs(sinA) < 0.2 ) { if(order.x == 1.0){ dir = sNormalPrev; } else { dir = sNormalNext; } } else { dir *= order.x / sinA; } code2: float k = step(0.2, abs(sinA)); dir = k * dir * order.x / sinA - (k-1.0) * (step(1.0, order.x + 1.0) * sNormalPrev + step(1.0, -order.x + 1.0) * sNormalNext);
  15. Actually I've used this calculations you can watch results on http://www.openglobus.org: It's not best like Simon's but good enough for me now and comparatively low calculations. og.math.TWO_PI = 2.0 * Math.PI; og.math.PI_TWO = Math.PI / 2.0; og.math.RADIANS = Math.PI / 180.0; og.math.DEGREES = 180.0 / Math.PI; // Angle between J2000 mean equator and the ecliptic plane. // 23 deg 26' 21".448 (Seidelmann, _Explanatory Supplement to the // Astronomical Almanac_ (1992), eqn 3.222-1. og.astro.J2000_OBLIQUITY = 23.4392911; og.math.rev = function (x) { return x - Math.floor(x / 360.0) * 360.0; }; og.math.Quaternion.yRotation = function (a) { a *= 0.5; return new og.math.Quaternion(0.0, Math.sin(a), 0.0, Math.cos(a)); }; /** * http://stjarnhimlen.se/comp/tutorial.html * a Mean distance, or semi-major axis * e Eccentricity * T Time at perihelion * * q Perihelion distance = a * (1 - e) * Q Aphelion distance = a * (1 + e) * * i Inclination, i.e. the "tilt" of the orbit relative to the * ecliptic. The inclination varies from 0 to 180 degrees. If * the inclination is larger than 90 degrees, the planet is in * a retrogade orbit, i.e. it moves "backwards". The most * well-known celestial body with retrogade motion is Comet Halley. * * N (usually written as "Capital Omega") Longitude of Ascending * Node. This is the angle, along the ecliptic, from the Vernal * Point to the Ascending Node, which is the intersection between * the orbit and the ecliptic, where the planet moves from south * of to north of the ecliptic, i.e. from negative to positive * latitudes. * * w (usually written as "small Omega") The angle from the Ascending * node to the Perihelion, along the orbit. * * P Orbital period = 365.256898326 * a**1.5/sqrt(1+m) days, * where m = the mass of the planet in solar masses (0 for * comets and asteroids). sqrt() is the square root function. * * n Daily motion = 360_deg / P degrees/day * * t Some epoch as a day count, e.g. Julian Day Number. The Time * at Perihelion, T, should then be expressed as the same day count. * * t - T Time since Perihelion, usually in days * * M Mean Anomaly = n * (t - T) = (t - T) * 360_deg / P * Mean Anomaly is 0 at perihelion and 180 degrees at aphelion * * L Mean Longitude = M + w + N * * E Eccentric anomaly, defined by Kepler's equation: M = E - e * sin(E) * An auxiliary angle to compute the position in an elliptic orbit * * v True anomaly: the angle from perihelion to the planet, as seen * from the Sun * * r Heliocentric distance: the planet's distance from the Sun. * * x,y,z Rectangular coordinates. Used e.g. when a heliocentric * position (seen from the Sun) should be converted to a * corresponding geocentric position (seen from the Earth). */ og.astro.earth.getSunPosition = function (jd) { var d = jd - og.jd.J2000; var w = 282.9404 + 4.70935E-5 * d; //longitude of perihelion var a = 1.000000; //mean distance, a.u. var e = 0.016709 - 1.151E-9 * d; //eccentricity var M = og.math.rev(356.0470 + 0.9856002585 * d); //mean anomaly var oblecl = og.astro.J2000_OBLIQUITY - 3.563E-7 * d; //obliquity of the ecliptic var L = og.math.rev(w + M); //Sun's mean longitude var E = M + og.math.DEGREES * e * Math.sin(M * og.math.RADIANS) * (1 + e * Math.cos(M * og.math.RADIANS)); //eccentric anomaly //Sun rectangular coordiantes, where the X axis points towards the perihelion var x = Math.cos(E * og.math.RADIANS) - e; var y = Math.sin(E * og.math.RADIANS) * Math.sqrt(1 - e * e); var r = Math.sqrt(x * x + y * y); // distance var v = Math.atan2(y, x) * og.math.DEGREES; // true anomaly var lon = og.math.rev(v + w); //longitude of the Sun //the Sun's ecliptic rectangular coordinates x = r * Math.cos(lon * og.math.RADIANS); y = r * Math.sin(lon * og.math.RADIANS); //We use oblecl, and rotate these coordinates var xequat = x; var yequat = y * Math.cos(oblecl * og.math.RADIANS); var zequat = y * Math.sin(oblecl * og.math.RADIANS); var theta = og.math.TWO_PI * (d * 24.0 / 23.9344694 - 259.853 / 360.0); // Siderial spin time return og.math.Quaternion.yRotation(-theta).mulVec3(new og.math.Vector3(-yequat * og.astro.AU_TO_METERS, zequat * og.astro.AU_TO_METERS, -xequat * og.astro.AU_TO_METERS)); //Convert to RA and Decl //var RA = Math.atan2(yequat, xequat) * og.math.DEGREES; //var Decl = Math.atan2(zequat, Math.sqrt(xequat * xequat + yequat * yequat)) * og.math.DEGREES; }; Thanks guys!