![]() Lastly, will L4D use parallax mapping? From what I heard it's a positive, but I'd just like to double check. I know on HL2World there was a member who released a pack for HL2 that successfully managed to get the shader fully working with additional options, but I've never fully understood anything more then the basic concepts of shaders, so don't know the limitations. My second wonder is, can it be turned on for nothing more then a map, and when I say this, I mean can I make it so that a map for say, Counter Strike: Source can be distributed with textures using parallax mapping and work? If yes, I take it would use something slightly more advanced then a point_clientcommand. What I want to know is why? Why did Valve decide to make it so that parallax mapping did not work on Source? Is there a problem that can cause fatal errors? (Such as with the func_precipitation issues.) Or was it that they just decided to turn it off because on the production of Half Life 2, it was rarely/not used at all? Vec2 P = lightDir.xy / lightDir.z * heightScale įloat r = currentLayerDepth > currentDepthMapValue ? 0.0 : 1.I know, I know We've all heard and moaned about parallax mapping before, but until now I never really got the concept, but now I do, I want to ask a few questions.įrom what I understand, by default, parallax mapping does not work on the Source engine, due to a simple statement in the code of the game that can easily be modified by anyone with a basic knowledge of programming. The full function ShadowCalc function may look like this: float ShadowCalc(vec2 texCoord, vec3 lightDir)įloat numLayers = mix(maxLayers, minLayers, abs(dot(vec3(0.0, 0.0, 1.0), lightDir))) This results in a condition for an early abort: if ( lightDir.z >= 0.0 ) ![]() If the z-component of lightDir is grater than 0.0, the the surface is lit from the back. Note, that the depth is decremented ( currentLayerDepth -= layerDepth) and the texture samples are taken in the opposite direction ( currentTexCoords += deltaTexCoords) in compare the the ParallaxMapping algorithm: while (currentLayerDepth 0.0)ĬurrentDepthMapValue = texture(heightMap, currentTexCoords).r įloat r = currentLayerDepth > currentDepthMapValue ? 0.0 : 1.0 īecause of the division by the z-component in ( P = lightDir.xy / lightDir.z), P and thus deltaTexCoords, points always to the light source (of course in the projection to the texture). The sampling has to be aborted if the maximum depth (minimum value of 0.0) is reached. Since the depth mao is an inverse depth map (1.0 is low), a fragment is in shadow if any layer depth ( currentLayerDepth) is less or equal the current height ( currentDepthMapValue). The initial height ( currentLayerDepth) is the height of the current fragment: float currentDepthMapValue = texture(heightMap, currentTexCoords).r įloat currentLayerDepth = currentDepthMapValue float shadow = dc > 0.0 ? ShadowCalc(currentTex, lightDir) : 0.0 To check if a fragment is in self-shadow, you have to track the ray to the light source from starting a the the "parallax" texel. Shadow = ShadowCalc(currentTex, lightDir) įragColor = shadow * dc * texture(diffuseMap, currentTex) įirst of all the direction of the light source to the fragment in texture space is: vec3 lightDir = TBN_norm * normalize(o_worldPos - light_pos) įloat dc = max(0.0, dot(-lightDir, normal)) If (currentTex.x > 1.0 || currentTex.y > 1.0 || currentTex.x 0) Vec2 currentTex = ParallaxMapping(o_texCoord, viewDir) Vec3 viewDir = TBN_norm * normalize(o_worldPos - viewPosition) Normalize(cross(world_normal, world_tangent)), Mat3 TBN_norm = transpose(mat3(normalize(world_tangent), While (currentLayerDepth currentLayerDepth ? 0.0 : 1.0 Vec2 P = viewDir.xy / viewDir.z * heightScale įloat currentDepthMapValue = texture(heightMap, currentTexCoords).r Vec2 ParallaxMapping (vec2 texCoord, vec3 viewDir)įloat numLayers = mix(maxLayers, minLayers, abs(dot(vec3(0.0, 0.0, 1.0), viewDir))) I've marked that parts I added to the original parallax tutorial code. ![]() Nothing changed from when it was just the parallax occlusion map. This is the result of the modified fragment shader. I tried modifying the fragment shader, but the shadows still don't show up. From what I understand, it's the same process as parallax occlusion mapping, but from the light's direction instead of the view direction. I've read a few papers on the topic, but I admit it's a bit advanced for me. I've implemented Parallax Occlusion Mapping through LearnOpengl, and now I want to add self-shadows so that the fragment extrusions throw shadows on the surface.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |