sergey.pozhidaev Posted October 1, 2015 Posted October 1, 2015 hi, i made displacement shader, but it works only on d3d11. -C++: Unigine::MaterialPtr mat = Unigine::Materials::get()->findMaterial("mat1"); if(mat.get()) { tid = mat->findTexture("tex1"); if(tid != -1) mat->setImageTextureName(tid, "tex.png"); } -material: <texture name="tex1" unit="8" shader="vertex" wrap="clamp" filter="bilinear">core/textures/mesh_base_height.dds</texture> -shader: #ifdef OPENGL uniform sampler2D s_texture_8; #elif DIRECT3D11 Texture2D s_texture_8 : register(t8); #endif #ifdef OPENGL ##extension GL_ARB_gpu_shader_fp64 : enable #endif #ifdef OPENGL float4 elev = textureLod(s_texture_8,texcoord.xy, 0) * 65536.0f; #elif DIRECT3D11 float4 elev = s_texture_8.SampleLevel(s_sampler_8,texcoord.xy, 0) * 65536.0f; #endif position += normal * elev.x; relief wawas only in d3d, opengl - zero elev.x? why?
helmut.bressler Posted October 1, 2015 Posted October 1, 2015 Hello sergey, I think the problem is that the mapping between the texture unit numbering in the material is different from the numbering in a non-fragment shader in opengl (I would guess in order to avoid naming conflicts. All s_textures live in the same namespace in a opengl shader program). I have a vertex shader which is using a texture. I bind the texture to unit 0 in the material and I have to access it as s_texture_16 in the vertex shader: <!-- material file: <texture name="starPos" unit="0" shader="vertex"> project/textures/white.dds</texture> --> // vertex shader: uniform sampler2D s_texture_16; So I guess in your case it should be s_texture_24 (unless 24 is already reserved for the geometry, controll or evaluation shader). Cheers Helmut
Recommended Posts