Search Results

Search found 1379 results on 56 pages for 'fragment shader'.

Page 8/56 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Can I use a vertex shader to display a models normals?

    - by geowar
    I'm currently using a VBO for the texture coordinates, normals and the vertices of a (3DS) model I'm drawing with "glDrawArrays(GL_TRIANGLES, ...);". For debugging I want to (temporarily) show the normals when drawing my model. Do I have to use immediate mode to draw each line from vert to vert+normal -OR- stuff another VBO with vert and vert+normal to draw all the normals… -OR- is there a way for the vertex shader to use the vertex and normal data already passed in when drawing the model to compute the V+N used when drawing the normals?

    Read the article

  • Hue, saturation, brightness, contrast effect in hlsl

    - by Vibhore Tanwer
    I am new to pixel shader, and I am trying to write a simple brightness, contrast, hue, saturation effect. I have written a shader for it but I doubt that my shader is not providing me correct result, Brightness, contrast, saturation is working fine, problem is with hue. if I apply hue between -1 to 1, it seems to be working fine, but to make things more sharp, I need to apply hue value between -180 and 180, like we can apply hue in Paint.NET. Here is my code. // Amount to shift the Hue, range 0 to 6 float Hue; float Brightness; float Contrast; float Saturation; float Alpha; sampler Samp : register(S0); // Converts the rgb value to hsv, where H's range is -1 to 5 float3 rgb_to_hsv(float3 RGB) { float r = RGB.x; float g = RGB.y; float b = RGB.z; float minChannel = min(r, min(g, b)); float maxChannel = max(r, max(g, b)); float h = 0; float s = 0; float v = maxChannel; float delta = maxChannel - minChannel; if (delta != 0) { s = delta / v; if (r == v) h = (g - b) / delta; else if (g == v) h = 2 + (b - r) / delta; else if (b == v) h = 4 + (r - g) / delta; } return float3(h, s, v); } float3 hsv_to_rgb(float3 HSV) { float3 RGB = HSV.z; float h = HSV.x; float s = HSV.y; float v = HSV.z; float i = floor(h); float f = h - i; float p = (1.0 - s); float q = (1.0 - s * f); float t = (1.0 - s * (1 - f)); if (i == 0) { RGB = float3(1, t, p); } else if (i == 1) { RGB = float3(q, 1, p); } else if (i == 2) { RGB = float3(p, 1, t); } else if (i == 3) { RGB = float3(p, q, 1); } else if (i == 4) { RGB = float3(t, p, 1); } else /* i == -1 */ { RGB = float3(1, p, q); } RGB *= v; return RGB; } float4 mainPS(float2 uv : TEXCOORD) : COLOR { float4 col = tex2D(Samp, uv); float3 hsv = rgb_to_hsv(col.xyz); hsv.x += Hue; // Put the hue back to the -1 to 5 range //if (hsv.x > 5) { hsv.x -= 6.0; } hsv = hsv_to_rgb(hsv); float4 newColor = float4(hsv,col.w); float4 colorWithBrightnessAndContrast = newColor; colorWithBrightnessAndContrast.rgb /= colorWithBrightnessAndContrast.a; colorWithBrightnessAndContrast.rgb = colorWithBrightnessAndContrast.rgb + Brightness; colorWithBrightnessAndContrast.rgb = ((colorWithBrightnessAndContrast.rgb - 0.5f) * max(Contrast + 1.0, 0)) + 0.5f; colorWithBrightnessAndContrast.rgb *= colorWithBrightnessAndContrast.a; float greyscale = dot(colorWithBrightnessAndContrast.rgb, float3(0.3, 0.59, 0.11)); colorWithBrightnessAndContrast.rgb = lerp(greyscale, colorWithBrightnessAndContrast.rgb, col.a * (Saturation + 1.0)); return colorWithBrightnessAndContrast; } technique TransformTexture { pass p0 { PixelShader = compile ps_2_0 mainPS(); } } Please If anyone can help me learning what am I doing wrong or any suggestions? Any help will be of great value. EDIT: Images of the effect at hue 180: On the left hand side, the effect I got with @teodron answer. On the right hand side, The effect Paint.NET gives and I'm trying to reproduce.

    Read the article

  • Flickering when accessing texture by offset

    - by TravisG
    I have this simple compute shader that basically just takes the input from one image and writes it to another. Both images are 128/128/128 in size and glDispatchCompute is called with (128/8,128/8,128/8). The source images are cleared to 0 before this compute shader is executed, so no undefined values should be floating around in there. (I have the appropriate memory barrier on the C++ side set before the 3D texture is accessed). This version works fine: #version 430 layout (location = 0, rgba16f) uniform image3D ping; layout (location = 1, rgba16f) uniform image3D pong; layout (local_size_x = 8, local_size_y = 8, local_size_z = 8) in; void main() { ivec3 sampleCoord = gl_GlobalInvocationID.xyz; imageStore(pong, imageLoad(ping,sampleCoord)); } Reading values from pong shows that it's just a copy, as intended. However, when I load data from ping with an offset: #version 430 layout (location = 0, rgba16f) uniform image3D ping; layout (location = 1, rgba16f) uniform image3D pong; layout (local_size_x = 8, local_size_y = 8, local_size_z = 8) in; void main() { ivec3 sampleCoord = gl_GlobalInvocationID.xyz; imageStore(pong, imageLoad(ping,sampleCoord+ivec3(1,0,0))); } The data that is written to pong seems to depend on the order of execution of the threads within the work groups, which makes no sense to me. When reading from the pong texture, visible flickering occurs in some spots on the texture. What am I doing wrong here?

    Read the article

  • Better solution for boolean mixing?

    - by Ruben Nunez
    Sorry if this question has been asked in the past, but searching Google and here didn't yield relevant results, so here goes. I'm working on a fragment shader that implements both conditional/boolean diffuse and bump mapping (that is to say, you don't need a diffuse texture or a normals texture, and if they're not present, they're simply changed to default values). My current solution is to use a uniform float to say "mix amount". For example, computing the diffuse texel works as: // Compute diffuse amount scaled by vCol // If no texture is present (mDif = 0.0), then DiffuseTexel = vCol // kT[0] is the diffuse texture // vTex is the texture co-ordinates // mDif is the uniform float containing the mix amount (either 0.0 or 1.0) vec4 DiffuseTexel = vCol*mix(vec4(1.0), texture2D(kT[0], vTex), mDif); While that works great and all, I was wondering if there's a better way of doing this, as I will never have any use for in-between values for funky effects. I know that perhaps the best solution is to simply write separate shaders for mDif=0.0 and mDif=1.0, but I'd like a more elegant solution than splicing shaders before compiling or writing multiple shader files and keeping each one updated. Any ideas are greatly appreciated. =)

    Read the article

  • XML fragment with multiple roots: suppressing VS error

    - by Laurent
    In Visual Studio, I have an XML file (with .xml extension) which contains an XML fragment that I use in my program: <tag1> data ... </tag1> <tag2> data ... </tag2> Visual Studio shows me an error in the error list: "XML document cannot contain multiple root level elements". But this is not a complete document, just a fragment that will be reused. I want to keep my 2 roots in my fragment. How can I get rid of the error message? Thanks

    Read the article

  • Pixel bender shaders with multiple outputs in flash?

    - by sold
    According to the pixel bender specs a shader can have one or more outputs. The pixel bender toolkit, whose "export to flash" option tends to be preety strict about the flash specific do's and dont's, would even compile such a shader without complaints. However actionscript's shader related classes seem to be geared toward single output shaders. Is there any way to have multiple shader outputs in flash?

    Read the article

  • Fragment not showing up and breaks other buttons on Layout

    - by Devin Crane
    I'm learning how to use Fragments, and trying to add a fragment tag_button.xml at runtime to a FrameLayout tagFragmentContainer deep within another layout, deepLayout.xml. I get no errors, but the fragment doesn't show up. When I make its container visible, I can see a small sliver of layout between the other elements already existing, but then it disappears after onCreateView(), and all the remaining buttons are broken, which is even more confusing to me. tag_button.xml is just a regular layout file with some text and a button. tagFragmentContainer, within a LinearLayout in the middle of a large layout file, deepLayout.xml: <LinearLayout android:id="@+id/tagButtonsLayout" android:layout_marginBottom="10dip" android:visibility="gone" style="@style/Form"> <FrameLayout android:id="@+id/tagFragmentContainer" android:layout_marginBottom="10dip" style="@style/Form"> </FrameLayout> </LinearLayout> In deepLayoutActivity, I make visible tagButtonsLayout and start TagButtonActivity: final LinearLayout anotherlm = (LinearLayout) findViewById(R.id.tagButtonsLayout); anotherlm.setVisibility(View.VISIBLE); Intent i = new Intent (this, TagButtonActivity.class); startActivity(i); TagButtonActivity is as follows: public class TagButtonActivity extends FragmentActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.action_expense); if (savedInstanceState != null) return; TagButtonFragment firstFragment = new TagButtonFragment(); getSupportFragmentManager().beginTransaction().add(R.id.tagFragmentContainer, firstFragment, "tagOne").commit(); } } TagButtonFragment: public class TagButtonFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(R.layout.tag_button, container, false); } } tag_button.xml: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" style="@style/Form"> <TextView android:id="@+id/tag_button_header" style="@style/FieldHeader" android:text="example text"/> <RelativeLayout android:id="@+id/tag_button_block" android:layout_width="match_parent" android:layout_marginLeft="2dip" android:layout_marginTop="3dip" android:layout_marginBottom="3dip" android:layout_marginRight="2dip" android:layout_height="43dip" android:clickable="true" android:background="@drawable/row_spinner_selector"> <ImageView android:id="@+id/question_arrow" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dip" android:layout_marginRight="10dip" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:src="@drawable/arrow_right"/> <TextView android:id="@+id/tag_question_text" android:layout_toLeftOf="@id/question_arrow" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="10dip" android:layout_centerVertical="true" android:textColor="@android:color/black" android:singleLine="true" android:ellipsize="end" android:textSize="15sp" android:text="@string/not_selected"/> </RelativeLayout> </LinearLayout> I would certainly appreciate any help in figuring this out from someone who knows fragments better than me! Thanks!

    Read the article

  • rails fragment cache store

    - by ash34
    Hi, I am unable to figure out where my cached fragments are being stored. What is the default location for fragment caching. Cached fragment hit: views/listed_products (0.1ms) I cannot find anything in the rails_root/public or rails_root/tmp/cache dirs thanks, ash

    Read the article

  • How to efficiently render resizable GUI elements in DirectX?

    - by PolGraphic
    I wonder what would be most efficient way to render the GUI elements. When we're talking about constant-size elements (that can still be moving), the textures' atlas seems to be good. But what with the resizeable elements? Let's say the panel (with textured borders)? Is there any better way than just render 9 rectangles with textures on them (I guess one texture and different textures coordinates for left-top corner, border, middle etc. used in shader)?

    Read the article

  • Fragment-shader blur ... how does this work?

    - by anon
    uniform sampler2D sampler0; uniform vec2 tc_offset[9]; void blur() { vec4 sample[9]; for(int i = 0; i < 9; ++i) sample[i] = texture2D(sampler0, gl_TexCoord[0].st + tc_offset[i]); gl_FragColor = (sample[0] + (2.0 * sample[1]) + sample[2] + (2.0 * sample[3]) + sample[4] + 2.0 * sample[5] + sample[6] + 2.0 * sample[7] + sample[8] ) / 13.0; } How does the sample[i] = texture2D(sample0, ...) line work? It seems like to blur an image, I have to first generate the image, yet here, I'm somehow trying to query the very iamge I'm generating. How does this work?

    Read the article

  • URL "fragment identifier" semantics for HTML documents

    - by Pointy
    I've been working with a new installation of the "MoinMoin" wiki software. As I was playing with it, typing in mostly random test pages, I created a link with a fragment blah blah see also [[SomeStuff#whatever|some other stuff about whatever]] Then I needed to figure out how to create the anchor for that "whatever" fragment identifier. I don't recall having to do that with MediaWiki, so I had to dig around, but finally I found that MoinMoin has an "Anchor" macro: == Whatever == <<Anchor(whatever)>> Looking at the generated HTML, I was surprised to see an empty <span> tag with an "id" value of "whatever". I expected that it'd be an <a> tag with a "name" attribute of "whatever". I dug around and found the source, and there's a comment that says they changed it from an <a> tag in order to avoid some IE problem with <pre> sections. This confused me — not because of the IE thing, but because it looked to me as if their "fix" had left the whole anchor mechanism completely broken. Much to my surprise, however, further testing indicated that it worked fine. I wrote a test page with 300 <span> tags all with "id" values, and I further shocked myself when Firefox behaved exactly as I would have expected it to had I used <a> tags. It also worked when I changed all the <span> tags to <em>. So by this time, you're either as surprised as I was, or else you're thinking "how can somebody that dumb have so many reputation points?" If you're in the second category, is it really the case that I've been typing in HTML for about 15 years now — a lot of HTML — and it's somehow escaped my notice that browsers use the HTML fragment to find any sort of element with a matching "id"? mind status: blown

    Read the article

  • show() progressdialog in asynctask inside fragment

    - by just_user
    I'm trying to display a progressDialog while getting an image from a url to a imageview. When trying to show the progressDialog the parent activity has leaked window... Strange thing is that I have two fragments in the this activity, in the first fragment this exact same way of calling the progressdialog works but when the fragment is replaced and i try to make it again it crashes. This is the asynctask I'm using inside the second fragment with the crash: class SkinPreviewImage extends AsyncTask<Void, Void, Void> { private ProgressDialog progressDialog; @Override protected void onPreExecute() { progressDialog = new ProgressDialog(getActivity()); progressDialog.setMessage("Loading preview..."); if(progressDialog != null) progressDialog.show(); progressDialog.setOnCancelListener(new OnCancelListener() { public void onCancel(DialogInterface arg0) { SkinPreviewImage.this.cancel(true); } }); } @Override protected Void doInBackground(Void... params) { try { URL newurl = new URL(url); Bitmap mIcon_val = BitmapFactory.decodeStream(newurl.openConnection().getInputStream()); skinPreview.setImageBitmap(mIcon_val); } catch (IOException e) { Log.e("SkinStoreDetail", e.getMessage()); } return null; } @Override protected void onPostExecute(Void v) { if(progressDialog != null) progressDialog.dismiss(); } } I've seen a few similar questions but the one closest to solve my problem used a groupactivity for the parent which I'm not using. Any suggestions?

    Read the article

  • Best approach to depth streaming via existing codec

    - by Kevin
    I'm working on a development system (and game) intended for games set mostly in static third-person views. We produce our scenery by CG and photographic techniques. Our background art is rendered off-line by a production-grade renderer. To allow the runtime imagery to properly interact with the background art, I wrote a program to convert from depth output by Mental Ray into a texture, and a pixel shader to draw a quad such that the Z data comes from the texture. This technique is working out very well, but now we've decided that some of the camera angle changes between scenes should be animated. The animation itself is straightforward to produce from our CG models. We intend to encode it to some HD video codec such as H.264. The problem is that in order to maintain our runtime imagery on the screen, the depth buffer will need to be loaded for each video frame. Due to the bandwidth, the video's depth data will need to be compressed efficiently. I've looked into methods for performing temporal compression of depth info and found an interesting research paper here: http://web4.cs.ucl.ac.uk/staff/j.kautz/publications/depth-streaming.pdf The method establishes a mapping between 16-bit depth values and YCbCr values. The mapping is tuned to the properties of existing video codecs in order to maximize precision of the decoded depths after the YCbCr has undergone video compression. It allows an existing, unmodified video codec to be used on the backend. I'm looking at how to pull this off with the least possible work. (This design change was unplanned.) Our game engine itself is native C++, presently for Win32 and DirectX, although we've worked hard to keep platform dependence segregated because we intend other ports. We don't have motion video facilities in the engine yet but will ultimately need that anyway for cinematics. I was planning on using some off-the-shelf motion video solution we can plug into our engine, and haven't chosen one yet. This new added requirement makes selecting one harder since, among other things, we'll now need to bypass colourspace conversion on one of the streams, and also will need to be playing two streams simultaneously in lockstep, on top of in some cases audio on one of them (for the cinematics). I'm also wondering if it's possible (or even useful) to do the conversion from YCbCr to depth in a pixel shader, or if it's better to just do it in CPU and separately load the resulting depth values into a locked tex. The conversion unfortunately does involve branching logic per-pixel. (There are more naive mappings that don't need branching, but they produce inferior results.) It could be reduced to a table lookup but the table would be 32MB. Programming is second-nature to me but I'm not that experienced with pix shaders and have zero knowledge of off-the-shelf video solutions. I'd therefore be interested in advice from others who may have dealt more with depth streaming, pixel shaders, and/or off-the-shelf codecs, regarding how feasible the proposed application is and what off-the-shelf video systems out there would best get along with this usage case.

    Read the article

  • Shader vs Shader Material , papervision specific , general insight welcome.

    - by RadAdam
    hello overflow. I asked this question on the pv3d forum and not a single person could, or cared to answer it. Im relatively new to 3d so i apologize if this is common sense to some. I have a sphere , in which i am applying a CellMaterial to. Looks great. I noticed that in the papervision sdk , there is also a CellShader. Should I be using this in congruence with the CellMaterial ? Should it be one or the other ? Is shader , a deprecated practice to Shader Material ? My initial thoughts were that the shader applies to the whole scene , while materials can be applied uniquely to objects. The documentation seems to show otherwise. What benefit if any could be gained by using both a CellShader and a CellMaterial ? id really love to get some ambient inclusion in there some how.

    Read the article

  • How can I use the dualforward parameter in my unity shader to use lightmaps and normal maps together?

    - by Raphaeltm
    I'm using the free version of unity and I would like to combine lightmaps with specularity and normal maps. After doing a -bunch- of research, I've figured out that there doesn't seem to be any easy way to do this in the free version of unity, which doesn't support deferred rendering/easy use of dual lightmaps. However, it looks like it's possible, by writing a custom shader, using the "dualforward" parameter in a shader, switching the lightmapping mode to "dual lightmaps" and turning on "Use in forward ren." (basically, writing a shader that specifies the use of dual lightmaps, which should allow for a combination of lightmaps and normal maps) So I downloaded the source code for the default shaders (because all I need is a normal specular bumped shader) and added "dualforward" to the parameters: Shader "Bumped Specular Dual Lightmaps" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) _Shininess ("Shininess", Range (0.03, 1)) = 0.078125 _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} _BumpMap ("Normalmap", 2D) = "bump" {} } SubShader { Tags { "RenderType"="Opaque" } LOD 400 CGPROGRAM #pragma surface surf BlinnPhong dualforward sampler2D _MainTex; sampler2D _BumpMap; fixed4 _Color; half _Shininess; struct Input { float2 uv_MainTex; float2 uv_BumpMap; }; void surf (Input IN, inout SurfaceOutput o) { fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); o.Albedo = tex.rgb * _Color.rgb; o.Gloss = tex.a; o.Alpha = tex.a * _Color.a; o.Specular = _Shininess; o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); } ENDCG } FallBack "Specular" } This, however, doesn't seem to work. When I keep the "dualforward" param, every object that uses it seems to be lit by the one directional light in the scene. When I remove the "dualforward" param, it they look like normal lightmapped objects with no normal maps or specularity. I noticed that the support for "dualforward" seems to be new in v.3.4.2, so I made sure to download it (I was running 3.4.1), but it still doesn't work. Anybody have any advice for me?

    Read the article

  • How to reference an object in a lower fragment in android

    - by Silas Greenback
    I am trying to build a help screen that is going to go on a mediaplayer. The idea is to put a fragment with a transparent theme on top of the current view. (See How do I create a help overlay like you see in a few Android apps and ICS? for the basic idea). Now, I understand the steps in the mentioned link, but how do I connect the circles and arrows and paragraphs next to each one (explaining what each one was) to the lower object? Example, I have an object: R.id.music_button and I want there to be and arrow that points to music button. Trying to support as many devices as we do it will be very difficult to just draw a few pictures as part of the top layout and expect them to line up. Again, how do I reference an object on a fragment below the top level? Thanks

    Read the article

  • Fragment savedInstanceState is always null (Android support lib)

    - by Evgeny Egorov
    I wrote a simple test project, but I cant understand why I always receive savedInstanceState = null in lifecycle methods onCreate, onCreateView and onActivityCreated. I change the screen orientation, see the log, but state not saved. Tell me please where is my mistake. Thanks. The code of fragment class is: public class TestFragment extends Fragment { private String state = "1"; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (savedInstanceState != null) { //never works state = savedInstanceState.getString("state"); } //always prints 1 Toast.makeText(getActivity(), state, Toast.LENGTH_SHORT).show(); return inflater.inflate(R.layout.fragment_layout, container, false); } @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putString("state", "2"); Log.e("", "saved 2"); } }

    Read the article

  • How to set TextureFilter to Point to make example Bloom filter work?

    - by Mr Bell
    I have simple app that renders some particles and now I am trying to apply the bloom shader from the xna samplers ( http://create.msdn.com/en-US/education/catalog/sample/bloom ) to it, but I am running into this exception: "XNA Framework HiDef profile requires TextureFilter to be Point when using texture format Vector4." When the BloomComponent tries to end the sprite batch in the DrawFullscreenQuad method: spriteBatch.Begin(0, BlendState.Opaque, SamplerState.PointWrap, null, null, effect); spriteBatch.Draw(texture, new Rectangle(0, 0, width, height), Color.White); spriteBatch.End(); //<------- Exception thrown here It seems to be related to the pixel shaders that I am using to animate the particle. In a nutshell, I have a texture2d in vector4 format that holds particle positions, and another one for velocities. Here is a snippet from that area: GraphicsDevice.SetRenderTarget(tempRenderTarget); animationEffect.CurrentTechnique = animationEffect.Techniques[technique]; spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque, SamplerState.PointWrap, DepthStencilState.DepthRead, RasterizerState.CullNone, animationEffect); spriteBatch.Draw(randomValues, new Rectangle(0, 0, width, height), Color.White); spriteBatch.End(); What I comment out the code that calls the particle animation pixel shaders the bloom component runs fine. Is there some state that I need to reset to make the bloom work?

    Read the article

  • Writing to a D3DFMT_R32F render target clamps to 1

    - by Mike
    I'm currently implementing a picking system. I render some objects in a frame buffer, which has a render target, which has the D3DFMT_R32F format. For each mesh, I set an integer constant evaluator, which is its material index. My shader is simple: I output the position of each vertex, and for each pixel, I cast the material index in float, and assign this value to the Red channel: int ObjectIndex; float4x4 WvpXf : WorldViewProjection< string UIWidget = "None"; >; struct VS_INPUT { float3 Position : POSITION; }; struct VS_OUTPUT { float4 Position : POSITION; }; struct PS_OUTPUT { float4 Color : COLOR0; }; VS_OUTPUT VSMain( const VS_INPUT input ) { VS_OUTPUT output = (VS_OUTPUT)0; output.Position = mul( float4(input.Position, 1), WvpXf ); return output; } PS_OUTPUT PSMain( const VS_OUTPUT input, in float2 vpos : VPOS ) { PS_OUTPUT output = (PS_OUTPUT)0; output.Color.r = float( ObjectIndex ); output.Color.gba = 0.0f; return output; } technique Default { pass P0 { VertexShader = compile vs_3_0 VSMain(); PixelShader = compile ps_3_0 PSMain(); } } The problem I have, is that somehow, the values written in the render target are clamped between 0.0f and 1.0f. I've tried to change the rendertarget format, but I always get clamped values... I don't know what the root of the problem is. For information, I have a depth render target attached to the frame buffer. I disabled the blend in the render state the stencil is disabled Any ideas?

    Read the article

  • SRV from UAV on the same texture in directx

    - by notabene
    I'm programming gpgpu raymarching (volumetric raytracing) in directx11. I succesfully perform compute shader and save raymarched volume data to texture. Then i want to use same texture as SRV in normal graphic pipeline. But it doesnt work, texture is not visible. Texture is ok, when i save it file it is what i expect. Texture rendering is ok too, when i render another SRV, it is ok. So problem is only in UAV-SRV. I also triple checked if pointers are ok. Please help, i'm getting mad about this. Here is some code: //before dispatch D3D11_TEXTURE2D_DESC textureDesc; ZeroMemory( &textureDesc, sizeof( textureDesc ) ); textureDesc.Width = xr; textureDesc.Height = yr; textureDesc.MipLevels = 1; textureDesc.ArraySize = 1; textureDesc.SampleDesc.Count = 1; textureDesc.SampleDesc.Quality = 0; textureDesc.Usage = D3D11_USAGE_DEFAULT; textureDesc.BindFlags = D3D11_BIND_UNORDERED_ACCESS | D3D11_BIND_SHADER_RESOURCE ; textureDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; D3D->CreateTexture2D( &textureDesc, NULL, &pTexture ); D3D11_UNORDERED_ACCESS_VIEW_DESC viewDescUAV; ZeroMemory( &viewDescUAV, sizeof( viewDescUAV ) ); viewDescUAV.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; viewDescUAV.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE2D; viewDescUAV.Texture2D.MipSlice = 0; D3DD->CreateUnorderedAccessView( pTexture, &viewDescUAV, &pTextureUAV ); //the getSRV function after dispatch. D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc ; ZeroMemory( &srvDesc, sizeof( srvDesc ) ); srvDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; srvDesc.Texture2D.MipLevels = 1; D3DD->CreateShaderResourceView( pTexture, &srvDesc, &pTextureSRV);

    Read the article

  • PyOpenGL - passing transformation matrix into shader

    - by M-V
    I am having trouble passing projection and modelview matrices into the GLSL shader from my PyOpenGL code. My understanding is that OpenGL matrices are column major, but when I pass in projection and modelview matrices as shown, I don't see anything. I tried the transpose of the matrices, and it worked for the modelview matrix, but the projection matrix doesn't work either way. Here is the code: import OpenGL from OpenGL.GL import * from OpenGL.GL.shaders import * from OpenGL.GLU import * from OpenGL.GLUT import * from OpenGL.GLUT.freeglut import * from OpenGL.arrays import vbo import numpy, math, sys strVS = """ attribute vec3 aVert; uniform mat4 uMVMatrix; uniform mat4 uPMatrix; uniform vec4 uColor; varying vec4 vCol; void main() { // option #1 - fails gl_Position = uPMatrix * uMVMatrix * vec4(aVert, 1.0); // option #2 - works gl_Position = vec4(aVert, 1.0); // set color vCol = vec4(uColor.rgb, 1.0); } """ strFS = """ varying vec4 vCol; void main() { // use vertex color gl_FragColor = vCol; } """ # particle system class class Scene: # initialization def __init__(self): # create shader self.program = compileProgram(compileShader(strVS, GL_VERTEX_SHADER), compileShader(strFS, GL_FRAGMENT_SHADER)) glUseProgram(self.program) self.pMatrixUniform = glGetUniformLocation(self.program, 'uPMatrix') self.mvMatrixUniform = glGetUniformLocation(self.program, "uMVMatrix") self.colorU = glGetUniformLocation(self.program, "uColor") # attributes self.vertIndex = glGetAttribLocation(self.program, "aVert") # color self.col0 = [1.0, 1.0, 0.0, 1.0] # define quad vertices s = 0.2 quadV = [ -s, s, 0.0, -s, -s, 0.0, s, s, 0.0, s, s, 0.0, -s, -s, 0.0, s, -s, 0.0 ] # vertices self.vertexBuffer = glGenBuffers(1) glBindBuffer(GL_ARRAY_BUFFER, self.vertexBuffer) vertexData = numpy.array(quadV, numpy.float32) glBufferData(GL_ARRAY_BUFFER, 4*len(vertexData), vertexData, GL_STATIC_DRAW) # render def render(self, pMatrix, mvMatrix): # use shader glUseProgram(self.program) # set proj matrix glUniformMatrix4fv(self.pMatrixUniform, 1, GL_FALSE, pMatrix) # set modelview matrix glUniformMatrix4fv(self.mvMatrixUniform, 1, GL_FALSE, mvMatrix) # set color glUniform4fv(self.colorU, 1, self.col0) #enable arrays glEnableVertexAttribArray(self.vertIndex) # set buffers glBindBuffer(GL_ARRAY_BUFFER, self.vertexBuffer) glVertexAttribPointer(self.vertIndex, 3, GL_FLOAT, GL_FALSE, 0, None) # draw glDrawArrays(GL_TRIANGLES, 0, 6) # disable arrays glDisableVertexAttribArray(self.vertIndex) class Renderer: def __init__(self): pass def reshape(self, width, height): self.width = width self.height = height self.aspect = width/float(height) glViewport(0, 0, self.width, self.height) glEnable(GL_DEPTH_TEST) glDisable(GL_CULL_FACE) glClearColor(0.8, 0.8, 0.8,1.0) glutPostRedisplay() def keyPressed(self, *args): sys.exit() def draw(self): glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) # build projection matrix fov = math.radians(45.0) f = 1.0/math.tan(fov/2.0) zN, zF = (0.1, 100.0) a = self.aspect pMatrix = numpy.array([f/a, 0.0, 0.0, 0.0, 0.0, f, 0.0, 0.0, 0.0, 0.0, (zF+zN)/(zN-zF), -1.0, 0.0, 0.0, 2.0*zF*zN/(zN-zF), 0.0], numpy.float32) # modelview matrix mvMatrix = numpy.array([1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.5, 0.0, -5.0, 1.0], numpy.float32) # render self.scene.render(pMatrix, mvMatrix) # swap buffers glutSwapBuffers() def run(self): glutInitDisplayMode(GLUT_RGBA) glutInitWindowSize(400, 400) self.window = glutCreateWindow("Minimal") glutReshapeFunc(self.reshape) glutDisplayFunc(self.draw) glutKeyboardFunc(self.keyPressed) # Checks for key strokes self.scene = Scene() glutMainLoop() glutInit(sys.argv) prog = Renderer() prog.run() When I use option #2 in the shader without either matrix, I get the following output: What am I doing wrong?

    Read the article

  • No view for id for fragment

    - by guillaume
    I'm trying to use le lib SlidingMenu in my app but i'm having some problems. I'm getting this error: 11-04 15:50:46.225: E/FragmentManager(21112): No view found for id 0x7f040009 (com.myapp:id/menu_frame) for fragment SampleListFragment{413805f0 #0 id=0x7f040009} BaseActivity.java package com.myapp; import android.support.v4.app.FragmentTransaction; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.Menu; import android.view.MenuItem; import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu; import com.jeremyfeinstein.slidingmenu.lib.app.SlidingFragmentActivity; public class BaseActivity extends SlidingFragmentActivity { private int mTitleRes; protected ListFragment mFrag; public BaseActivity(int titleRes) { mTitleRes = titleRes; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(mTitleRes); // set the Behind View setBehindContentView(R.layout.menu_frame); if (savedInstanceState == null) { FragmentTransaction t = this.getSupportFragmentManager().beginTransaction(); mFrag = new SampleListFragment(); t.replace(R.id.menu_frame, mFrag); t.commit(); } else { mFrag = (ListFragment) this.getSupportFragmentManager().findFragmentById(R.id.menu_frame); } // customize the SlidingMenu SlidingMenu slidingMenu = getSlidingMenu(); slidingMenu.setMode(SlidingMenu.LEFT); slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); slidingMenu.setShadowWidthRes(R.dimen.slidingmenu_shadow_width); slidingMenu.setShadowDrawable(R.drawable.slidingmenu_shadow); slidingMenu.setBehindOffsetRes(R.dimen.slidingmenu_offset); slidingMenu.setFadeDegree(0.35f); slidingMenu.setMenu(R.layout.slidingmenu); getActionBar().setDisplayHomeAsUpEnabled(true); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: toggle(); return true; } return super.onOptionsItemSelected(item); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); return true; } } menu.xml <?xml version="1.0" encoding="utf-8"?> <fragment xmlns:android="http://schemas.android.com/apk/res/android" android:name="com.myapp.SampleListFragment" android:layout_width="match_parent" android:layout_height="match_parent" > </fragment> menu_frame.xml <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/menu_frame" android:layout_width="match_parent" android:layout_height="match_parent" /> SampleListFragment.java package com.myapp; import android.content.Context; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.TextView; public class SampleListFragment extends ListFragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.list, null); } public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); SampleAdapter adapter = new SampleAdapter(getActivity()); for (int i = 0; i < 20; i++) { adapter.add(new SampleItem("Sample List", android.R.drawable.ic_menu_search)); } setListAdapter(adapter); } private class SampleItem { public String tag; public int iconRes; public SampleItem(String tag, int iconRes) { this.tag = tag; this.iconRes = iconRes; } } public class SampleAdapter extends ArrayAdapter<SampleItem> { public SampleAdapter(Context context) { super(context, 0); } public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = LayoutInflater.from(getContext()).inflate(R.layout.row, null); } ImageView icon = (ImageView) convertView.findViewById(R.id.row_icon); icon.setImageResource(getItem(position).iconRes); TextView title = (TextView) convertView.findViewById(R.id.row_title); title.setText(getItem(position).tag); return convertView; } } } MainActivity.java package com.myapp; import java.util.ArrayList; import beans.Tweet; import database.DatabaseHelper; import adapters.TweetListViewAdapter; import android.os.Bundle; import android.widget.ListView; public class MainActivity extends BaseActivity { public MainActivity(){ super(R.string.app_name); } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ListView listview = (ListView) findViewById(R.id.listview_tweets); DatabaseHelper db = new DatabaseHelper(this); ArrayList<Tweet> tweets = db.getAllTweets(); TweetListViewAdapter adapter = new TweetListViewAdapter(this, R.layout.listview_item_row, tweets); listview.setAdapter(adapter); setSlidingActionBarEnabled(false); } } I don't understand why the view menu_frame is not found because I have a view with the id menu_frame and this view is a child of the layout menu_frame.

    Read the article

  • VirtualBox sound problem under Ubuntu

    - by VoY
    As I recently upgraded to karmic I started to see the following stuff in the logs when I run VirtualBox: Oct 30 18:14:34 apocalypse pulseaudio[2813]: alsa-source.c: Resume failed, couldn't restore original fragment settings. (Old: 65536/65536, New 1073676288/65532)io[2813]: alsa-source.c: Resume failed, couldn't restore original fragment settings. (Old: 65536/65536, New 1073676288/65532)io[2813]: alsa-source.c: Resume failed, couldn't restore original fragment settings. (Old: 65536/65536, New 1073676288/65532)io[2813]: alsa-source.c: Resume failed, couldn't restore original fragment settings. (Old: 65536/65536, New 1073676288/65532)io[2813]: alsa-source.c: Resume failed, couldn't restore original fragment settings. (Old: 65536/65536, New 1073676288/65532)io[2813]: alsa-source.c: Resume failed, couldn't restore original fragment settings. (Old: 65536/65536, New 1073676288/65532)io[2813]: alsa-source.c: Resume failed, couldn't restore original fragment settings. (Old: 65536/65536, New 1073676288/65532)io[2813]: alsa-source.c: Resume failed, couldn't restore original fragment settings. (Old: 65536/65536, New 1073676288/65532)io[2813]: alsa-source.c: Resume failed, couldn't restore original fragment settings. (Old: 65536/65536, New 1073676288/65532)io[2813]: alsa-source.c: Resume failed, couldn't restore original fragment settings. (Old: 65536/65536, New 1073676288/65532)io[2813]: alsa-source.c: Resume failed, couldn't restore original fragment settings. (Old: 65536/65536, New 1073676288/65532)io[2813]: alsa-source.c: Resume failed, couldn't restore original fragment settings. (Old: 65536/65536, New 1073676288/65532) Oct 30 18:14:34 apocalypse pulseaudio[2813]: alsa-source.c: Resume failed, couldn't restore original fragment settings. (Old: 65536/65536, New 1073676288/65532) After a while the logs grow to large sizes and fill up all of my /var partition. In VirtualBox there is an option to choose between pulseaudio and alsa for sound, but it seems to have no effect. I am using virtualbox-3.0 packages, not the ose version. My system is up to date.

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >