a computer program that runs on graphics hardware and provides a high degree of control over how scenes are rendered

learn more… | top users | synonyms (1)

0
votes
1answer
108 views

How do I pass an object location into a vertex shader?

I am using Blender Game Engine. I want to create a large flat plane, and deform it locally near a moving object. So far (despite being a beginner at shaders) I've written a vertex shader for the ...
2
votes
2answers
201 views

How can I calculate spotlight lighting in Vertex/Fragment shader in Unity?

I've written a vertex/fragment shader for my game. It uses 3 textures and represents a floating water on the wall (so I have 1 texture for water, 1 for geometry and the last one is mask) so it looks ...
0
votes
1answer
108 views

XNA and HLSL shaders - Instancing using World Matrix array

I have posted this question on StackOverflow and was directed here, so I'll just copy the question: I am attempting to improvise some sort of hardware instancing in my game. I wish to draw multiple ...
3
votes
1answer
66 views

Why does my PixelShader ignore color but respond to alpha changes?

I started teaching myself some DirectX a short time ago and found something I'm confused about. For some reason, I can only get the color of the model I'm drawing to vary between black and white, ...
5
votes
3answers
326 views

How do I send multiple matrices to a vertex shader?

I'm practising animations using bones/skinning. I am trying to send the shader one matrix per vertex. I can think of these two approaches. Method 1 I have one uniform handle for each bone matrix ...
0
votes
0answers
59 views

Minimum/maximum depth of tile in OpenGL

I'm trying to implement tiled deferred rendering, but I'm stuck on calculating the min/max depth for each tile. I'm using compute shader for this. This is my shader code: #version 430 #define ...
2
votes
1answer
117 views

How to work with smaller intermediate textures in OpenGL and GLSL?

I'm working on a project rendering water simulated through smoothed-particle hydrodynamics (SPH) with a non-photorealistic look to use in games. In the actual stage of the project everything about ...
0
votes
1answer
97 views

Strange behaviour using VAO (OpenGL 4.0)

I want to display a simple textured Monkey mesh using VAO. Here's the code in the render part first without VAO to see what is the result I'm looking for. Texture *pTexture = ...
0
votes
1answer
137 views

translate-scroll repeated 2d texture using opengl shader

I managed to implement an infinite 2d texture scrolling using the following shader. btw I'm using cocos2d-x 2.2.1. The vertex shader: attribute vec4 a_position; attribute vec2 a_texCoord; #ifdef ...
0
votes
1answer
192 views

Using Appendbuffers in unity for terrain generation

Like many others I figured I would try and make the most of the monster processing power of the GPU but I'm having trouble getting the basics in place. CPU code: using UnityEngine; using ...
0
votes
0answers
93 views

How to fix problem in serpentine case using Blinn/Loop algorithm

I'm trying to implement Blinn/Loop algorithm to render cubic bezier on shader. I calculate the curve type using code below (v0, v1, v2, v3 are cubic bezier segment): CurveType ...
1
vote
1answer
70 views

SetFloat() in HLSL shader (effect) has no effect - variables stay at 0

I have a problem wherein I'm trying to set two simple float variables in my shader. I have a dozen other shaders in this project where it works fine, but for some reason, I've got a bug in this one ...
1
vote
0answers
576 views

How can I get this Shader for Unity working with Normal maps? [closed]

So I'm by no mean a shader coder, but I've been hacking around the last few days trying to get working a shader for the sprites of the skeletal animation tool Spine in Unity that can properly use ...
1
vote
1answer
73 views

Use of the xyY color space?

What's the use of the xyY colorspace in games? I'm not sure what's the advantage of using it in shader programming or elsewhere.
1
vote
1answer
133 views

Draw character silhouette when not visible

I have a mesh representing my character. I want to give it a partially transparent greyish silhouette when other objects are blocking it from view of the camera. I'm using Ogre3D, and GLSL as a ...
3
votes
1answer
491 views

Issue with interpolation on a burn shader (lerp and smoothstep)

I'm trying to create a simple burn shader. See here for more info on the method I'm using. However, I don't get why replacing the smoothstep with a lerp results in completely different results. Am I ...
1
vote
0answers
189 views

