Jump to content
  • Advertisement
deltaKshatriya

Geometry vs Texturing in Game Art

Recommended Posts

Hey all,

So although I've posted some stuff here for critique, by and large, I'm not really a CG artist who does stuff for games. To be fair, even CG art is primarily a side hobby for me. But anyhow, back on topic. One of the things I've noticed is that for general CG art, we generally prefer to use as much geometry as possible for building a scene, since we don't really care much about render time. For example, sometimes bricks will be modeled in to fully utilize the lighting calculations and what not. Now obviously, with game dev, that just isn't true, and I do have experience with this. What I've noticed, however, is that game art in many games (Dark Souls, etc.) really does seem to look like it's using a ton of geometry, especially with architecture. Now I can tell where textures are used, but I'm curious, what's the balance for geometry vs texture? When is a texture preferred to modeling geometry? 

I thought this would be interesting discussion. 

Share this post


Link to post
Share on other sites
Advertisement
1 minute ago, deltaKshatriya said:

For example, sometimes bricks will be modeled in to fully utilize the lighting calculations and what not. Now obviously, with game dev, that just isn't true, and I do have experience with this. What I've noticed, however, is that game art in many games (Dark Souls, etc.) really does seem to look like it's using a ton of geometry, especially with architecture. Now I can tell where textures are used, but I'm curious, what's the balance for geometry vs texture? When is a texture preferred to modeling geometry? 

Often you do model everything in excessive detail, down to cracks in bricks, first. Then, second you make a lower detailed mesh with the same general shape (a flat wall that covers all the bricks). Third, you "bake" all the geometric details from mesh #1 onto normal/depth/ao textures for use on mesh #2.

If done right, mesh #2 now has all the same details as mesh #1, but hardly any polygons. You can only really tell the difference when looking at it extremely closely, or when looking at the silhouette.

As when when to use each... it can be easy to get carried away with using low-poly meshes with large textures, but textures take up a LOT of memory. A compressed 1024x1024 normal map is about 1.3MB -- in that same amount of memory you could store over 40K vertices! So it can actually be better to use extra polygons and lower resolution textures, where possible.

The main thing that you never want to do is end up with so many triangles that they start to become smaller than one pixel. GPU's like to run pixel shaders on a block of 2x2 pixels at a time, so if a triangle only covers 1 pixel, the GPU will likely run the PS on 4 pixels, throw away three results, and keep one result! This means that meshes that have an extremely high polygon count can actually increase pixel shading costs by 300% :o Moreover, the fixed-function rasterizer probably works on 4x4 or 8x8 blocks of pixels, and only works at full efficiency if your triangles are bigger than that...

So -- use as many triangles as necessary, but then employ LOD (switching out models for lower detail versions when in the distance) to make sure that your on-screen triangles never get too small.

Share this post


Link to post
Share on other sites

Maybe as an artist you should not distinguish between geometry and texture too much at all. There may be a preprocessing toolchain that takes your art and converts it to efficient game assets. It may resample textures, merge materials, decide what details remain geometry or become normal maps, generate LODs. It may even remesh your geometry and turn details to displacement maps, geometry images, voxels or whatever turns out to be most efficient.

So thinking ahead it's probably most important you always create art with very high detail so it still looks as intended even if everything gets resampled and downscaled. E.g. a tool may rotate UVs and straight lines of texels could become jaggy, or a tool may remove long and thin features of geometry, etc. Being aware of such issues may become important, while caring about low poly count may become obsolete for the artist.

 

 

 

Share this post


Link to post
Share on other sites

I'm not a game artist by any means, I was just genuinely curious about the differences. It's interesting that both textures and geometry have limitations for game art. I knew about LOD tricks of course, since I've done some hobbyist game dev myself. 

I'd imagine that things like light fog, distance fog, camera angle, etc. can do a lot to change the visuals, potentially even hide some things? 

Share this post


Link to post
Share on other sites
27 minutes ago, deltaKshatriya said:

I'd imagine that things like light fog, distance fog, camera angle, etc. can do a lot to change the visuals, potentially even hide some things? 

