Displacement mapping.

Slides:



Advertisements
Similar presentations
D3D10 techniques from Frostbite
Advertisements

Stupid OpenGL Shader Tricks
Arquitetura de GPU´s. a. Arquitetura de Hardware.
Far Cry and DirectX Carsten Wenzel Carsten Wenzel.
Computer graphics & visualization GP-GPU. computer graphics & visualization Image Synthesis – WS 07/08 Dr. Jens Krüger – Computer Graphics and Visualization.
Efficient High-Level Shader Development
GPGPU labor IV. Scatter és gather. Kezdeti teendők Tantárgy honlapja, Scatter és gather A labor kiindulási alapjának letöltése (lab4_base.zip), kitömörítés.
Shadow map. Árnyékok kell: minden fényforrásra egy render target (Spotlight) egy közös depth buffer, aminek stimmel a mérete (EngineDeferred)
PCF,VSM,LISPSM…. Kezdeti teendők Letöltés: OgreLabShadowMappingBase.zip Kicsomagol.sln futtat Include, lib és working dir beállítása Fordítás Futtatás.
Ogre3D Compositor Framework. Kezdeti teendők OgrePostProcBase.zip letöltése Útvonalak beállítása Fordítás futtatás.
Kezdeti teendők Letöltés: OgreBillboardParticles.zip Kicsomagol Futtat: OgreBillboardParticles.sln Include és library útvonalak beállítása Working directory.
Displacement mapping Szécsi László. Letöltés rock.obj rkd.jpg rbump.jpg rnormal.jpg.
Ogre3D Alapok Model betöltés AnyagjellemzőkFényforrásokShaderek.
Environment mapping Szécsi László. copy-paste-rename gg007-Texture folder vcxproj, filters átnevezés solution/add existing project rename project working.
Árnyalás Szécsi László. giraffe.jpg letöltése SolutionDir/Media folderbe.
9.2. O THER NOTABLE AI A SPECTS / HLSL I NTRO Common board game AI approaches and Strategic AI.
Vertex Shader Tricks New Ways to Use the Vertex Shader to Improve Performance Bill Bilodeau Developer Technology Engineer, AMD.
Real-time Shading with Filtered Importance Sampling
Perspective aperture ygyg yryr n zgzg y s = y g (n/z g ) ysys y s = y r (n/z r ) zrzr.
Practical Implementation of High Dynamic Range Rendering Masaki Kawase BUNKASHA GAMES BUNKASHA PUBLISHING CO.,LTD
General Purpose GPU (GPGPU) Aaron Smith University of Texas at Austin Spring 2003.
Low-level Thinking in High-level Shading Languages Emil Persson Head of Research, Avalanche Studios.
Advanced Real-Time Shader Techniques
Michael I. Gold NVIDIA Corporation
Topics in Computer Graphics Spring Application.
Exploration of bump, parallax, relief and displacement mapping
Bump Mapping CSE 781 Roger Crawfis.
Week 8 - Friday.  What did we talk about last time?  Radiometry  Photometry  Colorimetry  Lighting with shader code  Ambient  Directional (diffuse.
Ben Constable Developer, Internet Explorer Frank Olivier Program Manager, Internet
Filtering Approaches for Real-Time Anti-Aliasing
ADVANCED SKIN SHADING WITH FACEWORKS Nathan Reed — NVIDIA March 24, 2014.
GAM532 DPS932 – Week 7 Introduction to shadows. Shadow Effects Light Surface No Shadows Shadows.
Week 8 - Wednesday.  What did we talk about last time?  Textures  Volume textures  Cube maps  Texture caching and compression  Procedural texturing.
GLSL II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of New.
Reflection and Transmission Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center.
GAM532 DPS932 – Week 1 Rendering Pipeline and Shaders.
CSE 872 Dr. Charles B. Owen Advanced Computer Graphics1 Illumination and Shading Lights Diffuse and Specular Illumination BasicEffect Setting and Animating.
Cg – C for Graphics Eric Vidal CS 280. History General graphics processing languages – Renderman shading language (1988) Assembly languages for graphics.
REAL-TIME VOLUME GRAPHICS Christof Rezk Salama Computer Graphics and Multimedia Group, University of Siegen, Germany Eurographics 2006 Real-Time Volume.
GPU Programming Robert Hero Quick Overview (The Old Way) Graphics cards process Triangles Graphics cards process Triangles Quads.
Geometric Objects and Transformations. Coordinate systems rial.html.
A Crash Course in HLSL Matt Christian.
Real-Time Shading Using Programmable Graphics Hardware Introduction, Setup and Examples Wan-Chun Ma National Taiwan University.
1 Dr. Scott Schaefer Programmable Shaders. 2/30 Graphics Cards Performance Nvidia Geforce 6800 GTX 1  6.4 billion pixels/sec Nvidia Geforce 7900 GTX.
GAM532 DPS932 – Week 2 Vertex Shaders. The Shader Pipeline Vertex Processing Primitive Assembly / Processing Rasterization Fragment Process Pixel Output.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Shaders in OpenGL Marshall Hahn. Introduction to Shaders in OpenGL In this talk, the basics of OpenGL Shading Language will be covered. This includes.
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E.
Bump Map 1. High Field Function: H(u, v) New Normal : N’
2009 GRAPHICS : PROJECT 1 BASED ON DX9 BASICS. Documented by Dongjoon Kim SNU CS Ph.D Course Student Contact : NOTE.
GLSL II.
What are shaders? In the field of computer graphics, a shader is a computer program that runs on the graphics processing unit(GPU) and is used to do shading.
3D Objects in WebGL Loading 3D model files. Announcement Midterm exam on 12/2 –No Internet connection. –Example code and exam questions will be on USB.
CgFX Sébastien Dominé, NVIDIA. Overview What is CgFX? CgFX runtime Production pipeline with CgFX CgFX Tools set Demo.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
Advanced Texture Mapping Bump Mapping & Environment Mapping (Reflection)
Advanced Materials Using Shaders. Show demo advanced_ogre.
Programmable Shaders Dr. Scott Schaefer.
Week 8 - Wednesday CS361.
GLSL II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of New.
Carl Johan Gribel, PhD student
Bump Mapping -1 Three scales of detail on an object
Chapter IX Bump Mapping
Illumination and Shading
Texture and Shadow Mapping
Chapter XIV Normal Mapping
Advanced Texture Mapping
Space groups Start w/ 2s and 21s 222.
Computer Graphics Shading in OpenGL
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

Displacement mapping

Kezdeti teendők Letöltés: OgreDisplacementMappingBase.zip Kicsomagol Futtat: OgreDisplacement.sln Include és library útvonalak beállítása Working directory beállítása Fordít Futtat

Próba

Material scheme … OIS::InputManager* OISInputManager; int schemecount = 1; int currentScheme = 0; String qualitySchemes[] = { "VeryLow", "Low", "Medium", "Height", "VeryHeight", "Ultra" }; void setupScene() renderWindow->setActive(true); renderWindow->getViewport(0)->setMaterialScheme(qualitySchemes[0]); material Phong { technique scheme VeryLow pass : PhongPass …

Minden sémához új technika a phong.material-ba if( mKeyboard->isKeyDown(OIS::KC_SPACE) && mTimeUntilNextToggle < 0) { currentScheme = (++currentScheme)%schemecount; renderWindow->getViewport(0)->setMaterialScheme(qualitySchemes[currentScheme]); mTimeUntilNextToggle = 0.2f; } Minden sémához új technika a phong.material-ba Minden technikának új pixel shadert írunk (ha implementáltunk egy új sémát schemecount ++)

Próba

normal mapping material Phong { technique scheme VeryLow … } scheme Low pass vertex_program_ref PhongShadingDisplacedVS fragment_program_ref PhongShadingNormalMappedPS

Phong.program vertex_program PhongShadingVS hlsl { } fragment_program PhongShadingPS hlsl vertex_program PhongShadingDisplacedVS hlsl source PhongDisplaced.hlsl entry_point displacedVS target vs_2_0 fragment_program PhongShadingNormalMappedPS hlsl entry_point normalMappedPS target ps_2_0

PhongDisplaced.hlsl struct VERTEX_IN { float4 position : POSITION; float4 normal : NORMAL; float2 texCoord : TEXCOORD0; float4 tangent : TANGENT; float4 binormal : BINORMAL; }; struct VERTEX_OUT float4 hPos : POSITION; float3 N : TEXCOORD0; float3 L : TEXCOORD1; float3 V : TEXCOORD2; float2 texCoord : TEXCOORD3; float3 T : TEXCOORD4; float3 B : TEXCOORD5;

VERTEX_OUT displacedVS(VERTEX_IN In, uniform float4x4 worldViewProj, uniform float4x4 worldView, uniform float4x4 worldViewIT, uniform float4 lightPos) { VERTEX_OUT Out = (VERTEX_OUT) 0; Out.hPos = mul(worldViewProj, In.position); Out.texCoord = In.texCoord; Out.V = -mul(worldView, In.position).xyz; Out.L = lightPos.xyz + lightPos.w * Out.V; Out.N = mul(worldViewIT, In.normal).xyz; Out.T = mul(worldViewIT, In.tangent).xyz; Out.B = mul(worldViewIT, In.binormal).xyz; return Out; }

sampler2D colorTex : register(s0); sampler2D normalMap : register(s1); float4 amientLightColor; float4 diffuseLightColor; float4 specularLightColor; float4 lightAttenuation; float4 ambientColor; float4 diffuseColor; float4 specularColor; float4 emissiveColor; float HEIGHT_SCALE = 0.1; float HEIGHT_BIAS = -0.08; float bumpScale = 1; float4 normalMappedPS(VERTEX_OUT In):COLOR0 { float3 N = normalize(In.N); float3 T = normalize(In.T); float3 B = normalize(In.B); float3x3 TangentToView = float3x3(T, B, N); float3 Nt = normalize(tex2D(normalMap, In.texCoord).xyz - float3(0.5, 0.5, 0.0)); Nt.z /= bumpScale; Nt = normalize(Nt); N = mul(Nt, TangentToView); //innentől ugyanaz, mint a sima phong shaderünk… következő dia float2 dtdx = ddx(In.texCoord); float2 dtdy = ddy(In.texCoord); float3 dpdx = ddx(-In.V); float3 dpdy = ddy(-In.V); float3 T = normalize(dpdx * dtdy.y - dpdy * dtdx.y); float3 B =normalize(dpdy * dtdx.x - dpdx * dtdy.x) ; float3 N = cross(T, B); N *= sign(-dot(N, -In.V));

… float d = length(In. L); float3 L = In … float d = length(In.L); float3 L = In.L / d; float3 V = normalize(In.V); float4 texColor = tex2D(colorTex, In.texCoord); float attenuation = 1.0 / (lightAttenuation.y + lightAttenuation.z * d + lightAttenuation.w * d * d); float4 ambient = amientLightColor * ambientColor; float4 diffuse = max(0,dot(N,L)) * diffuseColor * diffuseLightColor * attenuation; float3 H = normalize(L + V); float4 specular = pow(max(0, dot(N,H)), specularColor.w) * float4(specularColor.xyz, 1) * specularLightColor * attenuation; return texColor * (ambient + diffuse) + specular + emissiveColor; }

Próba (int schemecount = 2;)

Parallax Mapping float4 parallaxMappedPS(VERTEX_OUT In):COLOR0 { … float3 Nt = normalize(tex2D(normalMap, In.texCoord).xyz - float3(0.5, 0.5, 0.0)); float d = length(In.L); float3 L = In.L / d; float3 V = normalize(In.V); float3 Vt = mul(TangentToView, V); float h = tex2D(normalMap, In.texCoord).a * HEIGHT_SCALE + HEIGHT_BIAS; //In.texCoord += h * Vt.xy / Vt.z; //parallax //In.texCoord += h * Vt.xy; //parallax with offset limit In.texCoord += h * Nt.z * Vt.xy; //parallax with slope Nt = normalize(tex2D(normalMap, In.texCoord).xyz - float3(0.5, 0.5, 0.0)); Nt.z /= bumpScale; Nt = normalize(Nt); N = mul(Nt, TangentToView); float4 texColor = tex2D(colorTex, In.texCoord); float attenuation = …

Próba (int schemecount = 3;)

Iteratív parallax #define PARALLAX_ITERATION 5 float2 PARALLAX_MAPPING_ITER(float3 TexCoord, float3 View) { for(int i = 0; i < PARALLAX_ITERATION; i++) float3 N = tex2D(normalMap, TexCoord).xyz; float h = tex2D(normalMap, TexCoord).a * HEIGHT_SCALE + HEIGHT_BIAS; TexCoord += (h - TexCoord.z) * N.z * View; } return TexCoord.xy; float4 iterativeParallaxMappedPS(VERTEX_OUT In):COLOR0 … float3 Vt = mul(TangentToView, V); In.texCoord = PARALLAX_MAPPING_ITER(float3(In.texCoord, 0), Vt); float4 texColor = tex2D(colorTex, In.texCoord);

Próba (int schemecount = 4;)

Relief mapping float4 reliefMappedPS(VERTEX_OUT In):COLOR0 { … float3 Vt = mul(TangentToView, V); float3 sRange = -Vt * HEIGHT_SCALE / Vt.z * 0.5; float3 sPos = float3(In.texCoord, 0) - sRange; for( int i=0; i<12; i++ ) float bump = tex2D(normalMap, sPos.xy).a; sRange *= 0.5; if (sPos.z > bump * HEIGHT_SCALE) // If outside sPos += sRange; // Move forward else sPos -= sRange; // Move backward } In.texCoord = sPos.xy; float4 texColor = tex2D(colorTex, In.texCoord);

Próba (int schemecount = 5;)

Relief mapping + árnyékok float4 reliefShadowMappedPS(VERTEX_OUT In):COLOR0 { … for( int i=0; i<12; i++ ) } In.texCoord = sPos.xy; float shadow = 1.0; float h1 = sPos.z; float h = tex2D(normalMap, In.texCoord).a; float3 Lt = mul(TangentToView, L); sRange = -Lt * HEIGHT_SCALE / Lt.z * 0.5; sPos -= sRange * (1.0 - h - 0.5);

Folytatás… for( int i=0; i<10; i++ ) { float bump = tex2D(normalMap, sPos.xy).a; sRange *= 0.5; if (sPos.z > bump * HEIGHT_SCALE) // If outside sPos += sRange; // Move forward else sPos -= sRange; // Move backward } float h2 = sPos.z; if(h2 > h1 + 0.01) shadow = 0.3; float4 texColor = tex2D(colorTex, In.texCoord); … float attenuation = … attenuation *= shadow;

Próba (int schemecount = 6;)