Shadow mapping implementation not working?

I am trying to implement Shadow Mapping in my program using Java/LWJGL/OpenGL/GLSL, but I cannot get it to work properly. Let's start off with a screenshot first, then the relevant code and lastly ...
0
votes
1answer
128 views

Textures not displaying. Problem with fragment and vertex shaders

Hi i have newbe question. I am sending to gpu textures unit and they dont display. This is simple version of my fragment and vertexshader. (More complicated version also dont work with other textures ...
0
votes
2answers
123 views

Manage shader parameters

I'm making some test with OpenGL and I've got a problem with my application design. Currently, I've got something like that in pseudo code: // Ask to draw a given scene. renderer->drawScene( ...
1
vote
2answers
101 views

Bilinear filtering: Selecting pixels to interpolate between

When looking for implementations of bilinear filtering online, all the ones I can find seem to just pick the current pixel, and the three pixels to the bottom and right side of the current pixel. ...
1
vote
1answer
98 views

recommended shader pipeline infrastructure in core opengl 3.3

I am writing a game project in Go and I am using an OpenGl 3.3 core context to do my rendering stuff. At the moment I have different types of renderers. Each renderer has it's own pair of vertex- and ...
0
votes
2answers
175 views

How to mix pixel colors in Shader?

I have a pixel that have a colour RGB. This color is calculated by the shader and can be anything. How can I override this color by a colour I choose. If my pixel is white it's simple, I can do this: ...
0
votes
0answers
80 views

VertexColor shader is not working correctly in built application

I want to change the vertex colors of my mesh. The light sources must not affect the objects with this shader, its lighting must be determined only by its vertices colors, so I turned the Lighting ...
2
votes
2answers
260 views

How can I support many point light sources in a dynamically-generated level in Unity?

I'm currently working with a dungeon game which is similar to Dungeon Keeper by Mythic Entertainment. I'm using Unity and developing this game for Ipad 2 and above. Player can modify his dungeon, and ...
0
votes
1answer
281 views

Simple curiosity about glDrawElements function

I've written a very simple OpenGL program displaying a white cube. To do the job done I recovered vertex position and indice data from an OBJ file that describes my cube. Here's the OBJ file content : ...
2
votes
2answers
180 views

Where should shaders and lights be in a component-based entity system?

Where should I put the shader and the light / shadow calculation? Should that be a component too? And should the rendering system know how to handle them or should there be a separate light system? ...
1
vote
1answer
103 views

Starting with shaders and particles

I'm working on a flow field with particle systems and starting to learn about shaders in three.js. Current state of my work is available here. As such amount of calculations is quite heavy for a big ...
1
vote
2answers
1k views

2d metaballs with shader to give blobs of water effect?

I want to simulate blobs of water in a 2d game in Unity3d. One possible way of doing it is to use 3d metaballs moving in a 2d plane though this is very processor intensive. Do you think it would be ...
0
votes
1answer
101 views

How to share matrix in HLSL?

I am trying to share this across multiple effect files: matrix worldMatrix : register(vs_4_0, b0); If I set this from one effect file, will it effect every effect file which has the same type of ...
9
votes
3answers
641 views

How can I create a glitter effect?

I am trying to create a glittering effect for my realtime shader but I don't know how. Here is one example, and another example. What technique can I use to implement this?
0
votes
0answers
242 views

How does this bezier curve rendering shader determine if a curve is concave or convex?

I have read an article about rendering quadratic splines on a GPU with a shader. The algorithm is explained like this: For each quadratic Bézier curve we use Bézier control points of the curve to ...
6
votes
1answer
231 views

Should the Oj lobe of a Lafortune shader cause the light to be displaced?

I implemented the Lafortune shader in WebGL, and my biggest concern is about this formula: Explanation Kd/Ks is the material diffuse/specular color, ρd/ρs is the light diffuse/specular ...
2
votes
1answer
90 views

Light Space and Light Texture Space in shaders

I'm looking into material translucency and I'm working through some GPU Gems documentation (http://http.developer.nvidia.com/GPUGems/gpugems_ch16.html). In Example 16-4 it references matrices for ...
1
vote
1answer
58 views

Does `SetResourceArray` copy the data into the GPU?

I am trying to create multiple textures, and only several of them change every few frames. I don't want to have to copy in the whole array via SetResourceArray for just a few textures that change, ...
2
votes
1answer
118 views

How do we apply different textures to different faces generated via geometry shader?

I am trying to render a cube by starting of with one vertex into the shader, then geometry shader to expand into a cube, and then apply a different texture to each side. The part I am facing the issue ...
9
votes
3answers
1k views

How can I draw outlines around 3D models?

How can I draw outlines around 3D models? I'm referring to something like the effects in a recent Pokemon game, which appear to have a single-pixel outline around them:
1
vote
1answer
1k views

Additive “Sprites/Default” shader

The Sprites/Default shader multiplies the color with the provided tint, while I need to add it instead. I fixed this copying the shader (taken from here) and simply changing the line return ...
1
vote
2answers
149 views

How can I render 3D dots at object vertex positions?

What is the best way to put a dot on a vertex? I have a model (a plane for example) consisting of a few thousand vertices. I want to draw a red dot at every vertex's 3D position, just like 3ds Max's ...
0
votes
1answer
269 views

How to get pixel coordinates between 0,1 from SV_POSITION [duplicate]

I am new to HLSL and Directx. I was trying to write a simple gradient Shader by modifying one of Microsoft samples. 1.I can not understand why SV_POSITION is float4? If it is pixel coordinates ...
1
vote
1answer
1k views

Shader which supports vertex colors and pixel lights?

From my question at Unity Answers: Hello everyone, I'm facing a bit of a problem here: I need a shader which has the ability to colour individual vertices and be lit pixel by pixel. Until recently, I ...
1
vote
1answer
134 views

How to enable geometry shader in OpenGL 4.2?

I'm porting my Direct3D-based engine to OpenGL and I'm using geometry shaders for rendering text characters (basically, textured billboards). D3D version works fine, but in OpenGL mode it gives only ...
2
votes
1answer
311 views

Directx 11: emulating palette swapping with shader 5.0 and c++

i'm trying to swapping the colors using a texture as index and a second one as palette. Here is the full listing of the code: #include <windows.h> #include <windowsx.h> #include ...
10
votes
1answer
915 views

How do Raymarch shaders work?

I have been looking at shaders found here shadertoy.com and most of the cool ones have noise and raymarch in common. I do not understand the source code at all but I really want to. How do these ...
6
votes
3answers
566 views

How can I create a shader that will reproduce this lighting effect on terrain?

Notice the way in which the major light source in each image reflects off the ground, as a function of the distance between the light source and the viewer (?). Is this a (bumped) specular map? ...
1
vote
1answer
93 views

rrr subcsript for float type

I'm a little confused with this construction: float sdcolor = MyColor.r; // MyColor has float4 type float rcolor = sdcolor.rrr; // .ggg or .bbb isn't working return float4(rcolor , rcolor , rcolor , ...
0
votes
1answer
125 views

Why divide by w makes the pixel shader look better?

I'm writing a shader in HLSL (Direct3D11 with SharpDX) and after some computations I was trying to make a test and print the depth z of a specific point in my pixel shader, like this: myZ = ...
3
votes
1answer
260 views

Spritebatch Vertex shader world matrix change after each draw

I have a spritebatch where I draw some textures transformed in 3d space. The easy way was just Begin with the transformation matrix, draw, and end it right after. But that is silly, so I'm trying ...
0
votes
1answer
446 views

problem using glm::lookAt and glm::perspective

I'm trying to change the code from the 22th tutorial at http://ogldev.atspace.co.uk/, using the GLM library, but the result seems wrong. The problem is shown in the below picture: While it should be: ...
1
vote
0answers
90 views

Can't understand the Schlick model formula

I'm trying to implement the Schlick shading model in the fragment shader. I took the formulas from Karsten Schwenk's "a survey of shading models for real-time rendering": First of all I don't ...
-1
votes
1answer
196 views

is instanced rendering faster? [closed]

Is instanced rendering used in GLSL faster than doing something like this.. for(int i=0; i<10; i++) { glDrawArrays(GL_POINTS, 0, 3000); } Suppose I want to render 'grass', which is the best ...