To me the perfect reference is looking SD or highly compressed video. It has only little detail and it's blurry, but it looks 1000 times better than any game graphics. It proofs we can remove a lot of things. ('We' means programmers - programmers need to solve this, artists should not need to care. Actually they spend way too much time on high to low poly conversion, creating UVs etc. That's why i believe in automated tools.)

Share this post


Link to post
Share on other sites

This has been the problem with 3D graphics from the start, how many polygons can we use?

The answer is: no one knows.

There was a time where using alpha maps where used to make geometry look more complex; that was when computers had strict limits on polygons. These days computers can render millions of polygons but alpha sorting is much more expensive than it ever was; so doing the same thing will result with people calling you a fool.

 

So how do you know just how much geometry you can use?

Here is the rule of thumb: 64 000 vertices per draw call.(For optimized engines like Unreal and Unity).The thing is if you don't use the full 64 000 vertices per draw call it's still going to cost the same.

Except how many vertices each mesh has is hard to know. Because smooth groups and UV maps add to the account. So a simple object like a wall with bricks will have a simple almost flat UV map and no need for smooth groups, so can have lots more geometry. A motorcycle will need lots of uv maps for the complex shape and lots of smooth groups for the different materials, so will have less vertices.

Then there is the fact that there is no rule that one object should only have one draw call. Main characters in the game will often already have more than one material. In Dragon Age 2 the characters had many materials and so the characters had huge amount of polygons(> 182 000 even on low), the environment shared one material so objects in it like chairs where only in the hundreds(200 - 600 polygons).

It depends on the computer, the artist, the game type and the model. So no one really knows.

 

On 9/27/2017 at 7:38 PM, JoeJ said:

'We' means programmers - programmers need to solve this, artists should not need to care. Actually they spend way too much time on high to low poly conversion, creating UVs etc. That's why i believe in automated tools.

It's important for the artist to care, not caring would put a lot of extra pressure on the programmers and would allow the artist to shift blame. Team work is always important.

Auto tools can't do complex things yet and when they can they will be as smart as humans, so a artistic hand guiding it is important. Then there are the times where the auto tool makes such a mess you are better off without it.

On 9/27/2017 at 7:38 PM, JoeJ said:

To me the perfect reference is looking SD or highly compressed video. It has only little detail and it's blurry, but it looks 1000 times better than any game graphics. It proofs we can remove a lot of things.

Removing things is fine for videos where everything is batched, nothing is going to change suddenly.

So in a movie you can spend a few minutes compressing data, because you will only do it once. In a game textures have to be compressed at real time and uncompressed when used, so a heavy compression like the ones used in videos would reduce performance not gain it.

Share this post


Link to post
Share on other sites
6 hours ago, Scouting Ninja said:

 

On 27.9.2017 at 7:38 PM, JoeJ said:

'We' means programmers - programmers need to solve this, artists should not need to care. Actually they spend way too much time on high to low poly conversion, creating UVs etc. That's why i believe in automated tools.

It's important for the artist to care, not caring would put a lot of extra pressure on the programmers and would allow the artist to shift blame. Team work is always important.

Auto tools can't do complex things yet and when they can they will be as smart as humans, so a artistic hand guiding it is important. Then there are the times where the auto tool makes such a mess you are better off without it.

On 27.9.2017 at 7:38 PM, JoeJ said:

To me the perfect reference is looking SD or highly compressed video. It has only little detail and it's blurry, but it looks 1000 times better than any game graphics. It proofs we can remove a lot of things.

Removing things is fine for videos where everything is batched, nothing is going to change suddenly.

So in a movie you can spend a few minutes compressing data, because you will only do it once. In a game textures have to be compressed at real time and uncompressed when used, so a heavy compression like the ones used in videos would reduce performance not gain it.

Agree for the moment, but i assume things will (and have to) change a lot to improve performance of both artists and hardware.

A good analogy is the use of scanned real world data: This data requires automatic preprocessing and detail reduction anyways which already does forms of compression similar to video. It works, creates geometry and texture data totally different than a human, and still the result is usually more realistic than human made art. (Yes i know there is still human editing involved in any use of real world data)

I know the opposite is true as well and processing human made art is much more difficult and will introduce some unwanted effects, but we'll deal with that. We already do when baking hires to game asset and no one complains, but if we automate this entire process (which is very hard to achieve), there are lots of advantages for the Artist:

You don't care about generating low poly geometry / LODs.

You don't care about creating UVs (you only use them to paint your hires model, but layout and seams don't matter)

You don't care about any kind of seams at all never again.

 

Could i - under the assumption that minor details get lost but overall graphics quality actually improves -  convince you as an artist with these promises? Serious question - unfortunately i have to create such a tool, so i'd really like to hear more thoughts and doupts to prepare for resistance :) 

 

Advantages for the hardware: Much less triangles, less materials, less overall fragmentation of things. Better utilization of memory (e.g. texture space). Opens up the possibility to use other data structures to represent geometry (In my case a tree of samples covering any surface for realtime GI. Basically i need only a seamless lightmap texture atlas for this, but i think about adding more features to the tool).

 

Share this post


Link to post
Share on other sites

Warning the spoilers are boring , they are just there for people who want to know more about my opinion.

On 9/29/2017 at 7:50 AM, JoeJ said:

but if we automate this entire process (which is very hard to achieve), there are lots of advantages for the Artist:

It's true the way of the future will have artist just capturing what they need to produce there art and some kind of mind scanner will produce what ever they can imagine. I absolutely with no doubt believe this will happen, it was not what I argued against.

The two points I want to make is this:

Removing details from a mesh is not a very efficient way of optimizing models in the long term. The reason is simple it's not cost effective.

Spoiler

 

Think of it this way, if you had a piece of paper where you could only fit four numbers and you wanted to store a phone number. Would it be more efficient to learn the math needed for encryption or buying a bigger piece of paper.

This is what is happening with geometry, the hardware and software needed for rendering more is much cheaper than the software needed for removing data without loss. Then there is the fact that a already better way exist for handling 3D models like subD, decimate tools are used for LODs, and the amount these tools reduce is efficient and improving there ability to reduce polycount is not worth the cost.

The reason it's not worth the cost is that players who need the models overall polycount to drop are players with older computers, they often don't have much money to waste on games anyway and are there for a lesser target than players who buy expensive computers to render more polygons. So by the time software exists that reduces polygons at a much more effective rate, there will be no need to reduce the polygons.

 

The artist should care about how the tools making the art works.

Spoiler

 

The mistake your making here is thinking of the artist as the consumer, if the art was a motor vehicle, the artist is the manufacturer not the driver.

Lets say I had to produce a 3d model and my deadline was in 3 days, something goes wrong and some parts of my normal map is inverted. Who do I blame? Our team programmers maybe they didn't load the normal map correctly? The programmers behind the development software because it doesn't work perfectly at a press of a button? Maybe the API programmers because this is a problem with the shader?

Just maybe the person to blame for the inverted normals was the artist, because he either set the ray cast too long hitting the back of the opposite side of the mesh or the normal on that part of the mesh is flipped causing the ray to bake them inverted.

The simple fact is that the artist is the person best equipped to deal with the problems related to the art. You never have the time to contact a software developer when something goes wrong and you can't wait for a patch. Also knowing how your tools work allows you to better use them.

If you want to use a hammer you should know how it works before you hurt yourself, the same is true for all tools.

 

 

On 9/29/2017 at 7:50 AM, JoeJ said:

this entire process (which is very hard to achieve), there are lots of advantages for the Artist:

You don't care about generating low poly geometry / LODs.

There are 2 LODs a artist makes by hand this is The LOD1 and the last LOD. No matter how aggressive the LOD tool is this is how it's done. The reason is simple, it allows control over the generated LODs because you set the max and the min this way.

Having tools that are better reducing polycount won't change this, the artist needs a way to estimate the end results as they need to produce textures and shaders/materials for the LODs long before they actually have the LODs.

On 9/29/2017 at 7:50 AM, JoeJ said:

You don't care about creating UVs (you only use them to paint your hires model, but layout and seams don't matter)

You don't care about any kind of seams at all never again.

A texture isn't relative to a geometry and even if you did do this you would exceed the other limits of rendering too fast.

Spoiler

 

Consider a texture for a rock vs a building, your texture limit is 4096* 4096. If you then give the building it's own texture at max size and the rock it's own size max texture you get more details on your rock than building. This produces models that don't match.

OK, so what if your geometry was relative to the texture. Well most 3D modeling tools do this, you can just download Blender and use it's auto unwrap tool. The problem is that now your building has a 4K texture and your rock ends up with a 16*16 pixel texture and that will be blurry as a fogy window.

So you fix your relative problem with more textures, giving the rock a nice 4K texture and the building 256* 4K textures because that won't overload your players hard drive.

So to fix any problems you could have with unwrapping you give the software the ability to actually recognize objects so it can see the windows and only unwrap one and then use that part for all the windows. Then to deal with the window depth and make the model more than a block you give it the ability to read depth using the light captured in the images. Except a static light is a bad source so you give it the ability to compare two images. Except now you have the problem most tracking software has that it can't keep track of data behind objects so you give it the ability to imagine the missing data.

Before you know it's starting the robot revolution and over overthrow mankind because it now has the abilities of a human and the cold calculating mind of a computer.:o

 

 

 

So to prevent the total destruction of mankind you should find a way to abandon the concept of textures, or storing data because that is what textures are, and calculate every thing at real time by creating a computer as powerful as the world; except now there is no need to reduce the geometry because it's all particles now.

So all jokes aside there is a reason this hasn't be done before, because no one can think of a way to do it.

On 9/29/2017 at 7:50 AM, JoeJ said:

Could i - under the assumption that minor details get lost but overall graphics quality actually improves -  convince you as an artist with these promises?

There is a way to do this, it's why the toon style was invented. Animators needed to reduce details and keep things as interesting as it was before. So they simply removed the unimportant details and exaggerated the important ones.

If you really do plan to make software that will reduce polycount then start here and learn 3D modeling. If you have questions about 3D modeling you can ask in the art forum. Most 3D modelers are happy to bore other people with what they know.

Edited by Scouting Ninja

Share this post


Link to post
Share on other sites

... much more resistance than expected, and for very different reasons.

I'll think about it, thanks!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
  • Advertisement
  • Popular Tags

  • Similar Content

    • By Gregory Aaron Martin
      I'm writing a sprawling fantasy series. I've written shorter stories in the world I'm creating. I want to turn one of those short stories into a game. It can be 2D. It's about dragons. There's a story arc below that shows a starting point and an ending point. Details will be given if there's anyone interested. I'm a storyteller but I don't have much knowledge on game development.
       
      Synopsis: A young man with a very special gift returns to his mountainous home to find it invaded by a cult. The community he's been a part of his whole life has been cut off by the king to ensure the cult's influence remains limited as it's very influential. This cult believes the dragon they follow and worship rests in the mountains and with the king pulling his soldiers out, the cult can begin its dig underground. The young man learns that the last individual with the same special gift who held a coveted seat on the council was killed by the cult during the cult's takeover of the village community. The young man, like others with the same special ability as him, vied for the seat on the council but he was turned away either for his own safety or because of council secrets. The cult has its own members with this same special ability and they're very intimidating. The community is oppressed for months. Tired of this oppression and feeling abandoned by his king, the young man sets out with a few new comrades to battle this cult, putting on display his own talent with this special gift.They make it their mission to sabotage the cult's dig into the mountains in hopes the cult doesn't awaken their dragon. They also make it their mission to defeat the cult members who posses the special ability. They are successful with this and he is appointed to the coveted seat on the council. 
       
      Thanks
    • By cozzie
      Hi guys,
      I've been struggling to create a function to draw an arrow with 2 lines making up the arrowhead.
      The challenge is that I somehow can't get the rotation right.
      I've pasted the code below and an image of the result.
      Findings so far, when I replace the 3x3 part of the transform matrix to identity, I get the same visual result.
      Also when I switch colums A and C in the matrix, this specific arrow looks good (with is pointing in the positive X direction).
      Any input would be appreciated.
      bool CDebugDraw::AddArrow(const CR_VECTOR3 &pPos1, const CR_VECTOR3 &pPos2, const CR_VECTOR3 &pColor, const bool pDepthEnabled, const bool pPersistent, const uint64_t pLifeTime) { if(!AddLine(pPos1, pPos2, pColor, pDepthEnabled, pPersistent, pLifeTime)) return false; /* p1 ------- X / | \ | / | \ | / | \ | p2 -----|-----p3 | Z | | | | p0 */ CR_VECTOR3 arrowDir = pPos2 - pPos1; arrowDir.Normalize(); // model space CR_VECTOR3 p1 = CR_VECTOR3(0.0f, 0.0f, 0.0f); CR_VECTOR3 p2 = CR_VECTOR3(0.2f, 0.0f, -0.2f); CR_VECTOR3 p3 = CR_VECTOR3(-0.2f, 0.0f, -0.2f); // transformation: translate and rotate CR_VECTOR3 transl = pPos2; CR_VECTOR3 colA = arrowDir; CR_VECTOR3 tVec; if(colA.x != 0 && colA.z != 0) tVec = CR_VECTOR3(0.0f, 1.0f, 0.0); else tVec = CR_VECTOR3(0.0f, 0.0f, 1.0f); CR_VECTOR3 colB = CMathHelper::CrossVec3(colA, tVec); CR_VECTOR3 colC = CMathHelper::CrossVec3(colB, colA); CR_MATRIX4X4 transform; transform.m11 = colA.x; transform.m12 = colB.x; transform.m13 = colC.x; transform.m14 = 0.0f; transform.m21 = colA.y; transform.m22 = colB.y; transform.m23 = colC.y; transform.m24 = 0.0f; transform.m31 = colA.z; transform.m32 = colB.z; transform.m33 = colC.z; transform.m34 = 0.0f; transform.m41 = transl.x; transform.m42 = transl.y; transform.m43 = transl.z; transform.m44 = 1.0f; // transform = CMathHelper::ComposeWorldMatrix(transform, CR_VECTOR3(1.0f), CR_VECTOR3(0.0f, 90.0f, 0.0f), pPos2); // transform to worldspace p1 = CMathHelper::TransformVec3Coord(p1, transform); p2 = CMathHelper::TransformVec3Coord(p2, transform); p3 = CMathHelper::TransformVec3Coord(p3, transform); if(!AddLine(p1, p2, CR_VECTOR3(1.0f, 0.0f, 0.0f), pDepthEnabled, pPersistent, pLifeTime)) return false; if(!AddLine(p1, p3, CR_VECTOR3(1.0f, 0.0f, 0.0f), pDepthEnabled, pPersistent, pLifeTime)) return false; if(!AddCross(p2, 0.02f, CR_VECTOR3(0.0f, 0.0f, 1.0f), pDepthEnabled, pPersistent, pLifeTime)) return false; if(!AddCross(p3, 0.02f, CR_VECTOR3(0.0f, 0.0f, 1.0f), pDepthEnabled, pPersistent, pLifeTime)) return false; return true; } Incorrect result:

      Aimed/ correct result (independent of arrow direction):

    • By NanaMarfo
      Hello Everyone!
      I am looking for a small team to do a rendering project with me. The roles I need are:
      -Character Modeller
      -Environment Designer
      -Environment Modeller(Found)
      You can use this in your portfolio and you will be credited at the end.
      If you are interested, please email me at marfo343@gmail.com. Thank you!
    • By D34DPOOL
      Edit Your Profile D34DPOOL 0 Threads 0 Updates 0 Messages Network Mod DB GameFront Sign Out Add jobEdit jobDeleteC# Programmer for a Unity FPS at Anywhere   Programmers located Anywhere.
      Posted by D34DPOOL on May 20th, 2018
      Hello, my name is Mason, and I've been working on a Quake style arena shooter about destroying boxes on and off for about a year now. I have a proof of concept with all of the basic features, but as an artist with little programming skill I've reached the end of my abilities as a programmer haha. I need someone to help fix bugs, optomize code, and to implent new features into the game. As a programmer you will have creative freedom to suggest new features and modes to add into the game if you choose to, I'm usually very open to suggestions :).
      What is required:
      Skill using C#
      Experience with Unity
      Experience using UNET (since it is a multiplayer game), or the effort and ability to learn it
      Compensation:
      Since the game currently has no funding, we can split whatever revenue the game makes in the future. However if you would perfer I can create 2D and/or 3D assets for whatever you need in return for your time and work.
      It's a very open and chill enviornment, where you'll have relative creative freedom. I hope you are interested in joining the team, and have a good day!
       
      To apply email me at mangemason@yahoo.com
    • By Andrew Parkes
      I am a talented 2D/3D artist with 3 years animation working experience and a Degree in Illustration and Animation. I have won a world-wide art competition hosted by SFX magazine and am looking to develop a survival game. I have some knowledge of C sharp and have notes for a survival based game with flexible storyline and PVP. Looking for developers to team up with. I can create models, animations and artwork and I have beginner knowledge of C sharp with Unity. The idea is Inventory menu based gameplay and is inspired by games like DAYZ.
      Here is some early sci-fi concept art to give you an idea of the work level. Hope to work with like minded people and create something special. email me andrewparkesanim@gmail.com.
      Developers who share the same passion please contact me, or if you have a similar project and want me to join your team email me. 
      Many thanks, Andrew.

    • By thecheeselover
      I made this post on Reddit. I need ideas and information on how to create the ground mesh for my specifications.
    • By Canadian Map Makers
      GOVERNOR is a modernized version of the highly popular series of “Caesar” games. Our small team has already developed maps, written specifications, acquired music and performed the historical research needed to create a good base for the programming part of the project.

      Our ultimate goal is to create a world class multi-level strategic city building game, but to start with we would like to create some of the simpler modules to demonstrate proof of concept and graphical elegance.

       

      We would like programmers and graphical artists to come onboard to (initially) create:

      A module where Province wide infrastructure can be built on an interactive 3D map of one of the ancient Roman Provinces.
      A module where city infrastructure can be built on a real 3D interactive landscape.
      For both parts, geographically and historically accurate base maps will be prepared by our team cartographer. Graphics development will be using Blender. The game engine will be Unity.

       

      More information, and examples of the work carried out so far can be found at http://playgovernor.com/ (most of the interesting content is under the Encyclopedia tab).

       

      This project represents a good opportunity for upcoming programmers and 3D modeling artists to develop something for their portfolios in a relatively short time span, working closely with one of Canada’s leading cartographers. There is also the possibility of being involved in this project to the point of a finished game and commercial success! Above all, this is a fun project to work on.

       

      Best regards,

      Steve Chapman (Canadian Map Makers)

       
    • By RobMaddison
      Hi
      I’ve been working on a game engine for years and I’ve recently come back to it after a couple of years break.  Because my engine uses DirectX9.0c I thought maybe it would be a good idea to upgrade it to DX11. I then installed Windows 10 and starting tinkering around with the engine trying to refamiliarise myself with all the code.
      It all seems to work ok in the new OS but there’s something I’ve noticed that has caused a massive slowdown in frame rate. My engine has a relatively sophisticated terrain system which includes the ability to paint roads onto it, ala CryEngine. The roads are spline curves and built up with polygons matching the terrain surface. It used to work perfectly but I’ve noticed that when I’m dynamically adding the roads, which involves moving the spline curve control points around the surface of the terrain, the frame rate comes to a grinding halt.
      There’s some relatively complex processing going on each time the mouse moves - the road either side of the control point(s) being moved, is reconstructed in real time so you can position and bend the road precisely. On my previous OS, which was Win2k Pro, this worked really smoothly and in release mode there was barely any slow down in frame rate, but now it’s unusable. As part of the road reconstruction, I lock the vertex and index buffers and refill them with the new values so my question is, on windows 10 using DX9, is anyone aware of any locking issues? I’m aware that there can be contention when locking buffers dynamically but I’m locking with LOCK_DISCARD and this has never been an issue before.
      Any help would be greatly appreciated.
    • By MikhailGorobets
      I have a problem with SSAO. On left hand black area.
      Code shader:
      Texture2D<uint> texGBufferNormal : register(t0); Texture2D<float> texGBufferDepth : register(t1); Texture2D<float4> texSSAONoise : register(t2); float3 GetUV(float3 position) { float4 vp = mul(float4(position, 1.0), ViewProject); vp.xy = float2(0.5, 0.5) + float2(0.5, -0.5) * vp.xy / vp.w; return float3(vp.xy, vp.z / vp.w); } float3 GetNormal(in Texture2D<uint> texNormal, in int3 coord) { return normalize(2.0 * UnpackNormalSphermap(texNormal.Load(coord)) - 1.0); } float3 GetPosition(in Texture2D<float> texDepth, in int3 coord) { float4 position = 1.0; float2 size; texDepth.GetDimensions(size.x, size.y); position.x = 2.0 * (coord.x / size.x) - 1.0; position.y = -(2.0 * (coord.y / size.y) - 1.0); position.z = texDepth.Load(coord); position = mul(position, ViewProjectInverse); position /= position.w; return position.xyz; } float3 GetPosition(in float2 coord, float depth) { float4 position = 1.0; position.x = 2.0 * coord.x - 1.0; position.y = -(2.0 * coord.y - 1.0); position.z = depth; position = mul(position, ViewProjectInverse); position /= position.w; return position.xyz; } float DepthInvSqrt(float nonLinearDepth) { return 1 / sqrt(1.0 - nonLinearDepth); } float GetDepth(in Texture2D<float> texDepth, float2 uv) { return texGBufferDepth.Sample(samplerPoint, uv); } float GetDepth(in Texture2D<float> texDepth, int3 screenPos) { return texGBufferDepth.Load(screenPos); } float CalculateOcclusion(in float3 position, in float3 direction, in float radius, in float pixelDepth) { float3 uv = GetUV(position + radius * direction); float d1 = DepthInvSqrt(GetDepth(texGBufferDepth, uv.xy)); float d2 = DepthInvSqrt(uv.z); return step(d1 - d2, 0) * min(1.0, radius / abs(d2 - pixelDepth)); } float GetRNDTexFactor(float2 texSize) { float width; float height; texGBufferDepth.GetDimensions(width, height); return float2(width, height) / texSize; } float main(FullScreenPSIn input) : SV_TARGET0 { int3 screenPos = int3(input.Position.xy, 0); float depth = DepthInvSqrt(GetDepth(texGBufferDepth, screenPos)); float3 normal = GetNormal(texGBufferNormal, screenPos); float3 position = GetPosition(texGBufferDepth, screenPos) + normal * SSAO_NORMAL_BIAS; float3 random = normalize(2.0 * texSSAONoise.Sample(samplerNoise, input.Texcoord * GetRNDTexFactor(SSAO_RND_TEX_SIZE)).rgb - 1.0); float SSAO = 0; [unroll] for (int index = 0; index < SSAO_KERNEL_SIZE; index++) { float3 dir = reflect(SamplesKernel[index].xyz, random); SSAO += CalculateOcclusion(position, dir * sign(dot(dir, normal)), SSAO_RADIUS, depth); } return 1.0 - SSAO / SSAO_KERNEL_SIZE; }  



    • By Ike aka Dk
      Hello everyone 
      I am a programmer from Baku.
      I need a 3D Modeller for my shooter project in unity.I have 2 years Unity exp.
      Project will paid when we finish the work 
      If you interested write me on email:
      mr.danilo911@gmail.com
  • Advertisement
  • Popular Now

  • Forum Statistics

    • Total Topics
      631400
    • Total Posts
      2999860
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!